akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec A(N); readvec(A);

    set<int> s;
    REP(i, N) s.insert(A[i]);
    int ans = s.size();
    if(ans % 2 == 0) ans--;
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int abc[30];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string str;
    cin>>str;
    
    for(char c:str){
        abc[c-'a']++;
    }
    rep(i,26){
        if(abc[i]>=2){
            cout1("no")
            exit(0);
        }
    }
    cout1("yes")
}

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

char s[11];
ll an;
int n;

void go(int i = 0, ll a = 0, ll l = 0) {
	if (i == n ) { 
		if (l == 0)an += a;
		return;
	}
	ll d = s[i] - '0' + 10 * l;
	go(i + 1, a + d, 0);
	go(i + 1, a, d);
}

int main() {
	scanf("%s", s);
	n = strlen(s);
	go();
	printf("%lld", an);
}

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

int main()
{
    long long int a,b,n,ans;
    double x;

    cin>>a>>b>>n;

    if(b-1 <= n) x = (double) (b-1.0) / (double) b;
    else x = (double) n / (double) b;

    ans = floor((double) a * x) - a * floor(x);    

    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int B = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
 
    if (S == "Y") {
      B++;
    }
  }
  if (0 < B) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

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

ll a[30][30], c[30], b[30];
int main()
{
    ll n,m,x;
    cin>>n>>m>>x;

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


    int f;
    ll cost=0, mn=1e18;
    for(int i=0; i<(1<<n); i++)
    {
        memset(b, 0, sizeof(b));
        cost=0;
        for(int j=0; j<n; j++)
        {
            if(i & (1<<j))
            {
                cost+=c[j];
                for(int k=0; k<m; k++)
                    b[k]+=a[j][k];
            }
        }
        f=0;
        for(int k=0; k<m; k++)
         if(b[k]<x) f=1;

        if(!f) mn=min(mn, cost);
    }


    if(mn==1e18) cout<<"-1";
    else cout<<mn;
}


Measured memory_bytes: 3564
N,A,B = gets.split(" ").map{|v|
	v.to_i
}

ar = gets.split(" ").map{|v|
	v.to_i
}

# 貪欲 上位A個を取る A個目とA+1個目が異なるなら1通り
ar.sort!.reverse!

sum = 0
=begin
ar[0,A-1].inject{|v|
	sum += v
}
=end
for i in 0.. A-1
	sum += ar[i]
end
ave = sum.to_f/ A 
puts ave

if ar[A-1] != ar[A] then
	puts 1
	exit
end

n0 = ar.select{|x| x == ar[A-1]}.length
nb = ar.select{|x| x > ar[A-1]}.length

def fac(i)
=begin
	return [1 .. i].to_a.inject(1) { |sum, j| sum * j }
=end
j = 1
1.upto(i) do |k|
	j = j * k
end
return j
end


# 上位A個が異なる値ならば
if ave != ar[0]
	# n0 C (A-nb)
	puts fac(n0) / (fac(A-nb) * fac(n0-A+nb))
else
	#上位A個が全て同じ→A+1個以上取っても良い
	m = [n0, B].min
	
	sum = 0
	A.upto(m) do |i|
		sum += fac(n0) / (fac(i) * fac(n0-i))
	end
	puts sum
end

	

Measured memory_bytes: 1788
#include<iostream>

using namespace std;

int main() {

   int m = 0, f = 0, r = 0;
   cin >> m >> f >> r;
   while (m >= 0 || f >= 0 || r >= 0) {
      if (m < 0 || f < 0) {
         cout << "F";
      } else if (m + f < 30) {
         cout << "F";
      } else if (m + f < 50) {
         if (r >= 50) {
            cout << "C";
         } else {
            cout << "D";
         }
      } else if (m + f < 65) {
         cout << "C";
      } else if (m + f < 80) {
         cout << "B";
      } else {
         cout << "A";
      }
      cout << endl;
      cin >> m >> f >> r;
   }

   return 0;

}

Measured memory_bytes: 1156
package main

import (
  "fmt"
)

func main() {
  var n, a, b int
  fmt.Scanf("%d %d %d", &n, &a, &b)
  
  max := a
  min := a + b - n
  if a > b {
    max = b
  }
  if min < 0 {
    min = 0
  }
  
  fmt.Printf("%d %d\n", max, min)
}

Measured memory_bytes: 1832
#include <stdio.h>

int main(void) {
        int H, W;
	while(1){
	    scanf("%d %d", &H, &W);
	    if(H==0 && W==0){
	    	break;
	    }
	    for(int i=0; i<W; i++){
	    	printf("#");
	    }
	    printf("\n");
	    for(int i=0; i<H-2; i++){
	    	for(int j=0; j<W; j++){
	    		if(j==0 || j==W-1){
	    			printf("#");
	    		}else{
	    			printf(".");
	    		}
	    	}
	    	printf("\n");
	    }
	    for(int i=0; i<W; i++){
	    	printf("#");
	    }
	    printf("\n\n");
	}
	return 0;
}



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

using namespace std;
typedef long long ll;

const int MAXN = 1e5+2;
int a[MAXN] = {0};
int vis[MAXN] = {0};
int N;
void solve(){
	cin>>N;
	for (int i=0;i<N;i++){
		a[i] = 0x7fff7fff;
	}
	// deque instead priority_queue for 01-bfs.
	deque<pair<int,int>> dq;
	dq.emplace_back(1,1);
	while (!dq.empty()){
		auto top = dq.front();
		int u = top.first;
		int d = top.second;
		dq.pop_front();
//		cout<<u<<' '<<a[u]<<' '<<d<<endl;
		if (a[u]<=d){
			continue;
		}
		a[u] = d;
		if (u==0){
			break;
		}
		int v;
		v = u * 10 % N;
		dq.emplace_front(v, d);
		v = (u+1) % N;
		dq.emplace_back(v, d+1);
	}
	cout<<a[0]<<endl;
}

int main(){
// 	freopen("in.txt","r",stdin);
// 	freopen("out.txt","w",stdout);
	std::ios::sync_with_stdio(false);

		solve();

	return 0;
}



Measured memory_bytes: 1536
S =list(input());

S1 =[];
for i in range(len(S)):
    if i%2 ==0:
        S1.append("1");
    else:
        S1.append("0");

change1 =0;
change2 =0;

for i in range(len(S)):
    if S[i] !=S1[i]:
        change1 +=1;
    else:
        change2 +=1;
        
print(min(change1,change2));


Measured memory_bytes: 4652
import sys
import numpy as np

def main():
  input = sys.stdin.readline
  N, K = map(int, input().split())
  INF = N * K
  dp = input().strip()
  text =""
  for i in range(N):
    if i == K-1:
      text = text + dp[i].lower()
    else:
      text = text + dp[i]
  print(text)
  
main()

Measured memory_bytes: 21520
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

int N;
int A[100001];

int main(){
    cin>>N;
    repn(i,N) cin>>A[i];
    A[0]=A[1];

    int ans=1;
    bool rize=true;
    bool first=true;
    repn(i,N){
        if(A[i-1]==A[i]) continue;
        if(first){
            if(A[i-1]<A[i]) rize=true;
            else rize=false;
            first=false;
        }else{
            if(rize){
                if(A[i-1]>A[i]){
                    ans++;
                    first=true;
                }
            }else{
                if(A[i-1]<A[i]){
                    ans++;
                    first=true;
                }
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	 int n,m,c,k;
	 cin>>n>>m>>c;
	 int cnt = 0;
	 vector<int>b(m);
	 for(int  i = 0;i<m;i++)cin>>b[i];

	 for(int  i = 0;i<n;i++)
	 {
          int sum = c;
          for(int  i = 0;i<m;i++)
          {
          	 cin>>k;
          	 sum+=(b[i]*k);
          }

          if(sum >0)
          	cnt++;
	 }
	 cout<<cnt<<endl;	
}

Measured memory_bytes: 256
import fractions
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
n,m = (int(x) for x in input().split())
a = list(map(int, input().split()))
 
lc = int(lcm_list(a) // 2)
 
tmp = 0
bol = 0
num = a[0]
while num % 2 == 0:
        num = num // 2
        tmp += 1
cnt = 0
for num in a:
    cnt = 0
    while num % 2 == 0:
        num = num // 2
        cnt += 1
    if cnt != tmp:
        bol = 1
 
if lc > m: print(0)
elif bol == 1: print(0)
else: print(int(((m / lc) + 1) // 2))

Measured memory_bytes: 16308
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n;
    cin >> n;

    rep(_, n){
        string s[3]; cin >> s[0] >> s[1];
        
        int ans = 0;
        
        rep(k, 2){
            int p = 1;
            rep(i, s[k].size()){
            
                if(s[k][i] == 'm') ans += p*1000, p = 1;
                else if(s[k][i] == 'c') ans += p*100, p = 1;
                else if(s[k][i] == 'x') ans += p*10, p = 1;
                else if(s[k][i] == 'i') ans += p*1, p = 1;
                else if(s[k][i] == ' '){

                }
                else {
                    //cout << s[k][i] - '0' << endl;
                    p = s[k][i] - '0';
                    //p = 1;
                }
            }
            //cout << ans << endl;
        }


        //cout << ans << endl;

        while(ans != 0){
            if(1000 <= ans){
                if(ans / 1000 != 1) cout << ans / 1000;
                cout << 'm';
                ans %= 1000;
            }else if(100 <= ans){
                if(ans / 100 != 1) cout << ans / 100;
                cout << 'c';
                ans %= 100;
            }else if(10 <= ans){
                if(ans / 10 != 1) cout << ans / 10;
                cout << 'x';
                ans %= 10;
            }else{
                if(ans != 1) cout << ans;
                cout << 'i';
                ans = 0;
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  while(A>0&&C>0)
  {
    C=C-B;
    if(C<=0)
      break;
    A=A-D;
  }
  if(A<=0)
    cout<<"No";
  else 
    cout<<"Yes";
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	int ans = 0;
	bool up = false, down = false;
	for(int i = 0; i < n - 1; ++i) {
		if( a[i] < a[i + 1] ) {
			up = true;
		} else if( a[i] > a[i + 1] ) {
			down = true;
		} 
		
		if( up && down ) { 
			ans++;
			up = false; down = false;
		}
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 640
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()
q = int(input())
qqq = list(map(lambda s: s.strip(), sys.stdin.readlines()))

que = deque()

que.append(s)

rev = False

for a in qqq:
    b = a.split()

    if len(b) == 1:
        rev = not rev
    else:
        front = b[1] == "1"
        t = b[2] if not rev else "".join(reversed(b[2]))

        if front == (not rev):
            que.appendleft(t)
        else:
            que.append(t)

if rev:
    print("".join(reversed("".join(que))))
else:
    print("".join(que))

Measured memory_bytes: 113584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(){
    int N, M;
    cin >> N;
    vector<long long> T(N);
    long long time=0;
    for (int i=0; i<N; i++) {
        cin >> T.at(i);
        time+=T.at(i);
    }
    cin >> M;
    vector<int> P(M);
    vector<long long> X(M);
    for (int i=0; i<M; i++) {
        cin >> P.at(i) >> X.at(i);
    }
    for (int i=0; i<M; i++) {
        cout << time-T.at(P.at(i)-1)+X.at(i) << endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, count = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  vector<int> A(3,0);
  for(char c:S)
    A[c-'a']++;
  if(max({A[0],A[1],A[2]})-min({A[0],A[1],A[2]})<=1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 3704
#include <string>
#include <algorithm>
#include <cctype>
#include <iostream>
using namespace std;

char toUpper(char c){ return toupper(c); }

int main(){
    string s;
    getline(cin, s);
    transform(s.begin(), s.end(), s.begin(), toUpper);
    cout << s << endl;
}

Measured memory_bytes: 0
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int n, k;
	cin >> n >> k;
	cout << min(n % k, (k - n % k)) << endl;
}
int32_t main() {
	int t;
	t = 1;
	int cnt = 1;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=2e5+5;
ll a[M];
ll sum[M];
const ll mod=1e9+7;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
        sum[i]=(sum[i-1]+a[i])%mod;
    }
    ll res=0;
    for(int i=1;i<=n;i++)
    {
        res=(res+a[i]*(sum[n]-sum[i]+mod)%mod)%mod;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 6904
fn main() {
    // input
    let one = read_vec::<u64>();
    // N
    let _ = one[0];
    // K
    let k = one[1];

    // h
    let h = read_vec::<u64>();

    let ans = h.into_iter().filter(|h| h >= &k).count();

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

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string S;
  std::cin >> S;

  int i = 700;
  for (auto &&s : S) {
    if (s == 'o') i += 100;
  }

  std::cout << i << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	string S;
	cin >> N >> S;

	vector<int> west(N), reast(N);
	for (int i = 0; i < N; i++) {
		if (S[i] == 'W') west[i]++;
		if(i) west[i] += west[i - 1];
	}
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'E') reast[i]++;
		if (i != N - 1) reast[i] += reast[i + 1];
	}

	int ans = INF, cnt;
	for (int i = 0; i < N; i++) {
		cnt = 0;
		if (i) cnt += west[i - 1];
		if (i != N - 1) cnt += reast[i + 1];
		ans = min(ans, cnt);
	}

	cout << ans << "\n";

	return 0;
}

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

int main(){
  int n,x,a[110];
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int ans=0;
  for(int i=0;i<n;i++){
    if(x>=a[i]){
      x-=a[i];
      ans++;
    }
  }
  if (ans==n&& x>0) {
    ans--;
  }
  cout<<ans;

}


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

int main() {
    int a; cin >> a;
    string s; cin >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
N_ken, M_hon = map(int, input().split())
ab = []
yen = 0
hon = 0

for i in range(N_ken):
    tmp = list(map(int, input().split()))
    ab.append(tmp)

ab.sort()

for a, b in ab:
    tmp = min(M_hon - hon, b)
    yen += tmp * a
    hon += tmp
    
    if (hon == M_hon):
        break

print(yen)

Measured memory_bytes: 27756
from bisect import bisect_left as bl 
from copy import deepcopy as dc
from time import time
from random import randint
start=time()
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for _ in range(D)]

T=[randint(1,26) for _ in range(D)]

last=[[0] for _ in range(26)]
score=[0]*D
for i in range(D):
    contest=T[i]-1
    if i == 0:
        score[i]=S[i][contest]
    else:
        score[i]=score[i-1]+S[i][contest]
    last[contest].append(i+1)
    for j in range(26):
        blank=i+1-last[j][-1]
        score[i]-=blank*C[j]

def research(day,query,border):
    global last,T,score
    T2=dc(T)
    last2=dc(last)
    score2=dc(score)
    T2[day-1]=query
    for i in range(26):
        ind=bl(last2[i],day)
        last2[i]=last2[i][:ind]

    for i in range(day-1,D):
        contest=T2[i]-1
        if i == 0:
            score2[i]=S[i][contest]
        else:
            score2[i]=score2[i-1]+S[i][contest]
        last2[contest].append(i+1)
        for j in range(26):
            blank=i+1-last2[j][-1]
            score2[i]-=blank*C[j]
    if score2[-1]>=border:
        T=dc(T2)
        last=dc(last2)
        score=dc(score2)
    return
"""
while time()-start<=0.5:
    research(randint(1,D),randint(0,25),score[-1])
"""
for i in range(D):
    print(T[i])


Measured memory_bytes: 10188
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, X, Y = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

cnt = [0] * N
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        k = min([j - i, abs(X - i) + abs(Y - j) + 1, abs(Y - i) + abs(X - j) + 1])
        cnt[k] += 1

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

Measured memory_bytes: 9268
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, readline().split())
    ans = pow(N, M, MOD)
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
S = sorted(L)
cost = 0
cnt = 0
for i in range(N):
	if M - cnt <= S[i][1]:
		cost += S[i][0] * (M - cnt)
		break
	else:
		cost += S[i][0] * S[i][1]
		cnt += S[i][1]
print(cost)

Measured memory_bytes: 28652
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = "";
		int a, i;
		int[] num = new int[1001];
		ArrayList<Integer> list = new ArrayList<Integer>();
		ArrayList<Integer> next = new ArrayList<Integer>();
		
		while(true){
			s = sc.nextLine();
			if(s.compareTo("")==0) break;
			
			i=0;
			while(s.substring(i,i+1).compareTo(",")!=0)i++;
			a = Integer.valueOf(s.substring(0,i));
			if(list.indexOf(a)==-1){
				num[list.size()]++;
				list.add(a);
			}else{
				num[list.indexOf(a)]++;
			}	
		}
		
		while(sc.hasNext()){
			s = sc.next();
			
			i=0;
			while(s.substring(i,i+1).compareTo(",")!=0)i++;
			a = Integer.valueOf(s.substring(0,i));
			
			if(list.indexOf(a)!=-1){
				num[list.indexOf(a)]++;
				if(next.indexOf(a)==-1) next.add(a);
			}
		}
		Collections.sort(next);
		for(int j=0;j<next.size();j++){
			a = next.get(j);
			System.out.println(a + " " + num[list.indexOf(a)]);
		}
	
	}
}

Measured memory_bytes: 17164
# -*- coding: utf-8 -*-
#import sys
from collections import deque

S = input().strip()
Q = int(input().strip())
Q_list = [input().strip() for _ in range(Q)]
#-----

# order = 1:  左→右
# order =-1:  左←右
order=1

dq = deque()

for word in S:
    dq.append(word)

for line in Q_list:
    if line == "1":
        order *= -1
    else:
        t,f,c = line.split()
        
        if order == 1 and f == "1":
            dq.appendleft(c)
        elif order == 1 and f == "2":
            dq.append(c)
        elif order == -1 and f == "1":
            dq.append(c)
        elif order == -1 and f == "2":
            dq.appendleft(c)

if order == 1:
    print( *list(dq), sep="" )
else:
    print( *list(reversed(dq)), sep="" )


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D){
    cout << "Left" << endl;
  }
  else if (A+B < C+D){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 1e3+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}

void solve(){
	ll a[3];
	rep(i,0,3)
		cin >> a[i];
	sort(a,a+3);
	if(a[0]==5 && a[0]==a[1])
		cout << "YES";
	else
		cout << "NO";
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			var num = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var memo = new bool[num+1];
            var set = new HashSet<Tuple<int, int>>();

            for(int i = 0; i< input.Length; i++)
            {
                int tmp = input[i];
                int now = i + 1;

                set.Add(new Tuple<int, int>(tmp, now));
            }

            int count = 0;
            foreach(var item in set)
            {
                if (set.Contains(new Tuple<int, int>(item.Item2, item.Item1)) && !memo[item.Item2])
                {
                    memo[item.Item1] = true;
                    count++;
                }
            }

            Console.WriteLine(count);
		}		
		 
	}
}

Measured memory_bytes: 22856
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MAKEDIVS = lambda n: [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]

def main():
    n = II()
    divisors = MAKEDIVS(n)
    ans = len(str(divisors[-1][1]))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
struct Edge { int from, to; long long cost; };
using Graph = vector<vector<Edge>>;

struct Combination {
    vector<long long> fac, inv, finv;
    long long md = 0;
    Combination(int n, long long m): fac(n + 1), inv(n + 1), finv(n + 1) {
        md = m;
        fac[0] = fac[1] = 1;
        inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % md;
            inv[i] = md - inv[md % i] * (md / i) % md;
            finv[i] = finv[i - 1] * inv[i] % md;
        }
    }
    long long P(int n, int r) {
        if(r < 0 || n < r) return 0;
        return fac[n] * finv[n - r] % md;
    }
    long long C(int n, int r) {
        if(r < 0 || n < r) return 0;
        return fac[n] * (finv[r] * finv[n - r] % md) % md;
    }
    long long H(int n, int r) {
        if(r < 0 || n < r) return 0;
        return (r == 0 ? 1 : C(n + r - 1, r));
    }
};

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

    int n,k;
    cin>>n>>k;
    Combination c(2020,MOD);
    cout<<c.P(k,n)<<endl;
}


Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
 
using namespace std;
 
int main() {
    int sx, sy, tx, ty, x, y;
    cin >> sx >> sy >> tx >> ty;
    x = tx - sx;
    y = ty - sy;
    
    for (int i = 0; i < x; i++)
    {
        cout << 'R';
    }
    for (int i = 0; i < y; i++)
    {
        cout << 'U';
    }
    for (int i = 0; i < x; i++)
    {
        cout << 'L';
    }
    for (int i = 0; i < y; i++)
    {
        cout << 'D';
    }
 
    cout << 'D';
    for (int i = 0; i < x + 1; i++)
    {
        cout << 'R';
    }
    for (int i = 0; i < y + 1; i++)
    {
        cout << 'U';
    }
    cout << 'L';
 
    cout << 'U';
    for (int i = 0; i < x + 1; i++)
    {
        cout << 'L';
    }
    for (int i = 0; i < y + 1; i++)
    {
        cout << 'D';
    }
    cout << 'R';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
R,S,P = inpl()
a = input()
res = 0
for rem in range(k):
    dp = [[0]*3 for _ in range(len(range(rem,n,k))+1)]
    for i,j in enumerate(range(rem,n,k)):
        for x in range(3):
            pls = 0
            if x == 0 and a[j] == 's':
                pls += R
            if x == 1 and a[j] == 'p':
                pls += S
            if x == 2 and a[j] == 'r':
                pls += P
            for y in range(3):
                if x == y: continue
                dp[i+1][x] = max(dp[i][y]+pls, dp[i+1][x])
    # print(dp)
    res += max(dp[-1])
print(res)

Measured memory_bytes: 82008
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
H, W = 0, 0
A = []


def set_inputs():
    global H, W, A
    H, W = get_li()
    A = [get_str() for _ in range(H)]
    return


def main():
    set_inputs()
    # ----------MAIN----------
    stage = [[0 for _ in range(W)] for _ in range(H)]
    remaining = deque()
    for i, ai_ in enumerate(A):
        for j, a in enumerate(ai_):
            if a == ".":
                continue
            stage[i][j] = 1
            remaining.append((i, j))
    ans = 0
    while remaining:
        _next = deque()
        for (i, j) in remaining:
            stage[i][j] = 2
            if i > 0 and stage[i-1][j] == 0:
                stage[i-1][j] = 1
                _next.append((i-1, j))
            if i < H - 1 and stage[i+1][j] == 0:
                stage[i+1][j] = 1
                _next.append((i+1, j))
            if j > 0 and stage[i][j-1] == 0:
                stage[i][j-1] = 1
                _next.append((i, j-1))
            if j < W - 1 and stage[i][j+1] == 0:
                stage[i][j+1] = 1
                _next.append((i, j+1))
        remaining = _next
        ans += 1
    if ans == 0:
        print(0)
    else:
        print(ans - 1)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 122968
#include <bits/stdc++.h>
using namespace std;
int good[100100];
long long nums[100100];
int main(){
    for(int i = 0; i < 100100; ++i) good[i] = 1;
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i){
        cin >> nums[i];
    }
    for(int i = 0; i < m; ++i){
        int x, y;
        cin >> x >> y;
        if(nums[x] <= nums[y] && good[x] != 0) good[x] = 0;

        if(nums[y] <= nums[x] && good[y] != 0) good[y] = 0;
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(good[i] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4752
#include <stdio.h>

int main() {
    int abc;
    int a;
    int b;
    
    scanf("%d", &abc);
    scanf("%d %d", &a, &b);
    while(a <= b) {
        if(a%abc == 0) {
            printf("OK");
            return 0;
        }
        a++;
    }
    printf("NG");
    
    return 0;
}

Measured memory_bytes: 3216
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        int n3 = sc.nextInt();
        System.out.println(n3 + " " + n1 + " " + n2);
    }
}

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

int n;
int a[2][100];
int sum1 = 0, sum2 = 0;
int m;

int main(){
    cin >> n;
    for(int j = 0; j < n; j++){
        cin >> a[0][j];
    }
    for (int j = 0; j < n; j++){
        cin >> a[1][j];
        sum2 += a[1][j];
    }
    for(int j = 0; j < n; j++){
        sum1 += a[0][j];
        m = max(sum1 + sum2, m);
        sum2 -= a[1][j];
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<int> to(n+1);
  rep1(i,n) cin >> to[i];
  map<int,int> mp;
  int now = 1;
  int cnt = 0;
  int start = 0;
  int range = 0;
  while(cnt <= k){
    //cout << now;
    if(mp.count(now)){
      start = mp[now];
      range = cnt - start;
      break;
    }
    mp[now] = cnt;
    cnt ++;
    now = to[now];
  }
  //cout << endl;
  //for(auto p : mp) cout << p.first << ":" << p.second << endl;
  //cout << "k..." << k << endl;
  //cout << "start..." << start << endl;
  k -= start;
  //cout << "k..." << k << endl;
  //cout << "range..." << range << endl;
  if(range == 0){
    for(auto p : mp){
      if(p.second == k){
        cout << p.first << endl;
        return 0;
      }
    }
  }
  ll mod = k%range;
  //cout << "mod..." << mod << endl;
  ll target = mod + start;
  //cout << "target..." << target << endl;
  for(auto p : mp){
    if(p.second == target){
      cout << p.first << endl;
      return 0;
    }
  }
}


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

int main() {
    bool a[53];
    int n, b;
    char c;
	cin >> n;
	for (int i = 0; i < 53; i ++){
		a[i] = false;
	}
	for(int i = 1; i <= n; i++){
		cin >> c >> b;
		if (c == 'S')
			a[b] = true;
		else if (c == 'H')
			a[b+13] = true;
		else if (c == 'C')
			a[b+26] = true;	
		else a[b+39] =true;	
	}
	
	for (int i = 1; i < 53; i++){
		if (i < 14 && a[i] == false)
			cout << "S" << " " << i << endl;
		else if (i < 27 && a[i] == false)
			cout << "H" << " " << i-13 << endl;
		else if (i < 40 && a[i] == false)
			cout << "C" << " " << i-26 << endl;
		else if (a[i] == false)
			cout << "D" << " " << i-39 << endl;	
	}
	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl "\n"

using namespace std;

void dfs(int v)
{

}
void build(int ind,int low,int high)  // Build Segment Tree
{

}
int query(int ind,int low,int high,int l,int r)  //Query for Segment Tree
{

}
int main()
{
	string s;cin>>s;
	int c=0;
	int x=count(s.begin(),s.end(),'R');
	if(x==0) cout<<0;
	else if(x==3) cout<<3;
	else if(s[0]=='R' && s[1]=='R' || s[1]=='R'&&s[2]=='R') cout<<2;
	else cout<<1; 
	
 	
 	


return 0;
}



Measured memory_bytes: 3616
#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;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll ans = 0;
  ll now = 0;
  bool ok = false;
  s += "$";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
      ok = true;
      now++;
    } else {
      ok = false;
      ans = max(ans, now);
      now = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b>=k)
    {
        cout<<min(a,k)<<endl;
    }
    else
    {
        cout<<a-(k-(a+b))<<endl;
    }
    


    return 0;
}

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

int main() {
  int N=0, M=0;
  
  cin >> N;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
  for(int i=0; i<M; i++){
    cin >> t.at(i);
  }
  
  int point=0;
  int point_max=0;
  for(int i=0; i<N; i++){
    point = 0;
    for(int j=0; j<N; j++){
      if( s.at(i) == s.at(j) )
        point++;
    }
    for(int j=0; j<M; j++){
      if( s.at(i) == t.at(j) )
        point--;
    }
    if( point_max < point )
      point_max = point;
  }
  
  cout << point_max;
   
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

pii next_dir[2] = {
    {1, 0},
    {0, 1},
};

enum type {
    TYPE_NONE,
    TYPE_CHECKED,
};

void dfs(vector<vector<char>>& map, pii p) {
    map[p.first][p.second] = TYPE_NONE;
    debug("%d, %d\n", p.first, p.second);
    for(pii d: next_dir) {
        pii np = make_pair(
            p.first + d.first,
            p.second + d.second
        );
        if(map[np.first][np.second] == TYPE_NONE) continue;
        dfs(map, np);
        break;
    }
    return;
}

int main(void) {
    int row, col;
    cin >> row >> col;
    vector<vector<char>> map(row+2, vector<char>(col+2));
    for(int i = 1; i <= row; i++) {
        string str;
        cin >> str;
        for(int j = 1; j <= col; j++) {
            map[i][j] = (str[j-1] == '#');
        }
    }

    for(int i = 1; i <= row; i++) {
        for(int j = 1; j <= col; j++) {
            if(map[i][j] == TYPE_CHECKED) {
                dfs(map, make_pair(i, j));
                goto finish;
            }
        }
    }
finish:
    bool ans = 1;
    for(int i = 1; i <= row; i++) {
        for(int j = 1; j <= col; j++) {
            if(map[i][j] == TYPE_CHECKED) ans = 0;
        }
    }
    cout << (ans ? "Possible" : "Impossible") << endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int i;
    for(i=0;i<s.size();i++){
        if(s.at(i)=='A'){
            s.at(i)='T';
        }
        else if(s.at(i)=='T'){
            s.at(i)='A';
        }
        else if(s.at(i)=='C'){
            s.at(i)='G';
        }
        else if(s.at(i)=='G'){
            s.at(i)='C';
        }

        cout << s.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int prime(int);

int main()
{
	int N, i;
	int A[10001];
	scanf("%d",&N);
	for (i = 0; i <= N - 1; i++)
	{
		scanf("%d", &A[i]);
	}
	int m = 0, all = 0;
	for (i = 0; i <= N - 1; i++)
	{
		all += prime(A[i]);
	}
	printf("%d\n", all);
	return 0;
}


int prime(int x)
{
	if (x == 2 || x == 3) return 1;
	if (x == 1) return 0;
	if (x % 2 == 0) return 0;
	int i;
	for (i = 3; i <= sqrt((double)x); i += 2)
	{
		if (x%i == 0) return 0;
	}
	return 1;
}

Measured memory_bytes: 632
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int length = in.nextInt();
		int[] string = new int[length];
		for(int i = 0; i < length; i++)
		{
			string[i] = in.nextInt();
		}
		
		length = in.nextInt();
		int[] search = new int[length];
		for(int i = 0; i < length; i++)
		{
			search[i] = in.nextInt();
		}
		
		int count = 0;
		for(int i = 0; i < length; i++)
		{
			if(Search(string, search[i]))
			{
				count++;
			}
		}
		System.out.println(count);
	}
	
	public static boolean Search(int[] list, int n)
	{
		int start = 0;
		int end = list.length - 1;
		while(start <= end)
		{
			int mid = ((start + end) / 2);
		
			if(list[mid] == n)
			{
				return true;
			} else if (list[mid] > n) {
				end = mid - 1;
			}else {
				start = mid + 1;
			}
		}
		
		return false;
	}
}




Measured memory_bytes: 80092
#include<cstdio>
#include<iostream>

using namespace std;

#include <stdio.h>
//获取最大公约数
long long getGCD(long long a,long long b){
    long long temp;
    if(a < b){
      temp = a;
      a = b;
      b = temp;
    }
    if(a%b == 0){
        return b;
    }else{
        return getGCD(b,a%b);
    }
}
//获得最小公倍数
long long doLCM(long long* array,long long size){
    long long x,y,num=array[0],i,gcd;
    //去数组的第一和第二个数，计算它们的公倍数，然后再取第三个数，
    //和之前的公倍数计算它们的公倍数，直到只有一个数。
    for(i=0;(i+1)<size;i++){
        x=num;
        y=array[i+1];
    //计算公约数
        gcd = getGCD(x,y);
    //计算公倍数
    num = x/gcd * y/gcd * gcd;
    }
    return num;
}


int main()
{
    int n;
    cin >> n;
    long long  T[102];
    for(int i=0;i<n;i++)
    {
        cin >> T[i];
    }
   long long result = doLCM(T,n);
    printf("%lld\n",result);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int H, W;
  cin >> H >> W;

  int ans = min(H, W);
  if(H%3 == 0 || W%3 == 0) ans = 0;

  FOR(i, 1, H){
    int a = i*W;
    int b = (H-i)*(W/2);
    int c = (H-i)*(W-W/2);
    chmin(ans, max(max(a, b), c)-min(min(a, b), c));
  }
  FOR(i, 1, W){
    int a = i*H;
    int b = (W-i)*(H/2);
    int c = (W-i)*(H-H/2);
    chmin(ans, max(max(a, b), c)-min(min(a, b), c));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var max = input[1] / input[0];
            if (max < input[2])
            {
                Console.WriteLine(max);
            }
            else
            {
                Console.WriteLine(input[2]);
            }
        }
    }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
S = input()

directions = [False for _ in range(4)]
for s in S:
    if s == 'S':
        directions[0] = True
    if s == 'N':
        directions[1] = True
    if s == 'W':
        directions[2] = True
    if s == 'E':
        directions[3] = True


if directions[0] ^ directions[1] or directions[2] ^ directions[3]:
    print('No')

else:
    print('Yes')




Measured memory_bytes: 39856
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[10];
int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        p[0]=a+b;
        p[1]=b+c;
        p[2]=a+c;
        p[3]=b+c;
        p[4]=c+b;
        p[5]=b+a;
        sort(p,p+6);
        printf("%d\n",p[0]);
    }
}


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

int main() {
    ll n;
    cin >> n;

    ll ans = n * (n - 1) / 2;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

var lines = [];

var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", line => {
  lines.push(line.split(/\s/).map(x => parseInt(x)));
});

reader.on("close", () => {
  let n = lines.shift();
  let a = lines.shift();
  let b = lines.shift();

  let aSum = a.reduce((a, i) => a + i);
  let bSum = b.reduce((a, i) => a + i);

  if (aSum < bSum) {
    console.log(-1);
    return;
  }

  let count = 0;
  let positiveArr = [];
  let positiveSum = 0;
  let negativeSum = 0;
  let index = 0;

  for (let i = 0; i < n; i++) {
    let tmp = a[i] - b[i];
    if (tmp > 0) positiveArr.push(tmp);
    else if (tmp < 0) {
      count += 1;
      negativeSum += tmp;
    }
  }

  positiveArr.sort((a, b) => b - a);
  while (positiveSum + negativeSum < 0) {
    positiveSum += positiveArr[index];
    index++;
  }

  console.log(count + index);
});


Measured memory_bytes: 61320
import fractions
a,b,c,d = map(int, input().split())
bcBaisu = b // c
bdBaisu = b // d
acBaisu = (a -1) // c
adBaisu = (a-1) // d
cdlcm =  c * d // fractions.gcd(c, d)
bcdLcm = b // cdlcm
acdLcm = (a-1) // cdlcm

karib = b - (bcBaisu + bdBaisu -bcdLcm)
karia = a - 1 - (acBaisu + adBaisu - acdLcm)

print(int(karib - karia))


Measured memory_bytes: 5116