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

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();

        boolean[] primes = new boolean[100111];
        Arrays.fill(primes, true);
        for (int i = 2; i <= 100110; i++) {
            if (primes[i]) {
                for (int j = i + i; j <= 100110; j += i) {
                    primes[j] = false;
                }
            }
        }

        for (int i = 2; i <= 100110; i++) {
            if (primes[i] && (i >= n)) {
                System.out.println(i);
                System.exit(0);
            }
        }

        System.exit(0);
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23508
# 再帰上限の追加
import sys
sys.setrecursionlimit(1000000)

n = int(input())
a = list(map(int, input().split()))
for i in a:
    if i % 2 == 0 and not (i % 3 == 0 or i % 5 == 0):
        print("DENIED")
        sys.exit()

print("APPROVED")


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

int main(){
 int N;
 cin>>N;
 vector<int>dp(3);
 for(int days=1;days<=N;days++){
    vector<int>new_dp(3,0);
    vector<int>c(3);

    for(int i=0;i<3;i++)cin>>c[i];

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(i!=j){
                new_dp[j]=max(new_dp[j],dp[i]+c[j]);
            }
        }
    }
    dp=new_dp;
 }

cout<<max(dp[0],max(dp[1],dp[2]))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll int
#define double long double
#define MAX 530100
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = INF;
ll modulo = pow(10,9)+7;

void deal(){
	ll n , d;
	cin>>n>>d;
	cout<<(n/(2*d+1) + (n%(2*d+1) != 0));
	
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}

/*

4 6
4 8 7 8
1 2 4
2 1 2 2
1 3 4
2 1 1 8
1 1 3
1 1 4

*/

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

ll a,b,x;

int main()
{
    scanf("%lld%lld%lld",&a,&b,&x);
    printf("%lld",!(a%x)?b/x-a/x+1:b/x-a/x);
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

if __name__ == "__main__":

	h, w = map(int, input().split())
	a = []
	a.append('#'*(w+2))
	for _ in range(h):
		a.append('#' + input() + '#')
	a.append('#'*(w+2))

	for i in range(h+2):
		print(a[i])


Measured memory_bytes: 3060
n,x,d = map(int, input().split())

if d == 0:
    if x == 0:
        print(1)
    else:
        print(n+1)
    exit()

node = []
for i in range(n+1):
    j = n-i
    base = x*(i-j)
    base += 2*d*(i-1)*i//2
    right = (n-i)*i
    if d<0:
        base += 2*d*right
    node.append((base, right))

node.sort()
d = abs(d)
di = {}
mod = 2*d
ans = 0
for base, r in node:
    i = base%mod
    if i in di:
        right_most = di[i]
        if right_most < base:
            ans += r+1
            di[i] = base+2*d*r
        elif base+2*d*r <= right_most:
            continue
        else:
            nxt = base+2*d*r
            ans += (nxt-right_most)//mod
            di[i] = nxt
    else:
        ans += r+1
        di[i] = base+2*d*r

print(ans)

Measured memory_bytes: 69820
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 32940
N = int(input())
result = 1

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return (a * b) // gcd(a, b)


for i in range(0, N):
    num = int(input())
    result = lcm(result, num)
print(int(result))


Measured memory_bytes: 2940
def prime_factorize(n):
    result = []
    if n % 2 == 0:
        t = 0
        while n % 2 == 0:
            n //= 2
            t += 1
        result.append((2, t))
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i != 0:
            continue
        t = 0
        while n % i == 0:
            n //= i
            t += 1
        result.append((i, t))
        if n == 1:
            break
    if n != 1:
        result.append((n, 1))
    return result


N = int(input())

t = [0] * (N + 1)
for i in range(2, N + 1):
    for p, e in prime_factorize(i):
        t[p] += e

result = 1
for i in range(2, N + 1):
    if t[i] == 0:
        continue
    result = result * (t[i] + 1) % 1000000007
print(result)


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

int main() {
    int N, Q;
    cin >> N >> Q;

    vector<int> a(N + 1), b(N + 1);
    for (int i = 1; i <= N; ++i) a[i] = b[i] = N;

    ll black = ll(N - 2) * (N - 2);

    int H = N, W = N;

    while (Q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            if (x < W) {
                for (int i = x; i < W; ++i) {
                    b[i] = H;
                }
                W = x;
            }
            black -= b[x] - 2;

        } else {
            if (x < H) {
                for (int i = x; i < H; ++i) {
                    a[i] = W;
                }
                H = x;
            }
            black -= a[x] - 2;
        }
    }
    cout << black << endl;

    return 0;
}

Measured memory_bytes: 4840
n=int(input())
a=[*map(int,input().split())]
b=c=0
l=[]
for i in a:
  if i==0:
    b=1
  if i<0:
    c+=1
  l.append(abs(i))
print(sum(l)-[0,min(l)*2][c%2 and b<1])

Measured memory_bytes: 20104
#include <iostream>
#include <cstdio>
using namespace std;
int w[100000];
int n,k;
int work(int p)
{
    int sum,i=0,j=k;
    while(j--)
    {
        sum=0;
        while(sum+w[i]<=p)
        {
            sum += w[i];
            i++;
            if(i==n)
                return n;
        }
    }
    return i;
}
int main()
{
    int i,left=0,right=1000000000,mid;
    cin>>n>>k;
    for(i=0;i<n;i++)
        //cin>>w[i];
        scanf("%d",&w[i]);
    while(right-left>1)
    {
        mid = (right+left)/2;
        if(work(mid)<n)
            left = mid;
        else
            right = mid;
    }
    cout<<right<<endl;
    return 0;
}

Measured memory_bytes: 3588
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = zeros(Int,n,n)
	for i in 1:n
		a[i,:] = readline() |> split |> parseMap
	end
	f = 0
	for k in 1:n
		for i in 1:n
			for j in 1:n
				if a[i,j] > a[i,k]+a[k,j]
					f = 1
					break
				end
			end
		end
	end
	if f == 1
		println(-1)
	else
		s = 0
		for i in 1:n-1
			for j in i+1:n
				f = 0
				ff = 0
				for k in 1:n
					if i!=k&&j!=k
						if a[i,j]>=a[i,k]+a[k,j]
							f = 1
						end
					end
				end
				if f==0
					s += a[i,j]
				end
			end
		end
		println(s)
	end
end
main()

Measured memory_bytes: 121092
#include "bits/stdc++.h"
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vvi vector<vector<int>>
#define vi vector<int>
#define f first
#define s second
using namespace std;
const int mod = 1e9 + 7;
int logi(int n) {int p = 0; while (n / 2) {n = n / 2; p++;} return p;}
int poww(int x, int y) {int pro = 1; while (y) {if (y & 1)pro = ((pro % mod) * (x % mod) % mod); y = y >> 1; x = ((x % mod) * (x % mod) % mod);} return pro;}
int poww2(int x, int y) {int pro = 1; while (y) {if (y & 1)pro = pro * x; y = y >> 1; x = x * x;} return pro;}
bool isprime(int n) { if (n == 1) return false; for (int i = 2; i <= sqrt(n); i++) if (n % i == 0) return false; return true;}
vector<vector<int>> adj(3e6);
vi visited(3e6, 0);
vi prime(3e6, 0);
/*

*/
void sieve()
{
	prime[0] = prime[1] = 1;
	for (int i = 2; i <= 1000000; i++)
	{
		if (!prime[i])
		{
			for (int j = i + i; j <= 1000000; j += i)
			{
				prime[j] = 1;
				adj[j].push_back(i);
			}
		}
	}
	for (int i = 1; i <= 1000000; i++)
	{
		if (!prime[i])adj[i].push_back(i);
	}
	// for (int i = 2; i <= 1000000; i++)
	// {
	// 	for (int j = 0; j < adj[i].size(); j++)cout << adj[i][j] << " ";
	// 	cout << '\n';
	// }
}

int solve() {
	sieve();
	//for (auto it : adj[999995]) cout << it << " ";
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	map<int, int> mp;
	int flag = 0;
	for (int i = 0; i < n; i++)
	{
		int x = v[i];
		for (auto& it : adj[x])
		{
			if (mp[it])
			{
				flag = 1;
				break;
			}
			else mp[it] = 1;
			//cout << it << " ";
		}
		//cout << '\n';
		if (flag == 1)
		{
			break;
		}
	}
	if (flag == 0)cout << "pairwise coprime";
	else
	{
		int gcd = v[0];
		for (int i = 1; i < n; i++)
		{
			gcd = __gcd(gcd, v[i]);
		}
		if (gcd == 1)cout << "setwise coprime";
		else cout << "not coprime";
	}

	return 0;
}
int32_t main() {
	/*#ifndef ONLINE_JUDGE
		    //for getting input from input.txt
		    freopen("input.txt","r",stdin);
		    //for writing output to output.txt
		    freopen("output.txt","w",stdout);
	#endif*/
	fast;
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 174196
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long[] numbers = Console.ReadLine().Split().Select(long.Parse).ToArray();


        long[] tmp = new long[n];
        tmp[0] = numbers[0];
        for (int i = 1; i < n; i++)
        {
            if (tmp[i-1] > numbers[i-1])
            {
                tmp[i-1] = numbers[i-1];
            }
            tmp[i] = Math.Max(numbers[i - 1], tmp[i - 1]);
        }


        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            ans += tmp[i];
        }
        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    int N, M;
    cin >> N >> M;

    vector<int> a(M, 0);
    vector<int> c(M, 0); // 開放可能な宝箱をビットで表現
    for (int i = 0; i < M; i++)
    {
        int b;
        cin >> a[i] >> b;
        for (int j = 0; j < b; j++)
        {
            int d;
            cin >> d;
            d--;
            c[i] += (1 << d);
        }
    }

    // DP[i][j]: key-i までで j で表現された宝箱の組み合わせの最小費用
    vector<vector<int>> DP(M, vector<int>((1 << N), (1 << 25)));
    DP[0][0] = 0;
    DP[0][c[0]] = a[0];

    for (int i = 0; i < M - 1; i++)
    {
        DP[i + 1][0] = 0;
        for (int s = 0; s < (1 << N); s++)
        {
            DP[i + 1][s] = min(DP[i + 1][s], DP[i][s]);
            int newDP = min(DP[i][s] + a[i + 1], DP[i][s | c[i + 1]]);
            DP[i + 1][s | c[i + 1]] = min(DP[i + 1][s | c[i + 1]], newDP);
        }
    }

    int ans = DP[M - 1][(1 << N) - 1];
    if (ans != (1 << 25))
        cout << DP[M - 1][(1 << N) - 1] << endl;
    else
        cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 16256
#include<stdio.h>

int main(void){

	int K, A, B, Ad, Bd;

	scanf("%d", &K);
	scanf("%d %d", &A, &B);

	Ad = A / K;
	Bd = B / K;



	if(Bd - Ad >= 1 || A % K == 0 || B % K == 0)
		printf("OK");
	else
		printf("NG");

	return 0;

}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;

long long gcd(const long long& a, const long long& b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;
    ll c = 0;
    map<P, ll> m;
    set<P> used;
    
    for (int i = 0; i < n; ++i)
    {
        ll a, b;
        cin >> a >> b;
        if (a == 0 && b == 0)
        {
            c++;
            continue;
        }
        ll gc = gcd(abs(a), abs(b));
        a /= gc;
        b /= gc;
        if (b < 0)
        {
            a *= -1ll;
            b *= -1ll;
        }
        if (b == 0)
        {
            a = 1;
            b = 0;
        }
        if (a == 0)
        {
            a = 0;
            b = 1;
        }
        m[P(a, b)]++;
    }
    vector<ll> cc(n + 1);
    cc[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        cc[i] = 2ll * cc[i - 1] + 1ll;
        cc[i] %= mod;
    }
    
    ll ret = 1;
    for (auto itr = m.begin(); itr != m.end(); ++itr)
    {
        P cur = itr->first;
        if (itr->second == 0 || used.count(cur) != 0)
        {
            continue;
        }
        ll tmp = 1ll + cc[itr->second - 1ll];
        used.insert(cur);
        P check = P(-cur.second, cur.first);
        if (cur.first < 0)
        {
            check = P(cur.second, -cur.first);
        }
        if (cur.first == 0)
        {
            check = P(1, 0);
        }
        if (m[check] != 0)
        {
            tmp += cc[m[check] - 1ll];
            used.insert(check);
            tmp %= mod;
        }
        ret *= tmp;
        ret %= mod;
    }
    ret += c;
    ret %= mod;
    
    ret -= 1ll;
    if (ret < 0)
    {
        ret += mod;
    }
    
    cout << ret << endl;

    return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
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 (b<a) { a=b; return 1; } return 0; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

vector<vector<string>> ans(10);

string chars="abcdefghij";

void solve(int n){
    if(n==1)return;
    rfor(str,ans){
        
    }
}

signed main(void){
    int n;cin>>n;
    ans[0].push_back("a");
    repi(i,1,n){
        rfor(str,ans[i-1]){
            set<char> s;
            rfor(c,str)s.insert(c);
            rep(j,s.size()+1){
                string newstr=str;
                newstr.push_back(chars[j]);
                ans[i].push_back(newstr);
            }
        }
    }
    sort(all(ans[n-1]));
    rfor(str,ans[n-1]){
        cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 11380
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
tmp = 0

for i in range(N):
  tmp = B[i] - A[i]
  if tmp > 0:
    count+=A[i]
    if tmp - A[i+1] > 0:
      count+=A[i+1]
      A[i+1] = 0
    else:
      count+=tmp
      A[i+1]-=tmp
  else:
    count+=B[i]

  
print(count)
  

Measured memory_bytes: 81892
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		int total = inputs.nextInt();
		int houses = inputs.nextInt();
		int maxgap = -1;
		int dist = 0;
		int first = inputs.nextInt();
		int prev = first;
		int num=0;
		for(int i=1;i<houses;i++) {
			num = inputs.nextInt();
			dist+=num-prev;
			maxgap = Math.max(maxgap, num-prev);
			prev=num;
		}
		if(num!=0)
			dist+= first+total-num;
		maxgap = Math.max(maxgap, first+total-num);
		dist-=maxgap;
		System.out.println(dist);
	}

}


Measured memory_bytes: 64948
#include<stdio.h>
 
int main(){
 
 int i,j;
 
for(i=0;i<9;i++)
 for(j=0;j<9;j++)
  printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
 
 
    return 0;
}

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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;


int32_t main()
{
    int n = in(), k = in();
    int ans = 0;
    while(k--){
        int p = in();
        ans += p;
    }
    if(ans >= n) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
typedef long long ll;
const int N = 2e5 + 5;
const int LEN = 524288;
const int G = 5;
const int Mod = 924844033;
int n, fac[N], Ifac[N], que[N], qn, fa[N], sze[N], num[N];
int tot, first[N << 1], next[N << 1], end[N << 1];
int len, w[2][LEN], R[LEN], x[LEN], y[LEN];
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
inline void AddEdge(int x, int y) {
	next[++tot] = first[x], first[x] = tot, end[tot] = y;
	next[++tot] = first[y], first[y] = tot, end[tot] = x;
}
inline int pow(int x, int k) {
	ll res = 1, r = x;
	for (; k; k >>= 1, r = r * r % Mod)
		if (k & 1) res = res * r % Mod;
	return res;
}
void NTT(int *a, int n, int res) {
	for (int i = 0; i < n; ++i) if (i < R[i]) std :: swap(a[i], a[R[i]]);
	
	for (int k = 1; k < n; k <<= 1) {
		int x = w[res][n / k / 2];
		for (int str = 0; str < n; str += k << 1) {
			int wx = 1;
			for (int i = str; i < str + k; ++i) {
				int u1 = a[i], u2 = (ll)wx * a[i + k] % Mod;
				a[i] = (u1 + u2) % Mod;
				a[i + k] = (u1 - u2 + Mod) % Mod;
				wx = (ll)wx * x % Mod;
			}
		}
	}
	
	if (!res) {
		int Inv = pow(n, Mod - 2);
		for (int i = 0; i < n; ++i) a[i] = (ll)a[i] * Inv % Mod;
	}
}
inline void Init(int n) {
	len = 0;
	while ((1 << len) <= n) ++len;
	int x = pow(G, (Mod - 1) / (1 << len));
	w[0][0] = w[1][0] = 1;
	for (int i = 1; i < (1 << len); ++i) {
		R[i] = (R[i >> 1] >> 1) | ((i & 1) << len - 1);
		w[0][(1 << len) - i] = w[1][i] = (ll)w[1][i - 1] * x % Mod;
	}
}
inline int calc(int n, int m) {
	return (ll)fac[n] * Ifac[m] % Mod * Ifac[n - m] % Mod;
}
int main() {
	n = Get();
	for (int i = 1, u, v; i < n; ++i)
		u = Get(), v = Get(), AddEdge(u, v);
	
	que[qn = 1] = 1, fa[1] = 0;
	for (int ql = 1, u; u = que[ql], ql <= qn; sze[u] = 1, ++ql)
		for (int k = first[u], v; v = end[k], k; k = next[k])
			if (v != fa[u]) fa[v] = u, que[++qn] = v;
	for (int qr = qn, u; u = que[qr], qr > 1; --qr) sze[fa[u]] += sze[u];
	for (int i = 2; i <= n; ++i) ++num[sze[i]], ++num[n - sze[i]];
	
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % Mod;
	Ifac[n] = pow(fac[n], Mod - 2);
	for (int i = n; i; --i) Ifac[i - 1] = (ll)Ifac[i] * i % Mod;

	for (int i = 1; i <= n; ++i) x[i] = (ll)num[i] * fac[i] % Mod;
	for (int i = 0; i <= n; ++i) y[n - i] = Ifac[i];
	
	Init(2 * n), NTT(x, 1 << len, 1), NTT(y, 1 << len, 1);
	for (int i = 0; i < (1 << len); ++i) x[i] = (ll)x[i] * y[i] % Mod;
	NTT(x, 1 << len, 0);
	
	for (int i = 1; i <= n; ++i) 
		printf("%d\n", (int)(((ll)n * calc(n, i) % Mod - (ll)Ifac[i] * x[n + i] % Mod + Mod) % Mod));
	return 0;
}

Measured memory_bytes: 21760
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m;
  cin >> n >> m;

  cout << (n - 1) * (m - 1) << endl;

  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int> > x(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int temp = 0;
            for(int k = 0; k < d; k++){
                temp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            double d = pow(temp, 0.5);
            if(ceil(d) == floor(d)) count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

char grid[105][105];

int dp[105][105];
int h,w;

int32_t main(){
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		cin>>grid[i]+1;
	}
	memset(dp,-1,sizeof dp);
	dp[1][1] = grid[1][1]=='#';
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==1 && j==1){
				continue;
			}
			dp[i][j] = min(i>1?dp[i-1][j]+(grid[i][j]=='#'&&grid[i-1][j]=='.')
								:1e18,
							j>1?dp[i][j-1]+(grid[i][j]=='#'&&grid[i][j-1]=='.')
								:1e18);
		}
	}
	cout<<dp[h][w];
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[]a = new long[N];
		long[]b = new long[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		long[]c = new long[M];
		long[]d = new long[M];
		for(int i = 0; i < M; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		sc.close();
		int[]id = new int[N];
		Arrays.fill(id, 1);
		for(int i = 0; i < N; i++) {
			long t = Math.abs(a[i] - c[0]) + Math.abs(b[i] - d[0]);
			for(int j = 1; j < M; j++) {
				long k = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if(t > k) {
					t = k;
					id[i] = j + 1;
				}
			}
		}
		for(int i = 0; i < N; i++) {
			System.out.println(id[i]);
		}
	}
}

Measured memory_bytes: 21204
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    int nx=0,ny=0,max=0,ax=0,ay=0;
    while(1) {
      int x,y,z;
      cin >> x >> y;
      if(x==0 && y==0) break;
      nx+=x;
      ny+=y;
      z=nx*nx+ny*ny;
      if(z>=max) {
	if(z==max) {
	  if(nx>ax) {
	    max=z;
	    ax=nx;
	    ay=ny;
	  }
	} else {
	  max=z;
	  ax=nx;
	  ay=ny;
	}
      }
    }
    cout << ax << " " << ay << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_edges3(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;
const int N = 3e5 + 4;

int r[N], c[N];
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    int n, m, k;
    cin >> n >> m >> k;

    map<pair<int, int>, int> mp;
    int R[k], C[k];
    rep(i, 0, k){
        cin >> R[i] >> C[i];
        r[R[i]]++, c[C[i]]++;
        mp[MP(R[i], C[i])]++;
    }

    int mr = 0, mc = 0;
    rep(i, 1, N) if(r[mr] < r[i]) mr = i;
    rep(i, 1, N) if(c[mc] < c[i]) mc = i;

    vector<int> row, col;
    rep(i, 1, N) if(r[i] == r[mr]) row.pb(i);
    rep(i, 1, N) if(c[i] == c[mc]) col.pb(i);

    int loop = 0;
    int mx = 0;
    for(auto i : row){
        for(auto j : col){
            loop++;
            if(loop > 2000000){
                cout << mx;
                return 0;
            }
            int X = r[i] + c[j];
            X -= mp[MP(i, j)];
            mx = max(X, mx);
        }
    }


    cout << mx;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 153916
from collections import deque

n = int(input())
s = str(input())

s = deque(s)

s2 = deque(s.popleft())

for i in range(n - 1):
    if s2[len(s2)-1] == s[0]:
        s.popleft()
    else:
        s2.append(s.popleft())

print(len(s2))

Measured memory_bytes: 4212
#include <stdio.h>
#include <string.h>

int main(void)
{
    int alp_cnt[26] = {0};
    char str[1201] = {'\0'};

    while ( fgets(str, sizeof(str), stdin) != NULL ) {
        for ( int i = 0; i < strlen(str); i++ ) {
            if ( (0x41 <= str[i]) && (str[i] <= 0x5A) ) {
                alp_cnt[str[i] - 'A']++;
            } else if ( (0x61 <= str[i]) && (str[i] <= 0x7A) ) {
                alp_cnt[str[i] - 'a']++;
            }
        }
        memset(str, '\0', sizeof(str));
    }

    for ( int i = 0; i < 26; i++ ) {
        printf("%c : %d\n", 'a' + i, alp_cnt[i]);
    }

    return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 123456789

signed main(){
  string s;
  int size, g = 0, p = 0, ans = 0;
  
  cin>>s;

  size = s.size();

  for(int i  = 0; i < size; i++){
    if(s[i] == 'g'){
      if(g >= p+1)p++,ans++;
      else g++;
    } else {
      if(g >= p+1)p++;
      else g++,ans--;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

// パスカルの三角形を利用してnCrのテーブルをコンパイル時に O(nr) で構築する。
template<size_t N>
struct CombTable {
    static_assert(N < 70u, "Template parameter <N> is too large. It may be Overflow.");
    i64 mat[N+1][N+1];
    constexpr explicit CombTable() {
        for (int n = 0; n <= N; ++n) {
            for (int r = 0; r <= n; ++r) {
                mat[n][r] = ((r == 0 || n == r) ? (1) : (mat[n-1][r-1] + mat[n-1][r]));
            }
        }
    }
    i64 operator() (int n, int r) const { return (r < 0 || n < r) ? 0 : mat[n][r]; }
};

signed main()
{
    int N, A, B;
    i64 v[55];
    unordered_map<i64, int> cnt;

    cin >> N >> A >> B;
    for (int i = 0; i < N; ++i) {
        cin >> v[i];
        ++cnt[v[i]];
    }

    sort(v, v+N, greater<>());
    const i64 sum = accumulate(v, v+A, 0LL);
    const CombTable<60> comb;

    i64 ans = 0;
    for (int n = A; n <= B; ++n) {
        i64 s = 0;
        unordered_map<i64, int> c;
        for (int i = 0; i < n; ++i) {
            s += v[i];
            ++c[v[i]];
        }
        if (s * A == sum * n) {
            i64 p = 1;
            for (const auto e : c) { p *= comb(cnt[e.first], e.second); }
            ans += p;
        }
    }

    cout << fixed << setprecision(9) << double(sum) / A << endl;
    cout << (ans) << endl;

    return 0;
}


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

int main()
{
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++)
  {
    if (s.at(i) != t.at(i))
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3920
N,A,B=map(int,input().split())
s = input().rstrip()
count = 0
countB = 0
for i in range(N):
  if A+B <= count:
    print('No')
  else:
    if s[i] == 'a':
      print('Yes')
      count += 1
    elif s[i] =='b':
      if countB < B:
        print('Yes')
        countB += 1
        count += 1
      else:
        print('No')
    else:
      print('No')


Measured memory_bytes: 4040
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;

struct segtree{
    vector<ll> dat;
    int size;
    segtree(int n):dat(2*n-1,(1LL<<31)-1),size(n){};
    void update(int i,ll a){
        i+=this->size-1;
        dat[i]=a;
        while(i>0){
            i=(i-1)/2;
            dat[i]=min(dat[i+2+1],dat[i*2+2]);
        }
    }
    ll query(int a,int b){
        return querysub(a,b,0,0,this->size);
    }
    ll querysub(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return (1LL<<31)-1;
        else if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=querysub(a,b,k*2+1,l,(l+r)/2);
            ll vr=querysub(a,b,k*2+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};

int main(){
    ll n,d;cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;++i){
        ll x,y;cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char *argv[])
{

  int N, M;

  cin >> N >> M;

  vector<int> odd, even;

  for (int i = 0; i <= N; i++)
  {
    if ((i % 2) == 0)
    {
      even.push_back(i);
    }
  }

  for (int i = 0; i <= M; i++)
  {
    if ((i % 2) != 0)
    {
      odd.push_back(i);
    }
  }

  int r = 0;

  for (auto &&o : odd)
  {
    for (auto &&e : even)
    {
      //cout << e << " " << o << endl;

      if ((o + e) % 2 == 0)
      {
        r++;
      }
    }
  }

  int s = ((M * (M - 1)) / 2) + ((N * (N - 1)) / 2);

  cout << r + s << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np

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


N,K=spaceinput()

res=0

for i in range(1,N+1):
    if K>i:
        tmp=np.ceil(np.log2(K/i))
        res+=(0.5**tmp)/N
    else:
        res+=1/N

    


print(res)


Measured memory_bytes: 14400
import queue
N = int(input())
alist = [[] for _ in range(N+1)]
d = {}
q = queue.Queue()

for _ in range(N-1):
    u, v, w = map(int, input().split())
    alist[u].append(v)
    alist[v].append(u)
    d[(u, v)] = w % 2

q.put(1)
d[(1, 1)] = 0
seen = [False]*(N+1)
seen[1] = True

while not q.empty():
    s = q.get()
    for n in alist[s]:
        if not seen[n]:
            q.put(n)
            seen[n] = True
            d[(1, n)] = (d[1, s]+d[tuple(sorted([s, n]))]) % 2

for i in range(1, N+1):
    print(d[(1, i)])


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

int main() {
  int h,w;
  cin >> h>> w;
  string s[h][w];
  int dp[h][w];
  string tmp;
  for(int i = 0; i < h;i++){
    cin >> tmp;
    for(int j = 0; j < w;j++){
        s[i][j] = tmp[j];
    }
  }
  int tmpx,tmpy;
  
  if(s[0][0] == "#"){
    dp[0][0] = 1;
    
  }else{
    dp[0][0] = 0;
  }
  
  for(int i = 0; i < h;i++){
    for(int j = 0; j < w;j++){
      if(i == 0 && j == 0){
      
      }else if(i == 0){
        if(s[i][j-1] != s[i][j] && s[i][j] == "#" ){
          
          dp[i][j] = dp[i][j-1] + 1;
        }else {
          dp[i][j] = dp[i][j-1];
        }
      }else if(j == 0){ 
        if(s[i-1][j] != s[i][j] && s[i][j] == "#" ){
          dp[i][j] = dp[i-1][j] + 1;
        }else {
          dp[i][j] = dp[i-1][j];
        }
      }else{
        if(s[i][j-1] != s[i][j] && s[i][j] == "#" ){
          tmpy = dp[i][j-1] + 1;
        }else {
          tmpy = dp[i][j-1];
        }
    
        if(s[i-1][j] != s[i][j] && s[i][j] == "#" ){
          tmpx = dp[i-1][j] + 1;
        }else {
          tmpx = dp[i-1][j];
        }
        
        dp[i][j] = min(tmpx,tmpy);
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
  
  //for(int i = 0; i < h;i++){
  //  for(int j = 0; j < w;j++){
  //    cout << dp[i][j] << " ";
  //  }
  //  cout << endl;
  //}
  
 }

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll n;
  cin >>n ;
  //ll a, b, c;
  //cin >> a >> b;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  ll buf;
  vector<string> s(n);
  for(i=0;i<n;i++){
    cin >> s[i];
  }
  ll countb=0,counta=0,countba=0;
  for(i=0;i<n;i++){
    for(j=0;j+1<s[i].size();j++){
      if(s[i][j]=='A'&&s[i][j+1]=='B')
      result++;
    }
    if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A')
    countba++;
    else if(s[i][s[i].size()-1]=='A')
    counta++;
    else if(s[i][0]=='B')
    countb++;
  }
  if(countba>=1){
    if(max(counta,countb)>=1)
    result+=countba+min(counta,countb);
    else
    result+=countba-1;
  }
  else
   result+=min(counta,countb);

  cout<<result<<endl;





  return 0;
}

Measured memory_bytes: 768
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

int i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
void solve()
{
	int n; cin>>n;
	lli a[n];
	rep(i,0,n-1) cin>>a[i];
 lli max=-1; int ct=0;
	rep(i,0,n-1)
	  if(a[i]>=max)
       {
	  	 max=a[i]; ++ct;
       }

       cout<<ct<<"\n";
}

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

int main(){
  int n,t;
  cin >> n >> t;
  vector<int>tim(n);
  for(int i=0;i<n;i++)
    cin >> tim.at(i);
  int64_t ans=0,nt=-2e9;
  for(int i=0;i<n;i++){
    if(nt+t<tim.at(i)){
      ans+=t;
    }else{
      ans-=nt+t-tim.at(i);
      ans+=t;
    }
    nt=tim.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, x;
  cin >> n >> x;
  vi a(n);
  rep(i, n) cin >> a[i];
  int ans = 1, now = 0;
  rep(i, n) {
    now += a[i];
    if(now <= x) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

def is_prime(num):
    if num == 2:
        return True

    if num < 2 or num % 2 == 0:
        return False

    index = 3
    while index <= int(math.sqrt(num)) + 1:
        if num % index == 0:
            return False
        index += 2
    return True


n = int(input())

output = 0
for index in range(n):
    num = int(input())
    if is_prime(num):
        output += 1
print(output)


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

class Main{
    public static void main(String args[]) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s1 = new String(in.readLine());
        String s2 = new String(in.readLine());
        String s3 = new String(in.readLine());
        String s4 = new String(in.readLine());

        int n = Integer.parseInt(s1);

        int score = 0;
        char c2,c3,c4;
        for( int x = 0; x < n ; x++){
            c2 = s2.charAt(x);
            c3 = s3.charAt(x);
            c4 = s4.charAt(x);

            if( c2 != c3 ){
                if( c2 != c4){
                    if( c3 != c4){
                        score = score + 2;
                    }else{
                        score = score + 1;
                    }
                }else{
                    score = score + 1;
                }
            }else{
                if( c2 != c4){
                    score = score + 1;
                }
            }
        }
        System.out.print( score );
  }
}

Measured memory_bytes: 20692
// AOJ 0171: Dice Puzzle
// 2017.8.17 bal4u@uu
// 2017.12.29
// ?????????????????¢??¨??????????????????????????°

#include <stdio.h>

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };

int con[8][7][2] = {{{0}},
	{{0},{0},{0},{0},{0,3},{0},{0}},		// ?????????????????¨??¢??????
	{{0},{0},{1,5},{0},{0},{0},{0}},
	{{0},{0},{0,5},{2,4},{0},{0},{0}},
	{{0},{0},{0},{0},{0},{0},{0,1}},
	{{0},{0},{0},{0},{4,3},{0},{1,1}},
	{{0},{0},{5,5},{0},{0},{0},{2,1}},
	{{0},{0},{4,5},{6,4},{0},{0},{3,1}}};

char dice[8][8];
char kari[8][8], f[9];
char tr[128];

int rec(int n)
{
	int i, j, k, cnt;
	char tbl[7][2], c;

	if (n == 8) return 1;
	for (i = 0; i < 8; i++) {
		if (f[i]) continue;
		cnt = 0;
		for (j = 1; j <= 6; j++) if (con[n][j][1]) {
			c = tr[kari[con[n][j][0]][con[n][j][1]]];
			for (k = 1; ; k++) {
				if (k > 6) goto next;
				if (dice[i][k] == c) { tbl[cnt][0] = j, tbl[cnt++][1] = c; break; }
			}
		}

		for (j = 0; j < 24; j++) {
			for (k = 1; k <= 6; k++) kari[n][k] = dice[i][rot[j][k]];
			for (k = 0; k < cnt; k++) {
				if (kari[n][tbl[k][0]] != tbl[k][1]) break;
			}
			if (k < cnt) continue;
			f[i] = 1;
			if (rec(n+1)) return 1;
			f[i] = 0;
		}
		next:;
	}
	return 0;
}

int main()
{
	int i, j, k;
	char buf[10];

	for (i = 0; i < 26; i++) tr['a'+i] = 'A'+i, tr['A'+i] = 'a'+i;

	while (1) {
		for (i = 0; i < 8; i++) {
			fgets(buf, 10, stdin);
			if (*buf == '0') return 0;
			for (j = 0; j < 6; j++) dice[i][j+1] = buf[j];
			f[i] = 0;
		}
		for (i = 0; ; i++) {
			if (i == 7) { puts("NO"); break; }
			f[i] = 1;
			for (j = 0; j < 12; j++) {
				for (k = 1; k <= 6; k++) kari[0][k] = dice[i][rot[j][k]];
				if (rec(1)) { puts("YES"); goto next; }
			}
			f[i] = 0;
		}
		next:;
	}
	return 0;
}

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

int main()
{
  ll n; cin >> n;
  map<string, int> mp;
  for (int i=0; i<n; i++){
    string s; cin>>s;
    mp[s]++;
  }
  int x = 0;
  for (auto v:mp) {
    x = max(x, v.second);
  }
  for (auto v:mp) {
    if (x == v.second) cout << v.first << endl;
  }

  return 0;
}


Measured memory_bytes: 25216
#include<stdio.h>
main(void)
{
	int a,b,c,x;

	scanf("%d %d %d",&a,&b,&c);

	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	if(b>c){
		x=b;
		b=c;
		c=x;
	}
	if(a>b){
		x=a;
		a=b;
		b=x;
	}

	printf("%d %d %d\n",a,b,c);

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

ll P = 1000000007;

template <typename T> class RMQ {
  vector<T> data;
  T unit;

public:
  static const long long INF = 100000000000;
  int n;
  function<T(const T &, const T &)> f;
  RMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }
  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }
  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  ll a, b;
  cin >> n >> a >> b;
  vll v(n + 1);
  v[0] = -(1LL << 62);
  for (int i = 0; i < n; i++)
    cin >> v[i + 1];
  for (int i = 2; i <= n; i++)
    if (v[i] - v[i - 2] < min(a, b)) {
      cout << "0" << endl;
      return 0;
    }
  if (a > b)
    swap(a, b);
  RMQ<ll> rmq(n + 1, 0,
              [](const ll &l, const ll &r) { return (l + r) % 1000000007; });
  rmq.update(0, 1);
  rmq.update(1, 1);
  int p = 0;
  for (int i = 2; i <= n; i++) {
    auto j = upper_bound(v.begin(), v.begin() + i, v[i] - b) - v.begin();
    if (j > p)
      rmq.update(i, rmq.query(p, j));
    if (v[i] - v[i - 1] < a) {
      p = i - 1;
    }
  }
  cout << rmq.query(p, n + 1) << endl;
  return 0;
}


Measured memory_bytes: 5120
X, K, D = map(int, input().split())

X = abs(X)
_n = X // D

if _n >= K:
    print(X - K * D)
else:
    _j = K - _n
    if _j % 2 == 0:
        print(X - _n * D)
    else:
        print(abs(X-(_n+1)*D))


Measured memory_bytes: 9172
MOD = pow(10, 9) + 7

def modinv(a, mod):
    return pow(a, mod - 2, mod) % mod

def comb(n, r, mod):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) % mod
        res = res * modinv(i + 1, mod) % mod
    return res

n, a, b = map(int, input().split())

ans = (pow(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)) % MOD

print(ans)


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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

int main() {FIN;
    string s;
    cin>>s;
    if(s == "SUN")
        cout<<"7\n";
    else if(s == "MON")
        cout<<"6\n";
    else if(s == "TUE")
        cout<<"5\n";
    else if(s == "WED")
        cout<<"4\n";
    else if(s == "THU")
        cout<<"3\n";
    else if(s == "FRI")
        cout<<"2\n";
    else
        cout<<"1\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 12

char A[N], B[N], C[N];

int main(void)
{
    int i;
    char c1, c2;

    scanf("%s", A);
    scanf("%s", B);
    scanf("%s", C);

    for (i=0; A[i]!='\0'; i++)
        c1 = A[i];
    for (i=0; B[i]!='\0'; i++)
        c2 = B[i];

    if (c1 == B[0] && c2 == C[0])
        printf("YES");
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll a,b,c,d;
 cin>>a>>b>>c>>d;
 ll cnta = a/d;
 ll cntc = c/b;
 if( a%d != 0 ) cnta++;
 if( c%b != 0 ) cntc++;
 //cout<<cnta<<' '<<cntc<<endl;
 if( cnta >= cntc ) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636