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

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int H,W;
		int count1=0;
		int count2=0;
		
		
		while(true){
			H = as.nextInt();
			W = as.nextInt();
			
			if(H==0 && W==0){
				
				break;
				
			}
			
			for(int i=0;i<H;i++){
				
				if(i==2*count1){
					
					for(int j=0;j<W;j++){
						
						if(j==2*count2){
							
							System.out.print("#");
							
						}
						
						else{
							
							System.out.print(".");
							count2++;
							
						}
					}
					count2=0;
				}
				
				else{
					
					for(int j=0;j<W;j++){
					
						if(j==2*count2){
							
							System.out.print(".");
							
						}
						
						else{
							
							System.out.print("#");
							count2++;
							
						}
						
					}
					count2=0;
					count1++;
				}
				
				System.out.println();
				
				
			}
			
			System.out.println();
			count1=0;
		}
		
		

	}

}

Measured memory_bytes: 32824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
#define f first
#define s second
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (ll) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, s, arr[3005], mod = 998244353, dp[3005][3005];

int main() {
	fastio; cin >> n >> s;
	FOR(i, 1, n) cin >> arr[i];
	dp[0][0] = 1;
	FOR(i, 1, n) FOR(j, 0, s) {
		dp[i][j] += 2*dp[i-1][j];
		dp[i][j] %= mod;
		if (arr[i] <= j) {
			dp[i][j] += dp[i-1][j-arr[i]];
			dp[i][j] %= mod;
		}
	}
	cout << dp[n][s];
}


Measured memory_bytes: 74024
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int N,answer;
    char S[100];
    
    scanf("%s",S);
    
    if(strcmp(S,"Sunny") == 0){
        printf("Cloudy\n");
    }else if(strcmp(S,"Cloudy") == 0){
        printf("Rainy\n");
    }else{
        printf("Sunny\n");
    }
    
    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};




LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)x += mod1;
    return x;
}

const LL mod=1e9+7;

LL a[100002],fact[100002];

void find_fact()
{
    LL i;
    fact[1]=1LL;
    for(i=2LL;i<=100000;i++)fact[i]=(fact[i-1]*i)%mod;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    find_fact();
    LL i,k,n,ans=0LL;
    cin >> n >> k;
    for(i=1;i<=n;i++)cin >> a[i];
    sort(a+1,a+n+1,greater<LL>());
    for(i=1;i<=n;i++)
    {
        if(n - i >= k - 1LL) {
          LL p = mod_inverse(fact[n - i - (k - 1)], mod);
          LL q = mod_inverse(fact[k - 1], mod);
          LL down = (p * q) % mod;
          down = (a[i] * down) % mod;
          ans = (ans + down * fact[n - i]) % mod;
          if(ans < 0) ans += mod;
        }
        if(i >= k) {
          LL p = mod_inverse(fact[i - 1 - (k - 1)], mod);
          LL q = mod_inverse(fact[k - 1], mod);
          LL down = (p * q) % mod;
          down = (a[i] * down) % mod;
          ans = (ans - down * fact[i - 1]) % mod;
          if(ans < 0) ans += mod;
        }
    }
    if(ans < 0) ans += mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
N=int(input())
city=[0]*N
for i in range(N):
    x,y=map(int,input().split())
    city[i]=(i,x,y)
city.sort(key=lambda x:x[1])
data=[(city[i][0],city[i+1][0],city[i+1][1]-city[i][1]) for i in range(N-1)]
city.sort(key=lambda x:x[2])
data+=[(city[i][0],city[i+1][0],city[i+1][2]-city[i][2]) for i in range(N-1)]
data.sort(key=lambda x:x[2])
root=[-1]*N
def search(i):
    global root
    if root[i]>=0:
        root[i]=search(root[i])
        return root[i]
    return i
cost=0
for i,j,k in data:
    ri=search(i)
    rj=search(j)
    if ri==rj:
        continue
    elif root[ri]<=root[rj]:
        cost+=k
        root[ri]+=root[rj]
        root[rj]=ri
    elif root[ri]>root[rj]:
        cost+=k
        root[rj]+=root[ri]
        root[ri]=rj
print(cost)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int D;
    cin>>D;
    vi c(26),last(26,0);
    rep(i,26)cin>>c[i];
    vii s(D,vi(26));
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    rep(i,D){
        ll m=-LongINF,n=0;
        rep(j,26){
            ll sum=s[i][j];
            rep(k,26){
                if(j==k)continue;
                sum-=c[k]*(i-last[k]);
            }
            if(m<sum){
                m=sum;
                n=j+1;
            }
        }
        last[n-1]=i+1;
        cout<<n<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3664
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", (a - 1) * (b - 1));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(0)

// *start on @date: 2020-03-01 20:06

int vis[3][3];

int main()
{
    IOS;
    int t;
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> vis[i][j];
    int n;
    cin >> n;
    while (n--)
    {
        cin >> t;
        for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
        {
            if(vis[i][j]==t)
            vis[i][j]=-1;
        }            
    }
    int num=0,flag=0;
    for(int i=0;i<3;i++)
    {
        num=0;
        for(int j=0;j<3;j++)
        num+=vis[i][j];
        if(num==-3)
        flag=1;
    }
    
    for(int i=0;i<3;i++)
    {
        num=0;
        for(int j=0;j<3;j++)
        num+=vis[j][i];
        if(num==-3)
        flag=1;
    }
    if(vis[0][0]+vis[1][1]+vis[2][2]==-3)
    flag=1;
    
    if(vis[0][2]+vis[1][1]+vis[2][0]==-3)
    flag=1;
    if(flag)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

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

int main() {
  long long a,b,v,w;
  int t;
  cin >> a >> v >> b >> w >> t;
  if ( abs(a-b)<=(v-w)*t ) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0; 
}

Measured memory_bytes: 3564
A, B, K = map(int, input().split())
tmp = 0

if A >= K:
    A -= K
    print(A,B)
else:
    if B < K-A:
        A = B = 0
        print(A, B)
    else:
        B -= K-A
        A = 0
        print(A, B)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<string.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX_LIMIT 100000
#define mp make_pair
#define pb push_back
#define bb back
#define e endl
using namespace std;
int main()
    {
       ll n,k;
       cin>>n>>k;
       ll i;
       for(i=k-n+1;i<=k+n-1;i++){
           cout<<i<<" ";
       }
}

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

using namespace std;

int main()
{
  int n; 
  cin >> n;
  
  vector<int> nums;
  int i = 0;
  
  while (i < n)
  {
      int k;
    cin >> k;
    nums.push_back(k);
    i++;
    }
  
  if (n == 1)
  {
  	cout << "YES"; 
    return 0;
  }
  vector<int> ind;
    
  for (int i = 1; i < n; i++)
  {
  	if (nums[i] < nums[i-1])
    {
    	ind.push_back(i-1);
    }
  }
    
  if (ind.size() == 0)
  {
      cout << "YES";
      return 0;
  }
  
  if (ind.size() != 2 || nums[ind[0]+1] < nums[ind[1]+1] || nums[ind[1]] > nums[ind[0]])
  {
  	cout << "NO"; 
    return 0;
  }
  else
  {
  	cout << "YES"; 
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 998244353
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n;
int arr[100000+9];
ll dp[100000];
int k;
ll solve(int ind) {
    if (ind+1 == n) {
        return 0;
    }
    if(dp[ind] != -1)
        return dp[ind];
    ll a = 1e18;
    for(int i = 1;i<=k;i++){
        if (ind + i < n)
            a = min(a, solve(ind + i) + abs(arr[ind] - arr[ind + i]));
        else
            break;
    }
    return dp[ind] = a;
}
int main(){
    cin>>n>>k;
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp,-1, sizeof(dp));
    cout<<solve(0);
    return 0;
}

Measured memory_bytes: 6144
N = int(input())
map_T = map(int, input().split())
list_T = list(map_T)
M = int(input())
sumtime = sum(list_T)

for i in range(M):
  map_PX = map(int, input().split())
  list_PX = list(map_PX)
  sumtime_drink = sumtime- list_T[list_PX[0]- 1]+ list_PX[1]
  print(sumtime_drink)

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,a[300001],ans=0; Cin(n);
    rep(i,3*n) Cin(a[i]);
    sort(a,a+3*n,greater<int>());
    for(int i=1;i<2*n;i+=2){
        ans += a[i];
    }
    Cout(ans);
    return 0;
}

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

#define    int               long long int
 #define    bp(x)         __builtin_popcount(x)
#define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

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

int32_t main()
{
    fast
    int n,ans=0,x,y;    cin>>n;
    set<int>s1,s2;
    f(i,1,n){
        cin>>x>>y;
        s1.insert(x+y);
        s2.insert(x-y);
    }
    set<int>:: iterator  it=s1.end();
    it--;
    ans=*it- *(s1.begin());
    it=s2.end();
    it--;
    ans=max(*it- *(s2.begin()),ans);
    cout<<ans;
}

Measured memory_bytes: 22404
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Q;
  cin>>N>>Q;
  string s;
  cin>>s;
  int a[Q];
  int b[Q];
  int con[N];
  for(int i = 0;i<Q;i++){
    cin>>a[i]>>b[i];
  }
  con[0] = 0;
  for(int i = 1;i<N;i++){
    con[i] = con[i-1];
    if(s.at(i-1) == 'A' && s.at(i) == 'C'){
      con[i]++;
    }
  }
    
  for(int k = 0;k<Q;k++){
    cout << con[b[k]-1] - con[a[k]-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<vector <int>> G;

void create_edge(int a, int b, int c, int d);
int search(int st, int go);


int main(){

  int n,m;
  int start;
  int goal;
  int money;
  int pay;
  int g_money,b_money;
  int sarary;
  
    
  cin >> n;
  cin >> m;
  //cout << "ihjiwohjwi" << endl;
  
  G = vector <vector<int>>(20,vector<int>(20,1001));
  
  // cout << "1" << endl;

  for(int i = 0; m>i; ++i){
    int a,b,c,d;
    
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    create_edge(a,b,c,d);
  }

  //cout << "2" << endl;

  scanf("%d,%d,%d,%d",&start,&goal,&money,&pay);
  
  // cout << "money :" << money << endl;
  //cout << "pay :" << pay << endl;
  //cout << "koutuuhi :" << g_money + b_money << endl;

  g_money = search(start, goal);
  b_money = search(goal, start);
  
  sarary = money - (g_money + b_money + pay);
  
  //cout << "money :" << money << endl;
  //cout << "pay :" << pay << endl;
  //cout << "koutuuhi :" << g_money + b_money << endl;
 
  cout << sarary << endl;
  
  
}



void create_edge(int a, int b, int c, int d){

  G[a][b] = c;
  G[b][a] = d;

}



int search(int st, int go){

  int current;
  
  typedef pair < int, int > PII;
  vector <int>  cost(100, 1001);
  priority_queue < PII, vector < pair <int, int> >, greater < pair <int, int> > > que;
  //cout << "search" << endl;
  que.push(PII(0,st));
  cost[st] = 0;
  
  
  while(!que.empty()){
    current = que.top().second;
    que.pop();

    for(int k=0; k<20; k++){
      int temp;
      temp = G[current][k] + cost[current];

      if(G[current][k] != 1001 && temp < cost[k]){
	que.push(PII(temp,k));
	cost[k] = temp;
      }
    }  		 
  }
  
  return cost[go];
}
      
  



 

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x; cin >> x;
  int ans = 0;
  if(x==1) cout << 1;
  else{
 for(int i = 2; i <= sqrt(x); i++){
      for(int j = 2; pow(i, j) <= x; j++){
        if(ans < pow(i, j)){
          ans = pow(i, j);
        }
      }
    }
    cout << ans << endl;
}
}

Measured memory_bytes: 256
N = gets.to_i
A = [0] + gets.split.map(&:to_i) + [0]

S = (0..N).map {|i| (A[i]-A[i+1]).abs }.inject(&:+)

(1..N).each do |i|
  p, n = [A[i-1], A[i+1]].sort
  a = A[i]
  if p<=a and a<=n
    puts S
    next
  elsif a<=p
    puts S-(p-a)*2
    next
  elsif a>=n
    puts S-(a-n)*2
    next
  end
end


Measured memory_bytes: 13068
#include <cstdio>

int main() {
    int in[8] = { 0 };

    while (true) {
        for (int i = 0; i < 8; ++i) {
            if (scanf("%d", &in[i]) == EOF) {
                return 0;
            }
        }

        int hi = 0;
        int bl = 0;

        for (int i =  0; i < 4; ++i) {
            for (int j = 4; j < 8; ++j) {
                if (in[i] == in[j]) {
                    if (i == j - 4) {
                        hi++;
                    } else {
                        bl++;
                    }
                }
            }
        }

        printf("%d %d\n", hi, bl);
    }
}

Measured memory_bytes: 1028
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

struct dish {
	ll x, y;

	dish(ll tx = 0, ll ty = 0) {
		x = tx;
		y = ty;
	}

	void read() {
		cin >> x >> y;
	}

	bool operator<(const dish & d) const {
		return (x + y > d.x + d.y);
	}
};

#define MAXN (1 << 17)

dish a[MAXN];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		a[i].read();
	}
	sort(a, a + n);
	ll ret = 0;
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			ret -= a[i].y;
		} else {
			ret += a[i].x;
		}
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 5672
#include <iostream>

using namespace std;

int main()
{
    char x,y;
    cin>>x>>y;
    if (x>y)
    {
        cout<<">";
    }
    else if (x<y)
    {
        cout<<"<";
    }
    else if (x==y)
    {
        cout<<"=";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String b=scan.next();
	if(b.charAt(0)=='A') {
		System.out.println("T");
	}
	else if(b.charAt(0)=='T'){
		System.out.println("A");
	}
	else if(b.charAt(0)=='G') {
		System.out.println("C");
	}
	else if(b.charAt(0)=='C') {
		System.out.println("G");
	}
	}

}

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

int main(){
  string S, T;
  cin >> S >> T;
  
  int d = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) d++;
  }
  
  cout << d;
}

Measured memory_bytes: 3856
#include <iostream>

typedef long long ll;

using namespace std;

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 == m2){
        cout << "0" << endl;
    }else{
        cout << "1" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


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

	vint T(N);
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}

	sort(T.begin(), T.end());

	int ans = 0;
	int next = 0;

	while (next < N) {

		for (int i = 0; i < C && next + i < N; i++) {
			if (T[next + i] - T[next] > K) {
				next += i;
				ans++;
				break;
			}
			else if (i == C - 1 || next + i == N - 1) {
				next += C;
				ans++;
				break;
			}
		}


	}

	cout << ans;

}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,k,flag=0;
    cin>>k;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag=1;
            break;
        }
    }
    if(flag)
    cout<<"OK";
    else
    cout<<"NG";
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int cnt;

void insertionSort(vector<int> &A, int N, int g){
    for(int i=g; i<N; i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(vector<int> &A, int N){
    cnt = 0;
    vector<int> G;
    G.push_back(1);
    while(true){
        if(G[G.size()-1]*3+1 < N) G.push_back(G[G.size()-1]*3+1);
        else break;
    }
    cout << G.size() << endl;
    sort(G.begin(), G.end(), greater<int>());
    rep(i,G.size()){
        cout << G[i];
        if(i != G.size()-1) cout << " ";
    }cout << endl;
    rep(i,G.size()){
        insertionSort(A, N, G[i]);
    }
    cout << cnt << endl;
    rep(i,N){
        cout << A[i] << endl;
    }
}

int main()
{
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    shellSort(A, N);
}


Measured memory_bytes: 6708
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3132
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        var abk = Console.ReadLine().Split().Select(int.Parse).ToList();
        Console.WriteLine(Enumerable.Range(1, 1000).Reverse().Where(x => (abk[0] % x == 0) && (abk[1] % x == 0)).Skip(abk[2] - 1).First());
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll c[200005];
	ll j[200005];
	vector<pair<ll, ll> > jump;
	fill(j, j+200005, -1);
	for(ll i = 0; i < n; i++){
		cin >> c[i];
		if(j[c[i]] != -1 && j[c[i]] != i-1)jump.push_back(make_pair(j[c[i]], i));
		j[c[i]] = i;
	}
	sort(jump.begin(), jump.end());
	//for(int i = 0; i < (int)jump.size(); i++)cout << jump[i].first << ' ' << jump[i].second << endl;
	ll num[200005]={0};
	ll p = 0;
	num[0]=1;
	for(ll i = 0; i < n; i++){
		if(i)num[i]+=num[i-1], num[i]%=INF;
		if(p >= jump.size())continue;
		if(jump[p].first == i)num[jump[p].second]+=num[i], num[jump[p].second]%=INF, p++;
	}
	//for(int i = 0; i < n; i++)cout << num[i] << endl;
	cout << num[n-1]%INF << endl;
    return 0;
}

Measured memory_bytes: 9968
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n;
    string s;
    cin >> n >> s;

    string t = "";
    int fir = 'A';
    rep(i, s.length()){
        int num = ((s[i] - 'A') + n) % 26;
        t += char(num + fir);
    }

    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
// ABC167-E
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

ll modpow(ll x,ll y,ll mod){ //x^y
    if(y==0) return 1;
    if(y==1) return x%mod;
    if(y%2==1) return x*modpow(x,y-1,mod)%mod;
    ll t=modpow(x,y/2,mod);
    return (t*t)%mod;
}
vector<ll> fact(210000);
vector<ll> invfact(210000);
ll nck(ll n,ll k,ll mod){
    if(n<k or k<0) return 0;
    return (fact[n]*invfact[k])%mod*invfact[n-k]%mod;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,m,k;
    cin>>n>>m>>k;
    int mod=998244353;
    fact[0]=1;
    for(int i=1;i<210000;i++){
        fact[i]=fact[i-1]*i%mod;
    }
    //cout<<fact[20000]<<endl;
    invfact[210000-1]=modpow(fact[210000-1],mod-2,mod);
    //cout<<modpow(fact[210000-1],mod-2,mod)<<endl;
    for(int i=210000-2;i>-1;i=i-1){
        invfact[i]=invfact[i+1]*(i+1)%mod;
    }
    ll ans=0;
    for(int i=0;i<=k;i++){
        ll num=(nck(n-1,i,mod)*m)%mod*modpow(m-1,n-i-1,mod)%mod;
        //cout<<nck(n-1,i)<<endl;
        //cout<<modpow(m-1,n-i-1,mod)<<endl;
        ans+=num;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int x, a, b;
    cin >> x>>a>>b;
    if (abs(a-x)>abs(b-x))
    {
        cout << "B" << endl;
    }
    else
    {
        cout << "A" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
 
int main() {
    int a, b; cin >> a >> b;
    bool check = false;
    int num = max(a, b);

    for(int i=0; i<=num; i++){
        if(abs(a-i) == abs(b-i)){
            check = true;
            cout << i << endl;
            break;
        }
    }
    if(check == false) cout << "IMPOSSIBLE"<<endl;

    return 0;
}

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

    vector<int>d(n);
    for (int i=0;i<n;i++) {
        cin>>d[i];
    }
    sort(d.begin(),d.end());

    int answer=d[n/2]-d[n/2-1];

    cout<<answer<<endl;

}

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

int main() {
 	int n;
  	cin>>n;
  
  int a[n];
  rep(i,n)cin>>a[i];
  
  int ans=0;
  
  for(int i=0;i<n;i++){
  	if(i%2==0&&a[i]%2==1)ans++;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 a, b;
i64 f(i64 x) {
  if (x == 0) return 0;
  i64 y = 0;
  for (i64 i = 0; i <= x % 4; ++i) {
    y ^= x - i;
  }
  return y;
}
int main() {
  cin >> a >> b;
  cout << (f(b) ^ f(a - 1)) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            if (n == 0 && m == 0) {
                break;
            }
            int[] arr = new int[n];
            int max = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
            }
            for (int i = 0; i < n - 1; i++) {
                for (int j = i + 1; j < n; j++) {
                    int sum = arr[i] + arr[j];
                    if (sum > m) {
                        continue;
                    }
                    max = Math.max(max, sum);
                }
            }
            if (max == 0) {
                sb.append("NONE").append("\n");
            } else {
                sb.append(max).append("\n");
            }
        }
        System.out.print(sb);
    }
}



Measured memory_bytes: 51248
s = input()
n = len(s)

s_list = list(s)
r_list = list(s)
r_list.reverse()

first_s_list = s_list[0:(n - 1) // 2]
first_r_list = list(reversed(first_s_list))

last_s_list = s_list[(n - 1) // 2 + 1:n]
last_r_list = list(reversed(last_s_list))

if s_list == r_list and first_s_list == first_r_list and last_s_list == last_r_list:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

public class Program
{

    public static void Main()
    {
        new Program().Solver();
    }

    private long H;
    private long W;
    private long N;

    void Solver()
    {
        String[] input = Console.ReadLine().Split(' ');
        H = long.Parse(input[0]);
        W = long.Parse(input[1]);
        N = long.Parse(input[2]);
        Dictionary<long, Dictionary<long, int>> dic = new Dictionary<long, Dictionary<long, int>>();

        for (int n = 0; n < N; n++)
        {
            input = Console.ReadLine().Split(' ');
            long h = int.Parse(input[0]) - 1;
            long w = int.Parse(input[1]) - 1;
            for (int i = 0; i >= -2; i--)
            {
                long hh = h + i;
                if (hh < 0) continue;
                if (hh >= H - 2) continue;

                for (int j = 0; j >= -2; j--)
                {
                    long ww = w + j;
                    if (ww < 0) continue;
                    if (ww >= W - 2) continue;

                    if (!dic.ContainsKey(hh))
                    {
                        dic.Add(hh, new Dictionary<long, int>());
                    }

                    if (!dic[hh].ContainsKey(ww))
                    {
                        dic[hh].Add(ww, 1);
                    }
                    else
                    {
                        dic[hh][ww]++;
                    }
                }
            }
        }

        long[] res = new long[10];
        for (int i = 0; i < 10; i++) res[i] = 0;
        res[0] = (H - 2) * (W - 2);
        foreach (var wdic in dic.Values)
        {
            foreach (var index in wdic.Values)
            {
                res[0]--;
                res[index]++;
            }
        }

        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine(res[i]);
        }
    }
}


Measured memory_bytes: 101080
#include <bits/stdc++.h>
#define ref(i,n) for(int i=0;i<n;i++)
using namespace std;
#define INF 10000000
int a[200001],b[200001];
int main()
{
    int n;
    string s;
    cin>>n>>s;
    if(s.size()<=n) cout<<s;
    else {ref(i,n) cout<<s[i];cout<<"...";}
    return 0;

}


Measured memory_bytes: 3596
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if(err != nil) {
		panic(err)
	}
	return num
}

// 読み込みをfloat型へキャスト
func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	var out_num int
	num := make([]int, 0, 5)
	for i := 0; i < 5; i++ {
		num = append(num, nextInt())
	}
	for m := 0; m < 5; m++ {
		if num[m] == 0 {
			out_num = m + 1
		}
	}
	fmt.Println(out_num)
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}
	
const ll INF=2e18;
ll mult(ll a, ll b)
{
	if(a==0||b==0) return 0;
	if(a>INF/b) return INF;
	return a*b;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	ll cur=1;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x;
		cur=mult(cur,x);
	}
	if(cur>ll(1e18)) cout<<-1<<'\n';
	else cout<<cur<<'\n';
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string a[n];
    for(int i = 0; i < n; ++i){cin >> a[i];}
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i = 0; i < n; ++i){
        if(a[i] == "AC"){++ac;}
        if(a[i] == "WA"){++wa;}
        if(a[i] == "TLE"){++tle;}
        if(a[i] == "RE"){++re;}
    }
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    
    return 0;
}


Measured memory_bytes: 6752
#include<stdio.h>

int main(){
  int n,y,i,j,k;
  scanf("%d %d",&n,&y);
  for(i=0;i<=n;i++){
    for(j=0;j<=n-i;j++){
      int sum=10000*i+5000*j+1000*(n-i-j);
      if(sum==y){
        printf("%d %d %d",i,j,n-i-j);
        return 0;
      }
    }
  }


  puts("-1 -1 -1");

  return 0;
}

Measured memory_bytes: 128
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

p.sort()

s = 0
t = 0

for i in p:
    if i <= a:
        s += 1
        t += 1
    elif i <= b:
        t += 1

ans = min(s, t-s, len(p)-t)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define WR "txt"

void Open() { freopen(WR".in", "r", stdin); freopen(WR".out", "w", stdout); }
void Close() { fclose(stdin); fclose(stdout); }
using namespace std;
long long Read()  {
	long long val = 0, opt = 1; char ch;
	while (!isdigit(ch = getchar() )) if (ch == '-') opt = -1;
	while (isdigit( ch )) (val *= 10) += ch - '0', ch= getchar();
	return val * opt;
}

long long Sum, n, b, c, Ans;

void work()  {
	n = Read();
	for (int i = 1;i <= n; i++)  {
		b = Read(), c = Read();
		Ans += (c - 1) + (b * c - 1) / 9;
		Sum += (b * c - 1) % 9 + 1; 
	}
	Ans += (n - 1) + (Sum - 1) / 9;
	printf("%lld\n", Ans);
}

int main(void)  {
	//Open();
	work();
	//Close();
	return 0;
}

Measured memory_bytes: 256
from collections import deque
K=int(input())
reached=[0 for i in range(K)]
reached[1]=1
dist=[0 for i in range(K)]
q=deque([])
q.append(1)
while(len(q)>0):
    r=q.popleft()
    v=(r+1)%K
    reached[r]=1
    if (reached[v]==0):
        q.append(v)
        dist[v]=dist[r]+1
    v=(r*10)%K
    if (reached[v]==0):
        q.appendleft(v)
        dist[v]=dist[r]
    if (reached[0]==1):
        break
print(dist[0]+1)


Measured memory_bytes: 7528
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var list = new List<Tuple<string, int, int>>();
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine();
            var line = s.Split(' ');
            list.Add(new Tuple<string, int, int>(line[0], int.Parse(line[1]), i + 1));
        }
        list = list.OrderBy(f => f.Item1).ThenByDescending(f => f.Item2).ToList();
        foreach (var x in list) Console.WriteLine(x.Item3);
    }
}

Measured memory_bytes: 11616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b,c,d;
  cin >> a >> b >> c >> d;
  a += b;
  c += d;
  if (a==c) {
    cout << "Balanced " << endl;
  } else if (a<c) {
    cout << "Right" << endl;
  } else {
    cout << "Left" << endl;
  }
}

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

int main() {
 int H,J,I;
 int N;
 cin >> N ;
 H = N / 100;
 N = N % 100;
 J = N / 10;
 N = N % 10;
 I = N;
 cout << H + J + I << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

template<typename T> struct Combination
{
    vector<T> fact, rfact, inv;
    Combination(int n) : fact(n + 1), rfact(n + 1), inv(n + 1)
    {
        fact[0] = fact[1] = 1;
        rfact[0] = rfact[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < n + 1; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            rfact[i] = rfact[i - 1] * inv[i] % MOD;
        }
    }
    T C(int n, int k)
    {
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return fact[n] * (rfact[k] * rfact[n - k] % MOD) % MOD;
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    Combination<ll> cmd(n + k);
    cout << cmd.C(n + k - 1, k - 1) << endl;
    return 0;
}




Measured memory_bytes: 3228
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			if (!IsPrime(x)) {
				x++;
				if (x % 2 == 0) {
					x++;
				}
				while (!IsPrime(x)) {
					x += 2;
				}
			}
			Console.WriteLine(x);


			Console.Out.Flush();
		}

		#region 素数判定 bool IsPrime(long a)
		public static bool IsPrime(long a)
		{
			if (a == 2) { return true; }
			if (a < 2 || a % 2 == 0) { return false; }

			double sqrt = Math.Sqrt(a);
			for (int i = 3; i <= sqrt; i += 2) {
				if (a % i == 0) { return false; }
			}
			return true;
		}
		#endregion

	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int p, q, r;

int formula(string str){
  if(str == "0") return 0;
  if(str == "1") return 1;
  if(str == "2") return 2;
  if(str == "P") return p;
  if(str == "Q") return q;
  if(str == "R") return r;
  if(str[0] == '-') return 2 - formula(str.substr(1));
  int size = str.size();
  int cnt = 0;
  for(int i=0;i<str.size();i++){
    if(str[i] == '(') cnt++;
    if(str[i] == ')') cnt--;
    if(str[i] == '*' && cnt == 1) return min(formula(str.substr(1, i-1)), formula(str.substr(i+1, size-i-2)));
    if(str[i] == '+' && cnt == 1) return max(formula(str.substr(1, i-1)), formula(str.substr(i+1, size-i-2)));
  }
}

int solve(string str){
  int res = 0;
  for(p=0;p<=2;p++){
    for(q=0;q<=2;q++){
      for(r=0;r<=2;r++){
        if(formula(str) == 2) res++;
      }
    }
  }
  return res;
}

main(){
  string in;
  while(cin >> in){
    if(in == ".") break;
    cout << solve(in) << endl;
  }
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n, q;
	cin >> n;

	vector<int> S(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
	}

	cin >> q;
	vector<int> T(q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &T[i]);
	}

	int ans = 0;
	for (int i = 0; i < q; i++)
	{
		if (binary_search(S.begin(),S.end(),T[i]))
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3364
import sys
N, M = map(int, input().split())
S = []
for _ in range(M):
    s, c = map(int, input().split())
    S.append([s, str(c)])

if N == 1:
    for x in range(0, 10):
        check = True
        x = str(x)
        for s in S:
            if x[s[0] - 1] == s[1]:
                continue
            else:
                check = False

        if check:
            print(int(x))
            sys.exit()
            

if N == 2:
    for x in range(10, 99):
        check = True
        x = str(x)
        for s in S:
            if x[s[0] - 1] == s[1]:
                continue
            else:
                check = False

        if check:
            print(int(x))
            sys.exit()


if N == 3:
    for x in range(100, 999):
        check = True
        x = str(x)
        for s in S:
            if x[s[0] - 1] == s[1]:
                continue
            else:
                check = False

        if check:
            print(int(x))
            sys.exit()
print(-1)






Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000007
typedef long long ll;
using namespace std;

typedef pair<ll,ll> P;
const ll max_V = 100005;
const ll INF = 1000000000000000;

struct edge{ll to,cost;};

ll N;
ll M;
vector<edge> G[max_V];
bool used[max_V];
ll d[max_V];
ll pr[max_V];

void dijkstra(ll s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+N,INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
                pr[e.to]=v;
            }
        }
    }
}

int main(){
  cin >> N;
  for(int i=1;i<N;i++){
    ll a,b,c; cin >> a >> b >> c;
    a--; b--;
    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }
  ll Q,K; cin >> Q >> K;
  K--;
  dijkstra(K);
  for(int i=0;i<Q;i++){
    int x,y; cin >> x >> y;
    x--; y--;
    cout << d[x] + d[y] << endl;
  }
  return 0;
}

Measured memory_bytes: 11632
n = gets.to_i
as = gets.split.map(&:to_i).sort!

nums = as.each_with_object(Hash.new(0)) { |a, h| h[a] += 1 }
divisible = Array.new(as.last + 1, 1)
res = 0

as.each do |a|
  next if divisible[a] == 0
  res += 1 if nums[a] == 1

  a.step(as.last, a) do |i|
    divisible[i] = 0
  end
end

puts res


Measured memory_bytes: 43880
while True:
    m, f, r = (int(x) for x in input().split())
    
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65:
        print('B')
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5604
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	// remove odd strings
	var answer string
	for pos, r := range s {
		if pos%2 == 0 {
			answer = answer + string(r)
		}
	}
	fmt.Println(answer)
}


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

int main(){
  string str[]= {"Sunny", "Cloudy", "Rainy"};
  string s;
  cin>>s;
  if(s==str[0])
    cout<<str[1]<<endl;
  else if(s==str[1])
      cout<<str[2]<<endl;
  else if(s==str[2])
    cout<<str[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string s;
    int ch[26] = {};
    while(getline(cin,s)){
        for(int i = 0;i < (int)s.length();i++){
            if('a' <= s[i] && s[i] <= 'z')ch[s[i] - 'a']++;
            if('A' <= s[i] && s[i] <= 'Z')ch[s[i] - 'A']++;
        }
    }
    for(int i = 0;i < 26;i++){
        cout << (char)('a' + i) << " : " << ch[i] << endl;
    }
    return 0;
}


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

ll A[4010];
ll dp[4010][4010];

ll f(int l, int r){
	ll& d = dp[l][r];
	if(d != -1) return d;
	int len = r - l + 1;
	if(len <= 0) return d = 0;
	if(len == 1) return d = A[l];
	if(len == 2) return d = max(A[l], A[l + 1]);
	d = 0;
	int nl = l + 1, nr = r;
	if(A[nl] > A[nr]) nl++;
	else nr--;
	ll v1 = A[l] + f(nl, nr);
	nl = l, nr = r - 1;
	if(A[nl] > A[nr]) nl++;
	else nr--;
	ll v2 = A[r] + f(nl, nr);
	return d = max(v1, v2);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

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

	if(N == 1){
		cout << *max_element(A, A + N) << endl;
		return 0;
	}


	memset(dp, -1, sizeof dp);
	ll ans = 0;
	for(int i = 0; i < N; i++){
		ll v = A[i];
		int l = i + 1, r = i + N - 1;
		if(A[l] > A[r]) l++;
		else r--;
		v += f(l, r);
		ans = max(ans, v);
	}
	cout << ans << endl;
}

Measured memory_bytes: 128880
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
string s, t;
int cnt1[26];
int cnt2[26];
int main()
{
	int i;
	cin >> s >> t;
	rep(i, s.length()) cnt1[s[i] - 'a']++;
	rep(i, t.length()) cnt2[t[i] - 'a']++;
	sort(cnt1, cnt1 + 26);
	sort(cnt2, cnt2 + 26);
	rep(i, 26) if (cnt1[i] != cnt2[i]) { cout << "No" << endl; return 0; }
	cout << "Yes" << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int ret=0;
	char ch;
	while(cin>>ch)
		if(ch=='1')
			ret++;
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 380