akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main{
   	static void main() throws Exception{
   		long x=sc.nextLong();
   		int ans=0;
   		for(long i=2;i*i<=x;i++) {
   			int cnt=0;
   			int wanted=1;
   			while(x%i==0) {
   				cnt++;
   				x/=i;
   				if(cnt==wanted) {
   					cnt=0;
   					wanted++;
   					ans++;
   				}
   			}
   			
   		}
   		pw.println(x>1?(1+ans):ans);
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0)main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 32880
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long n)
{
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; ++p)
  {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0)
    {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}
int main()
{
  int x;
  cin >> x;
  for (int i = -118; i <= 119; i++)
  {
    for (int j = -117; j <= 118; j++)
    {
      if (pow(i, 5) - pow(j, 5) == x)
      {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4112
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>

using namespace std;


int main() {
	/*
	①同じ文字が異なる文字に変換された。(a->b,a->c)  例:aab&cdd
	②異なる文字が同じ文字に変換された。(b->a,c->a) こっちはOK 例：chokudai&redcoder
	の一つでも該当したらNo
	*/

	//input
	string S, T;
	cin >> S >> T;

	map<char, char> st;
	int ans_st = 0;

	//S,Tの同じ番目のmapをつくる
	for (int i = 0; i < S.size(); ++i) {
		char s = S[i];
		char t = T[i];

		st.insert(make_pair(s, t));
	}

	//①ここを高速化したい
	for (int i = 0; i < S.size(); ++i) {
		char tmp = T[i];
		if (st[S[i]] != tmp) {
			ans_st = 1;
			cout << "No" << endl;
			return 0;
		}
	}

	//Sの重複の削除
	sort(S.begin(), S.end());
	S.erase(unique(S.begin(), S.end()), S.end());

	//st[S[i]]をvecに格納する(Tに重複があるとき)
	vector<char> vec;
	for (int i = 0; i < st.size(); ++i) {
		vec.push_back(st[S[i]]);
	}
	//②vecに同じ文字があったら一つの文字が二つの変換先を持つということになるのでフラグを立てる
	for (int i = 0; i < vec.size(); ++i) {
		for (int j = i + 1; j < vec.size(); ++j) {
			if (vec[i] == vec[j]) {
				ans_st = 1;
				cout << "No" << endl;
				return 0;
			}
		}
	}

	if (ans_st == 0) cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 776
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a = sc.nextInt()
    (1 to 3) foreach {x =>
      sc.nextInt()
      ()
    }
    val e = sc.nextInt()
    val k =sc.nextInt()

    if (e - a <= k) println("Yay!") else println(":(")
  }
}


Measured memory_bytes: 25424
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  long long ans = pow(n/k, 3);
  if (k % 2 == 0) {
    int num = 0;
    FOR(i, 1, n+1) if (i % k == k/2) ++num;
    ans += pow(num, 3);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string o, e;
  cin >> o >> e;

  for (int i = 0; i < o.size() + e.size(); ++i) {
    if (i % 2 == 0) {
      cout << o[i / 2];
    } else {
      cout << e[i / 2];
    }
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();

        int red = 0, blue = 0;
        for(int n=0; n<N; n++){
            if(S.charAt(n)=='R') red++;
            else blue++;
        }
        System.out.println(red>blue ? "Yes" : "No");


    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

	int t[4][220000];
	int a[4][220000];
int main() {
	
	int H,W,N,sr,sc;
	cin>>H>>W>>N>>sr>>sc;
	string S,T;
	cin>>S>>T;

	fx(N){
		switch(S.at(x)){
			case 'L':t[0][x]++;break;
			case 'R':t[1][x]++;break;
			case 'U':t[2][x]++;break;
			case 'D':t[3][x]++;break;
		}
		switch(T.at(x)){
			case 'L':a[0][x]++;break;
			case 'R':a[1][x]++;break;
			case 'U':a[2][x]++;break;
			case 'D':a[3][x]++;break;
		}
	}

	bool takahashi=false;
	fx(N){
      //doublece(sc+t[1][x],sc-t[0][x])
		if(sc+t[1][x]>W||sc-t[0][x]<=0
		 ||sr-t[2][x]<=0||sr+t[3][x]>H){
			takahashi=true;
			break;
		}
      t[1][x]+=-a[0][x];t[0][x]+=-a[1][x];
      t[2][x]+=-a[3][x];t[3][x]+=-a[2][x];
      if(sc+t[1][x]<=0){t[1][x]+=a[0][x];}
      if(sc-t[0][x]>W){t[0][x]+=a[1][x];}
      if(sr-t[2][x]>H){t[2][x]+=a[3][x];}
      if(sr+t[3][x]<=0){t[3][x]+=a[2][x];}
 t[1][x+1]+=t[1][x];t[0][x+1]+=t[0][x];t[2][x+1]+=t[2][x];t[3][x+1]+=t[3][x];
	}
	if(takahashi){
		ce("NO")
	}else{
		ce("YES")
	}
}

Measured memory_bytes: 7432
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long x = sc.nextLong();
		long y = sc.nextLong();
		
		// 計算
		long result = 0;
		while(x <= y){
		    result++;
		    x *= 2;
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll N, count = 0;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    for(ll i=0; i<N+1; i++) {
        cin >> A[i];
    }
    for(ll i=0; i<N; i++) {
        cin >> B[i];
    }

    for(ll i=0; i<N; i++) {
        if(A[i] + A[i+1] <= B[i]) {
            count += A[i] + A[i+1];
            A[i+1] = 0;
        } else {
            count += B[i];
            if(B[i] >= A[i]) {
                A[i+1] -= B[i] - A[i];
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
B = [ ]
c = -1
for i in A:
  B.append(list(bin(i)))
for i in range(10000):  
  for j in range(N):
    if B[j][-i-1] == '0':
      continue
    else:
      c = i
      break
  if c == 0:
    print(0)
    break
  elif c>0:
    print(i)
    break

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<utility>
typedef std::pair<int,int> PP;
int H, W, N;
int sh, sw;
char tar[9] = { '1','2','3','4','5','6','7','8','9' };
char HW[1000][1000];
int cnt = 0;
const int INF = 1 << 30;
int ans;
int tx, ty;
int D[1000][1000];
void solve(int h, int w) {
	std::queue<PP> q;
	q.push(std::make_pair(h, w));
	for (int a = 0; a < H; a++) {
		for (int b = 0; b < W; b++) {
			D[a][b] = INF;
		}
	}
	D[h][w] = 0;
	while (q.size()) {
		std::pair<int, int> p = q.front();
		q.pop();
		if (HW[p.first][p.second] == tar[cnt]) {
			ans += D[p.first][p.second];
			tx = p.first;
			ty = p.second;
			return;
		}
		int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
		for (int i = 0; i < 4; i++) {
			int ux = p.first + dx[i];
			int uy = p.second + dy[i];
			if (0 <= ux&&ux < H && 0 <= uy&&uy < W&&D[ux][uy] == INF&&HW[ux][uy] != 'X') {
				q.push(std::make_pair(ux, uy));
				D[ux][uy] = D[p.first][p.second] + 1;
			}
		}
	}
	return;
}
int main() {
	std::cin >> H >> W >> N;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			std::cin >> HW[i][j];
			if (HW[i][j] == 'S') {
				sh = i;
				sw = j;
			}
		}
	}
	solve(sh, sw);
	for (int i = 0; i < N; i++) {
		cnt = i;
		solve(tx, ty);
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 7960
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int X,Y; cin >> X >> Y;
  if(X%Y) {
    cout << X << endl;
  } else {
    cout << -1 <<endl;
  }
}

Measured memory_bytes: 256
#C switch
n,m=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
data=[0 for i in range(n+1)]
s=0
for i in range(2**n):
    for j in range(n):
        if (i>>j&1)==1:
            data[j+1]=1
        else:
            data[j+1]=0
    for k in range(m):
        a=0
        for l in range(1,ks[k][0]+1):
            a=(a+data[ks[k][l]])%2
        if a!=p[k]:
            break
    else:
        s+=1
print(s)

Measured memory_bytes: 41200
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    px, py, pt = 0, 0, 0
    for i in range(n):
        t, x, y = XY[i]
        if abs(x - px) + abs(y - py) > abs(t - pt):
            print("No")
            break
        else:
            if (abs(x - px) + abs(y - py) - abs(t - pt)) % 2 != 0:
                print("No")
                break
            px, py, pt = x, y, t
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 27312
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include<set>
#include<numeric>
#include <unordered_map>
#include <deque>
#include <iostream>
#include <string>
#include <vector>
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#include<boost/math_fwd.hpp>
#endif
//#define dbg
#define p std::pair
#define vec std::vector
#define umap std::unordered_map
#define mp std::make_pair
#define all(cont) (cont).begin(), (cont).end()
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);

int main()
{
#ifdef dbg
	cout<<ULLONG_MAX<<endl;
#endif
unsigned ll n,k;
cin>>n>>k;
vec<int> v(n,0);
rep(i,n){

	cin>>v[i];
}
if(k>=n){cout<<0<<endl; return 0;}
sort(all(v));
unsigned ll ans=0;
rep(i,n-k){
	ans+=v[i];
}
cout<<ans<<endl;
return 0;
}

ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3984
#include<stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	long long X,Y;
	scanf("%lld%lld",&X,&Y);
	int ans1=0;
	//aを滅ぼす場合
	long long a=X*2,b1=0,b2=Y;
	while(1){
		long long t=(a+1)/2;
		long long tt=min(b2,t);
		b2-=tt;
		b1+=tt;
		b1-=min(b1,t-tt);
		if(b1+b2==0)break;
		ans1++;
		a-=b1+b2;
		if(a<=0)break;
		ans1++;
	}

	int ans2=0;
	//bを滅ぼす場合
	long long b=Y*2,a1=0,a2=X;
	while(1){
		b-=a1+a2;
		if(b<=0)break;
		ans2++;
		long long t=(b+1)/2;
		long long tt=min(a2,t);
		a2-=tt;
		a1+=tt;
		a1-=min(a1,t-tt);
		if(a1+a2==0)break;
		ans2++;
	}
	printf("%d\n",min(ans1,ans2));
}


Measured memory_bytes: 2148
#include <iostream>
using namespace std;
int main() {
	int n;
    cin >> n;
  	if(n / 100 == 7 || n % 10 == 7 || ((n / 10) % 10) == 7)
      	cout << "Yes" << endl;
  	else
      	cout << "No" << endl;
  	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,t;
	cin>>a>>b>>c;
	if(a>b)
	{
		t=a;
		a=b;
		b=t;
	}
	if(a>c)
	{
		t=a;
		a=c;
		c=t;
	}
	if(b>c)
	{
		t=b;
		b=c;
		c=t;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return  0;
 } 


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int DN=3005,DK=1e5+5,M=1e9+7;
int n,dp[DN][DN],sum;
string s;
int main()
{
	cin>>n;
	cin>>s;
	n=s.size();
	s="  "+s;
	n++;
	for(int i=1;i<=n;i++)
		dp[1][i]=1;
	for(int h=2;h<=n;h++)
	{
		if(s[h]=='<')
		{
			sum=0;
			for(int i=1;i<=n-h+1;i++)
			{
				sum=(sum+dp[h-1][i])%M;
				dp[h][i]=sum;
			}
			continue;
		}
		sum=dp[h-1][n-h+2];
		for(int i=n-h+1;i>0;i--)
		{
			dp[h][i]=sum;
			sum=(sum+dp[h-1][i])%M;
		}
	}
	sum=0;
	for(int i=1;i<=n;i++)	
		sum=(sum+dp[n][i])%M;
	cout<<sum;
}

Measured memory_bytes: 35200
n,m = map(int,input().split())
a=[]
for i in range(n):
    x = input().split()
    a.append(x)
b = []
for i in range(m):
    x = input()
    b.append(x)
z=[]
for i in range(n):
    c = 0
    for j in range(m):
        c += int(a[i][j])*int(b[j])
    print(c)


Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string s;
  cin >> s;
  string cur = "hi";
  for (int i = 0; i < 5; i++) {
    if (s == cur) {
      cout << "Yes" << endl;
      return 0;
    }
    cur += "hi";
  }
  cout << "No" << endl;
}

Measured memory_bytes: 768
n = int(input())
W = list(map(int, input().split()))

ans = float("inf")
for t in range(n - 1):
    S1 = sum(W[: t + 1])
    S2 = sum(W[t + 1 :])
    ans = min(ans, abs(S1 - S2))
print(ans)


Measured memory_bytes: 2940
using System;

namespace _1_D {
    class Program {
        static void Main (string[] args) {
            var S = Convert.ToInt32 (Console.ReadLine ());
            var h = S / 3600;
            var m = (S - h * 3600) / 60;
            var s = S - h * 3600 - m * 60;
            Console.WriteLine ($"{h}:{m}:{s}");
        }
    }
}



Measured memory_bytes: 16024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
using namespace std;
const int N=1e5+5,M=N*100+7;
int tot,ans;
int a[N],b[N],a1[N],b1[N];
int f[N],bel[M],h[M];
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) w|=ch=='-',ch=getchar();
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline int get(int x)
{
	return f[x]==x?x:f[x]=get(f[x]);
}
inline int hash(int x)
{
	int y=x%M;
	while(h[y]>=0 && h[y]!=x) y=(y+1)%M;
	return y;
}
int main()
{
	int n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=a1[i]=read();
		a[n+1]^=a[i];
	}
	a1[n+1]=a[n+1];
	for(int i=1;i<=n;i++)
	{
		b[i]=b1[i]=read();
		b[n+1]^=b[i];
	}
	b1[n+1]=b[n+1],n++;
	sort(a1+1,a1+1+n);
	sort(b1+1,b1+1+n);
	for(int i=1;i<=n;i++)
		if(a1[i]^b1[i]) return 0&printf("-1");
	memset(h,-1,sizeof(h));
	for(int i=1;i<=n;i++)
		if(i==n || a[i]^b[i])
		{
			if(i<n) ans++;
			int k=hash(a[i]);
			if(h[k]<0) h[k]=a[i],bel[k]=++tot;
			k=hash(b[i]);
			if(h[k]<0) h[k]=b[i],bel[k]=++tot;
		}
	for(int i=1;i<=tot;i++) f[i]=i;
	for(int i=1;i<=n;i++)
		if(a[i]^b[i]) f[get(bel[hash(a[i])])]=get(bel[hash(b[i])]);
	for(int i=1;i<=tot;i++)
		if(f[i]==i) ans++;
	printf("%d",ans-1);
	return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;


public class Main {
	static String S;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
			 S = sc.next();
		sc.close();

		int[] T = new int[4];
 		for (int i = 0; i < S.length(); i++) {
		    // 配列に順番に格納する
		    T[i] = Integer.parseInt(String.valueOf(S.charAt(i)));
		}

 		int flag = 0;

 		if(T[0]+T[1]+T[2]+T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"+"+T[1]+"+"+T[2]+"+"+T[3]+"=7");
 			flag++;
 		}
 		if(T[0]+T[1]+T[2]-T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"+"+T[1]+"+"+T[2]+"-"+T[3]+"=7");
 			flag++;
 		}
 		if(T[0]+T[1]-T[2]+T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"+"+T[1]+"-"+T[2]+"+"+T[3]+"=7");
 			flag++;
 		}
 		if(T[0]+T[1]-T[2]-T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"+"+T[1]+"-"+T[2]+"-"+T[3]+"=7");
 			flag++;
 		}
 		if(T[0]-T[1]+T[2]+T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"-"+T[1]+"+"+T[2]+"+"+T[3]+"=7");
 			flag++;
 		}
 		if(T[0]-T[1]+T[2]-T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"-"+T[1]+"+"+T[2]+"-"+T[3]+"=7");
 			flag++;
 		}
 		if(T[0]-T[1]-T[2]+T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"-"+T[1]+"-"+T[2]+"+"+T[3]+"=7");
 			flag++;
 		}
 		if(T[0]-T[1]-T[2]-T[3] == 7 && flag == 0){
 			System.out.println(T[0]+"-"+T[1]+"-"+T[2]+"-"+T[3]+"=7");
 			flag++;
 		}
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	for(int i=0;i<m;i++){
		int x,y; cin >> x >> y;
		if(x>(n+1)/2){
			if(n%2==0)x=n/2+1-(x-n/2);
			else x=n/2-(x-n/2)+2;
		}
		swap(x,y);
		if(x>(n+1)/2){
			if(n%2==0)x=n/2+1-(x-n/2);
			else x=n/2-(x-n/2)+2;
		}
		cout << min(x-1,y-1)%3+1 << endl;
	}
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2], xr[N], res[N];
#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}


void solve()
{
	cin >> n;
	lop(i, 0, n) cin >> xr[i];

	int i = 0, j = n - 1;
	while ( i < j )
	{
		arr[i] = (xr[i] ^ xr[j]);
		i++;
		j--;
	}

	int x = 0;
	lop(i, 1, (n / 2)) x ^= arr[i];
	res[n - 1] = (xr[0] ^ x);
	int fxr = (res[n - 1] ^ xr[n - 1]);
	lop(i, 0, n) res[i] = (fxr ^ xr[i]);

	prarr(res, 0, n); return;
}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





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


int main() {
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i]=='R') {
            int tmp = 0;
            for (int j = i; j < s.size() && s[j] == 'R'; j++) {
                tmp++;
            }
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;


    return 0;
}


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

int main() {
  int a;
  cin >> a;
  if (a >= 2800) {
    cout << "AGC" << endl;
  }
  else if (a >= 1200) {
    cout << "ARC" << endl;
  }
  else {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 256
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

from collections import defaultdict
dicts = defaultdict(int)

N=one_int()
X=many_int()

sorted_X = sorted(X)

for i in sorted_X:
    if i in dicts:
        dicts[i] += 1
    else:
        dicts[i] = 1

max_num = 1
for j in range(sorted_X[0]-1,sorted_X[-1]+1):
    temp_sum = dicts[j-1] + dicts[j] + dicts[j+1]
    
    if max_num < temp_sum:
        max_num = temp_sum

print(max_num)

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

using namespace std;

const int N = 5e5 + 5;

int n, k, top;
int p[N], q[N];

map <int, int> M;
list <int> L[N];

int main() {
    cin >> n >> k;
    M[0] = 0;
    for(int i = 1; i <= n; i++) scanf("%d", &p[i]), q[p[i]] = i;
    for(int i = 1; i < k; i++) M[p[i]] = i;
    for(int i = 1; i <= n; i++) L[i].push_back(i);
    for(int i = 1; i <= n; i++) {
        if(i + k - 1 <= n) M[p[i + k - 1]] = i + k - 1;
        auto it = -- M.find(p[i]);
        L[it -> second].splice(L[it -> second].end(), L[i]);
        M.erase(p[i]);
    }
    for(auto x : L[0]) p[++top] = x;
    for(int i = 1; i <= n; i++) q[p[i]] = i;
    for(int i = 1; i <= n; i++) printf("%d\n", q[i]);
    return 0;
}

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

int main(){
	int n, a, b, sum = 0, max;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		if (a == b) {
			sum ++;
			if (sum == 3) {
				cout << "Yes\n";
				return 0;
			}
		} else {
			sum = 0;
		}	
	}
	cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

const ll Mod = 1000000007;
/* --- */
using MT = decay<decltype(Mod)>::type;

MT inverse (MT a, MT n) {
	MT u = 0, v = 1;
	while (a != 0) {
		MT q = n / a;
		swap(u, v); v -= q * u;
		swap(n, a); a -= q * n;
	}
	assert(n == 1);
	return u;
}

class mint {
private: MT x;
public:
	void normalize() {
		if (x >= Mod || x < 0) x = (x % Mod) + Mod;
		if (x > Mod) x -= Mod;
	}
	mint(): x(0) {}
	mint(MT z): x(z) { normalize(); }
	const MT& operator() () const { return x; }

	mint operator+ (const mint& z) { MT r = x + z(); if (r > Mod) r -= Mod; return mint(r); }
	mint operator- (const mint& z) { MT r = x - z(); if (r < 0) r += Mod; return mint(r); }
	mint operator* (const mint& z) { MT r = x * z(); if (r > Mod) r %= Mod; return mint(r); }
	mint operator/ (const mint& z) { return (*this) * mint(inverse(z(), Mod)); }

	mint operator+= (const mint& z) { (*this) = (*this) + z; return (*this); }
	mint operator-= (const mint& z) { (*this) = (*this) - z; return (*this); }
	mint operator*= (const mint& z) { (*this) = (*this) * z; return (*this); }
	mint operator/= (const mint& z) { (*this) = (*this) / z; return (*this); }

	friend std::istream& operator>> (std::istream&, mint&);
};

std::istream& operator>> (std::istream& stream, mint& p) {
	MT v; stream >> v; p.x = v; p.normalize(); return stream;
}
std::ostream& operator<< (std::ostream& stream, const mint& p) { return stream << p(); }
mint operator+ (const MT& p, const mint& q) { return mint(p) + q; }
mint operator- (const MT& p, const mint& q) { return mint(p) - q; }
mint operator* (const MT& p, const mint& q) { return mint(p) * q; }
mint operator/ (const MT& p, const mint& q) { return mint(p) / q; }
string to_string (const mint& p) { return to_string(p()); }

mint powMod (mint a, MT b) {
	mint res = 1, x = a;
	while (b > 0) {
		if (b & 1) res *= x;
		x *= x;
		b >>= 1;
	}
	return res;
}
/* --- */
const int N = 100100;
mint fac[N], inv[N];
mint bin (int a, int b) {
  return fac[a] * inv[a - b] * inv[b];
}

vector<int> factorize (int x) {
  vector<int> res;
  for (int i = 2; i * i <= x; i++) {
    int k = 0;
    while (x % i == 0) { x /= i; k++; }
    res.push_back(k);
  }
  if (x > 1) res.push_back(1);
  return res;
}

int main() {
  fac[0] = 1;
  for (int i = 1; i < N; i++) fac[i] = i * fac[i - 1];
  for (int i = 0; i < N; i++) inv[i] = inverse(fac[i](), Mod);

  int n, m;
  scanf("%d%d", &n, &m);
  mint ans = 1; 
  vector<int> pw = factorize(m);
  for (int i = 0; i < sz(pw); i++) ans *= bin(n - 1 + pw[i], pw[i]);
  printf("%lld\n", ans());
}



Measured memory_bytes: 1920
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Fdn(i,b,a) for(int i=b;i>=a;--i)
#define Printno {puts("-1"); return 0;}
using namespace std;
const int MAXN=1000005;

int n,ans,p[MAXN],ed[MAXN],tot;
char a[MAXN],b[MAXN],ch[MAXN];

bool check(int mid){
	Fdn(i,tot,mid+1){
		if(p[i-mid]-mid<ed[i]) return 0;
	}
	return 1;
}

int main(){
	scanf("%d%s%s",&n,a+1,b+1);
	int j=n+1, pr=n;
	bool bo=1;
	Fdn(i,n,1){
		if(b[i-1]!=b[i]){
			j=min(j-1,i);
			while(j>0&&a[j]!=b[i]) j--;
			//printf("%d :find %d\n",i,j);
			if(!j) Printno;
			p[++tot]=j;
			ed[tot]=pr; pr=i-1;
			ch[tot]=b[i];
		}
		if(a[i]!=b[i]) bo=0;
	}
	if(bo){puts("0"); return 0;}
	//Fdn(i,tot,1) printf("test: %d %d\n",p[i],ed[i]);
	p[0]=n+1;
	int l=0, r=tot, mid;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)) ans=mid, r=mid-1; else l=mid+1;
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 10880
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
inline void check_max(int a,int &b){if(a>b)b=a;}
inline void check_min(int a,int &b){if(a<b)b=a;}
const int N=2050;
struct key
{
	int x,y,w;
	bool operator < (const key & h) const {return w>h.w;}
	key(int a=0,int b=0,int c=0){x=a,y=b,w=c;}
}s[N*N];
struct ucs
{
	int q[N],w[N];
	void init(int n){for(int i=1;i<=n;i++)q[i]=i,w[i]=1;}
	int ask(int p){return p==q[p]?p:q[p]=ask(q[p]);}
	void uni(int u,int v)
	{
		int fu=ask(u),fv=ask(v);
		w[fv]+=w[fu];
		q[fu]=fv;
	}
	int query(int p){return w[ask(p)];}
}A[N],B[N];

bool got(){for(char c=getchar();;c=getchar())if(c=='#')return 1;else if(c=='.')return 0;}
int a[N][N],f[N][N];
int n,m,ans,tot;
bool vis[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			a[i][j]=got();
			f[i][j]=std::min(f[i-1][j-1],std::min(f[i-1][j],f[i][j-1]))+1;
			int tmp=a[i][j]+a[i-1][j]+a[i][j-1]+a[i-1][j-1];
			if(tmp==1 || tmp==3)f[i][j]=1;
			s[++tot]=key(i,j,f[i][j]);
		}
	std::sort(s+1,s+tot+1);
	for(int i=1;i<=n;i++)A[i].init(m);
	for(int i=1;i<=m;i++)B[i].init(n);

	int minw=n+m;
	ans=0;
	for(int i=1;i<=tot;i++)
	{
		check_min(s[i].w,minw);
		int x=s[i].x,y=s[i].y;
//		printf("%d %d : %d\n",x,y,minw);

		if(vis[x][y-1])A[x].uni(y,y-1);
		if(vis[x][y+1])A[x].uni(y,y+1);
		if(vis[x-1][y])B[y].uni(x,x-1);
		if(vis[x+1][y])B[y].uni(x,x+1);
		check_max((A[x].query(y)+minw-1)*minw,ans);
		check_max((B[y].query(x)+minw-1)*minw,ans);
		vis[x][y]=1;
	}
	printf("%d\n",ans);

//	for(int i=1;i<=n;i++,printf("\n"))
//		for(int j=1;j<=m;j++)printf("%d ",f[i][j]);
	return 0;
}


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

#define int long long
const int MOD = 10000000000007LL;


int dp[410][410] = {};
int a[410];

//[l, r)
int solve(int l, int r){

    //cout << l << " " << r << endl;
    if(!(dp[l][r] == MOD)) return dp[l][r];
    if(r - l == 1){
        dp[l][r] = 0;
        return dp[l][r];
    }

    int rec = MOD;
    int sum = 0;
    for(int i = l; i < r; i++){
        sum += a[i];
    }

    for(int i = l + 1; i < r; i++){    
        rec = min(rec, solve(l, i) + solve(i, r) + sum);
    }

    dp[l][r] = rec;
    return dp[l][r];
}

signed main(){

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

    cout << solve(0, n) << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define int long long
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int imos[100010];

signed main()
{
    int N;
    cin >> N;

    imos[0] = 1;

    rep(i, N) {
        int a, b;
        cin >> a >> b;

        imos[a]++, imos[b + 1]--;
    }

    rep1(i, 100005) imos[i] += imos[i - 1];

    int ma = 0;

    rep(i, 100005) if (imos[i] >= i) ma = i;

    cout << ma - 1 << endl;
}

Measured memory_bytes: 1936
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define MOD 1000000007
#define INF 2000000000
#define DESPACITO 1000000000000000000
#define PI acos(-1);
#define E 998244353
#define pb push_back
#define mp make_pair
#define pdd pair<double,double>
#define ll long long

using namespace std;

int dp1[200000],dp2[200000];
int n,a,b,c,d;
string s;

int solve1(int ind)
{
	if(ind==c)
		return 1;
	if(ind>c)
		return 0;
	if(dp1[ind]!=-1)
		return dp1[ind];
	if(s[ind]=='#')
		return 0;
	dp1[ind]=max(solve1(ind+1),solve1(ind+2));
	return dp1[ind];
}
int solve2(int ind)
{
	if(ind==d)
		return 1;
	if(ind>d)
		return 0;
	if(dp2[ind]!=-1)
		return dp2[ind];
	if(s[ind]=='#')
		return 0;
	dp2[ind]=max(solve2(ind+1),solve2(ind+2));
	return dp2[ind];
}


int main()
{
	IOS;
	cin >> n >> a >> b >> c >> d;
	cin >> s;
	memset(dp1,-1,sizeof(dp1));
	memset(dp2,-1,sizeof(dp2));
	a--;
	b--;
	c--;
	d--;
	if(!solve1(a))
	{
		cout << "No";
		return 0;
	}
	if(!solve2(b))
	{
		cout << "No";
		return 0;
	}
	if(c<d)
	{
		cout << "Yes";
		return 0;
	}
	REP(i,b,d)
	{
		if(solve2(i) && solve1(i-1) && solve1(i+1))
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 7632
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>a>>b;
     l=max(a,b);
     r=min(a,b);
     p=16-(a+b);
     x=p/2;
     if(p%2==1){
        x++;
     }
     //cout<<x<<" "<<l-r<<endl;
     if((l-r)<=x){
        cout<<"Yay!"<<endl;
     }
     else{
        cout<<":("<<endl;

     }

     return EXIT_SUCCESS;
}



Measured memory_bytes: 3580
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    r = int(r)
    if r < 1200:
        print('ABC')
    elif r < 2800:
        print('ARC')
    else:
        print('AGC')

if __name__ == '__main__':
    main()



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

const int N=3e6;
const int mod=998244353;
int n,k,ans,fac[N+5],inv[N+5],infac[N+5];

void init()
{
    int i;scanf("%d%d",&n,&k);
    fac[0]=1;for(i=1;i<=N;++i) fac[i]=1LL*fac[i-1]*i%mod;
    inv[1]=1;for(i=2;i<=N;++i) inv[i]=1LL*inv[mod%i]*(mod-mod/i)%mod;
    infac[0]=1;for(i=1;i<=N;++i) infac[i]=1LL*infac[i-1]*inv[i]%mod;
}

int C(int x,int y)
{
    if(y>x) return 0;
    return 1LL*fac[x]*infac[y]%mod*infac[x-y]%mod;
}

void calc(int x,int y,int T)
{
    if(T<=0) return;
    int ret=C(x+y,x);
    if(T<=y) ret-=C(x+y,y-T);
    if(ret<0) ret+=mod;
    ans+=ret;if(ans>=mod) ans-=mod;
}

void work()
{
    int i,j;
    for(i=0,j=k;i<=k;++i,--j)
    {
        if(i<j) continue;
        else if(i==j) calc(i,j-1,i-n+1);
        else calc(i,j,i-n+1);
    }
    printf("%d\n",ans);
}

int main()
{
    init();
    work();
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
int dy[] = {1, 0, 0, -1};
int dx[] = {0, 1, -1, 0};
int b[110][110];
int w, h;
int xs, ys, xg, yg;
int color;
bool flag = false;
bool used[110][110];

void dfs(int y, int x){
	rep(i, 4){
		int ny = y + dy[i], nx = x + dx[i];
		if(used[ny][nx]) continue;//???????????¨???????????????????????????
		if(!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
		if(b[ny][nx] != color) continue;
		if(ny == yg && nx == xg){
			used[ny][nx] = true;
			flag = true; return;//????????????
		}
		used[ny][nx] = true;
		dfs(ny, nx);
	}
	return;//????????¢?????¨???????????????
}

int main(void){
	while(1){
		rep(i, 110)rep(j, 110){
			b[i][j] = -1; used[i][j] = false;
		}
		cin >> w >> h;
		if(w == 0 && h == 0) return 0;
		cin >> xs >> ys >> xg >> yg;
		xs--; ys--; xg--; yg--;
		int n; cin >> n;
		rep(i, n){
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			x--; y--;
			if(d == 0){//?¨?
				b[y][x] = b[y][x + 1] = b[y][x + 2] = b[y][x + 3] = c;
				b[y + 1][x] = b[y + 1][x + 1] = b[y + 1][x + 2] = b[y + 1][x + 3] = c;
			}else{//???
				b[y][x] = b[y][x + 1] = c;
				b[y + 1][x] = b[y + 1][x + 1] = c;
				b[y + 2][x] = b[y + 2][x + 1] = c;
				b[y + 3][x] = b[y + 3][x + 1] = c;
			}
		}
		color = b[ys][xs];
		if(color == -1) {//?????????????????????????????????
			printf("NG\n"); continue;
		}
		used[ys][xs] = true; flag = false;
		dfs(ys, xs);
		if(flag) printf("OK\n");
		else printf("NG\n");
	}
}

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



int main() {
  int n;
  ll ans=0;
  cin >> n;
  for(int i=1; i<(n+1); i++){
    if(i%3 != 0 && i%5 != 0) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    vector<int> v;
    while(t--){
        int n;
        cin>>n;
        int m;
        cin>>m;
        int a[m];
        for(int i=1;i<=m;i++){
            a[i]=0;
        }
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            for(int j=0;j<x;j++){
                int y;
                cin>>y;
                a[y]++;
            }
        }
        int cnt=0;
        for(int i=1;i<=m;i++){
            if(a[i]%n==0 && a[i]>=n) cnt++;
        }
        cout<<cnt;
    }
}
    

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

multiset<string> S;
multiset<string>::iterator itL, itR;
int X, Y, Z;

int main() {
	scanf("%d%d%d", &X, &Y, &Z);
	while(X--) S.insert("a");
	while(Y--) S.insert("b");
	while(Z--) S.insert("c");
	while(S.size() > 1) {
		itL = S.begin();
		itR = S.end(); itR--;
		S.insert((*itL) + (*itR));
		S.erase(itL); S.erase(itR);
	}
	printf("%s", S.begin()->c_str());
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int N;
	cin >> N;

	vector<int> d(N);
	for(int i=0; i<N; i++)
		cin >> d[i];

	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());

	cout << d.size() << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define test cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
void yn(bool b){ cout << (b ? "Yes" : "No") << endl; }
void YN(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


void solve() {
  int l, r, d;
  cin >> l >> r >> d;
  int cntr = r/d;
  int cntl = (l-1)/d;
  cout << cntr-cntl << endl;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3576
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append((int(input()), False))
    T.append((T[-1][0] + K, True))
T.sort(key=lambda x: (x[0], x[1]))
ans = 0
arrived = 0
head = 0
for t, bo in T:
    if arrived == 0 and not bo:
        head = t
    arrived += not bo
    if (bo and arrived > 0 and head <= t - K) or arrived == C:
        arrived = 0
        ans += 1
        head = 2000000009
if arrived > 0:
    ans += 1
print(ans)

Measured memory_bytes: 39868
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var line1, line2 string
	fmt.Scan(&line1, &line2)
	arr1, arr2 := make([]string, n), make([]string, n)
	for i, j := range line1 {
		arr1[i] = string(j)
	}
	for i, j := range line2 {
		arr2[i] = string(j)
	}
	arr := make([]int, 0)
	for i := 0; i < n; i++ {
		a, b := arr1[i], arr2[i]
		if a == b {
			arr = append(arr, 1)
		} else {
			arr = append(arr, 2)
			i++
		}
	}
	prev, count := 0, 1
	for _, i := range arr {
		switch i {
		case 1:
			switch prev {
			case 0: count *= 3
			case 1: count *= 2
			case 2: count *= 1
			}
		case 2:
			switch prev {
			case 0: count *= 3 * 2
			case 1: count *= 2
			case 2: count *= 3
			}
		}
		count %= 1000000007
		prev = i
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int N;
    cin >> N;

    int two_num=0;

    rep(i, N) {
        int k;
        cin >> k;
        while(k % 2 == 0) {
            two_num += 1;
            k = k / 2;
        }
    }

    cout << two_num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <numeric>
#include <algorithm>
#include <iterator>

int main(){
    int N, A1[100], A2[100];
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A1[i]);
    }
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A2[i]);
    }

    int x[100], ans;
    for (int n = 0; n < N; ++n) {
        x[n] = std::accumulate(std::begin(A1), std::begin(A1) + n + 1, 0) + std::accumulate(std::begin(A2) + n, std::begin(A2) + N, 0);
    }
    ans = *std::max_element(std::begin(x), std::begin(x) + N);

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}

Measured memory_bytes: 24264
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include "stdio.h"
 
using namespace std;
 
struct Node {
    int key;
    Node *prev, *next;
};
class DoublyLinkedList
{
private:
    Node *sentinel;
public:
    DoublyLinkedList() {
        Initialize();
    }
    void Initialize() {
        sentinel = new Node;
        sentinel->prev = sentinel;
        sentinel->next = sentinel;
    }
    Node *ListSearch(int key) {
        Node *current = sentinel->next;
        while (current != sentinel && current->key != key) {
            current = current->next;
        }
        return current;
    }
    int ListSize() {
        int count = 0;
        Node *current = sentinel->next;
        while (current != sentinel) {
            count++;
            current = current->next;
        }
        return count;
    }
    void PrintList() {
        Node *current = sentinel->next;
        int iterator = 0;
        while (1) {
            if (current == sentinel) break;
            if (iterator++) printf(" ");
            printf("%d", current->key);
            current = current->next;
        }
        printf("\n");
    }
    void Insert(int key) {
        Node *x = new Node;
        x->key = key;
        x->next = sentinel->next;
        sentinel->next->prev = x;
        sentinel->next = x;
        x->prev = sentinel;
    }
    void DeleteNode(Node *node) {
        if (node == sentinel) return;
        node->next->prev = node->prev;
        node->prev->next = node->next;
        delete node;
    }
    void DeleteFirst() {
        DeleteNode(sentinel->next);
    }
    void DeleteLast() {
        DeleteNode(sentinel->prev);
    }
    void DeleteKey(int key) {
        DeleteNode(ListSearch(key));
    }
    void DeleteAll() {
 
    }
    ~DoublyLinkedList() {
 
    }
};
 
int main() {
    int key, n;
    char command[20];
 
    scanf("%d", &n);
 
    DoublyLinkedList list = DoublyLinkedList();
 
    for (int i = 0; i < n; i++) {
        scanf("%s %d", command, &key);
        if (command[0] == 'i') {
            list.Insert(key);
        }
        else if (command[0] == 'd') {
            if (strlen(command) > 6) {
                if (command[6] == 'F') list.DeleteFirst();
                if (command[6] == 'L') list.DeleteLast();
            }
            else {
                list.DeleteKey(key);
            }
        }
         
    }
 
    list.PrintList();
 
    return 0;
}


Measured memory_bytes: 34464
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    double x1,y1,x2,y2,x,y,l;
   
    cin >> x1 >> y1 >> x2 >> y2;
    x = x2 - x1;
    y = y2 - y1;
    l = sqrt((x*x) + (y*y));
    
    printf("%lf\n",l);
    return 0;
    
}


Measured memory_bytes: 3216