akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define IS_DEBUG true

#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl

void sortIncrease(vector<int> &array);
void sortDecrease(vector<int> &array);

int main()
{
	int N;
	cin >> N;
	int min = 999999;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		//A.push_back(a);
		int b = 0;
		while (1)
		{
			if (a % 2 == 0)
			{
				a /= 2;
				b++;
			}
			else
			{
				break;
			}
		}
		if (b == 0)
		{
			RESULT_OUTPUT(0);
			return 0;
		}
		if (b < min)
			min = b;
	}
	RESULT_OUTPUT(min);


	if (IS_DEBUG)
	{
		int end;
		cin >> end;
	}
    return 0;
}

Measured memory_bytes: 256
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto r = readln.strip.to!int;
	writeln( solve( r ) );
}

auto solve( in int r )
{
	if( r < 1200 ) return "ABC";
	if( r < 2800 ) return "ARC";
	return "AGC";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N ;
  vector <int> a(N);
  for (int i = 0; i < N; i ++) {
    int ai;
    cin >> ai;
    a.at(i) = ai;
  }//配列aを作成
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end()); //aの要素を大きい順に並べ替え
  int sum_Alice = 0;
  int sum_Bob = 0;
  for (int j = 0; j < (N+1)/2; j ++) sum_Alice += a.at(2 * j);
  for (int k = 0; k < N/2; k ++) sum_Bob += a.at(2 * k + 1);
  cout << sum_Alice - sum_Bob << endl;
}



Measured memory_bytes: 256
def ns():
    import sys
    return map(int, sys.stdin.readline().split())
  
def ss():
    import sys
    return sys.stdin.readline().strip()
  
def dp():
  N, = ns()
  S = ss()
  
  c = sum(1 for s in S if s == '.')
  DP = [float('inf')] * (N+1)
  DP[0] = c

  for i, s in enumerate(S):
    if i < N:
      if s == '.':
      	DP[i+1] = DP[i] - 1
      else:
        DP[i+1] = DP[i] + 1
  return min(DP)

print(dp())


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

int main(){
  int n;
  cin >> n;
  vector<int> b(n-1);
  vector<int> a(n);
  rep(i,n-1) cin >> b[i];
  
  a[0] = b[0];
  a[n-1] = b[n-2];
  
  for(int i=1;i<=n-2;i++){
    a[i] = min(b[i-1],b[i]);
  }
  
  ll ans = 0;
  rep(i,n) ans += a[i];
  
  cout << ans << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    ll ans = o;
    int odds = l % 2 + j % 2 + i % 2;
    if (odds >= 2 && l && i && j) {
        ans += 3;
        --l;
        --i;
        --j;
    }
    ans += i / 2 * 2;
    ans += j / 2 * 2;
    ans += l / 2 * 2;
    cout << ans << '\n';
}


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

int checker(int x){
  if(x>=753){return x-753;}
  else return 753-x;
}

int main() {
  string S; cin >> S;
  int SIZE=S.size()-2;
  int64_t MY=stoll(S);
  vector<int> gard(SIZE);
  for (int i=0;i<SIZE;i++){
    gard.at(i)=checker(MY%1000);
    MY/=10;
  }
  sort(gard.begin(), gard.end());
  cout << gard.at(0) << endl;
}

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

int main(void){
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> dp(n+1,vector<int>(n+1,0));
    int ans = 0;
    for(int i=n-1; i>=0; i--){
        for(int j=n-1; j>=0; j--){
            if(s[i] == s[j]){
                dp[i][j] = 1 + dp[i+1][j+1];
                ans = max(ans, min(dp[i][j], abs(i-j)));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 98176
#include <stdio.h>

int main( void ) {
	int i, ch, count[ 4 ] = {}, min;

	while ( ( ch = getchar() ) != EOF )
		switch ( ch ) {
			case 'K': count[ 0 ]++; break;
			case 'U': count[ 1 ]++; break;
			case 'P': count[ 2 ]++; break;
			case 'C': count[ 3 ]++; break;
		}

	min = count[ 0 ];
	for ( i = 1; i < 4; i++ )
		if ( count[ i ] < min )
			min = count[ i ];

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

	return 0;
}

Measured memory_bytes: 524
#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 MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=x-1;i>=;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

int main(){
    ll h,n,ans=0;cin>>n>>h;
    ll a[201010];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    repr(i,n-h){
        
        ans+=a[i];
        
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int K=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int key=B/K;
		if(A<=key*K&&key*K<=B)
			System.out.println("OK");
		else
			System.out.println("NG");
	}
}


Measured memory_bytes: 35724
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;


int H[101];
signed main() {
	int mx = 0;
	int N; cin >> N;
	REP(i, N) {
		cin >> H[i];
	}
	int ans = 0;
	REP(i, N) {
		if (H[i] >= mx) {
			ans++;
			mx = H[i];
		}
	}
	print(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main(){
	int N;
	cin >> N;
	int num = 111;
	for (int i = 1; i <= 9; i++) {
		if (N <= num * i) {
			cout << num * i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import queue
import sys

readline = sys.stdin.readline


def main():
    n_rooms, n_passages = map(int, input().split())
    passages = (map(int, readline().strip().split()) for _ in range(n_passages))

    connections = [set() for _ in range(n_rooms+1)]  # type: list
    for a, b in passages:
        connections[a].add(b)
        connections[b].add(a)

    que = queue.Queue()
    que.put((0, 1))  # parent, current

    signs = [-1] * (n_rooms + 1)

    while not que.empty():
        parent, current = que.get()

        if signs[current] != -1:
            continue

        signs[current] = parent

        for room in connections[current]:
            if signs[room] == -1:
                que.put((current, room))

    print('Yes')
    for sign in signs[2:]:
        print(sign)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68204
#include <stdio.h>
#include <stdlib.h>


int main(){
    int X, Y;
    scanf("%d%d", &X, &Y);
    int x = 2*X - Y/2; //つる
    int y = Y/2 - X; //かめ
    if(x<0 || y<0 || x+y!=X || 2*x+4*y!=Y){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }

    return 0;
}




Measured memory_bytes: 1652
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
ll a,b,c,d;
cin >> a >> b >> c >> d;
cout << max({a * c, a * d, b * c, b * d}) << endl;
return 0;
}


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

using namespace std;

int a,b;
string s,t,u;

int main() {
	cin>>s>>t>>a>>b>>u;
	if(u==s) printf("%d %d\n",max(0,a-1),b);
	else printf("%d %d\n",a,max(0,b-1));
	return 0;
} 

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

int main(){
    int a[2], k;
    cin >> a[0] >> a[1] >> k;

    for(int i = 0; i < k; i++){
        if(a[i%2] % 2 == 1) a[i%2]--;
        a[1-i%2] += a[i%2]/2;
        a[i%2] /= 2;
    }

    cout << a[0] << " " << a[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

ll num_digit(ll n){
    ll nd = 0;
    for(nd = 0; n > 0; ++nd){
        n /= 10;
    }
    return nd;
}

ll solve(ll n, ll nd, ll pos, ll total, ll n3, ll n5, ll n7){
    if(nd == pos){
        if(n3 == 0 || n5 == 0 || n7 == 0 || total > n){
            return 0;
        }else{
            return 1;
        }
    }else{
        ll ret = 0;
        ret += solve(n, nd, pos + 1, 10 * total + 3, n3 + 1, n5, n7);
        ret += solve(n, nd, pos + 1, 10 * total + 5, n3, n5 + 1, n7);
        ret += solve(n, nd, pos + 1, 10 * total + 7, n3, n5, n7 + 1);
        if(n3 + n5 + n7 == 0){
            ret += solve(n, nd, pos + 1, 10 * total, n3, n5, n7);
        }
        return ret;
    }
}

int main(){
    ll n;
    cin >> n;
    ll nd = num_digit(n);
    cout << solve(n, nd, 0, 0, 0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main(){
  int N;
  string s;
  cin >> N >> s;
  int ans = 0;
  rep(i,N){
    int tmp = 0;
    vector<int> v(26);
    for(int j = 0; j < i; j++){
      v[s[j] - 'a']++;
    }
    // cout << v[0] << endl;
    for(int k=i; k<N; k++) if(v[s[k]-'a']) tmp++,v[s[k]-'a']=0;
    ans = max(ans,tmp);
  }
  cout << ans  << 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++)
int main(){ 
    int a,b;
    cin>>a>>b;
    vector<string> s(a);
    REP(i,a) cin>>s[i];
    REP(i,a){
        cout<<s[i]<<endl;
        cout<<s[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
solve :: [String] -> IO ()
solve (str:q:cs) = do
    foldM_ ope str $ map words cs
    where
    slice :: String -> Int -> Int -> (String,String,String)
    slice str bgn end =
        let (a,b) = splitAt bgn str in
        let (c,d) = splitAt (1+end-bgn) b in
        (a,c,d)
    --
    ope :: String -> [String] -> IO String
    --
    ope str ["print",a,b] = do
        let [a',b'] = map read [a,b]
        let (_,c,_) = slice str a' b'
        putStrLn c
        return str 
    --
    ope str ["reverse",a,b] = do
        let [a',b'] = map read [a,b]
        let (l,c,r) = slice str a' b'
        return $ l ++ reverse c ++ r
    --
    ope str ["replace",a,b,p] = do
        let [a',b'] = map read [a,b]
        let (l,c,r) = slice str a' b'
        return $ l ++ zipWith (\a b->b) c p ++ r
    --
    ope _ _ = undefined

main =
    solve . lines =<< getContents                                         

Measured memory_bytes: 5420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans;
int main()
{
	ll n; cin >> n;
	for(ll i = 2; i * i <= n; ++i)
		if(n % i == 0)
		{
			int cnt = 0;
			while(n % i == 0)
				n /= i, ++cnt;
			for(int j = 1; cnt >= j; ++j)
			{
				cnt -= j;
				++ans;
			}
			
		}
	if(n > 1)
		++ans;
	cout << ans << endl;
	return 0;
}

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

int main()
{
  	int a, b, c, x, y, yu;
    cin>>a>>b>>c;
  	x=b;
    y=c;
  	yu=a-b;
  	y=y-yu;
	if(y<0)
    	cout<<0;
  	else
  		cout<<y;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#define maxn 100005
using namespace std;
typedef long long ll;
int main()
{
	int _;
	scanf("%d",&_);
	while(_--)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		ll temp=sqrt(x*y);
//		cerr<<"its ";
		if(temp*temp==x*y)
		{
			ll ans=2ll*temp;
			ans-=2;
			if(x!=y)
			ans--;
			printf("%lld\n",ans);
		}
		else
		{
			if(temp*(temp+1)>=x*y)
				printf("%lld\n",2ll*temp-2+1-1);
			else
				printf("%lld\n",2ll*temp-1);
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[110][110];
int b[110][110];
int main()
{
    int i,j,m,n,x,z;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        for(j=0;j<=m;j++)
            scanf("%c",&a[i][j]);
    for(i=0;i<=n;i++)
        for(j=0;j<=m;j++)
        {
            if(a[i][j]=='#')
                b[i][j]='#';
            else
            {
                if(a[i+1][j]=='#')
                    b[i][j]++;
                if(a[i+1][j-1]=='#')
                    b[i][j]++;
                if(a[i+1][j+1]=='#')
                    b[i][j]++;
                if(a[i-1][j]=='#')
                    b[i][j]++;
                if(a[i-1][j-1]=='#')
                    b[i][j]++;
                if(a[i-1][j+1]=='#')
                    b[i][j]++;
                if(a[i][j-1]=='#')
                    b[i][j]++;
                if(a[i][j+1]=='#')
                    b[i][j]++;
            }
        }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(b[i][j]=='#')
                printf("#");
            else
                printf("%d",b[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n;
  ll a[n],b[n];
  for (ll i = 0; i < n; ++i)
  {
  cin>>a[i];
  }
   for (ll i = 0; i < n; ++i)
  {
  cin>>b[i];
  if(a[i]-b[i]>0)
    c+=a[i] - b[i];
  }

  cout<<c<<" ";
}

signed main(){
     
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);

int main(){
  int n,m;
  cin >> n >> m;
  
  vector<int>k(m);
  vector<vector<int>>s(10,vector<int>(10));
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  
  vector<int>p(m);
  rep(i,m) cin >> p[i];
  
  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    int on=0;
    for(int i=0;i<m;i++){
      int sum=0;
      for(int j=0;j<k[i];j++){       
        if((bit >> s[i][j])&1){
          sum++;
        }
      }
      sum%=2;
      if(sum==p[i])on++;
    }
    if(on==m)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin>>x;
    if(x>=400&&x<=599)
    cout<<"8";
    else if(x>=600&&x<=799)
    cout<<"7";
    else if(x>=800&&x<=999)
    cout<<"6";
    else if(x>=1000&&x<=1199)
    cout<<"5";
    else if(x>=1200&&x<=1399)
    cout<<"4";
    else if(x>=1400&&x<=1599)
    cout<<"3";
    else if(x>=1600&&x<=1799)
    cout<<"2";
    else if(x>=1800&&x<=1999)
    cout<<"1";
    
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;
const int MAXM = 4005;
const int mod = 1e9 + 7;

int n, mxa, mxb, ans, a[MAXN], b[MAXN], fac[MAXN], inv[MAXN], f[MAXM][MAXM];

inline int C(int x, int y) { return 1LL * fac[x] * inv[y] % mod * inv[x - y] % mod; }

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 1; i <= n; i ++)
		mxa = max(mxa, a[i] = Read()), mxb = max(mxb, b[i] = Read());
	for (int i = 2; i <= mxa + mxb << 1; i ++)
		fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i <= mxa + mxb << 1; i ++)
		inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
	for (int i = 1; i <= n; i ++)
		f[mxa - a[i]][mxb - b[i]] ++;
	for (int i = 0; i <= mxa << 1; i ++)
		for (int j = 0; j <= mxb << 1; j ++)
		{
			if (i)
				f[i][j] = (f[i][j] + f[i - 1][j]) % mod;
			if (j)
				f[i][j] = (f[i][j] + f[i][j - 1]) % mod;
		}
	for (int i = 1; i <= n; i ++)
		ans = (ans + f[mxa + a[i]][mxb + b[i]] - C(a[i] + b[i] << 1, a[i] << 1)) % mod;
	ans = 1LL * (ans + mod) * (mod + 1) / 2 % mod;
	return printf("%d\n", ans), 0;
}


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

int main() {
    std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
    int n;
    cin >> n;
    unordered_map<string, int> frq;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
    	string s;
    	cin >> s;
    	sort(s.begin(), s.end());
    	ans += frq[s]++;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 10660
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	ps := ReadInts(N)

	cnt := 0
	for i := 1; i <= N; i++ {
		if ps[i-1] != i {
			cnt++
		}
	}
	if cnt == 0 || cnt == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    final static int SENTINEL = Integer.MAX_VALUE;

    static long merge(int[] A, int left, int mid, int right) {
        long cnt = 0;
        int n1 = mid - left;
        int n2 = right - mid;

        int[] L = new int[n1 + 1];
        int[] R = new int[n2 + 1];
        System.arraycopy(A, left, L, 0, n1);
        System.arraycopy(A, mid, R, 0, n2);
        L[n1] = SENTINEL;
        R[n2] = SENTINEL;

        int i = 0, j = 0;
        for (int k = left; k < right; k++) {
            if (L[i] <= R[j]) {
                A[k] = L[i];
                i++;
            } else {
                A[k] = R[j];
                j++;
                cnt += n1 - i;
            }
        }
        return cnt;
    }

    static long mergeSort(int[] A, int left, int right) {
        if (right - left > 1) {
            int mid = (left + right) / 2;
            long a = mergeSort(A, left, mid);
            long b = mergeSort(A, mid, right);
            long c = merge(A, left, mid, right);
            return a + b + c;
        } else {
            return 0;
        }
    }

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            final int n = Integer.parseInt(in.readLine());
            final int[] A = Arrays.stream(in.readLine().split(" "))
                    .mapToInt(Integer::parseInt).toArray();

            long ret = mergeSort(A, 0, n);

            System.out.println(ret);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 75032
N = int(input())
if N <= 9:
  print(N)
elif 10 <= N <= 99:
  print(9)
elif 100 <= N <= 999:
  print(N-90)
elif 1000 <= N <= 9999:
  print(909)
elif 10000 <= N <= 99999:
  print(N-9090)
else:
  print(90909)
  

Measured memory_bytes: 2940
#include<bits/stdc++.h>
     #define pa pair<int,int>
     #define ppa pair<pa,pa>
#define pb push_back
#define mp make_pair
    using namespace std;
int h,w;
int a[600][600];
vector<pa> ve;
vector<ppa> ans;
int main(){
    cin>>h>>w;
  for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin>>a[i][j];
  for(int i=1;i<=h;i++){
  	if(i%2){
    for(int j=1;j<=w;j++)ve.push_back(make_pair(i,j));
    }
    else{
    for(int j=w;j>=1;j--)ve.push_back(make_pair(i,j));
    }
  }
  
  for(int i=0;i<h*w-1;i++){
  	if(a[ve[i].first][ve[i].second]%2){
    	ans.pb(mp(ve[i],ve[i+1]));
      a[ve[i].first][ve[i].second]--;
      a[ve[i+1].first][ve[i+1].second]++;
    }
  }

  cout<<ans.size()<<endl;
  for(auto v:ans){
  cout<<v.first.first<<" "<<v.first.second<<" "<<v.second.first<<" "<<v.second.second<<endl;
  }
      return 0;
    }

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

using namespace std;

typedef long long ll;

int main() {
  ll n; 
  while (cin >> n) {
    ll sum = 0;
    for (ll i = 1; i <= n; i++) {
      if ((n - i) / i <= i) {
        break;
      }
      if ((n - i) % i == 0) {
        sum += (n - i) / i;
      }
    }
    cout << sum << '\n';
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,s[200100],t[200100],res;
vector<int>v;
void ADD(int x){while(x<=m)t[x]++,x+=x&-x;}
int ASK(int x){int r=0;while(x)r+=t[x],x-=x&-x;return r;}
signed main(){
	scanf("%lld%lld",&n,&m),v.push_back(0);
	for(int i=1;i<=n;i++)scanf("%lld",&s[i]),s[i]-=m,s[i]+=s[i-1],v.push_back(s[i]);
	sort(v.begin(),v.end()),v.resize(unique(v.begin(),v.end())-v.begin()),m=v.size();
	for(int i=0;i<=n;i++)s[i]=lower_bound(v.begin(),v.end(),s[i])-v.begin()+1,res+=ASK(s[i]),ADD(s[i]);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 5104
# -*- coding: utf-8 -*-
"""
C - K-th Substring
https://beta.atcoder.jp/contests/abc097/tasks/arc097_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, K):
    l = len(s)
    substrings = set()
    for i in range(l):
        for j in range(i+K+1):
            t = s[i:j]
            if len(t):
                substrings.add(t)
    ans = list(substrings)
    ans.sort()
    return ans[K - 1]


def main(args):
    s = input().strip()
    K = int(input())
    ans = solve(s, K)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 4464
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int a[101010], b[101010];
vector<pair<int, int>>v;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i], v.emplace_back(a[i], 1);
	for (int i = 0; i < n; i++) cin >> b[i], v.emplace_back(b[i], 2);
	sort(ALL(v));
	LL ans = 1;
	int pa = 0, pb = 0;
	for (int i = 0; i < 2 * n; i++) {
		if (v[i].second == 1) {
			if (pb == 0)pa++;
			else (ans *= pb) %= MOD,pb--;
		}
		if (v[i].second == 2) {
			if (pa == 0)pb++;
			else (ans *= pa) %= MOD,pa--;
		}
	}
	cout << ans%MOD << endl;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants
#define INF 1e9

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin


// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N=in();
  double total=0.;
  rep(i,N){
    string s, u;
    cin >> s >> u;
    if(u=="JPY"){
      total += static_cast<double>(atoi(s.c_str()));
    } else {
      total += static_cast<double>(380000.0*atof(s.c_str()));
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long K, long long X){
	cout << X-K+1;
	for (ll i = 1; i < K*2-1; i++) {
		cout << " " << X-K+1+i;
	}
	cout << endl;
}

int main(){	
	long long X;
	long long K;
	scanf("%lld",&K);
	scanf("%lld",&X);
	solve(K, X);
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

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

    long n = sc.nextLong();
    int ans = 10;

    for(int i = 1; i <= Math.sqrt(n); i++){
      if(n % i == 0){
        int buf = String.valueOf(n / i).length();
        if(ans > buf){
          ans = buf;
        }
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

template <int MaxN = 100000, long long mod = 1000000007LL>
class Modlib {
    long long _fact[MaxN + 1];
    long long _fact_inv[MaxN + 1];

public:
    // x^n
    long long pow(long long x, long long n) const {
        long long ret = 1LL;
        long long t = x % mod;
        while (n > 0) {
            if (n & 1LL) {
                ret *= t;
                ret %= mod;
            }
            t *= t;
            t %= mod;
            n >>= 1;
        }
        return ret;
    }
    // xの逆元
    // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    constexpr long long inv(long long a) const {
        long long b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            a ^= b;
            b ^= a;
            a ^= b;

            u -= t * v;
            u ^= v;
            v ^= u;
            u ^= v;
        }
        u %= mod;
        if (u < 0)
            u += mod;
        return u;
    }
    // n!
    long long fact(long long n) const {
        return _fact[n];
    }
    // nPk
    long long perm(long long n, long long k) const {
        return fact(n) * _fact_inv[n - k] % mod;
    }
    // nCk
    long long comb(long long n, long long k) const {
        return perm(n, k) * _fact_inv[k] % mod;
    }

    constexpr Modlib() : _fact{}, _fact_inv{} {
        _fact[0] = _fact[1] = 1LL;
        for (int i = 2; i <= MaxN; ++i) {
            _fact[i] = _fact[i - 1] * i % mod;
        }
        _fact_inv[MaxN] = inv(_fact[MaxN]);
        for (int i = MaxN - 1; i >= 0; --i) {
            _fact_inv[i] = _fact_inv[i + 1] * (i + 1) % mod;
        }
    }
};

constexpr ll mod = 998244353LL;
constexpr auto modlib = Modlib<300000, mod>();

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for (ll i = 0; i <= n; ++i) {
        ll j = k - a * i;
        if (j % b != 0)
            continue;
        j /= b;
        if (!(0 <= j && j <= n))
            continue;
        ans += modlib.comb(n, i) * modlib.comb(n, j) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

struct Card { char suit, value; };

void Bubble(struct Card A[], int N) {
    for (int i=0; i<N; i++) {
        for (int j = N-1; j>=i+1; j--) {
            if (A[j].value < A[j-1].value) {
                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t;
            }
        }
    }
}

void Selection(struct Card A[], int N) {
    for (int i=0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for (int i=0; i<N; i++) {
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for (int i = 0; i < N; i++) {
        C2[i] = C1[i];
    }
    
    Bubble(C1, N);
    Selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    
    return 0;
}






Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#include <math.h>
const int INF = 1001001001;
int main() {
    int N;
    double A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    vector<double>X;
    vector<double>Y;
    for(int i=0;i<=F;i++){
        for(int j=0;j<=F;j++){
            int x=i*A*100+j*B*100;
            if(x<=F){X.push_back(x);}
        }
    }
    for(int i=0;i<=F;i++){
        for(int j=0;j<=F;j++){
            int y=i*C+j*D;
            if(y<=F){Y.push_back(y);}
        }
    }
    double ans=0;int MAXX=0;int MAXY=0;
    for(int i=0;i<X.size();i++){
        for(int j=0;j<Y.size();j++){
          if((X[i]+Y[j])<=F&&Y[j]/(X[i]+Y[j])<=E/(100+E)){
              ans=max(ans,Y[j]/(X[i]+Y[j]));
              if(ans<=Y[j]/(X[i]+Y[j])){MAXX=X[i];MAXY=Y[j];}
          }
        }
    }
    cout<<MAXX+MAXY<<" "<<MAXY<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN = 200005;

void wynik(ll& a, ll b) {
	a = max(a, b);
}

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

	int n, w;
	cin >> n >> w;	
	ll dp[MAXN];
	for(int i=0; i<n; i++)	{
		int waga, koszt;	
		cin >> waga >> koszt;
		for(int j=w-waga; j>=0; j--)
			wynik(dp[j+waga], dp[j] + koszt);
	}
	ll R = 0;
	for(int i=0; i<= w; i++)
		wynik(R, dp[i]);
	cout << R;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] a = br.readLine().split(" ");
            String[] b = br.readLine().split(" ");

            int c = Integer.parseInt(a[0]);
            int d = Integer.parseInt(a[1]);
            int e = Integer.parseInt(b[0]);
            int f = Integer.parseInt(b[1]);

            System.out.println((c- e) * (d - f));
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	K := nextInt()
	S := nextInt()
	W := nextInt()

	dev := W / K
	if dev*K >= S {
		fmt.Print("OK")
	} else {
		fmt.Print("NG")
	}
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll n; cin >> n;
    vll a(n); REP(i, n) cin >> a[i];
    sort(ALL(a));
    ll j = 0, m = INF;
    REP(i, n)
    {
        if(abs(2*a[i] - a[n-1]) < m)
        {
            m = abs(2*a[i] - a[n-1]);
            j = i;
        }
    }

    cout << a[n-1] << " " << a[j] << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

typedef long long ll;
using namespace std;

int t = 0;
int target_edge = 0;

template<class T>
void combination(const vector<T>& seed, int target_size, bool (*callback)(const vector<T>&)) {
    vector<int> indices(target_size);
    const int seed_size = seed.size();
    int start_index = 0;
    int size = 0;

    while (size >= 0) {
        for (int i = start_index; i < seed_size; ++i) {
            indices[size++] = i;
            if (size == target_size) {
                vector<T> comb(target_size);
                for (int x = 0; x < target_size; ++x) {
                    comb[x] = seed[indices[x]];
                }
                if (callback(comb)) return;
                break;
            }
        }
        --size;
        if (size < 0) break;
        start_index = indices[size] + 1;
    }
}

///////////////// How to use

bool my_callback(const vector<int>& comb) {
    int n = comb.size();
    if (t < target_edge) {
    for (int i=0; i<n; ++i)
        cout << comb[i] << " ";
    cout << endl;
    }
    t++;
    return false;
}


int main() {

    int N, K;
    cin >>  N >> K;
    

    int max_edge = (N - 1) * (N -2) / 2;
    if (K > max_edge) {
        cout << -1 << '\n';
        return 0;
    }
     vector<int> vals;
    for (int i = 1; i <= N; i++) vals.push_back(i);
    
    target_edge = max_edge - K + N - 1;

    cout << target_edge << '\n';

    combination(vals, 2, my_callback);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;



int main(){
    int N, M, K; cin >> N >> M >> K;
    if(K % N == 0 || K % M == 0){
        cout << "Yes" << endl;
        return 0;
    }

    for(int i = 0; i <= N; i++){
        for(int j = 0; j < M; j++){
            ll tmp = N*M - N*j - M * i + 2*i*j;
            if(tmp == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val x = sc.nextInt
  println(if(x == 2)2 else nextPrime(x))

  def isPrime(n: Int): Boolean = (2 to math.sqrt(n).toInt).forall(n % _ != 0)

  @scala.annotation.tailrec
  def nextPrime(n: Int): Int = if (isPrime(n)) n else nextPrime(n + 1)
}


Measured memory_bytes: 27324
#include <iostream>
#include <vector>

int main()
{
	std::vector<int> hist(100, 0);

	int index = 0;
	int max = 0;
	while (std::cin >> index)
	{
		hist[index - 1]++;
		if (max < hist[index - 1])
		{
			max = hist[index - 1];
		}
	}

	int i = 1;
	for (const auto& h : hist)
	{
		if (h == max)
		{
			std::cout << i << std::endl;
		}
		++i;
	}

	return 0;
}

Measured memory_bytes: 3052
import java.util.*;

public class Main {

    static final long MOD = 1_000_000_007L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        long[] c = new long[26];
        for (int i = 0; i < n; i++) {
            int idx = s[i] - 'a';
            c[idx]++;
        }
        long ans = 1L;
        for (int i = 0; i < 26; i++) {
            ans = (ans * (c[i]+1)) % MOD;
        }
        System.out.println((ans + MOD -1) % MOD);
        sc.close();

    }

}


Measured memory_bytes: 39520
import sys
n = int(input())
W = ['']*n
for i in range(n):
    W[i] = input()
if len(W) != len(set(W)):
    print('No')
    sys.exit(0)
for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        print('No')
        sys.exit(0)
print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

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

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	dump(c - min(c, a - b));
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> p(N, 0);
    for (int i = 0; i < N; i++)
        cin >> p[i];

    int ans = 0;
    for (int i = 0; i < N; i++)
        ans += p[i];

    sort(all(p));
    ans -= p[N-1]/2;

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


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
    ll n,m;
    cin>>n>>m;
    if(n>=m/2){
        cout<<m/2<<endl;
    }else{
        ll ans=n;
        m=m-n*2;
        ans+=(m/4);
        cout<<ans<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v[3];
map<ll,ll>m;
string s[3],s2;
void input(){
    cin>>a>>b;
    v[0]={1,3,5,7,8,10,12};
    v[1]={4,6,9,12};
    v[2]={2};
}
void src(){
    if(2==count_if(v[0].begin(),v[0].end(),[](auto x){return x==a;})+count_if(v[0].begin(),v[0].end(),[](auto x){return x==b;}))
    {cout<<"Yes";return;}
    if(2==count_if(v[1].begin(),v[1].end(),[](auto x){return x==a;})+count_if(v[1].begin(),v[1].end(),[](auto x){return x==b;}))
    {cout<<"Yes";return;}
    if(2==count_if(v[2].begin(),v[2].end(),[](auto x){return x==a;})+count_if(v[2].begin(),v[2].end(),[](auto x){return x==b;}))
    {cout<<"Yes";return;}
    cout<<"No";
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256