akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=705;
int G[maxn][maxn];
int col[maxn];
bool ok=1;
int n,m;
pi dfs(int u,int c)
{
    col[u]=c;
    pi ret={0,0};
    if(c) ret.second++;
    else ret.first++;
    for(int i=1;i<=n;i++)
    {
        if(G[u][i])
        {
            if(col[i]!=-1&&col[i]==c)
            {
                ok=0;
                return ret;
            }
            else if(col[i]==-1)
            {
                auto cur=dfs(i,c^1);
                ret.first+=cur.first;
                ret.second+=cur.second;
            }
        }
    }
    return ret;
}
int main()
{
    cin>>n>>m;
    for(int i=0,u,v;i<m;i++)
    {
        cin>>u>>v;
        G[u][v]=G[v][u]=1;
    }
    int c1=0,c2=0,cc=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++) 
        {
            if(i!=j)
                G[i][j]^=1;
            if(i<j&&G[i][j]) cc++;
        }
    int ans;
    memset(col,-1,sizeof(col));
    vc<pi> all;
    for(int i=1;i<=n;i++)
    {
        if(col[i]==-1)
        {
            pi cur=dfs(i,0);
            all.push_back(cur);
        }
        if(!ok) break;
    }
    if(!ok) ans=-1;
    else
    {
        int tmp=0;
        int t=0;
        vc<vc<vi>> dp(2,vc<vi>(n+1,vi(n+1,0)));
        dp[0][0][0]=1;
        for(auto u:all)
        {
            for(int i=u.second;i<=n;i++)
            {
                for(int j=u.first;j<=n;j++)
                    dp[t^1][i][j]|=dp[t][i-u.second][j-u.first];
            }
            for(int i=u.first;i<=n;i++)
            {
                for(int j=u.second;j<=n;j++)
                    dp[t^1][i][j]|=dp[t][i-u.first][j-u.second];
            }
            t^=1;
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(dp[t][i][j]) tmp=max(tmp,i*j);
            }
        }
        ans=m-(tmp-cc);

    }
    print(ans);
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

void fixdate(string & str)
{
    string clect = "2018";
    string date = str.substr(4);
    str = clect + date;
}


int main(void) {
    string S;
    cin >> S;

    fixdate(S);

    cout << S << endl;
       
    return 0;
}

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

void insertionSort(int [],int);
void trace(int [],int);

int main(){
    int N;
    cin >> N;
    
    int A[N];
    for(int i = 0;i<N;i++)cin >> A[i];
    
    trace(A,N);
    
    insertionSort(A,N);

    return 0;
}

void insertionSort(int A[],int N){

    int v,j,i;

    for(i=1;i<N;i++){
        v = A[i];
        j = i-1;

        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A,N);
    }
    return;
}

void trace(int A[],int N){
    int i;
    for(i=0;i<N;i++){
        if(i==N-1){
            cout << A[i] << "\n";
        }
        else{
            cout << A[i] << " ";
            }

    }
    return;
}


Measured memory_bytes: 3116
#include<stdio.h>
int main()
{
    int n,sum=0,h,sum1=0,sum2=0;
    double d;
    scanf("%d",&n);
    int ara[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
        sum=sum+ara[i];
    }
    h=sum/n;
    for(int i=0;i<n;i++)
    {
        sum1=sum1+(ara[i]-h)*(ara[i]-h);
        h++;
        sum2=sum2+(ara[i]-h)*(ara[i]-h);
        h--;
    }
    if(sum1>sum2) printf("%d\n",sum2);
    else printf("%d\n",sum1);
    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long  ll;
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<endl; 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<"No"; return 0;}
const ll MOD = 1e9 + 7;
const int N = 200005;
const int INF = 1e8;
const ll MOD1=998244353;
using namespace std;

int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 int n;
 cin>>n;
 vector<int> arr(n);
 forn cin>>arr[i];
 set<int> s;
 for(int i=0;i<n-1;i++)
 {
           if(arr[i]<arr[i+1]) s.insert(i+1);
 }
 int ans=0;
 for(int i=0;i<n-1;i++)
 {
           auto x=s.lower_bound(i+1);
           int pos;
           if(x==s.end()) pos=n;
           else pos=*x;
          // if(pos-i-1>ans) cout<<i+1<<" ";
           ans=max(ans,pos-i-1);
 }
 cout<<ans;
 return 0;
 

}

Measured memory_bytes: 5376
#include<iostream>

using namespace std;

int main() {
	int x, y;

	while (true) {
		cin >> x >> y;
		if (x + y) {
			if (x > y) {
				int tmp = x;
				x = y;
				y = tmp;
			}
			cout << x << " " << y << endl;
		}
		else
			break;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h> 
 #define _USE_MATH_DEFINES 
 #include <math.h> 
 
 
 int main(){ 
    int a, b, angle; 
     double s, l, h; 
 
 
     scanf("%d %d %d", &a, &b, &angle); 
     // sin(), cos(), tan()は角度がラジアン 
     // 度数法からラジアン法への変換：角度(ラジアン)＝角度(度数)*π/180 
     // 定数としてπを使うには：math.hのdefineを利用する。 
     // 参考：dandelion's log » VC++でM_PIが使えなかった理由判明 http://www.atinfinity.info/blog/archives/14 
     h=b*sin(angle*M_PI/180.0); 
     s=a*h/2; 
     l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0))); 
     printf("%f\n", s); 
     printf("%f\n", l); 
     printf("%f\n", h); 
 
 
     return 0; 
 } 



Measured memory_bytes: 2068
#include<stdio.h>
#include<string.h>
char str[101][101];
char k[101];
int main()
{
	int i,j,m,n;
	scanf("%d %d",&m,&n);
	for(i=0 ; i<m ; i++)
	{
		scanf("%s",str[i]);
	}
	for(j=0 ; j<m ; j++)
		for(i=0 ; i<(m-1) ; i++)
		{
			if (strcmp(str[i],str[i+1])>0)
			{
				strcpy(k,str[i]);
				strcpy(str[i],str[i+1]);
				strcpy(str[i+1],k);
			}
		}
		for(i=0 ; i<m ; i++)
		{
        	printf("%s",str[i]);
		}
		return 0;
}

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

using namespace std;

int main(){
	int n, k; cin>>n>>k;
	int a[n];
	for(int i = 0; i < n; i++) cin>>a[i];
	
	int MAX = INT_MAX;
	int dp[n];
	for(int i = 1; i < n; i++) dp[i] = MAX;
	dp[0] = 0;
	
	for(int i = 1; i < n; i++){
		for(int j = 1; j <= k; j++){
	     	if((i-j) >= 0) dp[i] = min(dp[i-j]+abs(a[i] - a[i-j]), dp[i]);
	    }
	}
	
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<ll,ll> > xy(n);
    REP(i,n){
        ll x,y;
        cin >> x >> y;
        xy[i]=make_pair(x,y);
    }
    sort(ALL(xy));
    int ans = 50;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ll p = (xy[j].fi) - (xy[i].fi);
            ll q = (xy[j].se) - (xy[i].se);
            vint used(n,0);
            REP(k,n){
                used[k]=0;
            }
            int tmp = 0;
            for(int k=0;k<n;k++){
                if(used[k]==0){
                    used[k]=1;
                    tmp++;
                    ll maxx = xy[k].fi;
                    ll maxy = xy[k].se;
                    ll minx = xy[k].fi;
                    ll miny = xy[k].se;
                    bool f = true;
                    while(f){
                        f=false;
                        for(int l=0;l<n;l++){
                            if(used[l]==0&&xy[l].fi==maxx+p&&xy[l].se==maxy+q){
                                used[l]=1;
                                maxx = xy[l].fi;
                                maxy = xy[l].se;
                                f=true;
                            }else  if(used[l]==0&&xy[l].fi==minx-p&&xy[l].se==miny-q){
                                used[l]=1;
                                minx = xy[l].fi;
                                miny = xy[l].se;
                                f=true;
                            }
                        }
                    }
                }
                
            }
            ans = min(tmp,ans);
        }
    }
    if(n==1){
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
int GCD(int x,int y){if(x%y==0)return y;else return GCD(y,x%y);}
using namespace std;
int main(){
	int K;
	long long int sum=0;
	cin>>K;
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			for(int k=1;k<=K;k++){
				sum+=GCD(i,GCD(j,k));
			}
		}
	}
	cout<<sum;
	return 0;
}

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

int main(){
    int D, T, S;
    cin >> D >> T >> S;
    if(D%S == 0){
        if(D/S <= T){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        if((D/S)+1 <= T){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

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

const char* YesOrNo(bool condition) {
  const char* ret[] = {"No", "Yes"};
  return ret[condition];
}

int main() {
  int N, A;
  cin >> N >> A;
  cout << YesOrNo((N % 500) <= A) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
const int N=5e2+10;
int val[N][N];
void add(int x,int y){
    int temp;
    while(x<N){
        temp=y;
        while(temp<N){
            val[x][temp]++;
            temp+=temp&-temp;
        }
        x+=x&-x;
    }
    return ;
}
int ask(int x,int y){
    int temp,ans=0;
    while(x){
        temp=y;
        while(temp){
            ans+=val[x][temp];
            temp^=temp&-temp;
        }
        x^=x&-x;
    }
    return ans;
}
int main(){
    int l,r,n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)val[i][j]=0;
    while(m--){
        scanf("%d%d",&l,&r);
        add(l,r);
    }
    while(q--){
        scanf("%d%d",&l,&r);
        l--;
        printf("%d\n",ask(r,r)-ask(l,r)-ask(r,l)+ask(l,l));
    }
}

Measured memory_bytes: 1792
N = int(input())
d = {}
for i in range(N):
    s = list(map(str, input()))
    s.sort()
    s = "".join(s)
    d[s] = d[s] + 1 if s in d else 1
ans = 0
for i in d.values():
    ans += i * (i-1) // 2
print(ans)


Measured memory_bytes: 99924
#include <iostream>
#include <math.h>
using namespace std;

int main(){
        unsigned long long N;
        cin >> N;
        int i,a,b=0;
        int ans1,ans2;
        for(i=1; i<=sqrt(N); i++) {
                if(N%i==0) {
                        ans1 = i;
                        ans2 = N/i;
                }
        }
        if(ans1>ans2) {
                a=ans1;
        }else{
                a=ans2;
        }
        while(a>0) {
                a /=10;
                b++;
        }
        cout << b << endl;
        return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> T(n);
    rep(i, n) cin >> T[i];
    sort(ALL(T));
    ll ans = 0;
    rep(i, n) {
        ans++;
        ll time = T[i] + k;
        ll cnt = 1;
        while(i + 1 < n && cnt < c && T[i + 1] <= time) {
            i++;
            cnt++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
def main():
    from itertools import product
    from math import gcd

    K = int(input())

    ans = 0
    for prod in product(range(1, K + 1), repeat=3):
        a, b, c = prod
        ans += gcd(gcd(a, b), c)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;


int main()
{
  int N;

  vector< int > A(4, 0);
  cin >> N;
  for(int i = 0; i < N; i++) {
    int S;
    cin >> S;
    A[S % 4]++;
  }

  while(A[1] > 0) {
    A[1]--;
    A[0]--;
  }
  while(A[3] > 0) {
    A[0]--;
    A[3]--;
  }
  if(A[2] == 0) {
    A[0]++;
  }

  if(A[0] < 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int k=n%10;
  if(k==2 || k==4|| k==5|| k==7|| k==9)
    cout<<"hon";
  else
    if(k==0||k==6||k==8||k==1)
      cout<<"pon";
  else
    cout<<"bon";
  
}


Measured memory_bytes: 3544
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main() {
  int w, h, n, s;
  // xp[2]:長方形を作るx座標の左端、右端を表す（xp[0]: 右, xp[1]: 左）
  // yp[2]:長方形を作るy座標の上端、下端を表す（yp[0]: 上, yp[1]: 下）
  int xp[2], yp[2];

  cin >> w >> h >> n;

  // 初期位置をセット
  xp[0] = w;
  xp[1] = 0;
  yp[0] = h;
  yp[1] = 0;

  for (int i = 0; i < n; i++) {
    int x, y, a;
    cin >> x >> y >> a;

    if (a == 1 && xp[1] < x) xp[1] = x;
    else if (a == 2 && xp[0] > x) xp[0] = x;
    else if (a == 3 && yp[1] < y) yp[1] = y;
    else if(a == 4 && yp[0] > y) yp[0] = y;
  }

  w = xp[0] - xp[1];
  h = yp[0] - yp[1];

  if (w < 0 || h < 0) cout << 0 << endl;
  else cout << w * h << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int e;
  while(cin>>e,e){
    int ans=1e9;
    for(int z=0;z*z*z<=e;++z)
      for(int y=0;y*y<=e-z*z*z;++y)
        ans=min(ans,z+y+e-z*z*z-y*y);
    cout<<ans<<endl;
  }
  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll a,b,c;cin>>a>>b>>c;
a = abs(a);
if(a<=c){
  if(b%2==0) cout << a;
  else cout << abs(a-c);
}
else if(a/c<b){
  if((b-a/c)%2==0) cout << a-(a/c*c);
  else cout << min (abs((a-(a/c*c)) - c), (a-(a/c*c)) + c);
  }
else cout << a-b*c;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, k;
	int ans;
	while (true){
		int a[100001] = {}, b[100001] = {};
		n = 0; k = 0;
		ans = 0;
		cin >> n >> k;
		if (n == 0 || k == 0)	break;
		for (int i = 1; i <= n; i++){
			cin >> a[i];
		}
		for (int x = 0; x<k; x++){
			b[1] += a[x + 1];
		}
		ans = b[1];
		for (int i = 2; i <= n; i++){
			if ((i+k)==(n+1))	break;
			b[i] = b[i - 1] - a[i - 1] + a[i + k - 1];
			ans = max(b[i], ans);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1948
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

int main(){
	int r,g,b;

	cin >> r >> g >>b;

	int s = r*100 + g*10 + b;

	if(s%4 == 0)YES;
	else NO;

	return  0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,a,b;
  int i,j;
  int s;
  int t=0;
  scanf("%d%d%d",&n,&a,&b);
  for(i=0;i<=n;i++){
    j=i;
    s=0;
    while(1){
      s+=j%10;
      if(j/10!=0){
        j/=10;
      } else if(j/10==0){
        break;
      }
    }
    if(a<=s && s<=b) t+=i;
  }
  printf("%d",t);
  return 0;
}


Measured memory_bytes: 1656
//AtCoder ABC054 B - Template Matching
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N,M;
    cin>>N>>M;
    vector<string> nt(N);
    vector<string> mt(M);
    for(auto&&n :nt){
        cin>>n;
    }
    for(auto&&m :mt){
        cin>>m;
    }
    //
    auto check_func = [&](int x,int y){
        bool ret = true;
        for(int yy=0;yy<mt.size();++yy){
            if (strncmp(&nt[y+yy][x],&mt[yy][0],mt[0].size())!=0){
                ret = false;
                break;
            }
        }
        return ret;
    };
    bool ans=false;
    for(int x=0;x<nt[0].size()-mt[0].size()+1;++x){
        for(int y=0;y<nt.size()-mt.size()+1;++y) {
            if(check_func(x,y)){
                ans=true;
                break;
            }
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000009
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// ============================================================

int main() {
        
    get2(n,k);
    fill_nums(A,n);
    if(k>=n) {
        printf("0\n");
        return 0;
    }

    sort(ALL(A), greater<ll>());
    ll sum = 0;
    rep2(i,k,n) sum += A[i];
    printf("%lld\n", sum);

    return 0;  
}   

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, k, c[17] = {}, a[17][17] = {}, z = mod;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }
    for (int i = 0; i < (1 << n); i++) {
        int d[17] = {}, e = 0, y = 0;
        for (int j = 0; j < n; j++) if (i & (1 << j)) {
            e += c[j];
            for (int l = 0; l < m; l++) d[l] += a[j][l];
        }
        for (int j = 0; j < m; j++) if (d[j] < k) y = 1;
        if (!y) z = min(z, e);
    }
    if (z == mod) cout << -1;
    else cout << z;
}


Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(30);
  vector<vector<int>> a(30, vector<int>(30));
  rep(i, m) cin >> b[i];
  
  int cnt = 0;
  rep(i, n) {
    int x = c;
    rep(j, m) {
      int a;
      cin >> a;
      x += a*b[j];
    }
    if (x > 0) cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
hoge=[]
for i in range(n):
  hoge.append(int(input()))
  
hoge.sort(reverse=True)
ans=[]
for i in range(n-k+1):
  ans.append(hoge[i]-hoge[i+k-1])
print(min(ans))

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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}
const int MAXN = 120000;

int was[MAXN];
int sz[MAXN];
ll gans;
vector<pair<int, ll> > eds[MAXN];
int n;

void dfs1(int v) {
    was[v] = 1;
    sz[v] = 1;
    for (pair<int, ll> e: eds[v]) {
        int u = e.first;
        if (was[u])
            continue;
        dfs1(u);
        sz[v] += sz[u];
    }
}

void dfs2(int v) {
    was[v] = 1;
    sz[v] = 1;
    for (pair<int, ll> e: eds[v]) {
        int u = e.first;
        if (was[u])
            continue;
        dfs2(u);
        sz[v] += sz[u];
        gans += e.second * 2 * sz[u];
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        ll c;
        scanf("%d%d%lld", &a, &b, &c);
        --a, --b;
        eds[a].push_back(make_pair(b, c));
        eds[b].push_back(make_pair(a, c));
    }
    dfs1(0);
    int bst = -1;
    for (int i = 0; i < n; ++i)
        if (sz[i] * 2 >= n && (bst == -1 || sz[i] < sz[bst]))
            bst = i;
    memset(was, 0, sizeof(was));
    dfs2(bst);
    memset(was, 0, sizeof(was));
    ll me = 1e9 + 1000;
    int fl = 0;
    for (pair<int, ll> e: eds[bst]) {
        int u = e.first;
        if (sz[u] * 2 == n) {
            fl = 1;
            me = e.second;
        }
        else if (!fl) {
            me = min(me, e.second);
        }
    }
    cout << gans - me << "\n";
    return 0;
}




Measured memory_bytes: 13184
#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();

	 vector<ll> nums(3);
	 scan(nums);

	 if (nums[0] + nums[1] + 1 >= nums[2]) {
		 cout << nums[2] + nums[1] << endl;
		 return 0;
	 }

	 cout << nums[0] + nums[1] + 1 + nums[1] << endl;
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}


Measured memory_bytes: 888
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int max = 0;
        for (int i = 0 ; i < N ; i++) {
            int count = 0;

            String X = S.substring(0, i + 1);
            String Y = S.substring(i + 1, N);
            Set<String> setX = new HashSet<>();
            for (int j = 0; j < X.length(); j++) {
                setX.add(String.valueOf(X.charAt(j)));
            }
            Set<String> setY= new HashSet<>();
            for (int k = 0; k < Y.length(); k++) {
                setY.add(String.valueOf(Y.charAt(k)));
            }
            Iterator<String> iterator = setY.iterator();
            while (iterator.hasNext()) {
                if (setX.contains(iterator.next())) {
                    count++;
                }
            }
            max = Math.max(max, count);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23124
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 05:13:17 2018

@author: Yuki
"""

import collections

N = int(input())

A = [int(input()) for i in range(N)]

A_dict = collections.Counter(A)

cnt = 0
for val in A_dict.values():
    if val%2==1:
        cnt += 1
print(cnt)

Measured memory_bytes: 16636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	cout << "ABC";
	cout << n << endl;

	return 0;
}


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

#define vi vector<int>
#define vvi vector<vi>

const int INF = 1e9 + 5;

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

    int n,k;
    cin >> n >> k;
    vi l(n, 0);

    while(k--){
        int d;
        cin >> d;
        while(d--){
            int a;
            cin >> a;
            l[a-1] = 1;
        }
    }
    int ans =0;
    for(int i = 0; i < l.size(); i++){
        if(l[i] == 0){
            ans++;
        }
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		int i;
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		System.out.println((x-r<0)||(y-r<0)||(x+r>W)||(y+r>H) ? "No" : "Yes");
	}
}

Measured memory_bytes: 17356
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
//	sync;
	ll y,m,d;
	scanf("%lld/%lld/%lld",&y,&m,&d);
	//ll sum=y-1+12*(m-1)+d;
	if(m<5)
	printf("Heisei");
	else
	printf("TBD");
}

Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int K,S;
    cin>>K>>S;
    int minu=min(K,S);
    ll count=0;
    vector<int> M(2*K+1);
    REP(i,K+1){
        REP(j,K+1){
            M[i+j]+=1;
        }
    }
    REP(i,2*K+1){
        if(S-i<=K&&S-i>=0){
            count+=M[i];
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a,b;
  scanf("%d %d",&a,&b);
  if (b<=a)
  {
    int b_ = a;
    a = b;
    b = b_;
  }
  
  for (int i = 0;i < b; i++)
  {
    printf("%d",a);
  }
  
  return 0;
}

Measured memory_bytes: 128
a,b=map(int,input().split())
x=10
tmpa=a
tmpb=b
for i in range(tmpb-1):
    a+=tmpa*x
    x*=10
x=10
for i in range(tmpa-1):
    b+=tmpb*x
    x*=10

print(min(str(a),str(b)))

Measured memory_bytes: 3064
n, k, s = map(int, input().split())

if s <= 2:
    not_s = 3
else:
    not_s = s - 1

res = []
for i in range(k):
    res.append(s)
while len(res) < n:
    res.append(not_s)
for i in range(n):
    print(res[i])

Measured memory_bytes: 5008
#include <iostream>
#include <cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;

int main(){

   ll n,k;
   cin>>n>>k;
   ll nums[n];
   for(int i = 0;i<n;i++) cin>>nums[i];
   sort(nums,nums+n);
   ll sum = 0;
    for(int i = 0;i<k;i++) sum += nums[i];;
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3196
from itertools import combinations
n=int(input())
l=[int(i) for i in input().split()][:n]
cnt=0
if n<3:
  print(0)
else:
  c=list(combinations(l,3))
  for j in range(len(c)):
    if c[j][0]==c[j][1] or c[j][1]==c[j][2] or c[j][0]==c[j][2]:
      continue
    else:
        if c[j][0]+c[j][1]>c[j][2] and c[j][0]+c[j][2]>c[j][1] and c[j][1]+c[j][2]>c[j][0]:
            cnt+=1
    
  print(cnt)
      


  

Measured memory_bytes: 20492
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
    int siz;
    cin>>siz;
    string word;
    cin>>word;
    int counter = 0;
    int r1= 0;
    string safe="";
    string a1 = "";
    string a2 = "";
    string a3 = "";
    for(int i = 0; i < siz; i++)
    {
        if(counter <= siz - 3)
        {

            a1.push_back(word[counter]);
            a2.push_back(word[counter+1]);
            a3.push_back(word[counter+2]);
            safe =a1+a2+a3;
        }
        if(safe == "ABC")
        {
            r1 = r1 + 1;
            counter = counter + 3;
        }else
        {
            counter = counter +1;
        }
        safe="";
        a1  ="";
        a2  ="";
        a3  ="";
    }
    cout<<r1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

void dijkstra()
{
  int minv;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++)
  {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1)
  {
    minv = INFTY;
    int u = -1;
    for(int i=0;i<n;i++)
    {
      if(minv > d[i] && color[i] != BLACK)
      {
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(int v = 0; v<n;v++)
    {
      if(color[v] != BLACK && M[u][v] != INFTY)
      {
        if(d[v]>d[u] + M[u][v])
        {
          d[v] = d[u]+M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for(int i=0;i<n;i++)
  {
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main()
{
  cin >> n;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      M[i][j] = INFTY;
    }
  }

  int k,c,u,v;
  for(int i=0;i<n;i++)
  {
    cin >> u >> k;
    for(int j=0;j<k;j++)
    {
      cin >> v >> c;
      M[u][v] = c;
    }
  }

  dijkstra();
  return 0;
}



Measured memory_bytes: 3136
#include <cstdio>
#include <iostream>
#include <stack>
#include <string>
using namespace std;

bool isNumber(char c){
    if( c >= '0' && c <= '9' ) return true;
    return false;
}

int main(){
    string s;
    while( getline(cin,s) ){
        int minusFlag = 1;
        double n = 0.0;
        stack<double> st;
        s += " "; // 入力が数字1個のために空白スペースを末尾に追加

        for(int i=0 ; i < s.size() ; i++ ){
            char c = s[i];
            if( c == '-' && isNumber(s[i+1]) ){ // 負の数を表す'-'だったとき
                minusFlag = -1;
            }else if( isNumber(c) ){ // 数字だったとき
                n *= 10.0;
                n += c - '0';
            }else  if( c == ' ' && isNumber(s[i-1]) ){ // 空白だったとき
                n = n * minusFlag;
                st.push( n );
                n = 0.0;
                minusFlag = 1;
            }else if( c == '+' || c == '-' || c == '*' || c == '/' ){ // 演算子だったとき
                double a = st.top();
                st.pop();
                double b = st.top();
                st.pop();
                if( c == '+' ) st.push( b + a );
                if( c == '-' ) st.push( b - a );
                if( c == '*' ) st.push( b * a );
                if( c == '/' ) st.push( b / a );
            }
        }
        printf("%.8f\n", st.top() );
    }
}

Measured memory_bytes: 1232
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long    ←保留
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
//C++(GCC9.2.1)

/*signed*/int main() {
    //宣言
    long long n;
    cin >> n;
    vector<long long> a(n);
    rep(i, n)cin >> a[i];
    long long ans = 0;
    for(int i=0;i<n;++i) if (a[i] % 2 == 1) ans = 1;
    if (ans == 1) cout << "first" << endl;
    else cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
map<pair<pair<int,int>,pair<int,int> >,int>arr;
vector<pair<int,int> >v;
vector<int>vs[4];
main()
{
	int t,p,w,va;
    scanf("%d%d",&t,&p);
    for(int i = 0;i < t;i++)
    {
        scanf("%d%d",&w,&va);
        v.push_back(make_pair(w,va));
    }
    sort(v.begin(),v.end());
    for(int i = 0;i < t;i++)
    {
        vs[v[i].first-v[0].first].push_back(-v[i].second);
    }
    for(int i = 0;i < 4;i++)
    {
        sort(vs[i].begin(),vs[i].end());
    }
    arr[make_pair(make_pair(0,0),make_pair(0,0))]=0;
    int mx=0;
    for(long long i = 0;i <= vs[0].size();i++)
    {
        for(int j = 0;j <= vs[1].size();j++)
        {
            for(int k = 0;k <= vs[2].size();k++)
            {
                for(int l = 0;l <= vs[3].size();l++)
                {
                    //  printf("%d %d %d %d\n",i,j,k,l);
                    int tmp=arr[make_pair(make_pair(i,j),make_pair(k,l))];
                    if(i!=vs[0].size())
                    arr[make_pair(make_pair(i+1,j),make_pair(k,l))]=tmp-vs[0][i];
                    if(j!=vs[1].size())
                    arr[make_pair(make_pair(i,j+1),make_pair(k,l))]=tmp-vs[1][j];
                    if(k!=vs[2].size())
                    arr[make_pair(make_pair(i,j),make_pair(k+1,l))]=tmp-vs[2][k];
                    if(l!=vs[3].size())
                    arr[make_pair(make_pair(i,j),make_pair(k,l+1))]=tmp-vs[3][l];
                    if(j+2*k+3*l+(i+j+k+l)*v[0].first<=p)
                    mx=max(mx,arr[make_pair(make_pair(i,j),make_pair(k,l))]);
                }
            }
        }
    }
    printf("%d",mx);
}


Measured memory_bytes: 28800
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))

int main(){
	int A;
	string S;

	cin >> A >> S;
	if(A >= 3200) cout << S << endl;
	else cout << "red" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cassert>
#include<algorithm>
using namespace std;
long long n,a[100];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",a+i);
	sort(a+1,a+1+n);
	long long cur=n,ans=0;
	while(a[cur]>=n)
	{
		long long x=(a[cur]-n+1)/n;
		a[cur]-=x*n;
		if(a[cur]>=n)a[cur]-=n,x++;
		for(int i=1;i<=n;i++)
			if(i!=cur)a[i]+=x;
		ans+=x;
		sort(a+1,a+1+n);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

vector<long> pp;

void preparePrime( long maxp )
{
    long i;
    vector<long> a(maxp+1);
    for(i=2; i<=maxp; i++) {
        long k=i+i;
        while(k<=maxp) {
            a[k]=1;
            k+=i;
        }
    }
    for(i=2; i<=maxp; i++) {
        if(a[i]==0) pp.push_back( i );
    }
    return;
}

void decompositPrime( long a, vector<pair<long,long> >& vv )
{
    preparePrime( (long)sqrt((double)a) );

    long i;
    for(i=0; i<(long)pp.size(); i++) {
        long count = 0;
        while(a % pp[i] == 0 ) {
            a /= pp[i];
            count ++;
        }
        if(count>0) vv.push_back( make_pair( pp[i], count ) );
        if (a==1) break;
    }
    if(a>1) {
        vv.push_back( make_pair( a, 1 ) );
    }

    return;
}

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    map<long, long> zz;
    long i,j;
    for(i=2; i<=n; i++) {
        vector<pair<long,long> >  vv;
        decompositPrime( i, vv );
        for(j=0; j<vv.size(); j++) {
            zz[vv[j].first] += vv[j].second;
        }
    }

    ll  ans=1;
    auto it=zz.begin();
    for(; it!=zz.end(); ++it) {
        ans = ans * (it->second + 1) % MOD;
    }
    printf("%lld\n", ans);

    return 0;
}


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

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

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

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 212345;

int a[N], n;

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

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];

    int ans = 0, pos = 1;
    for (int i = 1; i <= n; ++i) {
        while (pos <= n && a[pos] != i) ++pos;
        if (pos <= n) {
            ++ans;
            ++pos;
        }
    }

    if (ans == 0) cout << -1 << '\n';
    else cout << n - ans << '\n';
    return 0;
}

Measured memory_bytes: 1024
import numpy as np
N, M = map(int, input().split())
X = list(map(int, input().split()))
sortX = np.array(sorted(X), dtype=np.int64)
diffX = np.sort(np.diff(sortX))
if N == 1:
    print(np.sum(diffX))
    exit()
ans = np.sum(diffX[:-(N-1)])
print(ans)


Measured memory_bytes: 38148
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  VI t(n); for (int i = 0; i < n; i++) cin >> t[i];
  VI v(n + 1); for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = n - 1; i >= 0; i--) {
    v[i] = min(v[i], v[i + 1] + t[i]);
  }
  for (int i = 0; i < n; i++) {
    t[i] <<= 1;
    v[i] <<= 1;
  }
  double res = 0.0;
  int tmp = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t[i]; j++) {
      res += min({v[i], j + tmp, -(j - t[i]) + v[i + 1]});
    }
    tmp = min({v[i], t[i] + tmp, v[i + 1]});
  }
  res /= 4.0;
  cout << fixed << setprecision(5) << res << '\n';
  return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int P = 1e9 + 7 , N = 2002 , M = N * N;
inline void pp(int &x,int d) {if((x+=d)>=P)x-=P;}
int n , K , fac[M] , ifac[M];
int f[N][N];
inline int comb(int a,int b) {
  return ll(fac[a])*ifac[b]%P*ifac[a-b]%P;
}

int main(){
  cin >> n >> K;
  int tot = n * K;
  if(K == 1) {
    cout << 1 << endl;
    return 0;
  }
  rep(i,0,tot+1) fac[i]=i?ll(fac[i-1])*i%P:1;
  rep(i,0,tot+1) ifac[i]=i<2?1:P-ll(P/i)*ifac[P%i]%P;
  rep(i,1,tot+1) ifac[i]=ll(ifac[i-1])*ifac[i]%P;
  rep(i,0,n+1) rep(j,i,n+1) {
    if(i == 0 && j == 0) {
      f[i][j] = 1;
      continue;
    }
    if(i) f[i][j] = f[i-1][j];
    if(j > i) pp(f[i][j] , ll(f[i][j-1]) *
        comb(i + j * (K - 1) - 1 , K - 2) % P);
  }
  cout << ll(f[n][n]) * fac[n] % P << endl;
  return 0;
}


Measured memory_bytes: 47232