akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    lint N, K;
    cin >> N >> K;
    vector<lint> A(N);
    REP(i, N) cin >> A[i];
    lint ans = 0;
    REP(i, N) {
        FOR(j, i+1, N) {
            if(A[i] > A[j]) ans++;
        }
    }
    ans = (ans * K) % MOD;
    sort(A.begin(), A.end());
    lint smallerthan = 0;
    FOR(i, 1, N) {
        if(A[i] > A[i-1]) smallerthan = i;
        ans = ((K * (K-1) / 2) % MOD * smallerthan % MOD + ans) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable:4996)

int main(void) {
	int K = 0, X = 0;
	scanf("%d%d", &K, &X);
	if (K * 500 >= X) {
		printf("Yes");

	}
	else {
		printf("No");
	} 
	return 0;
}




Measured memory_bytes: 128
from functools import reduce
def dishes(a,b,c,d,e):
    s = [a,b,c,d,e]
    k = list(map(lambda x:(int(x/10)+1)*10 if x%10 != 0 else (int(x/10))*10,s))
    x = [k[i] - s[i] for i in range(len(s))]
    i = x.index(max(x))
    k.remove(k[i])
    k.append(s[i])
    ans = reduce(lambda x,y:x + y,k)
    return ans

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
print(dishes(a,b,c,d,e))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
  ll h,w,m;
  cin>>h>>w>>m;
  vector<ll> r(h+1),c(w+1);
  map<pair<int,int>,int> mp;
  range(i,0,m)
  {
    int x,y;
    cin>>x>>y;
    r[x]++,c[y]++;
    mp[make_pair(x,y)]++;
  }
  
  ll mxr=0,mxc=0,ans=0;
  vector<ll> row,col;
 
  for(int rr=1;rr<=h;rr++)
    if(r[rr]>mxr)
      mxr=r[rr];

  for(int cc=1;cc<=w;cc++)
    if(c[cc]>mxc)
      mxc=c[cc];

  for(int rr=1;rr<=h;rr++)
    if(r[rr]==mxr)
     row.pb(rr);

  for(int cc=1;cc<=w;cc++)
    if(c[cc]==mxc)
      col.pb(cc);
    
  bool ok=false;
  int id=0;
  for(ll R:row)
  {
    for(ll C:col)
    {
      ll temp=mxc+mxr;
      if(mp[{R,C}])temp--;
    
      if(id>0&&temp>ans)
      {
        ans=temp;
        ok=1;
        break;
      }else if(id>0&&temp<ans)
      {
        ok=1;
        break;
      }
      id++;
      ans=max(ans,temp);
    }
    if(ok)break;
  }
  cout<<ans;
}


Measured memory_bytes: 39680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

int main(){
    ll k,x;cin>>k>>x;
    if(500*k>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read(),k=read(),s=read();
	if(s==1e9)
	{
		for(int i=1;i<=k;i++) printf("%d ",s);
		for(int i=k+1;i<=n;i++) printf("%d ",1);
	}
	else
	{
		for(int i=1;i<=k;i++) printf("%d ",s);
		for(int i=k+1;i<=n;i++) printf("%d ",1+s);
	}
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      
      if(Character.isUpperCase(line.charAt(0))){
      	System.out.println("A");
      }else{
      	System.out.println("a");
      }
    }
}

Measured memory_bytes: 35640
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
 
bool myfunction (int i,int j) 
{
    if (j%10 == 0) {
        return true;
    } else if (i%10 == 0) {
        return false;
    } else {
        return (i%10<j%10);
    }
}
 
int main(){
    int i;
    int ans = 0;
    int temp;
    vector <int> list;
    
    for (i=0; i<5; i++) {
        cin >> temp;
        list.push_back(temp);
    }
    
    sort(list.begin(), list.end(), myfunction);
    
    for (i=4; i>0; i--) {
        if (list[i] % 10 == 0) {
            ans += list[i];
        } else {
            ans += (list[i] / 10 + 1)*10;
        }
    }
    
    ans += list[0];
    
    cout << ans;
    
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
int H,W;
char mp[1010][1010];
ll dp[1010][1010];




int main() {
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> mp[i][j];
        }
    }
    
    dp[1][1] = 1;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(i == 1 && j == 1)continue;
            if(mp[i-1][j-1] == '.'){
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
            dp[i][j] %= MOD;
        }
    }
    cout << dp[H][W] << endl;
    
}

Measured memory_bytes: 9216
#define w 200001
p;main(n,m,j,i){
  long int k,a[w],A[w],b[w],B[w];
  scanf("%d%d%ld",&n,&m,&k);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    //(i==0)&&(A[i]=B[i]=0);
    A[i+1]=A[i]+a[i];
  }
    
  for(i=0;i<m;i++){
    scanf("%ld",&b[i]);
    //if(i==0){B[i]=0;}
    B[i+1]=B[i]+b[i];
  }
  int mo=m;
        
  for(i=0;i<=n;i++){
    if(A[i]>k)break;
            
    for(j=mo;j>=0;j--){
      if(A[i]+B[j]<=k){
        if(i+j>p)p=i+j;
        mo=j;
        break;
      }
    }
  }
  printf("%d",p);
}


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

signed main(){
  
  int r, D, x;
  cin>>r>>D>>x;
  
  for(int i=1;i<=10;i++){
    x = r * x - D;
    cout<<x<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
P = {}
for i in range(1,N+1):
  P[i] = []

for i in range(M):
  p, y = map(int, input().split())
  P[p].append((y, i))

ans = {}
for k,v in P.items():
  v.sort(key=lambda x: x[0])
  for n in range(len(v)):
    y, i = v[n]
    ans[i] = "{p:06d}{n:06d}".format(p=k, n=n+1)

for v in ans.values():
  print(v)

Measured memory_bytes: 53796
/**
 *	@file: A.cpp
 *	@author: Huy Le
 *	@created: 08-11-2020 10:09:56
**/


#include<bits/stdc++.h>
using namespace std;

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n;
vector<ll> a;

void solve() {
	read(n);
	a.clear();
	map<pair<ll,ll>, ll> cnt;
	for(int i=0; i<n; ++i) {
		long double tmp;
		read(tmp);
		ll a1=llround(tmp*1e9);
		ll t1=a1,c1=0,c2=0,t2=a1;
		while(t1%2==0) {
			t1/=2;
			++c1;
		}
		while(t2%5==0) {
			t2/=5;
			++c2;
		}
		cnt[{c1,c2}]++;
	}
	ll ans=0;
	for(auto it1:cnt)
		for(auto it2:cnt) {
			if(it1.first.first+it2.first.first >= 18 && it1.first.second+it2.first.second >= 18) {
				if(it1 < it2)
					ans+=it1.second*it2.second;
				else if(it1 == it2)
					ans+=it1.second*(it1.second-1)/2;
			}
		}
	print(ans);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
int main(){

  int A,B,C,D,P;
  cin >>A>>B>>C>>D>>P;
  
  int X=A*P;
  int Y=B;
  
  if(P>C)Y+=(P-C)*D;

  cout <<min(X,Y)<<endl;
  
  return 0;

}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, k;
	cin >> a >> b >> k;

	int t = 0;
	for (int i = a; i >= 1; i--) {
		if (a % i == 0 && b%i == 0) {
			t++;
		}
		if (k == t) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,c,t1,t2,t3;
	scanf("%d %d %d",&a,&b,&c);
	t1 = a;
	if (b < t1) {
		t1 = b;
		t2 = a;
	} else {
		t2 = b;
	}
	if (c <= t1) {
		t3 = t2;
		t2 = t1;
		t1 = c;
	} else if ((t1 < c) && (c <= t2)) {
		t3 = t2;
		t2 = c;
	} else {
		t3 = c;
	}
	printf("%d %d %d\n",t1,t2,t3);
	return 0;
}


Measured memory_bytes: 2124
#include <stdio.h>

int main(void) {

  int n;
  int age;

  int gen[10];

  int i;


  while(1) {

    scanf("%d",&n);

    if(n==0) break;

    for(i=0;i<7;i++) gen[i]=0;

    for(i=0;i<n;i++) {

      scanf("%d",&age);

      if(age<10) gen[0]++;

      else if(age<20) gen[1]++;

      else if(age<30) gen[2]++;
      
      else if(age<40) gen[3]++;

      else if(age<50) gen[4]++;

      else if(age<60) gen[5]++;

      else gen[6]++;

    }

    for(i=0;i<7;i++) printf("%d\n",gen[i]);

  }

  return 0;

}

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

int main( void )
{
    long long int N;
    cin >> N;
    long long int x = N;
    int sum = 0;
    
    while ( x > 0 )
    {
        sum += x % 10;
        x /= 10;
    }
    
    if( N % sum == 0 )
    {
        cout << "Yes" << endl;
    }
    
    else 
        cout << "No" << endl;
}

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

int main() {
    int H1, H2, M1, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int h = abs(H2 - H1);
    int m = M2 - M1;
    int M = h * 60 + m - K;
    cout << M << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
long long inv(long long p){
    long long x=1;
    for(int i=mod-2;i>0;i/=2){
        if(i%2)x=x*p%mod;
        p=p*p%mod;
    }
    return x;
}
long long c(long long a,long long b){
    long long x=1,y=1;
    for(int i=a;i>a-b;i--)x=x*i%mod;
    for(int i=1;i<=b;i++)y=y*i%mod;
    return x*inv(y)%mod;
}
int main(){
    int s;
    cin>>s;
    long long ans=0;
    for(int i=1;s-3*i>=0;i++)ans=(ans+c(s-2*i-1,i-1))%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
import sys 
MOD = 10 ** 9 + 7
INF = 10**11
from heapq import heapify,heappush,heappop

def prim(n,G):
    ans = 0
    used = [0] * n
    used[0] = 1
    q = []
    for e,c in G[0]:
        heappush(q,(c,e))
    
    while len(q):
        c1,e1 = heappop(q)
        if used[e1]:
            continue
        used[e1] = 1
        for e2,c2 in G[e1]:
            if used[e2] == 0:
                heappush(q,(c2,e2))
        ans += c1
    return ans

def main():
    n,m = map(int,input().split())
    G = [[] for _ in range(n)]
    for _ in range(m):
        a,b,c = map(int,input().split())
        G[a].append((b,c))
        G[b].append((a,c))
    ans = prim(n,G)
    print(ans)
if __name__=='__main__':
    main()


Measured memory_bytes: 37268
#include <iostream>

using namespace std;

int main() {
    long long int n, a, b;
    cin >> n >> a >> b;
    if (a > b || b - a > n) cout << 0;
    else cout << (b * (n - 1) + a) - (a * (n - 1) + b) + 1;
    return 0;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll sum = 0;
    ll Ncopy = N;
    while(N > 0){
        sum += N % 10;
        N /= 10;
    }

    if(Ncopy % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using ll = long long;
struct Product {
  ll w, v;
};
//bool operator<(const Product& l, const Product& r) {
//  l.v > r.v;
//}

int main(int argc, char** argv) {
  ll N, W;
  std::cin >> N >> W;
  std::vector<Product> P(N);
  for (auto i = 0;i < N;++i) std::cin >> P[i].w >> P[i].v;
  std::vector<std::vector<ll>> dp(N, std::vector<ll>(W+1, 0));

  if (P[0].w <= W) dp[0][P[0].w] = P[0].v;
  for (auto i = 1;i < N;++i) {
    for (auto j = 0;j <= W;++j) {
      dp[i][j] = dp[i-1][j];
    }
    for (ll j = 0;j < W;++j) {
      if (j + P[i].w <= W) dp[i][j+P[i].w] = std::max(dp[i][j+P[i].w], dp[i-1][j] + P[i].v);
    }
  }

  ll max_value {};
  for (auto i = 0;i <= W;++i) {
    max_value = std::max(max_value, dp[N-1][i]);
  }
  std::cout << max_value << '\n';
}


Measured memory_bytes: 79488
h,w=map(int,input().split())
m=[]
for i in range(h):
  m.append(list(map(lambda x:int(x=="#"),list(input())))+[1,1])
m+=[[1 for i in range(w+2)]]*2
mx=0
d=[(1,0),(-1,0),(0,1),(0,-1)]
for x in range(h):
  for y in range(w):
        if m[x][y]:
          continue
        s=[(x,y)]
        c=-1
        v=[[0 for i in range(w)] for i in range(h)]
        v[x][y]=1
        while s:
          ns=[]
          for i in s:
            for j in d:
              if m[i[0]+j[0]][i[1]+j[1]] or v[i[0]+j[0]][i[1]+j[1]]:
                continue
              v[i[0]+j[0]][i[1]+j[1]]=1
              ns.append((i[0]+j[0],i[1]+j[1]))
          s=ns
          c+=1
        mx=max(mx,c)
print(mx)
          
      

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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  int ans = 0;
  bool judge = true;
  
  for(int i=0; i<N; i +=2) {
    if(s.at(i) =='L') {
      judge = false;
      break;
    }
    for(int j=1; j<N; j +=2) {
      if(s.at(j) =='R') {
        judge = false;
        break;
      }
    }
  }
  if(judge == true) cout << "Yes" << endl;
  if(judge == false) cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Graph {
	int N;
	vector<vector<int>> edge;
	vector<int> d, f;

public:
	Graph(int n) : N(n), edge(n + 1), d(n + 1), f(n + 1) {
		REP(i, N) {
			add(0, i + 1);
		}
	}
	void add(int u, int v) {
		edge[u].emplace_back(v);
	}
	int dfs(int i) {
		f[i] = d[i];
		for (auto &j : edge[i]) {
			if (!d[j]) {
				d[j] = f[i] + 1;
				f[i] = dfs(j);
			}
		}
		return ++f[i];
	}
	void ans() {
		dfs(0);
		for (int i = 1; i <= N; ++i) {
			cout << i << " " << d[i] << " " << f[i] << endl;
		}
	}
};

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

	int n;
	cin >> n;
	Graph graph(n);
	REP(x, n) {
		int u, k;
		cin >> u >> k;
		REP(y, k) {
			int v;
			cin >> v;
			graph.add(u, v);
		}
	}
	graph.ans();

	return 0;
}


Measured memory_bytes: 3168
def abc(s: str)->int:
    count = 0  # 操作回数
    countA = 0  # 現在連続している 'A' の数

    i, N = 0, len(s)
    while i < N:
        if s[i] == 'A':
            countA += 1
            i += 1
        elif s[i] == 'B':
            if countA > 0 and i+1 < N and s[i+1] == 'C':
                count += countA
                i += 2
            else:
                countA = 0
                i += 1
        else:  # s[i] == 'C'
            countA = 0
            i += 1

    return count


if __name__ == "__main__":
    s = input()

    ans = abc(s)
    print(ans)


Measured memory_bytes: 3500
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int D = in.nextInt();

        long ans[][] = new long[C + 1][D + 1];
        long i = 1;
        for (int c = C; c >= A; c--) {
            ans[c][D] = i;
            i *= D;
            i %= MOD;
        }
        i = 1;
        for (int d = D; d >= B; d--) {
            ans[C][d] = i;
            i *= C;
            i %= MOD;
        }
        for (int a = C - 1; a >= A; a--) {
            i = 0;
            for (int b = D - 1; b >= B; b--) {
                i += ans[a + 1][b + 1];
                i *= a;
                i %= MOD;
                ans[a][b] = (i + ans[a + 1][b] * b) % MOD;
            }
        }
        out.println(ans[A][B]);

        out.flush();
    }

    static final int MOD = 998244353;

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



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

#define NMAX 201
#define INF 2000000000

#define MOD 2019

using namespace std;

int L, R;

int main()
{
    cin >> L >> R;

    if((R - L + 1) / 2019 != 0)
    {
        cout << 0 << '\n';
        return 0;
    }

    L = L % MOD;
    R = R % MOD;
    if(L > R) swap(L, R);
    int minn = MOD;

    for(int i = L; i <= R; i++)
        for(int j = i + 1; j <= R; j++)
        {
            int val = i * j % MOD;
            if(val < minn)
                minn = val;
        }
    cout << minn << '\n';
    return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> count(m);
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    vector<int> ai(k);
    for (int j = 0; j < k; j++) cin >> ai.at(j);
    for (int a : ai) count.at(a-1) += 1;
  }
  int ans = 0;
  for (int c : count) if (c == n) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] w = new int[n];
		int souwa = 0;
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			souwa += w[i];
		}
		sc.close();
		int sa = 100000000;
		for (int t = 0; t < n; t++) {
			int wa = 0;
			for (int i = 0; i < t; i++) {
				wa += w[i];
			}
			int tmp = souwa - wa;
			int saa = Math.abs(wa - tmp);
			if (saa < sa)
				sa = saa;
		}
		System.out.println(sa);
	}
}


Measured memory_bytes: 23252
N = int(input())
aLst = list(map(int, input().split()))
bLst = list(map(int, input().split()))

ans = 0

for i in range(N):
    tmp = aLst[i] - bLst[i]
    if tmp < 0:
        if aLst[i + 1] - (bLst[i] - aLst[i]) <= 0:
            ans += aLst[i] + aLst[i + 1]
            aLst[i + 1] = 0
        else:
            ans += bLst[i]
            aLst[i + 1] = aLst[i + 1] - (bLst[i] - aLst[i])
    else:
        ans += bLst[i]
print(ans)

Measured memory_bytes: 18476
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
n = len(a)

iCost = [0]*(n-1)
for i in range(n-1):
    iCost[i] = abs(a[i+1]-a[i])

totCost = sum(iCost)

modCost = [0]*n # cost of when i-1th connected to i+1th point
modCost[1] = abs(a[2])
for i in range(2, n-1):
    modCost[i] = abs(a[i+1]-a[i-1])

for i in range(1, n-1):
    print(totCost - iCost[i-1] - iCost[i] + modCost[i])


Measured memory_bytes: 88420
import java.util.Scanner;

public class Main {

	static int[] a;
	static int count;
	static int j;
	static boolean first;
	static boolean[] already;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			String str = cin.next();
			first=true;
			already = new boolean[10];
			label:for(j = 1; j < 10;j++){
				String s = str+j;
				a = new int[10];
				count=14;
				
				for(int i = 0; i < s.length();i++){
					a[(int)(s.charAt(i)-'0')]++;
					if(a[(int)(s.charAt(i)-'0')]>4){
						continue label;
					}
				}
				
				hai();
			}
			if(first){
				System.out.println(0);
			}
			else{
				System.out.println();
			}
		}
	}
	static  void hai(){
		for(int i = 1; i <10;i++){
			//System.out.print(a[i]);
		}
		//System.out.println();
		if(already[j]){
			return;
		}
		// 頭
		if(count==2){
			for(int i = 1;i<=9;i++){
				if(a[i]==2){
					if(!first){
						System.out.print(" "+j);
					}
					else{
						System.out.print(j);
						first=false;
					}
					already[j]=true;
					return;
				}

			}
		}
		
		// 刻子
		for(int i = 1;i<= 9;i++){
			if(a[i]>=3){
				a[i]-=3;
				count-=3;
				hai();
				a[i]+=3;
				count+=3;
			}
		}
		// 順子
		for(int i = 1;i <= 7;i++){
			if(a[i]>0&&a[i+1]>0&&a[i+2]>0){
				a[i]--;
				a[i+1]--;
				a[i+2]--;
				count-=3;
				hai();
				a[i]++;
				a[i+1]++;
				a[i+2]++;
				count+=3;
			}
		}
	}
}

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

template<class T> inline bool chmin(T& a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmax(T& a, T b) {
  if(a < b) { 
    a = b;
    return true;
  }

  return false;
}

const ll INF = 1LL << 60;
ll dp[100100];

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for(int i = 0; i < N; i++) {
    cin >> h[i];
  }
  for(int i = 0; i < N; i++) {
    dp[i] = INF;
  }

  dp[0] = 0;

  for(int i = 1; i < N; i++) {
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i > 1)
    chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << dp[N - 1];
  return 0;
}


Measured memory_bytes: 1408
use proconio::{fastout, input};
use regex::Regex;

fn main() {
    input!(alpha: String);
    let upper = Regex::new(r"[A-Z]").unwrap();
    let lower = Regex::new(r"[a-z]").unwrap();
    if upper.is_match(alpha.as_str()) {
        println!("A")
    } else if lower.is_match(alpha.as_str()) {
        println!("a")
    }
}


Measured memory_bytes: 3044
/*O(N)解法 累積max current_maxという変数にそれまでの高さの最大値を格納。.
H[i] と current_max との比較が終わったら、H[i] という値を加味して current_max を再び更新*/
#include <bits/stdc++.h>
using namespace std;
int main()  {
  int N; cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  int res = 0;
  int current_max = 0;
  for (int i = 0; i < N; i++) {
    // i 番目が、i-1 番目以前の最大値以上だったらカウント
    if (H[i] >= current_max) res++;
     // これまでの最大値を新たに更新する
    if (current_max < H[i]) current_max = H[i];
  }
cout << res << endl;
}
/*解説の解法 O(N^2)　入力を配列で受け取り、各 i = 1, 2, ..., N について全ての j = 1, 2, ..., i − 1 に対して Hi ≥ Hj かを確認
し、そうであった i の数を数えることで答えを求めることができる。　　最初こんな感じで考えてたけどうまく実装できなかった。
#include <bits/stdc++.h>
using namespace std;
int main()  {
  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 0;
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < N; i++)  {
    bool is_candidate = true;
    for (int j = 0; j < i; j++)  {
      if (a[j]>a[i])  {
      is_candidate = false;
      break;
    }
  }
  if(is_candidate) ++ans;
}
cout << ans <<endl;
}*/

/*自分の解法　今考えている番号iより小さい1~i-1についてソートして最大のもの=b[i-1]についてa[i]と比較
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  int ans = 1;
  for (int i = 1; i < N; i++)  {
    vector<int> b(i);
      for (int j = 0; j < i; j++) b[j] = a[j];
    sort(b.begin(), b.end());
    
        if (a[i] >= b[i-1]) ++ans;
  }
  cout << ans << endl;
}
*/

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

from collections import Counter

ctr = Counter(A)

n_even = len([1 for v in ctr.values() if v%2 == 0])

if n_even % 2 == 0:
    print(len(ctr))
else:
    print(len(ctr)-1)

Measured memory_bytes: 62124
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int count[] = {0,0,0,0};
	string str;
	for(int i=0; i < n; i++ ){
	    cin >> str;
	    if(str == "AC"){
	        count[0]++;
	    }else if(str == "WA"){
	        count[1]++;
	    }else if(str == "TLE"){
	        count[2]++;
	    }else if(str == "RE"){
	        count[3]++;
	    }
	}
	cout << "AC x " << count[0] << endl;
	cout << "WA x " << count[1] << endl;
	cout << "TLE x " << count[2] << endl;
	cout << "RE x " << count[3] << endl;
    
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX],n;

    cin >> n;
    for(int i = 0; i < n; ++i) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; ++i){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
ll myPow(ll a,ll b) {
    ll ret = 1;
    ll tmp = a;
    REP(i,b) ret = (ret * tmp) % MOD;
    return ret;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

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

    vector<int> a(N),b(N),c(N);

    REP(i,N) cin >> a[i];
    

    ll sum_p = 0;
    ll sum_n = 0;
    ll ans = 0;
    REP(i,N) {
        cin >> b[i];
        c[i] = a[i]-b[i];

        if(a[i]<b[i]) sum_n += b[i]-a[i];
        else {
            sum_p += a[i] - b[i];
            ans++;
        }
    }

    if(sum_p<sum_n) {
        pl(-1)
        return 0;
    }

    sort(all(c),greater<>());

    REP(i,N) {
        if(sum_n <=0) break;

        sum_n -= c[i];
        ans--;
    }

    pl(N-ans)

    return 0;
}

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

using namespace std;

string s;
long long int number , result;
int main(){
	cin >> s;
	for(int i=0;i<s.size();i++)
		result+=s[i]-'0';
	number = stoll(s);
	if(number%result == 0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

//挿入ソート
void insertionSort(int A[], const int N)
{
    int i, j;

    for( i = 0; i < N; ++i ){
        int tmp = A[i];
        for( j = i-1; -1 < j && tmp < A[j]; --j ){
            A[j+1] = A[j];
        }
        A[j+1] = tmp;

        //出力
        for( j = 0; j < N; ++j ){
            printf("%d", A[j]);
            if( j != N-1 ) printf(" ");
        }
        printf("\n");
    }
}

int main()
{
    int i;

    //入力
    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 2756
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    string s = to_string(i);
    string r = to_string(i);
    reverse(r.begin(), r.end());
    if (s == r) ans++;

  }
  P(ans);

  return 0;

}



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

int main()
{
	int a[6];
	for(int i=1;i<=5;i++)
	   cin>>a[i];
	for(int i=1;i<=5;i++)
    {
    	if(a[i]==0)
    	   cout<<i;
    }
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>

using namespace std;

int main()
{
    int N, C[10][10] = {0}, save, a, b, sum = 0;
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        save = i;
        b = save % 10;
        while (save)
        {
            a = save % 10;
            save /= 10;
        }
        C[a][b]++;
    }
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            sum += C[i][j] * C[j][i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[200]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+200);
    reverse(a,a+200);
    cout<<a[0]-a[n-1]<<endl;
    return 0;
}

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

int main(){
 int a,b; cin >>a >>b;
 if(b==1){cout <<0; return 0;}
 if(a>=b){cout <<1; return 0;}
 else cout <<1+ceil(1.0*(b-a)/(a-1));
return 0;
}

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

signed main() {
  long long a, b, c;
  cin >> a >> b >> c;
  long long comp = -a - b + c;
  if(comp < 0 || comp * comp <= 4 * a * b){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    int n, k;
    cin>>n>>k;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end(),greater<int>());
    
    int ans=0;
    rep(i,k) ans+=l[i];
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  string s1 = "";
  string s2 = "";
  
  if (n%2 == 0){
    for (int i=0;i<int(n/2);i++){
      s1 += s[i];
      s2 += s[int(n/2)+i];      
    }
  }
  
  if(s1 != "" && s1 == s2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


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

int32_t main()
{
    int n;
    cin>>n;
    int ob=0,cb=0;
   string str;
   cin>>str;
    for(int i=0;i<n;i++)
    {
        char c=str[i];
       if(c==')')
        {
            if(ob)ob--;
            else
            cb++;
        }
        if(c=='(')
        ob++;
    }
    cout<<string(cb,'(');
    cout<<str;
    cout<<string(ob,')')<<endl;
}

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

int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    
    int n; cin>>n;
    vector<int> t(n); for(e: t) cin>>e;
    vector<int> a(n); for(e: a) cin>>e;

    vector<int> d(n);
    int m=0;
    for(int i=0; i<n; ++i) {
        if (t[i]>m) { d[i]=-1; m=t[i]; }
        else { d[i]=t[i]; }
    }
    m=0;
    for(int i=n-1; i>=0; --i) {
        if (d[i]<0 and a[i]<t[i]) { cout<<0<<endl; return 0; }
        if (m<a[i]) { m=a[i]; d[i]=-1; }
        else { d[i]=min(d[i], a[i]); }
    }

    long res=1;
    for(e: d)
        if (e>0) res=res*e%1000000007;
    cout<<res<<endl;
}


Measured memory_bytes: 1408
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int c1 = scan.nextInt();
        int c5 = scan.nextInt();
        int c10 = scan.nextInt();
        int c50 = scan.nextInt();
        int c100 = scan.nextInt();
        int c500 = scan.nextInt();

          if((c10*10)+c1+(c5*5)+(c50*50)+(c100*100)+(c500*500)>=1000){
              System.out.println(1);
          }else{
              
              System.out.println(0);
          }
        }
    }



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

int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int big;
        if(a>=b && a>=c)
            big=a;
        else if(b>=a && b>=c)
            big=b;
        else if(c>=a && c>=b)
            big=c;

        int cost;
        cost=a+b+c-big;

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


Measured memory_bytes: 256
<?php
  
$N = trim(fgets(STDIN));
$S = trim(fgets(STDIN));

if ($N % 2 !== 0) {
    exit("No");
}

$arr = str_split($S, $N / 2);
if ($arr[0] === $arr[1]) {
    echo "Yes";
}else {
    echo "No";
}

Measured memory_bytes: 4604
#!/usr/bin/env ruby

if __FILE__ == $0
	loop do
		a, op, b = gets.split
		if op == '?' then
			break
		end

		a, b = [a, b].map { |x| x.to_i }
		puts op!='+' ? op!='-' ? op!='*' ? a/b : a*b : a-b : a+b
	end
end



Measured memory_bytes: 6876
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

X = int(input())
primeNum = seachPrimeNum(100003)
i = 0
while True:
    if primeNum[i] >= X:
        ans = primeNum[i]
        break
    else:
        i += 1

print(ans)


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




namespace ConsoleApplication1 {

    

    class ClassMain {



        public static int mctoint(string mc) {
            int result = 0;
            int bi = 1;
            for (int i = 0; i < mc.Length; i++) {
                if (char.IsDigit(mc[i])) {
                    bi = mc[i]-'0';
                }
                else {
                    if (mc[i] == 'm') { result += bi * 1000; }
                    if (mc[i] == 'c') { result += bi * 100; }
                    if (mc[i] == 'x') { result += bi * 10; }
                    if (mc[i] == 'i') { result += bi ; }
                    bi = 1;
                }
            }
            return result;
        }

        public static string inttomc(int num) {
            string result = "";
            if (num / 1000 >= 2) {
                result += num / 1000 + "m";
            }
            else if(num/1000==1){
                result +="m";
            }
            num %= 1000;
            if (num / 100 >= 2) {
                result += num / 100 + "c";
            }
            else if(num/100==1){
                result +="c";
            }
            num %= 100;

            if (num / 10 >= 2) {
                result += num / 10 + "x";
            }
            else if (num / 10 == 1) {
                result += "x";
            }
            num %= 10;
            if (num >= 2) {
                result += num + "i";
            }
            else if (num  == 1) {
                result += "i";
            }
            return result;            
        }

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = ints[0];
                int n = int.Parse(line);                
                if (n == 0) { break; }
                for (int i = 0; i < n; i++) {
                    string[] strs = Console.ReadLine().Split(' ');
                   // Console.WriteLine(mctoint(strs[0]) + "," + mctoint(strs[1]));
                    int sum = mctoint(strs[0]) + mctoint(strs[1]);
                    Console.WriteLine(inttomc(sum));

                }


                
                    
              //Console.WriteLine();
                    
                



            }
        }
    }
}

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

int addCharNum(string s, int *i){
  int n = 0;
  int j;
  for (j = *i; '0' <= s[j] && s[j] <= '9' && j < s.size(); j++){
    n *= 10;
    n += s[j] - '0';
  }
  *i = j;
  return n;
}

int main() {
  int sum = 0;
  int i;
  string s;
  while(cin>>s) {
    for(i=0;i<s.size();i++) {
      if('0' <= s[i] && s[i] <= '9') {
        sum += addCharNum(s, &i);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1184
#include<iostream>
using namespace std;
int main(){
	int d, x, i, j, a[101] = {0}, n, Count;;
	cin >> n >> d >> x;
	Count = x;
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	for(i = 0; i < n; i++){
		for(j = 0;; j++){
			if((j+1)*a[i] + 1 <= d){
				Count++;
			}else{
				break;
			}
		}
	}
	cout <<  Count+n << endl;
	return 0;
} 
// 1 
// 1

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long int N;
    cin >> N;
    char stones[N];
    cin >> stones;

    long int W_counter = 0;
    long int R_counter = 0;
    for(long int i = 0;i<N;i++){
        if(stones[i]=='W'){
                W_counter++;
        }
        if(stones[i]=='R'){
                R_counter++;
        }
    }
    long int resR_counter = 0;
    for(long int i = 0;i<R_counter;i++){
        if(stones[i]=='R'){
            resR_counter++;
        }
    }


    cout << R_counter-resR_counter;
    return 0;

}


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

int main(){
  int a, b, c, x, ans=0;
  cin >> a >> b >> c >> x;

  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
    if(0<=(x-500*i-100*j)/50 && (x-500*i-100*j)/50<=c) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str_a = scan.next();
		String str_b = scan.next();
		int a_length = str_a.length();
		int b_length = str_b.length();
		String message = "";
		if(a_length > b_length) {
			message = "GREATER";
		} else if(a_length < b_length) {
			message = "LESS";
		} else {
			int i = 0;
			for(i = 0; i < a_length; i++) {
				int a = Integer.parseInt(str_a.charAt(i) + "");
				int b = Integer.parseInt(str_b.charAt(i) + "");
				if(a > b) {
					message = "GREATER";
					break;
				} else if(a < b) {
					message = "LESS";
					break;
				}
			}
			if(i == a_length) {
				message = "EQUAL";
			}
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
     static int M,N;
        public static void main(String[] a)throws java.io.IOException{
            Scanner sc=new Scanner(System.in);
            while(sc.hasNextInt()){
                    N=sc.nextInt();
                    M=sc.nextInt();
                    if(N==0||M==0)break;
                    int ans =0;
                    int [][] fin =new int[M][N];
                    for(int i=0;i<M;i++){
                        for(int j=0;j<N ;j++){
                            fin[i][j] = sc.nextInt();
                        }
                    }
  
                    
                    
                    
                    for(int i=0;i<M;i++){
                        for(int j=0;j<N;j++){
                            if(fin[i][j] == 1){
                                ++ans;
                                temp(i,j,fin);
  
                            }
                        }
                    }
                    
                    
                    
                    
                    System.out.println(ans);
                    sc.nextLine();
            }
    }
  
  
          public static void temp(int y,int x,int [][] fin){
              fin[y][x] = 0;
              for(int i=-1;i<=1;i++){
                  for(int j=-1;j<=1;j++){
                  int n1 =x+j;
                  int n2 =y+i;
                  if(0<=n1 && n1< N &&0<=n2 && n2 <M &&fin[n2][n1]==1)
                      temp(n2,n1,fin);
                  }
              }
              return;
          }
}

Measured memory_bytes: 42576
import Data.List
f :: [String]->[String]
f []=[]
f (x:xs)=if elem '#' x then x:f xs else f xs

f3::Int->Int->Int
f3 l r
   |r<=0 = -l
   |0<=l = r
   |otherwise=(minimum [-l,r])+r-l

f2 ::[Int]->[Int]->Int->Int->[Int]
f2 _ [] _ ans=[]
f2 (x:xs) (y:ys) k ans
     |k>1=f2 (x:xs) ys (k-1) ans
     |otherwise=(f3 x y):f2 xs ys 0 ans
main = do 
       a<-getLine
       b<-getLine
       let (n:k:[])=(map read . words) a::[Int]
           xs=(map read .words) b ::[Int]
       putStrLn $ show $ minimum $ f2 xs xs k 2000000000 

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int a[100001];
bool went[100001];

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N) scanf("%d", &a[i]);
	int now = 1, cnt = 0;
	while(1) {
		if(went[now]) {
			printf("-1\n");
			return 0;
		}
		if(now == 2) break;
		went[now] = true;
		now = a[now - 1];
		++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 768