akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/algorithm/searching/knuth_morris_pratt.hpp>

int main() {
    using namespace std;
    using namespace boost::algorithm;
    string s, t;
    cin >> s >> t;
    auto p = knuth_morris_pratt<decltype(t.begin())>(t.begin(), t.end());
    while(s.size() < t.size())s += s;
    unsigned long N = s.size(), M = t.size();
    s += s;

    vector<unsigned long> idx(N);
    {
        string Q = t + "_" + s;
        vector<long> KMP(Q.size() + 1);
        KMP[0] = -1;
        long j = -1;
        for(unsigned long i = 0; i < Q.size(); ++i){
            while(j >= 0 && Q[i] != Q[j])j = KMP[j];
            ++j;
            KMP[i + 1] = j;
            if(KMP[i + 1] >= M && i >= KMP[i + 1] + M && i < KMP[i + 1] + N + M)idx[i - KMP[i + 1] - M] = ~0UL;
        }
    }
    auto f = [rec = [&idx, &M, &N](auto f, unsigned long i, unsigned long t, unsigned long k) -> unsigned long{
        if(!idx[i])return 0;
        if(i == t && k)idx[i] = 2 * N;
        else if(!~idx[i])idx[i] = f(f, (i + M) % N, t, 1) + 1;
        return idx[i];
    }](unsigned long n){rec(rec, n, n, 0);};
    for(unsigned long i = 0; i < N; ++i)f(i);

    unsigned long ans = *max_element(idx.begin(), idx.end());
    if(ans > N)puts("-1");
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 46576
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  vector<int> a(N), h(N);
  for (int &x : h) {
    scanf("%d", &x);
  }

  int res = 0;
  while (a != h) {
    bool open = false;
    for (int i = 0; i < N; ++i) {
      if (a[i] < h[i]) {
        open = true;
        ++a[i];
      } else {
        res += open;
        open = false;
      }
    }
    res += open;
  }

  printf("%d\n", res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

char a[505][505];
bitset<505> x[505], y[505];

int main() {
	if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);

	int H, W; cin >> H >> W;
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j) cin >> a[i][j];
	
	for (int i = 0; i < W; ++i) x[0][i] = y[H-1][i] = 1;
	for (int i = 1; i < H-1; ++i)
		for (int j = 0; j < W; ++j) (j&1 ? x[i][j] : y[i][j]) = 1;

	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
			if (a[i][j] == '#') x[i][j] = y[i][j] = 1;

	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
			cout << (x[i][j] ? '#' : '.') << (j < W-1 ? "" : "\n");
	cout << '\n';
	for (int i = 0; i < H; ++i)
		for (int j = 0; j < W; ++j)
			cout << (y[i][j] ? '#' : '.') << (j < W-1 ? "" : "\n");
}


Measured memory_bytes: 3972
#include <cstdio>
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;

int main() {
	array<array<int,10>,2> ar;
	for(int i = 0; 2 > i; i++){
		for(int j = 0; 10 > j; j++){
			scanf("%d\n", &ar[i][j]);
		}
		sort(ar[i].begin(), ar[i].end(), [](int a, int b){return a > b;});
	}
	printf("%d %d\n", accumulate(ar[0].begin(), ar[0].begin()+3, 0), accumulate(ar[1].begin(), ar[1].begin()+3, 0));
	return 0;
}

Measured memory_bytes: 3140
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// solve


int main(){
    // code here
    long long int a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    printf("%s", a+b+c == 17? "YES":"NO");
    return 0;
}


Measured memory_bytes: 128
import numpy as np
import sys

n, k = [int(a) for a in input().split()]
s = input()

consecutive_ones = [len(x) for x in s.split("0") if x != '']
consecutive_zeros = [len(x) for x in s.split("1") if x != '']

if len(consecutive_zeros) == 0:
    print(n)
    sys.exit(0)

if len(consecutive_ones) == 0:
    if k > 0:
        print(n)
    else:
        print(0)
    sys.exit(0)

cumsum_ones = list(np.convolve(consecutive_ones, np.ones(k+1), mode='valid'))
cumsum_zeros = list(np.convolve(consecutive_zeros, np.ones(k), mode='valid'))

if s[0] == "0":
    cumsum_ones.insert(0, sum(consecutive_ones[:k]))

if s[-1] == "0":
    cumsum_ones.append(sum(consecutive_ones[-k:]))

z = [x + y for x,y in zip(cumsum_ones, cumsum_zeros)]
result = int(max(z))
print(result)

Measured memory_bytes: 19144
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main()
{
	int n;
	cin >> n;
	vector<char> c(n);
	int wc = 0;
	rep(i, n) {
		cin >> c[i];
		if (c[i] == 'W') {
			wc++;
		}
	}
	int rc = 0;
	reverse(c.begin(), c.end());
	for (int i = 0; i < wc; i++) {
		if (c[i] == 'R') {
			rc++;
		}
	}
	cout << rc << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3628
#

import sys
input=sys.stdin.readline
MOD=10**9+7


def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    if N==1:
        print(A[0])
        exit()
    A.sort()
    A2n=[]
    for i in range(0,N,2):
        if i+1>=N:
            break
        if A[i]<=0 and A[i+1]<=0:
            A2n.append(A[i]*A[i+1])
        else:
            break

    A.sort(reverse=True)
    ans=1
    if A[0]<=0 and K%2==1:
        for i in range(K):
            ans=(ans*A[i])%MOD
        print(ans)
        exit()
    ni=0
    i=0
    while(K>0):
        if i+1<N and len(A2n)-ni>0 and A[i]*A[i+1]<A2n[ni] and K>=2:
                ans=(ans*A2n[ni])%MOD
                K-=2
                ni+=1
        else:
            ans=(ans*A[i])%MOD
            i+=1
            K-=1
    print(ans)
            
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 95372
n = input()
v_list = list(map(int, input().split()))

from heapq import heappush, heappop, heapify

heapify(v_list)

while len(v_list) > 1:
    x = heappop(v_list)
    y = heappop(v_list)
    heappush(v_list, (x + y) / 2)

print(v_list[0])

Measured memory_bytes: 38384
def kaibun(s):
    rev = ''.join(list(reversed(s)))
    #print(rev)
    if s == rev:
        return True

def main():
    S = input()
    N = len(S)

    if kaibun(S) and kaibun(S[:(N-1)//2]) and kaibun(S[(N+1)//2:]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import deque
import sys

def fnw(n,s):
    sm=deque([])
    if n<=len(s):
        for _ in range(n):
            sm.append(s.popleft())
    return ''.join(sm)

def jfws(s):
    fws=fnw(5,s)
    if fws=='dream':
        fws=fnw(2,s)
        if fws=='er':
            if s:
                if s[0]=='a':
                    s.extendleft(deque(reversed(list(fws))))
        else:
            s.extendleft(deque(reversed(list(fws))))
        return False
    elif fws=='erase':
        fws=fnw(1,s)
        if fws!='r' and fws!='':
            s.appendleft(fws)
        return False
    else:
        return True 

def main(s):
    while s:
        if jfws(s):
            return 'NO'
    return 'YES'

s=deque(sys.stdin.readline().strip())
print(main(s))



Measured memory_bytes: 10068
#include <iostream>
#include <string>
#include <vector>

using namespace std;

const int d[][2] = { {0,1}, {-1,0}, {0,-1}, {1,0} };

void fill(vector<string> &v, int r, int c) {
    int R = v.size();
    int C = v[0].size();

    if(r < 0 || R <= r || c < 0 || C <= c) return;
    if(v[r][c] != '1') return;
    v[r][c] = '0';

    for(int i = 0; i < 4; ++i) {
        int nr = r + d[i][0];
        int nc = c + d[i][1];
        fill(v, nr, nc);
    }
}


int main() {
    while(true) {
        vector<string> v(12);
        for(int i = 0; i < 12; ++i) cin >> v[i];
        if(cin.eof()) break;

        int ans = 0;
        for(int r = 0; r < 12; ++r)
            for(int c = 0; c < 12; ++c)
                if(v[r][c] == '1') {
                    fill(v, r, c);
                    ++ans;
                }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}


int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n, 0) cin >> a[i];
    int count = 0;
    int flag = 0;

    while (1) {
        rep(i, n, 0) {
            if (a[i] % 2 == 0) {
                a[i] = a[i] / 2;
            } else {
                flag = 1;
            }
        }
        if (flag == 1) break;
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
//#include <numeric> //iota
//#include <sstream>
#include <cstring>
//#include <tuple>
//#include <random>
//#include <string>
//#include <unordered_set>
//#include <bitset>
//#include <unordered_map>
//#include <stack>
#include <cmath>
//#include <deque>
#include <queue>
//#include <list>
#include <array>
using namespace std;
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define vec vector
#define pb push_back
#define pp pop_back
#define fi first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define se second
#define un_map unordered_map
#define rep(i,a,n) for (int i = a; i < n; ++i) 
#define inc_rep(i,a,n,inc) for (int i = a; i < n; i += inc) 
#define couts(x) cout << x << "\n" 
#define watch(x) cout << #x << " : " << x << endl;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long, long long>  PLII;
template<typename T>
void print(vector<T>& v) {rep(i, 0, (int)v.size()) cout << v[i] << " ";cout << endl;}
int nxt() {int x;cin >> x;return x;}
ll nxtl() {ll x;cin >> x;return x;}
string nxts() {string x;cin >> x;return x;}
double nxtd() {double x; cin >> x; return x;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

vector<vector<int>> v(2e5 + 100);
vector<int> visit(2e5 + 100);

int dfs(int val) {
	if (visit[val]) {
		return 0;
	}
	visit[val] = 1;
	int w = 0;
	for (auto x : v[val]) {
		w += dfs(x);
	}
	return 1 + w;
}


int main() {
	IOS;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vector<ll> val;
	for (int i = 0; i < n; ++i) {
		if (!visit[i]) {
			ll x = dfs(i);
			//cout << x << endl;
			val.push_back(x);
		}
	}
	sort(all(val));
	ll ans = val[0];
	for (int i = 1; i < (int)val.size(); ++i) {
		ans += (val[i] - val[i - 1]);
	}
	cout << ans;
}















	



Measured memory_bytes: 21088
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back




int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    char x,y;
    cin>>x;
    if ('a'<=x && 'z'>=x)y='a';
    else y='A';
    cout<<y<<endl;
    
    
    
   
   
    
    
   
   
   
   
   
   
	return 0;
}


Measured memory_bytes: 3656
import java.util.*;class Main{public static void main(String[]a){int i=0;Scanner s=new Scanner(System.in);for(;;){String t=s.nextLine(),r="";if(t.equals("."))break;for(char c:t.toCharArray()){i="()[]".indexOf(c);r+=i<0?"":i;}for(;i<99;i++)r=r.replace("01","").replace("23","");System.out.println(r.equals("")?"yes":"no");}}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(void){ 
    int n;
    cin >> n;
    vector<ll> A;
    for(int i=0; i<n; i++){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    vector<ll> from_l;
    vector<ll> from_r;

    from_l.push_back(A[0]);
    from_r.push_back(A[n-1]);
    for(int i=1; i<n; i++){
        ll tmp_gcd_l = gcd(from_l[i-1], A[i]);
        ll tmp_gcd_r = gcd(from_r[i-1], A[n-i-1]);
        from_l.push_back(tmp_gcd_l);
        from_r.push_back(tmp_gcd_r);
    }
    reverse(from_r.begin(), from_r.end());

    ll ans = max(from_l[n-2], from_r[1]);
    for(int i=1; i<=n-2; i++){
        if(gcd(from_l[i-1], from_r[i+1]) > ans){
            ans = gcd(from_l[i-1], from_r[i+1]);
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3444
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >>N;
  int count=0;
  for(int a=0;a<=N/4;a++){
    for(int b=0;b<=N/7;b++){
      int sum=4*a+7*b;
      if (sum==N){
        count++;
      }
    }
  }
  if(count!=0){ 
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
    
}


Measured memory_bytes: 256
n=int(input())
countab=0
counta=0
countb=0
count=0
for i in range(n):
  w=input()
  num=len(w)
  for j in range(num-1):
    if w[j]=="A" and w[j+1]=="B":
      count+=1
  if w[0]=="B" and w[-1]=="A":
    countab+=1
  elif w[0]=="B":
    countb+=1
  elif w[-1]=="A":
    counta+=1
ans=count
if countab==0:
  pass
else:
  ans+=countab-1
if counta==0 and countb==0:
  print(ans)
else:
  if countab==0:
    pass
  else:
    ans+=1
  ans+=min(counta,countb)
  print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
const int MAXN = 1e5+5;
vector<P> v[MAXN];
int vis[MAXN];
int color[MAXN];
int dis[MAXN];
void bfs(int st)
{
    dis[st] =0 ;
    vis[st] = 1;
    queue<int> q;
    q.push(st);
    while(!q.empty())
    {
        int now = q.front();
        q.pop();
        for(int i = 0; i < v[now].size(); i++)
        {
            int nxt = v[now][i].second;
            int w = v[now][i].first;
            if(!vis[nxt])
            {
                vis[nxt] = 1;
                dis[nxt] = dis[now] + w;
                q.push(nxt);
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++)
    {
        int st, ed, w;
        cin >>st >> ed >> w;
        v[st].push_back(P(w, ed));
        v[ed].push_back(P(w, st));
    }
    bfs(1);
    color[1]  =1;
    for(int i = 2; i <= n; i++)
    {
        if(dis[i] % 2 == 0)
        {
            color[i] = 1;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10204
#include<stdio.h>
int main(void)
{
int a,x,i,j,k,v;
while(1){
scanf("%d %d", &a,&x);
if(a==0&&x==0){
break;
}
v = 0;
for(i = 1;  i < a-1;i++){
 for(j = i+1;  j < a;j++){
  for(k = j+1;  k < a+1;k++){
        if(x ==i + j  +  k)
          ++v;

     }
  }
}

 printf("%d\n",v);
}
 return 0;
}

    

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;

int main(){
  int k;
  cin >> k;
  int p1[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << p1[k-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
class UnionFind
{
public:
    vector<T> par;
    UnionFind(T n) : par(n, -1) {}
    void init(T n)
    {
        for (ll i = 0; i < n; i++)
        {
            par[i] = -1;
        }
    }

    ll root(T x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool same(T x, T y)
    {
        return root(x) == root(y);
    }

    bool merge(T x, T y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(T x)
    {
        return -par[root(x)];
    }
};

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,m;
cin >> n >> m;
vector<pair<ll,ll>> edges(m);
for(ll i = 0; i < m; i++){
    cin >> edges[i].first >> edges[i].second;
    edges[i].first--;
    edges[i].second--;
}
ll ans = 0;
for(ll i = 0; i < m; i++){
    UnionFind<ll> uft(n);
    uft.init(n);
    for(ll j = 0; j < m; j++){
        if(j == i){

        }
        else
        {
            uft.merge(edges[j].first,edges[j].second);
        }
    }
    if(uft.size(0) != n)
    ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N=int(input())
    A=list(map(int,input().split()))
    ans=1000
    stocks=0
    for i in range(N-1):
        if A[i]>A[i+1]:
            ans+=stocks*A[i]
            stocks=0
        else:
            stocks+=(ans//A[i])
            ans-=(ans//A[i])*A[i]
    print(ans+stocks*A[-1])
if __name__=='__main__':
    main()

Measured memory_bytes: 61900
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

typedef long long ll;

ll dat[100005];
ll a[100005];
ll b[100005];

int main()
{
    int n;
    ll tmp = 0;
    ll ans = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        dat[i] = a[i] - b[i];
    }

    sort(dat, dat + n, greater<ll>());

    for (int i = 0; i < n; i++) {
        if (dat[i] < 0) {
            ans++;
            tmp -= dat[i];
        }
    }

    int i = 0;
    while (i < n && tmp > 0) {
        tmp -= dat[i];
        ans++;

        i++;
    }

    cout << (i == n ? -1 : ans) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"OK"<<"\n"
#define no cout<<"NG"<<"\n"
#define INF (ll)1e14+5
#define nax (ll)5e4+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define MAX_N 3005
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
// look for  all edge cases
//search for a pattern




int main(){
	fast;
	
	int a,b,k;
	
	cin >> k >> a >> b;
	int val = k;
	bool ok= false;
	deb(val);
	while(k <= b){
		if(k>=a && k <=b){
			deb(k);
			ok = true;
			break;
		}
		k += val;
	}
 	if(ok)
		yes;
	else
		no;
 	
	return 0;
}

	


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//printf("%.12lf\n",mid);
//const long long sze = 2*(2^(long long)(ceil(log(100000)/log(2))));
/*
// get part of decimal
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
const long long mod = 1000000007;
const double eps = .0000000001;
inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};
long long deg(long long a, long long k){
  long long res = 1;
  long long cur = a;

  while (k) {
    if (k % 2) {
      res = (res * cur) % mod;
    }
    k /= 2;
    cur = (cur * cur) % mod;
  }
  return res;
}

long long nck(long long nn, long long k){
  long long res = 1;
	for(int i = nn; i >nn-k; i--) // numerator
	{
		res = (res * i)%mod;
	}
	for(int i = 2; i <= k; i++)
	{
		res = (res*deg(i, mod - 2))%mod;
	}
	res %= mod;
	return res;
}
vector<long long> primeFactors(long long n)
{
    // Print the number of 2s that divide n
    vector<long long> res;
    bool found = false;
    while (n%2 == 0)
    {
      found = true;
        n = n/2;
        res.push_back(2);
    }
   
    // n must be odd at this point.  So we can skip 
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
      
        // While i divides n, print i and divide n
        bool found2 = false;
        while (n%i == 0)
        { 
          found2 = true;
            n = n/i;
            res.push_back(i);
        }
        
    }

    // This condition is to handle the case when n 
    // is a prime number greater than 2
    if (n > 2)
        res.push_back(n);
    return res;
}
long long choose(long long n, long long k){
    if (k == 0) return 1;
    return (n * choose(n - 1, k - 1)) / k;
}
long long part(int n, int k){
  if (k > n){
    return 0;
  }
  if (k == 1){
    return 1;
  }
  if (n == 1){
    return 1;
  }
  return (part(n-1, k-1)%mod+part(n-k, k)%mod)%mod;
}
int main(){
    prep();
    int n, m;
    cin >> n >> m;
    vector<long long> pf = primeFactors(m);
    map<int, int>mp;
    set<int> ones;
    for (int i=0; i<pf.size(); i++){
      ones.insert(pf[i]);
      if (mp.find(pf[i]) == mp.end()){
        mp[pf[i]] = 1;
      }else{
        mp[pf[i]]++;
      }
    }
    // 1. find how many separations of k the prime can have
    // 2. find how many
    long long res = 1;
    for (int i : ones){
      int amt = mp.find(i) -> second;
      int sep = 1;
      long long curr = 0;
      while (true){
        if (sep > amt){
          break;
        }
        long long currnck = nck(n, sep);
        long long parts = nck(amt-1, sep-1);
        curr += (currnck*parts)%mod;
        curr %= mod;
        sep++;
      }
      res *= curr;
      res %= mod;
    }
    cout << res;
    return 0;
}      



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;

  Y -= N;
  for (int i = 0; i <= N; i++) {
    int num10 = i;
    int ret = (Y - 9 * num10);
    if (ret % 4 != 0) continue;
    int num5 = ret / 4;
    if (num5 >= 0 && num5 + i <= N) {
      int num1 = N - num5 - i;
      cout << num10 << " " << num5 << " " << num1 << "\n";
      return 0;
    }
  }
  print("-1 -1 -1");
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,K   = map(int,input().split())
lst_a = list(map(int, input().split()))

dp= [-1 for i in range(K+1)]
dp[0] = 0
for i in range(1,K+1):
	check = False
	for j in lst_a:
		if(i-j>=0):
			if (dp[i-j] == 0):
				check = True
	if(check): dp[i]= 1
	else : dp[i]= 0

if(dp[K]==1):
	print("First")
else:
	print("Second")

Measured memory_bytes: 44912
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
    int n;cin>>n;
    vector<int>C;
    int a;
    fol(i,n){
        cin>>a;
        C.pb(a);
    }
    int Alice=0,Bob=0;
    sort(C.rbegin(),C.rend());
    fol(i,n){
        (i%2?Bob:Alice)+=C[i];
    }
    cout << Alice-Bob << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());
        for(int i = X; i >= 1; i--)
        {
            for(int j = 2; j < 32; j++)
            {
                int n = j * j;
                if (n > X) break;
                while (true)
                {
                    int n2 = n * j;
                    if (n2 <= X)
                        n *= j;
                    else
                        break;
                }
                if(n == i)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
        }
        Console.WriteLine(1);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int n,k,f=0,fn=0;
    cin>>n>>k;
    vector<int> a(10000000);
    vector<int> b(10000000);

    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<k;i++){
        if(b[f]==0){
            b[f]=1;
            f=a[f]-1;
        }
        else{
            fn=f;
            for(int j=0;j<n;j++){
                fn=a[fn]-1;
                if(fn==f){
                    fn=j+1;
                    break;
                }
            }
            for(int j=0;j<(k-i)%fn;j++){
                f=a[f]-1;
            }
            break;
        }
    }
    cout<<f+1<<endl;
    return 0;
}


Measured memory_bytes: 81416
from operator import itemgetter

n=int(input())
s=[]
li=[]
ans=0
cnt=1

for i in range(n):
  s.append(sorted(input()))
s.sort(key=itemgetter(9,8,7,6,5,4,3,2,1,0))
s=s+['']

for i in range(n):
  if s[i]==s[i+1]:
    cnt+=1
  elif cnt>1:
    li.append(int(cnt*(cnt-1)/2))
    cnt=1
  else:
    cnt=1
print(int(sum(li)))

Measured memory_bytes: 38780
import java.util.Scanner;
import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int kazu[] = new int[128];
		for (int i = 0; i < 128; i++)
		{
			kazu[i] = 0;
		}
		StringBuilder sb = new StringBuilder();
		while(sc.hasNext())
		{
			sb.append(sc.nextLine());
		}
		String line = sb.toString();
		line = line.toLowerCase();
		for (int i = 0; i < line.length(); i++)
		{
			kazu[line.charAt(i)]++;
		}
		for (int i = 'a'; i <= 'z'; i++)
		{
			System.out.println((char)(i) + " : " + kazu[i]);
		}
		sc.close();
	}
}


Measured memory_bytes: 26216
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
#define vi vector<int>
int n,k;
vi a[7];
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
vi inv(vi a)
{
	vi b;b.resize(n);
	for(int i=0;i<n;i++) b[a[i]]=i;
	return b;
}
vi mul(vi a,vi b)
{
	vi c;c.resize(n);
	for(int i=0;i<n;i++) c[i]=a[b[i]];
	return c;
}
vi ksm(vi x,int mi)
{
	vi ans;ans.resize(n);
	for(int i=0;i<n;i++) ans[i]=i;
	while(mi)
	{
		if(mi&1) ans=mul(ans,x);
		x=mul(x,x);
		mi>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&k);
	a[1].resize(n);for(int i=0;i<n;i++) a[1][i]=read(),a[1][i]--;
	a[2].resize(n);for(int i=0;i<n;i++) a[2][i]=read(),a[2][i]--;
	for(int i=3;i<=6;i++) a[i]=mul(a[i-1],inv(a[i-2]));
	if(k<=6)
	{
		for(int i=0;i<n;i++) printf("%d ",a[k][i]+1);
		return 0;
	}
	vi A=mul(mul(a[2],inv(a[1])),mul(inv(a[2]),a[1]));
	A=ksm(A,(k-1)/6);
	A=mul(mul(A,a[(k-1)%6+1]),inv(A));
	for(int i=0;i<n;i++) printf("%d ",A[i]+1);
}

Measured memory_bytes: 9056
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    if len(s)==26:
        for i in range(25,0,-1):
            if s[i]<s[i-1]:
                continue
            else:
                sx=s[i-1]
                for j in range(1,25):
                    sy=chr(ord(sx)+j)
                    if sy in s[i:]:
                        print(s[:i-1]+sy)
                        sys.exit()
        else:
            print(-1)
    else:
        for i in range(26):
            if chr(ord('a')+i) in s:
                continue
            print(s+chr(ord('a')+i))
            break

if __name__=='__main__':
    main()

Measured memory_bytes: 38256
n,k = map(int, input().split())
s = input()
happy, no = 0,0
for i in range(1,n):
    if s[i] == s[i-1]:
        happy += 1
    else: no += 1

for i in range(k):
    if no == 1:
        no -= 1
        happy += 1
        break
    no -= 2
    happy += 2
print(min(happy, n-1))

Measured memory_bytes: 9264
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	max_tmp := 0
	max := 0
	for i := 0; i < len(s); i++ {
		flag := false
		switch string(s[i]) {
		case "A", "C", "T", "G":
			max_tmp++
		default:
			flag = true
		}

		if i == len(s)-1 {
			flag = true
		}
		if flag == true {
			if max < max_tmp {
				max = max_tmp
			}
			max_tmp = 0
		}
	}
	fmt.Println(max)
}

Measured memory_bytes: 512
use proconio::input;


fn solve(n: i32, a: Vec::<usize>, b: Vec::<i32>, c: Vec<i32>) {
    let mut ans: i32 = 0;

    for i in 0..(n-1) as usize {
        if a[i]+1 == a[i+1] {
            ans += c[a[i]-1];
        }
    }

    for bi in b {
        ans += bi;
    }

    println!("{}", ans);
}

fn main() {
    input! {
        n: i32,
        a: [usize; n],
        b: [i32; n],
        c: [i32; n-1],
    }
    solve(n, a, b, c);
}


Measured memory_bytes: 2164
n,k,l=map(int,input().split())

data=[[] for i in range(n+1)]
for i in range(k):
    p,q=map(int,input().split())
    data[p].append(q)
    data[q].append(p)
parent=[0]*(n+1)
num=1
for i in range(1,n+1):
    if parent[i]==0:
        parent[i]=num
        que=[i]
        while que:
            h=que.pop()
            for u in data[h]:
                if parent[u]==0:
                    parent[u]=num
                    que.append(u)
        num+=1

data=[[] for i in range(n+1)]
for i in range(l):
    r,s=map(int,input().split())
    data[r].append(s)
    data[s].append(r)
flag=[0]*(n+1)
num=1
for i in range(1,n+1):
    if flag[i]==0:
        flag[i]=num
        que=[i]
        while que:
            h=que.pop()
            for u in data[h]:
                if flag[u]==0:
                    flag[u]=num
                    que.append(u)
        num+=1

lst=[]
for i in range(1,n+1):
    lst.append([parent[i],flag[i],i])

ans=[1]*(n+1)
lst.sort()
k=0
for i in range(1,n):
    if lst[i][:2]==lst[i-1][:2]:
        k+=1
    else:
        for j in range(i-1-k,i):
            ans[lst[j][2]]+=k
        k=0
for j in range(n-1-k,n):
    ans[lst[j][2]]+=k
print(*ans[1:])

Measured memory_bytes: 126412
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

SA = raw_input()
SB = raw_input()
SC = raw_input()

x = SA[0]
SA = SA[1:]
while 1:
    if x == "a" and SA:
        x = SA[0]
        SA = SA[1:]
    elif x == "b" and SB:
        x = SB[0]
        SB = SB[1:]
    elif x == "c" and SC:
        x = SC[0]
        SC = SC[1:]
    else:
        print x.upper()
        break


Measured memory_bytes: 4132
w,h,n = map(int,input().split())
 
x1 = 0
x2 = w
y1 = 0
y2 = h

for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    x1 = max(x1,x)
  elif a == 2:
    x2 = min(x2,x)
  elif a == 3:
    y1 = max(y1,y) 
  elif a == 4:
    y2 = min(y2,y) 

if x1 >= x2 or y1 >= y2:
    print(0)
else:
    print(abs(x1-x2)*abs(y1-y2))

Measured memory_bytes: 9076
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define MI          map<int, int>
#define PI          pair<int, int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)3e2+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
long double dp[N][N][N];	
int main(){
	int n;
	cin >> n;
	int sushi[3]={0,0,0};
	int a;
	fr(i,1,n){
		cin >> a;
		if(a!=0) sushi[a-1]++;
	}
	fr(i,0,n+2) fr(j,0,n+2) fr(k,0,n+2) dp[i][j][k]=0;
	fr(c3,0,n+1) fr(c2,0,n+1) fr(c1,0,n+1) {
	double sm = c1 + c2 + c3;
	if (sm == 0) continue;
	dp[c1][c2][c3] = ((double) n)/ sm;
	if (c1) dp[c1][c2][c3] += dp[c1 - 1][c2][c3] * c1 / sm;
	if (c2) dp[c1][c2][c3] += dp[c1 + 1][c2 - 1][c3] * c2 / sm;
	if (c3) dp[c1][c2][c3] += dp[c1][c2 + 1][c3 - 1] * c3 / sm;
	}
	cout << fixed << setprecision(10) << dp[sushi[0]][sushi[1]][sushi[2]] << endl;
return 0;
 
}



Measured memory_bytes: 442624
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define LL long long
using namespace std;

int n, ans, a, b, num[105];

void divide(int x)
{
	for(int i=2; i<=x; i++)
	{
		while(x%i==0) num[i]++, x/=i;
	}
	if(x>1) num[x]++;
}

int main()
{
	scanf("%d", &n);
	for(int i=2; i<=n; i++) divide(i);
	for(int i=1; i<=100; i++)
	{
		if(num[i]>=4) a++;
		if(num[i]<4 && num[i]>=2) b++;
	}
	ans=b*a*(a-1)/2+a*(a-1)*(a-2)/2;
	for(int i=1; i<=100; i++)
	{
		if(num[i]>=14)
			for(int j=1; j<=100; j++)
				if(i!=j && num[j]>=4) ans++;
		if(num[i]>=24)
			for(int j=1; j<=100; j++)
				if(i!=j && num[j]>=2) ans++;
		if(num[i]>=74) ans++;
	}
	printf("%d", ans);
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    int s[3];
    F0R(i,3) cin >>s[i];
    sort(s,s+3);
    cout << s[2]*10 +s[1]+s[0]<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<stdio.h>
int ans = 0;
int x[6] = {1,2,3,4,5,6};
char aa[10] ={0};
int a=0,b=0,c=0,d=0;

void func(){
    if(aa[0] == 'N'){
        a = x[0];b = x[1];c = x[4];d = x[5];
        x[0] = b;x[1] = d;x[4] = a;x[5] = c;
        ans += x[0];
        a=0,b=0,c=0,d=0;
    }
    else if(aa[0] == 'E'){
        a = x[0];b = x[2];c = x[3];d = x[5];
        x[0] = c;x[2] = a;x[3] = d;x[5] = b;
        ans += x[0];
        a=0,b=0,c=0,d=0;
    }
    else if(aa[0] == 'W'){
        a = x[0];b = x[2];c = x[3];d = x[5];
        x[0] = b;x[2] = d;x[3] = a;x[5] = c;
        ans += x[0];
        a=0,b=0,c=0,d=0;
    }
    else if(aa[0] == 'S'){
        a = x[0];b = x[1];c = x[4];d = x[5];
        x[0] = c;x[1] = a;x[4] = d;x[5] = b;
        ans += x[0];
        a=0,b=0,c=0,d=0;
    }
    else if(aa[0] =='R'){
        a = x[1];b = x[2];c = x[3];d = x[4];
        x[1] = b;x[2] = d;x[3] = a;x[4] = c;
        ans += x[0];
        a=0,b=0,c=0,d=0;
    }
    else{
        a = x[1];b = x[2];c = x[3];d = x[4];
        x[1] = c;x[2] = a;x[3] = d;x[4] = b;
        ans += x[0];
        a=0,b=0,c=0,d=0;
    }

}
int main(void)
{
    int n;
    int i,j;

    for(;;){
    scanf("%d",&n);
    if(n == 0)break;
    for (i = 0;i < n; i++){
        scanf("%s",aa);
        func();
    }
    printf("%d\n",ans+1);
    for(i = 0;i < 6; i++)x[i] = i+1;
    a=0,b=0,c=0,d=0;
    ans = 0;
    }
    return 0;
}

Measured memory_bytes: 600
# リストをスタックに使う
stack = []
X = str(input())
for i in range(len(X)):
    if X[i] == "S":
        stack.append(X[i])
    elif X[i] == "T" and (len(stack) == 0 or stack[-1] == "T"):
        stack.append(X[i])
    elif X[i] == "T" and stack[-1] == "S":
        stack.pop()
print(len(stack))


Measured memory_bytes: 5096
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    if (x==3||x==5||x==7) {
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;



signed main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);

	int A, B, C;

	cin>>A>>B>>C;

	if(A==B)cout<<C;
	else if(A==C)cout<<B;
	else if(B==C)cout<<A;
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int H, W, N;
  long long mod = 1000000007;
  scanf("%d",&H);
  scanf("%d",&W);
  scanf("%d",&N);
  int ans = (N+std::max(H, W)-1)/std::max(H, W);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 888
N = int(input())
S = [list(input()) for i in range(N)]
ans = 0
for n in range(N):
    flag = True
    for i in range(N):
        for j in range(i, N):
            if S[i][j] == S[j][i]:
                continue
            flag = False
            break
        if not flag:
            break
    if flag:
        ans += N
    for i in range(N):
        S[i] = [S[i][-1-n]] + S[i]
print(ans)

Measured memory_bytes: 103088
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cerr << #x << " = " << x << '\n';
#define PR(A, n) cerr << #A << " = "; for (int i=1; i<=n; ++i) cerr << A[i] << ' '; cerr << '\n';
#define PR0(A, n) cerr << #A << " = "; for (int i=0; i<n; ++i) cerr << A[i] << ' '; cerr << '\n';

int main() {
	//freopen("A.inp", "r", stdin);
	//freopen("A.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	int64_t x, y;
	cin >> x >> y;
	if (x%y==0)
		cout << -1;
	else cout << x*(y-1);
}

Measured memory_bytes: 256
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
B=sorted(A,key=lambda x: x[2])
#(i,j)が中心座標にあるとき
for i in range(101):
  for j in range(101):
    H=abs(B[-1][0]-i)+abs(B[-1][1]-j)+B[-1][2]
    for k in range(N-1):
      if max(H-abs(B[k][0]-i)-abs(B[k][1]-j),0)!=B[k][2]:
        break
    else:
      print(i,j,H)     
      exit()

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
    int a,b,c;
    int i = 0, j = 0;
    int number[3];
    int temp = 0;
    scanf("%d %d %d", &a,&b,&c);
    number[0] = a;
    number[1] = b;
    number[2] = c;
    for(i = 0; i<(3-1); ++i){
        for(j = 0; j<(3-1); ++j){
            if(number[j] > number[j+1]){
                temp        = number[j];
                number[j]   = number[j+1];
                number[j+1] = temp;
            }
        }
    }
    printf("%d %d %d\n",number[0],number[1],number[2]);
    return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
typedef long long ll;

int main(int argc, char const *argv[]) {
    ll N, X;
    std::cin >> N >> X;
    ll x[N];
    for (size_t i = 0; i < N; i++) {
        std::cin >> x[i];
    }
    ll ans = std::abs(X - x[0]);
    for (size_t i = 1; i < N; i++) {
        ans = std::__gcd(std::abs(X - x[i]), ans);
    }
    std::cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
int read(){
    char ch=getchar(); int w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
int main(){
	int x=read();
	cout<<360/__gcd(360,x)<<"\n";
    return 0;
}



Measured memory_bytes: 3620
A, B, C, D = map(int, list(input()))
op = ['+', '-']

for p in range(2):
    for q in range(2):
        for r in range(2):
            s = '{}{}{}{}{}{}{}'.format(A, op[p], B, op[q], C, op[r], D)
            if eval(s) == 7:
                print(s + '=7')
                exit()


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+10;
int n, pA[N], pB[N], fx[N], fy[N];
ll s[N], a, b;


int main() {
	cin>>n>>a>>b;
	REP(i,1,n) cin>>s[i];
	int pa = 1, pb = 1;
	REP(i,1,n) {
		while (s[pa]+a<=s[i]) ++pa;
		while (s[pb]+b<=s[i]) ++pb;
		pA[i] = pa-1;
		pB[i] = pb-1;
	}
	fx[0] = fy[0] = 1;
	int px = 0, py = 0;
	REP(i,2,n) {
		int xi = fy[min(i-2,pA[i])];
		int yi = fx[min(i-2,pB[i])];
		if (pA[i]<i-1) {
			REP(j,px,i-2) fx[j]=0;
			px = i-1;
		}
		if (pB[i]<i-1) {
			REP(j,py,i-2) fy[j]=0;
			py = i-1;
		}
		fx[i-1] = (fx[i-1]+fx[i-2]+(ll)xi)%P;
		fy[i-1] = (fy[i-1]+fy[i-2]+(ll)yi)%P;
	}
	int ans = (fx[n-1]+fy[n-1])%P;
	printf("%d\n", ans);
}









Measured memory_bytes: 11264
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
  int e;
  int x = 0;
  int y = 0;
  int z = 0;
  while(cin >> e && e > 0){
    int min = e;
    int zmax = ceil(pow(e, 1.0/3.0));
    int ymax = ceil(pow(e, 1.0/2.0));
    for(int i=0; i<=zmax; i++){
      for(int j=0; j<=ymax; j++){
        int y2 = j * j;
        int z3 = i * i * i;
        x = e - y2 - z3;
        if(x < 0){
          break;
        }
        if(min > x + i + j){
          min = x + i + j;
        }
      }
    }
    cout << min << endl;
  }

  return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int D = 2019;
int dp[2019];

void solve() {
    string S;
    cin >> S;
    int L = S.size();
    reverse(S.begin(), S.end());
    dp[0] = 1;
    int m = 0;
    int ten = 1;
    for (int i = 0; i < L; ++i) {
        m = m + (S[i] - '0') * ten;
        m %= D;
        dp[m]++;
        ten *= 10;
        ten %= D;
    }
    int ans = 0;
    for (int i = 0; i < 2019; ++i) {
        int x = dp[i];
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3744
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<LL>G, cnt;
std::set<LL>list;
void dfs(LL v)
{
	if (cnt[v] >= 2 || cnt[v] == -1) return;
	++cnt[v];
	list.insert(v);
	dfs(G[v]);
}

int main()
{
	in >> N;
	std::vector<LL>a(N);
	a.resize(N);
	rep(i, N) in >> a[i];

	G.resize(N + 1); cnt.resize(N + 1);
	rep(i, N) G[i + 1] = (i + a[i]) % N + 1;

	LL ans = 0;
	rep(i, N)
	{
		if (cnt[i + 1] == 0)
		{
			list.clear();
			dfs(i + 1);
			for (auto j : list)
			{
				if (cnt[j] < 2) cnt[j] = -1;
			}
		}
	}
	rep(i, N)
	{
		if (cnt[i + 1] >= 2) ++ans;
	}

	out << ans << std::endl;
}



Measured memory_bytes: 16004