akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstdio>

using namespace std;


double dist1(int n,int *a,int *b){
	int i;
	double sum=0;	
	for(i=0;i<n;i++){
		sum+=fabs(a[i]-b[i]);	
		}
	return sum;
	}

double dist2(int n,int *a,int *b){
	int i;
	double sum=0;	
	for(i=0;i<n;i++){
		sum+=pow(a[i]-b[i],2);	
		}
	return sqrt(sum);
	}
	
double dist3(int n,int *a,int *b){
	int i;
	double sum=0;	
	for(i=0;i<n;i++){
		sum+=pow(fabs(a[i]-b[i]),3.0);	
		}
	return pow(sum,1.0/3);
	}

double dist4(int n,int *a,int *b){
	int i;
	double sum=0;	
	for(i=0;i<n;i++){
		if(sum<=fabs(a[i]-b[i])) sum=fabs(a[i]-b[i]);
		}
	return sum;
	}


int main(void){
	int a;
	cin >>a;
	int b[1000];
	int c[1000];
	int i;
	for (i=0;i<a;i++){
		cin >> b[i];
		}
	for(i=0;i<a;i++){
		cin >> c[i];
		}
	double dis1=dist1(a,b,c);
	double dis2=dist2(a,b,c);
	double dis3=dist3(a,b,c);
	double dis4=dist4(a,b,c);
	printf("%.6f\n%.6f\n%.6f\n%.6f\n",dis1,dis2,dis3,dis4);
	return 0;
	}

Measured memory_bytes: 1264
#include <stdio.h>

int main(void){
	int a,b,r,temp;
	scanf("%d%d",&a,&b);

	if(a<b){
		temp=b;
		b=a;
		a=temp;
	}

	while(b>0){
		r=a%b;
		a=b;
		b=r;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 592
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for _ in range(n):
    d[input()] += 1
sorted_pairs = [(k, v) for k, v in sorted(d.items(), key=lambda item: item[1], reverse=True)]   
max_freq = sorted_pairs[0][1]

result = []
for k, v in sorted_pairs:
    if v != max_freq:
        break
    result.append(k)

for s in sorted(result):
    print(s)

Measured memory_bytes: 57052
import sys
for line in sys.stdin:
    H, W = map(int, line.split())
    if H == W == 0:
        break
    for i in range(H):
        if i % 2:
            mark = '.'
        else:
            mark = '#'
        for j in range(W):
            if mark == '#':
                print('#', end='')
                mark = '.'
            else:
                print('.', end='')
                mark = '#'
        print()
    print()

Measured memory_bytes: 8984
sel='C'

if sel=='A':
    S=input()
    if S[2]==S[3] and S[4]==S[5]:
        print('Yes')
    else:
        print('No')

if sel=='B':
    X=int(input())
    ans=0
    ans+=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

if sel=='C':
    K,N=map(int,input().split())
    A=[int(i) for i in input().split()]
    d=[A[0]+K-A[-1]]
    for i in range(N-1):
        d.append(A[i+1]-A[i])
    d.sort()
    print(K-d[-1])

# if sel=='D':




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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
typedef long long ll;

string dic_order(vector<string> s){
    string rel = s[0];
    for(int i = 1; i < s.size(); i++){
        rel = rel < s[i] ? rel : s[i];
    }
    return rel;
}

int main() {
    string sd,t;
    cin >> sd >> t;
    int slen = (int)sd.length();
    int tlen = (int)t.length();
    vector<string> s;
    if(slen < tlen){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    rep(i,slen-tlen+1){
        string sub = sd.substr(i,tlen);
        bool ok = true;
        rep(j, tlen){
            if(sub[j] != '?' && sub[j] != t[j]){ //ダメ
                ok = false;
            }
        }
        if(ok){ //該当部分を正解に置き換え
            int id = i;
            s.push_back(sd);
            rep(j, tlen){
                s[s.size()-1][id] = t[j];
                id++;
            }
            rep(j, slen){
                if(s[s.size()-1][j] == '?') s[s.size()-1][j] = 'a';
            }
        }
    }
    //rep(i, s.size()) cout << s[i] << endl;
    if(s.size() != 0){
        string ans = dic_order(s);
        cout << ans << endl;
        return 0;
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f(int x) {
  int count = 0;
  if(x % 2 == 1) {
  	for(int i = 1; i <= x; i++) {
   	 if(x % i == 0)
      	count++;
 	 }
  }
  return count;
}
int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 0; i <= N; i++) {
    if(f(i) == 8) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int dp[103][100005];
int fun(int i,int j,int a[]){
    if(j<0)return 0;
    if(i==0){
        if(j<=a[i])return 1;
        return 0;
    }
    if(dp[i][j]!=-1)return dp[i][j];
    int ans=(fun(i-1,j,a)+mod)%mod;
    ans+=fun(i,j-1,a);
    ans%=mod;
    ans-=fun(i-1,j-a[i]-1,a);
    ans+=mod;
    ans%=mod;
    return dp[i][j]=ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<fun(n-1,k,a);
    return 0;
}

Measured memory_bytes: 88576
#include <iostream>
using namespace std;
int main(){
	int n;
	int a[1000];
	cin >> n;
	for( int i=0 ; i<n ; i++ ){
		cin >> a[i] ;
		cout << a[i];
		if( i!=n-1 )
			cout <<" ";
	}
	cout << endl;
	for( int i=1 ; i<n ; i++ ){
		int v=a[i];
		int j=i-1;
		while(j>=0 && a[j] > v ){
			a[j+1] = a[j];
			j--; 
		}
		a[j+1]=v;
		for( int j=0 ; j<n ; j++ ){
			cout << a[j];
			if( j!=n-1 )
				cout << " ";
		}
		cout << endl;
	}
}

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

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

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <iterator>
#include <algorithm>

typedef long long lint;

using namespace std;

void showIntArray(lint a[], lint n);

int main() {
  int N, K;
  cin >> N >> K;
  if (K == 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << (N - (K - 1)) - 1 << endl;;
  return 0;
}

void showIntArray(lint a[], lint n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}


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

int main() {
    int N, d[100], ans = 0;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
<?php

list($a, $b, $c, $d) = explode(' ', trim(fgets(STDIN)));

$takahashi = $c % $b === 0 ? (int)floor($c / $b) : ((int)floor($c / $b) + 1);
$aoki = $a % $d === 0 ? (int)floor($a / $d) : ((int)floor($a / $d) + 1);

echo $takahashi <= $aoki ? 'Yes' : 'No';


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
int H[21];

int main(){

    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(int i = 0; i < 2; i++){
        if(A>B){
            ans += A;
            A--;
        }
        else{
            ans += B;
            B--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>> N;
    cout << N * N * N << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

	if (a + b >= a - b && a + b >= a * b) cout << a + b << endl;
	else if (a - b >= a + b && a - b >= a * b) cout << a - b << endl;
	else cout << a * b << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
int w,h,x,y,r;
cin>>w>>h>>x>>y>>r;
if(w>=(x+r) && h>=(y+r) && x>0 && y>0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;


    return 0; 
}


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

using namespace std;

using int64 = long long;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  // For float output:
  cout << fixed << setprecision(10);

  int n;
  cin >> n;
  vector<double> ps(n);
  for (int i = 0; i < n; i++) cin >> ps[i];

  vector<vector<double>> dp = Make2DVector(n + 1, n + 1, 0.0);
  dp[0][0] = 1.0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      dp[i + 1][j] += (1.0 - ps[i]) * dp[i][j];
      dp[i + 1][j + 1] += ps[i] * dp[i][j];
    }
  }

  double ans = 0.0;
  for (int i = n / 2 + 1; i <= n; i++) {
    ans += dp[n][i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n;
  cin>>n;
  double cnt=0.00;
  rep(i,n) {
    double a;
    string s;
    cin>>a>>s;
    if(s=="JPY") cnt+=a;
    else cnt+=380000.0*a;
  }
  cout<<(double)cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][t[i]];
        last[t[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    auto start = std::chrono::system_clock::now();      // 計測スタート時刻を保存
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);

    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);
    rep(i,d)t[i] = rnd1(mt);
    best = score();
    // vecprint(t);
    while(true){
        auto end = std::chrono::system_clock::now();       // 計測終了時刻を保存
        auto dur = end - start;        // 要した時間を計算
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        if(msec>=1900) break;

        int day1 = rnd2(mt);
        int day2 = rnd2(mt);
        int con = rnd1(mt);
        swap(t[day1], t[day2]);
        // int old = t[day];
        // t[day] = con;
        ll now_s = score();
        if(best < now_s) best = now_s;
        else swap(t[day1], t[day2]);
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3604
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	llint dam=0,n,m,i;cin>>n>>m;
	vector<int>one(n, 0);
	vector<int>two(n,-1);
	vector<int>san(n,-1);
	map<pair<int,int>,int>mem;
	for(i=0;i<m;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		if(a<b){swap(a,b);}
		auto za=mp(a,b);
		if(a>b+2){
			if(mem.count(za)==0){mem[za]=c;dam++;}
			else if(mem[za]!=c){cout<<0<<endl;return 0;}
		}else if(a==b+2){
			if(san[a-1]==-1){san[a-1]=c;}
			else{san[a-1]^=c;san[a-1]+=10;}
		}else if(a==b+1){
			if(two[a]==-1){two[a]=c;}
			else{two[a]^=c;two[a]+=10;}
		}else if(a==b){
			if(one[a]==-1){one[a]=c;}
			else{one[a]^=c;one[a]+=10;}
		}
	}
	llint xp=0,yp=0;//0,1
	if(one[0]!=11){xp++;}
	if(one[0]!=10){yp++;}
	for(i=1;i<n;i++){
		int nx=1,ny=1;
		if(san[i]==-1){nx=2;ny=2;}
		else if(san[i]==11){nx=0;}
		else if(san[i]==10){ny=0;}
		
		if(one[i]==-1){nx*=2;ny*=2;}
		else if(one[i]==11){nx=0;}
		else if(one[i]==10){ny=0;}
		
		int tx=1,ty=1;
		if(two[i]==-1){tx=2;ty=2;}
		else if(two[i]==11){tx=0;}
		else if(two[i]==10){ty=0;}
		
		llint gx=nx*tx*xp+nx*ty*yp;
		llint gy=ny*tx*yp+ny*ty*xp;
		xp=gx%mod;yp=gy%mod;
	}
	llint ans=xp+yp;
	if(ans%2==1){ans+=mod;}
	ans/=2;
	llint bgen=2;
	llint kak=(n*n)-n*5+6;
	kak/=2;kak-=dam;
	//cerr<<"k="<<kak<<endl;
	for(int h=0;h<60;h++){
		if((1LL<<h)&kak){ans*=bgen;ans%=mod;}
		bgen*=bgen;bgen%=mod;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4608
#include <stdio.h>

int main() {
	static char used[101];
	int a, b, c, i, cnt;

	scanf("%d%d%d", &a, &b, &c);
	used[a] = used[b] = used[c] = 1;
	cnt = 0;
	for (i = 1; i <= 100; i++)
		cnt += used[i];
	printf("%d\n", cnt);
	return 0;
}


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

int main(){
	string s;
	int len,i;
	cin>>s;
	len=s.size();
	for(i=0;i<len/2;i++){
		if(s[i]!=s[len-i-1]){
			cout<<"No";
			return 0;
		}
		if(s[i]!=s[(len-1)/2-i-1]){
			cout<<"No";
			return 0;
		}
	}
	for(i=len-1;i>=(len+3)/4*3;i--){
		if(s[i-1]!=s[(len+3)/2+(len-i)-1]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
A,B,C=map(int,input().split())
if A==B and B!=C:
    print("Yes")
if A==C and A!=B:
    print("Yes")
if B==C and B!=A:
    print("Yes")
if A==B==C:
    print("No")
if A!=B and B!=C and C!=A:
    print("No")

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i+1;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

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


typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
    /* Credits: Thomas Draper */
    if ((first == last) || (first == k) || (last == k))
        return false;
    Iterator itr1 = first;
    Iterator itr2 = last;
    ++itr1;
    if (last == itr1)
        return false;
    itr1 = last;
    --itr1;
    itr1 = k;
    --itr2;
    while (first != itr1)
    {
        if (*--itr1 < *itr2)
        {
            Iterator j = k;
            while (!(*itr1 < *j)) ++j;
            iter_swap(itr1,j);
            ++itr1;
            ++j;
            itr2 = k;
            rotate(itr1,j,last);
            while (last != j)
            {
                ++j;
                ++itr2;
            }
            rotate(k,itr2,last);
            return true;
        }
    }
    rotate(first,k,last);
    return false;
}

int main() {
    int K,S;
    ll ans =0;
    cin >> K >> S;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(S-i-j>=0&&S-i-j<=K){
                ans++;
            }
        }

    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int x;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> x;
	for(int i = x;;i++){
		if(isp(i)){
			cout << i << endl;
			break;
		}
	}
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
l, r = [], []
t = [0] * (N+1)
for i in range(N):
    t[i + 1] = t[i] +(1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 52440
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>

using namespace std;

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

    int n;
    cin >> n;

    vector<int> P(n);

    int count = 0;

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

    for(int i = 1; i < n - 1; i++)
    {
        if(P[i] > P[i + 1] && P[i] < P[i - 1])
        {
            count++;
        } else if(P[i] < P[i + 1] && P[i] > P[i - 1])
        {
            count++;
        }
    }

    cout << count << endl;
}

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

int main() {
	string s, ans;
	cin >> s;
	if (s == "Sunny") {
		ans = "Cloudy";
	}
	else if(s == "Cloudy") {
		ans = "Rainy";
	}
	else if (s == "Rainy") {
		ans = "Sunny";
	}
	cout << ans << endl;
}

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

namespace Atcoder2
{
    class Program
    {
        static void Main(string[] args)
        {
            string ans = "";

            for(int i = 0; i < 3; i++)
            {
                string str = Console.ReadLine();
                ans += str[i];
            }

            Console.WriteLine(ans);
        }
    }
}


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n-1);
    vector<int> y(n,0);
    rep(i,n-1){
        cin>>a[i];
        y[a[i]-1]+=1;
    }
    rep(i,n){
        cout<<y[i]<<endl;
    }

    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A;
    long double B;
    cin >> A >> B;

    cout << ll(A*B) << endl;
    return 0;
}

Measured memory_bytes: 3756
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using ll = long long;
using namespace std;

void solve() {
    int n;
    cin>>n; int od=0;
    for (int j=1;j<=n;j=j+2) {
        int count =0;
        for (int i=1;i*i<=j;i++) {
            if (j%i==0) count++;
        }
        if(count == 4) od++;
    }
    cout<<od<<'\n';


}

int main()
{
    std::ios::sync_with_stdio(false); \
        std::cin.tie(NULL);
    int test;
    test=1;
    while (test--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  map<int,int>m;
  rep(i,n){
    int tmp;
    cin >> tmp;
    m[tmp]++;
  }
  ll ans = 0;
  for(auto& i : m){
    if(i.first > i.second)ans += i.second;
    else ans += min(i.second - i.first,i.second);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	cin>>n;
	int ar[n], orar[n];
	fore(i, 0, n) cin>>ar[i], orar[i] = ar[i];
	int me, med;
	sort(orar, orar + n);
	me = orar[n/2 - 1];
	med = orar[n/2];
	fore(i, 0, n)
	{
		if(ar[i] <= me)
			cout<<med<<'\n';
		else
			cout<<me<<'\n';
	}
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

int main(){

int ans=0;
int N;
scanf("%d",&N);
char blue[N][11];
for (int i = 0; i < N; i++){
  scanf("%s",blue[i]);
}
int M;
scanf("%d",&M);
char red[M][11];
for (int i = 0; i < M; i++){
  scanf("%s",red[i]);
}

for (int i = 0; i < N; i++)
{
  int gain=0,r_count=0,b_count=1;
  for (int j = i+1; j < N; j++){
    if(strcmp(blue[i],blue[j])==0){b_count++;}
  }
  for (int j = 0; j < M; j++){
    if(strcmp(blue[i],red[j])==0){r_count++;}
  }
  if(b_count-r_count>0){gain = b_count-r_count;}
  if(ans<gain){ans = gain;}
}

printf("%d",ans);

return 0;

}

Measured memory_bytes: 1712
use std::io::Read;

fn check(s : &[u8], t : &[u8]) -> bool {
    let n = s.len();
    let mut m = [26; 26];
    for i in 0..n {
        let a = (s[i] - b'a') as usize;
        let b = t[i] - b'a';
        if m[a] == 26 {
            m[a] = b
        } else if m[a] != b {
            return false;
        }
    }
    true
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let s = it.next().unwrap().as_bytes();
    let t = it.next().unwrap().as_bytes();
    println!("{}", if check(s, t) && check(t, s) { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
def bisect_left(A, x, lo=0, hi=None):
    hi = len(A)
    while lo < hi:
        mid = (lo + hi) // 2
        if A[mid] < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0
for t in T:
    idx = bisect_left(S, t)

    if 0 <= idx < len(S):
        if t == S[idx]: ans += 1

print(ans)



Measured memory_bytes: 16712
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
int dp[100011] = {0};
int r, p, s;
int fu(char st){
	if(st=='r')return p;
	else if(st=='p') return s;
	else return r;
}
void solve(){
	int n, k, res=0;
	cin>>n>>k;
	cin>>r>>s>>p;
	string g;
	cin>>g;
	FOR(i, 0, k){
		res+=fu(g[i]);
		dp[i] = res;
	}
	//cout<<dp[k-1]<<endl;
	FOR(i, k, sz(g)){
		if(g[i-k]==g[i]){

			dp[i] = dp[i-1];
			g[i]='0';
		}
		else{
			dp[i] = dp[i-1]+fu(g[i]);
		}
		//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1];
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	return 0;
 
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n, d;
  cin >> n >> d;
  if (n%(2*d+1) == 0) cout << n/(2*d+1) << endl;
  else cout << n/(2*d+1)+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int a,b;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> a >> b;
    cout << 2*b-a;

}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,a[100005],S[100005],ans;

bool check(ll x) {
	ll tot=0;
	for (int i=n; i>=1; i--) {
		int l=1,r=n,mid,res=-1;
		while (l<=r) {
			mid=(l+r)/2;
			if (a[i]+a[mid]>=x) r=mid-1,res=mid;
				else l=mid+1;
		}
		if (res==-1) continue;
		tot+=n-res+1;
	}
	
	if (tot>=m) return 1;
	return 0;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	
	cin>>n>>m;
	
	for (int i=1; i<=n; i++) 
		cin>>a[i];
	
	sort(a+1,a+n+1);
	
	for (int i=1; i<=n; i++)
		S[i]=S[i-1]+a[i];
	
	ll l=0,r=2*a[n],mid,res=-1,resu=-1;
	
	while (l<=r) {
		mid=(l+r)/2;
		if (check(mid)) res=mid,l=mid+1;
			else r=mid-1;
	}

	ll tot=0;
	
	for (int i=n; i>=1; i--) {
		l=1,r=n,resu=-1;
		while (l<=r) {
			mid=(l+r)/2;
			if (a[i]+a[mid]>=res) r=mid-1,resu=mid;
				else l=mid+1;
		}
		if (resu==-1) continue;
		tot+=n-resu+1;
		ans+=S[n]-S[resu-1]+a[i]*(n-resu+1);
	}
	
	ans-=(tot-m)*res;
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#define ll long long
using namespace std;
const int maxn = 2e5+5;
const int M = 1e9+7;
struct edge
{
    int u,v,nxt;
}es[maxn<<1];
int head[maxn],tot,n;
ll fac[maxn],inv[maxn],sz[maxn],dp[maxn],ans[maxn];
void add(int u,int v)
{
    es[++tot].u = u;
    es[tot].v = v;
    es[tot].nxt = head[u];
    head[u] = tot;
}
ll qpow(ll a,ll b)
{
    ll s = 1;
    while(b)
    {
        if(b&1) s = s*a%M;
        a = a*a%M;
        b>>=1;
    }
    return s;
}
void init()
{
    fac[0] = fac[1] =1;
    inv[0] = inv[1] = 1;
    for(int i=2;i<=n;i++) fac[i] = i*fac[i-1]%M;
    for(int i=2;i<=n;i++) inv[i] = qpow(fac[i],M-2);
}
ll C(ll a,ll b)
{
    ll res = 1ll*fac[a]*inv[b]%M*inv[a-b]%M;
    return res;
}
void dfs1(int u,int f)
{
    sz[u] = 1,dp[u]=1;
    for(int i=head[u];i!=-1;i=es[i].nxt)
    {
        int v = es[i].v;
        if(v==f) continue;
        dfs1(v,u);
        sz[u] += sz[v];
        dp[u] = 1ll*dp[u]*inv[sz[v]]%M*dp[v]%M;
    }
    dp[u] = 1ll*dp[u]*fac[sz[u]-1]%M;
}
void dfs2(int u,int f)
{
    if(u!=1) ans[u] = 1LL*ans[f]*qpow(C(n-1,sz[u]),M-2)%M*C(n-1,sz[u]-1)%M;
    for(int i=head[u];i!=-1;i=es[i].nxt)
    {
        int v = es[i].v;
        if(v==f) continue;
        dfs2(v,u);
    }
}
int main()
{
    memset(head,-1,sizeof(head));
    cin>>n;
    int u,v;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v;
        add(u,v);
        add(v,u);
    }
    init();
    dfs1(1,-1);
    ans[1] = dp[1];
    dfs2(1,-1);
    for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 15616
#!/usr/bin/env python3
import sys


def solve(K: int):
    ne = K // 2
    no = ne + K % 2

    print(int(ne*no))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n, a, b = input().split()

n = int(n)
x = int(a)
y = int(b)

maxim = 0
mini = 0

if x > y:
    maxim = y
else:
    maxim = x

if x + y > n:
    mini = x + y - n

print(str(maxim) + ' ' + str(mini))

Measured memory_bytes: 3060
// atcoder/code-festival-2017-qualc/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n;
  while (cin >> n) {
    vec<int> a(n);
    cin >> a;
    int cnt = 0;
    for (int bit = 0; bit < (1 << (2 * n)); ++bit) {
      vec<int> b;
      int x = bit;
      for (int i = 0; i < n; ++i) {
        int y = x % 4;
        if (y == 0) b.push_back(a[i]);
        if (y == 1) b.push_back(a[i] + 1);
        if (y == 2) b.push_back(a[i] - 1);
        x /= 4;
      }
      if (a.size() != b.size()) continue;
      int p = 1;
      each (i, b) p *= i;
      cnt += (p % 2 == 0);
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll dp[200000],h[200000];   
int main()
{
    IOS
    ll n,k;
    cin>>n>>k;
    REP(i,n)
    {
        cin>>h[i+1];
    }

    dp[0]=0;
    dp[1]=0;
    
    for(int i=2;i<=n;i++)
    {
        dp[i]=1e9;
        for(int j=i-1;j>0&&j>=i-k;j--)
        {
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		Console.WriteLine((p[0] + p[1] + p[2]) >= 22 ? "bust" : "win");
		
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;

int main(){
	int N, M;
	cin>>N>>M;
	vi A[300];
	rep(i,N){
		rep(_,M){
			int a;
			cin>>a;
			A[i].push_back(a);
		}
	}
	int ans=1000;
	while(!A[0].empty()){
		multiset<int> st;
		set<int> er;
		rep(i,N) st.insert(A[i][0]);
		int tmp=0;
		for(auto it=st.begin(); it!=st.end(); it++)tmp=max(tmp, (int)st.count(*it));
		ans=min(ans, tmp);
		for(auto it=st.begin(); it!=st.end(); it++)if((int)st.count(*it)==tmp)er.insert(*it);
		for(auto it=er.begin(); it!=er.end(); it++){
          	int k=*it;
          	rep(i,N){
			
				auto itr=find(A[i].begin(), A[i].end(), k);
				A[i].erase(itr);
            }
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {
  
 
	public static void main(String[]args) {
    	Scanner sc = new Scanner(System.in);
          String S = sc.next();
      	  String T = sc.next();
      if(S.equals(T.substring(0, T.length() -1)))
        System.out.println("Yes");
      else
        System.out.println("No");
    
    }
}

Measured memory_bytes: 35688
import java.util.*;
import java.awt.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = m;

        for (int i = m/n; i > 0; i--) {
            if (m%i == 0) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
 
int main() {
    int n;
    while (std::cin >> n && n) {
        std::vector<int> a;
        int minLength = 10000000;
 
        for (int i = 0; i < n; i++) {
            int b;
            std::cin >> b;
            a.push_back(b);
        }
 
        std::sort(a.begin(), a.end());
 

        for (int i = 0; i < a.size() - 1; i++) {
            minLength = std::min(a[i + 1] - a[i], minLength);
        }
 
        std::cout << minLength << std::endl;
    }
    return 0;
}

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

int main() {
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int p=1;
  int q=0;
  for(int i=0;i<n;i++){
    q+=a.at(i);
    if(q<=x){
      p++;
    }
    else{
      break;
    }
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max 32
int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int gcd(int x, int y) {
    int tmp = x % y;
    while (tmp != 0) {
        x = y;
        y = tmp;
        tmp = x % y;
    }
    return y;
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3108
s = input()
t = input()

for i in range(len(s)-len(t), -1, -1):
    for j in range(len(t)):
        if s[i+j]=="?" or s[i+j]==t[j]:
            continue
        else:
            break
    else:
        s = s[:i] + t + s[i+len(t):]
        for k in range(len(s)):
            if s[k]=="?":
                s = s[:k] + "a" + s[k+1:]
        print(s)
        exit()

print("UNRESTORABLE")

Measured memory_bytes: 3064
from sys import stdin
def check(n,s):
    n=str(n)
    for i in range(len(n)):
        if int(n[i]) not in s:
            return False
    else:
        return True

def main():
    #入力
    readline=stdin.readline
    N,K=map(int,readline().split())
    D=list(map(int,readline().split()))

    s=set([0,1,2,3,4,5,6,7,8,9])
    s0=set(D)
    s1=s-s0
    M=int(str(max(s1))*(len(str(N))+1))

    for i in range(N,M+1):
        if check(i,s1):
            print(i)
            break

if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#define r(i,n)for(int i=0;i<n;i++)
using namespace std;
#define F first
#define S second
typedef pair<int,int>P;
int n,m,x,y,K,a[102][102],flag,amin[102][102],amax[102][102];
string s;
vector<P>v1[102],v2[102];
bool ch(){
  r(i,m){
    r(j,v1[i].size()){
      r(k,v2[i].size()){
	if(v1[i][j].F==v2[i][k].F&&v1[i][j].S<v2[i][k].S) return 1;
      }
    }
  }
  return 0;
}
void make_Graph(){
  r(i,102)r(j,102)amax[i][j]=1e8;
  r(i,m){
    r(j,v1[i].size())amax[i][v1[i][j].F]=min(amax[i][v1[i][j].F],v1[i][j].S);
    r(j,v2[i].size())amin[i][v2[i][j].F]=max(amin[i][v2[i][j].F],v2[i][j].S);
    r(j,102)amin[i][j]=min(amin[i][j],amax[i][j]);
  }
  r(i,m)r(j,m)r(k,102)if(amax[i][k]<amin[j][k])a[i][j]=-1;
}
int main(){
  cin>>m>>n;
  r(i,m){
    cin>>K;
    r(j,K){
      cin>>x>>s>>y;
      if(s=="<=")v1[i].push_back(P(x,y));
      else v2[i].push_back(P(x,y));
    }
  }
  if(ch())cout<<"No"<<endl;
  else{
    r(i,102)r(j,102)a[i][j]=(i==j?0:1e8);
    make_Graph();
    n++;
    r(o,m)r(i,m)r(j,m)a[i][j]=min(a[i][j],a[i][o]+a[o][j]);
    r(i,102)if(a[i][i]<0)flag++;
    cout<<(flag?"No":"Yes")<<endl;
  }
}

Measured memory_bytes: 3384
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n; cin >> n;
    bool gg = true;
    while(n--)
    {
        int a; cin >> a;
        if(a % 2 == 0 && (a % 3 && a % 5)) gg = false;
    }

    cout << (gg ? "APPROVED" : "DENIED") << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
using namespace std;

int main() {
    std::string S;
    cin >> S;
    std::map<std::string, int> m;
    m["SUN"] = 7;
    m["MON"] = 6;
    m["TUE"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;
    m["SAT"] = 1;
    std::cout << m[S] << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {  
 int N, A, c;
 int b = 30;
  cin >> N;
  for (int i = 0; i < N; i++){
    c = 0;
    cin >> A;
    while (A % 2 == 0){
      A = A / 2;
      c++;
    }if (c < b){
      b = c;
    }
  }cout << b <<endl;
}

Measured memory_bytes: 3588
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a: int, b: int) -> int:
    """a, bの最小公倍数(least common multiple: LCM)を求める
    計算量: O(log(min(a, b)))
    """
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める"""
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans

          

n, xx = map(int, input().split())
x = list(map(int, input().split())) + [xx]
x = sorted(x)
diff = []
for i in range(n):
    diff.append(x[i + 1] - x[i])
    
print(multi_gcd(diff))

Measured memory_bytes: 64536
unittest
{
	assert( [ "3 4", "2 1 3", "3 1 2 3", "2 3 2" ].parse.expand.solve == 1 );
	assert( [ "5 5", "4 2 3 4 5", "4 1 3 4 5", "4 1 2 4 5", "4 1 2 3 5", "4 1 2 3 4" ].parse.expand.solve == 0 );
	assert( [ "1 30", "3 5 10 30" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto ass = new long[][]( nm[ 0 ] );
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front.split.to!( long[] )[ 1 .. $ ];
	}
	return tuple( nm[ 1 ], ass );
}

auto solve( long m, long[][] ass )
{
	foreach( ref as; ass )
	{
		as.sort();
	}
	
	auto ans = 0L;
	auto kis = new long[]( ass.length );
	for( auto i = 0L; i < m; i++ )
	{
		auto c = 0L;
		foreach( ai, as; ass )
		{
			if( kis[ ai ] < as.length && as[ kis[ ai ] ] == i + 1 )
			{
				kis[ ai ]++;
				c++;
			}
		}
		if( c == ass.length ) ans++;
	}
	
	return ans;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
lr = [None]*n
for i in range(n):
    x,l = map(int, input().split())
    lr[i] = (x-l, x+l)
lr.sort(key=lambda x: x[1])
ans = 0
c = -10**10
for l,r in lr:
    if c<=l:
        ans += 1
        c = r
print(ans)

Measured memory_bytes: 76812