akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    double v[51];
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v, v + n);

    double ans = (v[0] + v[1]) / 2.0;
    for (int i = 2; i < n; i++) {
        ans = (ans + v[i]) / 2.0;
    }
    cout << ans << '\n';


    return 0;
}


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

using namespace std;

int main(void)
{
    int n[3];
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n + 3);
    cout << n[0] + n[1] + n[2] * 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int w,h,l;
int al,ar,au,ad;
int s;

struct NODE{
	int x,y,flag;
}tu[105];

bool cmp(NODE a,NODE b){
	if(a.flag != b.flag) return a.flag < b.flag;
	else if(a.flag == 1) return a.x < b.x;
	else if(a.flag == 2) return a.x > b.x;
	else if(a.flag == 3) return a.y < b.y;
	else if(a.flag == 4) return a.y > b.y;
}

int main()
{
	scanf("%d %d %d",&w,&h,&l);
	al = 0;ar = w;
	au = h;ad = 0;
	for(int i = 1;i <= l;i++){
		scanf("%d %d %d",&tu[i].x,&tu[i].y,&tu[i].flag);
	}
		sort(tu + 1,tu + 1 + l,cmp);
		for(int i = 1;i <= l;i++){
			if(tu[i].flag == 1){
				al = tu[i].x;
			}
			else if(tu[i].flag == 2){
				ar = tu[i].x;
			}
			else if(tu[i].flag == 3){
				ad = tu[i].y;
			}
			else if(tu[i].flag == 4){
				au = tu[i].y;
			}
		}
	if(ar < al || au < ad) s = 0;
	else s = (ar - al) * (au - ad);
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int Q = int.Parse(str[0]);
        int H = Math.Min(Q*2,int.Parse(str[1]));
        int S = Math.Min(int.Parse(str[2]),H*2);
        int D = Math.Min(int.Parse(str[3]),S*2);
        long N = int.Parse(Console.ReadLine());
        long count = D * (N / 2) + S * (N % 2);
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 13140
unittest
{
	assert( [ "2", "tourist", "petr", "e" ].parse.expand.solve == "1" );
	assert( [ "2", "?o?r?s?", "?et?", "e" ].parse.expand.solve == "1 2 3" );
	assert( [ "4", "e", "e", "e", "e", "e" ].parse.expand.solve == "1 2 3 4 5" );
	assert( [ "5", "??", "??", "d?", "?e", "?f", "zzz" ].parse.expand.solve == "6" );
	assert( [ "7", "atcoder", "topcoder", "codeforces", "hackerrank", "csacademy", "codechef", "atcoder", "square" ].parse.expand.solve == "7" );
	assert( [ "7", "??i?", "?o???g????", "??m??x?", "?h?????i", "s????", "?og????", "u??", "square" ].parse.expand.solve == "1 2 3 4 5 6 7" );

	assert( [ "2", "?cc", "??", "aa" ].parse.expand.solve == "1 2" );		// 追加ケース
	assert( [ "3", "??c", "aaa", "aad", "aac" ].parse.expand.solve == "2 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 n = input.front.to!( long );
	auto ss = new dchar[][ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	input.popFront;
	auto t = input.front.to!( dchar[] );
	return tuple( ss, t );
}

auto solve( dchar[][] ss, dchar[] t )
{
	auto us = ss.sort!( ( a, b ) => b < a ).find!( ( a, b ) => a <= b )( t ).array;
	foreach_reverse( i, u; us )
	{
		if( t < u.replace( "?", "a" ) ) us = us[ 0 .. i ] ~ us[ i + 1 .. $ ];
	}
	
	auto anss = [ us.length.signed + 1 ];
	foreach( u; us )
	{
		if( t <= u.replace( "?", "z" ) ) anss ~= anss[ $ - 1 ] - 1;
	}
	return anss.retro.map!( to!string ).join( " " );
}


Measured memory_bytes: 3068
#include <stdio.h>

//#define DEBUG

int main(void)
{
    FILE* fpin;
#ifdef DEBUG
    fpin=fopen("input.txt","r");
#else
    fpin=stdin;
#endif

    while(feof(fpin)==0){
        int n; //student number
        double w,h; //weight and height
        fscanf(fpin,"%d,%lf,%lf\n",&n,&w,&h);
        
        double bmi=w/(h*h);
        if(bmi>=25.0f){
            printf("%d\n",n); 
        }
    }

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
P B[105];
int main(){
    ll N;
    cin>>N;
    set<P> st;
    for(ll i=0;i<N;i++){
        ll a,b;
        cin>>a>>b;
        st.insert(P(a,b));
    }
    for(ll i=0;i<N;i++){
        ll a,b;
        cin>>a>>b;
        B[i]=P(a,b);
    }
    sort(B,B+N);
    ll ans=0;
    for(ll i=0;i<N;i++){
        P mx=P(0,-1);
        for(auto o:st){
           if(o.first<B[i].first && o.second<B[i].second){
               if(mx.second<o.second){
                   mx=o;
               }
           }
        }
        if(mx!=P(0,-1)){
            st.erase(mx);
            ans++;
        }
        /*cout<<"B[i]:"<<B[i].first<<","<<B[i].second<<endl;
        for(auto o:st){
            cout<<o.first<<","<<o.second<<"   ";
        }cout<<endl;*/
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define int long long
inline LL read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	LL k=0,kk=1;if (c=='-')c=getchar(),kk=-1;
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(LL x){if (x<0)x=-x,putchar('-');if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(LL x){write(x);puts("");}
int n,a[1000010],ans;
signed main(){
	n=read();for (int i=1;i<=n;i++)a[i]=read();
	if (a[1])return puts("-1"),0;
	for (int i=n;i>=2;i--)
		if (a[i-1]+1<a[i])return puts("-1"),0;
			else if (a[i-1]+1==a[i])ans++;else ans+=a[i];
	writeln(ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <queue>

using namespace std;
typedef long long ll;
static const ll mod = 1000003;

int main() {

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    string S;
    cin >> S;

    bool can = true;

    if (S[C-1] == '#') can = false;
    if (S[D-1] == '#') can = false;

    for (int i = A; i < C - 1; i++) {
        if (S[i] == '#' and S[i+1] == '#') {
            can = false;
            break;
        }
    }


    for (int i = B; i < D - 1; i++) {
        if (S[i] == '#' and S[i+1] == '#') {
            can = false;
            break;
        }
    }


    if (C > D) {
        bool can2 = false;
        for (int i = B-1; i < D; i++) {
            if (S[i-1] == '.' and S[i] == '.' and S[i+1] == '.') {
                can2 = true;
            break;
            }
        }

    if (can and can2)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';

    }
    else {


        if (can)
            cout << "Yes" << '\n';
        else
            cout << "No" << '\n';
    }

}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;

int main(void){
    int N;
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    cout << (a * b) << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){
    int a, b, x;
    scanf ("%d%d%d", &a, &b, &x);
    int dif;

    if (x >= a){
        dif = x-a;
    } else {
        dif = a-x;
    }
    
    if (a == x){
        printf ("YES\n");
    } else if (a < x && b >= dif){
        printf ("YES\n");
    } else {
        printf ("NO\n");
    } 
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int A, B; cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
inline int read() {
	int f=1,sum=0;
	char x=getchar();
	for(;(x<'0'||x>'9');x=getchar()) if(x=='-') f=-1;
	for(;x>='0'&&x<='9';x=getchar()) sum=sum*10+x-'0';
	return f*sum;
}

#define M 105
#define mod 1000000007
int n;
int a[M];
int tot,st[M],dui[M],f[M][M];

inline int qpow(int x,int ci) {
	int sum=1;
	for(;ci;ci>>=1,x=1ll*x*x%mod)
		if(ci&1) sum=1ll*x*sum%mod;
	return sum;
}

inline void inc(int &x,int y){x+=y,x-=x>=mod?mod:0;}

int main() {
	//freopen("a.in","r",stdin);
	n=read();
	for1(1,n,i) {
		a[i]=read();
		dui[i]=a[i]-1;
	}
	sort(dui+1,dui+n+1);
	for1(1,n,i) {
		if(dui[i]!=dui[i-1]) ++tot;
		st[tot]=dui[i];
	}
	for1(1,n,i) {
		if(a[i]==1) a[i]=0;
		else for1(1,tot,j) if(a[i]==st[j]+1) a[i]=j;
	}
	f[1][0]=2;
	for1(1,a[1],i) f[1][i]=1ll*(qpow(2,st[i]-st[i-1])-1)*qpow(2,st[a[1]]-st[i]+1)%mod;
	//for1(0,a[1],i) cout<<f[1][i]<<" "; cout<<endl;
	for1(2,n,i) {
		for1(1,tot,j) {
			if(!f[i-1][j]) continue;
			if(j<=a[i]) {
				int k=1;
				if(a[i]>a[i-1]) k=qpow(2,st[a[i]]-st[a[i-1]]);
				inc(f[i][j],1ll*k*f[i-1][j]%mod);
			}
			else {
				inc(f[i][0],2ll*f[i-1][j]%mod);
			}
		}
		inc(f[i][0],2ll*f[i-1][0]%mod);
		if(a[i]>a[i-1]) {
			for1(a[i-1]+1,a[i],j) {
				inc(f[i][j],1ll*f[i-1][0]*(qpow(2,st[j]-st[j-1])-1)%mod*qpow(2,st[a[i]]-st[j]+1)%mod);
			}
		}
	}
	//for1(0,a[n],i) cout<<f[n][i]<<" "; cout<<endl;
	int ans=0;
	for1(0,tot,i) inc(ans,f[n][i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	char buf[300],s[20],c;
	char x[5]="that",y[5]="this";
	int a[26][3],b[26][3],n,i,j,k,flag1,flag2;

	for(i=0;i<26;i++)
		for(j=0;j<3;j++){
			a[i][j]=((x[j+1]-'a')*i-(x[0]-'a')*i+2600)%26;
			b[i][j]=((y[j+1]-'a')*i-(y[0]-'a')*i+2600)%26;
		}
	scanf("%d%*c",&n);
	for(i=0;i<n;i++){
		j=0;
		k=0;
		flag1=-1;
		flag2=-1;
		while(scanf("%c",&c)!=EOF){
			buf[j]=c;
			if(c==' '||c=='\n'){
				if(k==4){
					for(k=0;k<26;k++)
						if((260+s[1]-s[0])%26==a[k][0]&&(260+s[2]-s[0])%26==a[k][1]&&(260+s[3]-s[0])%26==a[k][2]){
							flag1=k;
							flag2=(26*26+s[0]-'a'-('t'-'a')*k)%26;
						}else if((260+s[1]-s[0])%26==b[k][0]&&(260+s[2]-s[0])%26==b[k][1]&&(260+s[3]-s[0])%26==b[k][2]){
							flag1=k;
							flag2=(26*26+s[0]-'a'-('t'-'a')*k)%26;
						}
				}
				k=0;
				if(c=='\n')
					break;
			}else{
				s[k]=c;
				k++;
				if(k>10)
					k=0;
			}
			j++;
		}
		for(j=0;buf[j]!='\n';j++)
			if(buf[j]==' ')
				printf(" ");
			else{
				for(k=0;(k*flag1+flag2)%26!=(buf[j]-'a'+26)%26&&k<30;k++);
				printf("%c",'a'+k);
			}
		printf("\n");
	}
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  
  if(N % 10 == 3){cout << "bon" << endl;}
  else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
  {
    cout << "pon" << endl;
  }
  else{cout << "hon" << endl;}
}

Measured memory_bytes: 3636
import collections

def main():
    n = int(input())

    s_list = []

    for i in range(n):
        s = str(input())
        s_list.append(s)

    c = collections.Counter(s_list)
    c_list = c.most_common()

    print_count = len(c_list)
    new_list = []

    for j in range(len(c_list)):
        new_list.append(c_list[j][0])
        if j != len(c_list)-1:
            if c_list[j+1][1] < c_list[j][1]:
                print_count = j+1
                break
    
    sorted_list = sorted(new_list)
    for k in sorted_list:
        print(k)
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 49208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int max = N % K;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
#define endl "\n"

int main(int argc, const char * argv[]) {
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    if(s<="2019/04/30"){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
}

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

using namespace std;

int main()
{
	int x;
	cin>>x;
	if(x >=400 and x < 600) cout<<8<<endl;
	if(x >=600 and x < 800) cout<<7<<endl;
	if(x >=800 and x < 1000) cout<<6<<endl;
	if(x >=1000 and x < 1200) cout<<5<<endl;
	if(x >=1200 and x < 1400) cout<<4<<endl;
	if(x >=1400 and x < 1600) cout<<3<<endl;
	if(x >=1600 and x < 1800) cout<<2<<endl;
	if(x >=1800 and x < 2000) cout<<1<<endl;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int[] map = new int[101];
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        map[i*j] = 1;
      }
    }

    Scanner sc = new Scanner(System.in);
    if (map[sc.nextInt()] == 1) System.out.println("Yes");
    else System.out.println("No");
    sc.close();
    return;
  }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 
    int n;
    cin>>n;
  	if(n%10==2 ||n%10==4||n%10==5||n%10==7||n%10==9)puts("hon");
  	else if(n%10==3)puts("bon");
  	else puts("pon");
    return 0;
}


Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    long mod = 1000000000+7;
    public static void main(String[] args) throws Exception {
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    String solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        // sort according to the deadline
        PriorityQueue<int[]> pq = new PriorityQueue<>(n,(o1,o2)->(o1[1]==o2[1]?o1[0]-o2[0]:o1[1]-o2[1]));
        for(int i=0;i<n;i++){
            int a = sc.nextInt(), b = sc.nextInt();
            // b is the deadline. a is the necessary time
            pq.add(new int[]{a,b});
        }
        int time = 0;
        while(pq.size()>0){
            int[] task = pq.poll();
            time += task[0];
            if(time>task[1]) return "No";
        }
        return "Yes";
    }
}



Measured memory_bytes: 105712
h, w = map(int, input().split())
s = [input() for _ in range(h)]
mark = "#" * (w + 2)
for i in range(h + 2):
    if i == 0 or i == h + 1:
        print(mark)
    else:
        print("#" + s[i - 1] + "#")
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
typedef long long lli;
#define MOD 1000000007
lli n,c;
vector<lli> a;
vector<lli> b;
lli dp[401][401];
lli dp2[401][401];
int main(int argc, char const *argv[]) {
    for(lli i = 0;i <= 400;i++) dp2[i][0] = 1;
    for(lli i = 0;i <= 400;i++) for(lli j = 0;j < 400;j++) dp2[i][j+1] = (dp2[i][j]*i)%MOD;
    for(lli i = 0;i < 400;i++) for(lli j = 0;j <= 400;j++) dp2[i+1][j] += dp2[i][j],dp2[i+1][j] %= MOD;
    cin >> n >> c;
    a = vector<lli> (n);
    b = vector<lli> (n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    for(lli i = 0;i < n;i++) cin >> b[i];
    dp[0][0] = 1;
    for(lli i = 0;i < n;i++){
        for(lli j = 0;j <= c;j++){
            for(lli k = j,t = 0;k <= c;k++,t++){
                dp[i+1][k] += (dp[i][j]*((dp2[b[i]][t]-dp2[a[i]-1][t]+MOD)%MOD))%MOD;dp[i+1][k] %= MOD;
            }
        }
    }
    cout << dp[n][c] << endl;
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

vector<vector<int> > c(10,vector<int>(10));

int dfs(int st,int sum,int mi){
  if(st==1){
    if(sum<mi){
      return sum;
    }else{
      return mi;
    }
  }
  if(sum>=mi){
    return mi;
  }
  vector<int> ret(11,100000);
  rep(i,10){
    if(i!=st && c[st][i]<mi){
      //cout<<st<<' '<<i<<' '<<c[st][i]<<'\n';
      ret[i]=dfs(i,sum+c[st][i],mi);
    }
  }
  return min(*min_element(begin(ret),end(ret)),mi);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    vector<vector<int> > a(h+1,vector<int>(w+1));
    rep(i,10){
      rep(j,10){
        cin>>c[i][j];
      }
    }
    FOR(i,1,h+1){
      FOR(j,1,w+1){
        cin>>a[i][j];
      }
    }
    int ans=0;
    vector<int> memo(10,-1);
    FOR(i,1,h+1){
      FOR(j,1,w+1){
        if(a[i][j]!=-1 && a[i][j]!=1){
          if(memo[a[i][j]]>=0){
            ans+=memo[a[i][j]];
          }else{
            memo[a[i][j]]=dfs(a[i][j],0,c[a[i][j]][1]);
            ans+=memo[a[i][j]];
          }
        }
      }
    }
    //cout_vec(memo);
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
void solve_A(); // void solve_B(); // void solve_C(); // void solve_D();
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve_A();
	return 0;
}

void solve_A(){
    ll N; cin >> N;
    string S = to_string(N);
    ll ans = 0;
    ll tmp = 0;
    for(int i = 0; i < (int)S.length();i++){
        ll X = 9*(S.length() - 1 - i) + (S[i] - '0' - 1) + tmp;
        ans = max(ans,X);
        tmp += (S[i] - '0');
    }
    ans = max(ans,tmp);
    cout << ans << endl;
}


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

using namespace std;

const int N = 1e5 + 5;
int n, m, arr[N], marked[N], pen[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int a;
        string s;
        cin >> a >> s;
        if(s == "WA"){
            if(!marked[a]){
                pen[a]++;
            }
        } else {
            if(!marked[a]){
                marked[a] = 1;
            } 
        }
    }
    int pent = 0;
    int cor = 0;
    for(int i = 1; i <= n; i++){
        cor += marked[i];
        if(marked[i]){
            pent += pen[i];
        }
    }
    cout << cor << " " << pent << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

#define debug(x) cout << #x << " = " << x << endl;

using namespace std;

int main(void){

  int N,M;
  cin >> N >> M;
  
  int oneForOther[N];
  int otherForOne[N];

  fill(oneForOther,oneForOther+N,0);
  fill(otherForOne,otherForOne+N,0);

  int from, to;
  
  for(int i = 0;i<M;++i){
    cin >> from >> to;
    if(from == 1) oneForOther[to-1] = 1;
    if(to == N) otherForOne[from-1]= 1;
  }

  for(int i = 0;i<N;++i){
    if(oneForOther[i] == 1 && otherForOne[i] == 1){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  
  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 1792
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

a=II()
print(a + a*a + a*a*a)


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

int n; cin>>n;
int arr[n],brr[n];
for(int i=0;i<n;i++){ cin>>arr[i]; brr[i]=arr[i];}
sort(brr,brr+n);
int c=0;
for(int i=0;i<n;i++) if(arr[i]!=brr[i]) c++;
if(c==0||c==2) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    string S,R;cin >> S >> R;
    long long ans;
    //before == true:一個前が横並び falseなら縦並び
    bool before = false;
    for(int i = 0;i<N;i++){
        //縦向き
        if(S.at(i) == R.at(i)){
            if(i == 0){
                ans = 3;
                before = false;
                continue;
            }
            //前が横向きなら1通りしかない
            if(before){
                ans *= 1;
            }
            else{
                ans *= 2;
            }
            before = false;
        }
        else{
            //横向き
            if(i == 0){
                ans = 6;
                before = true;
                i++;
                continue;
            }
            i++;
            if(before){
                ans *= 3;
            }
            else{
                ans *= 2;
            }
            before = true;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3684
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node
{
    int key;
    Node *prev, *next;
};

Node *nil;

void init()
{
	nil=(Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key)
{
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key)
{
	Node *cur = nil->next;
	while(cur != nil && cur->key != key)
	{
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t)
{
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void printList()
{
	Node *cur = nil->next;
	int i=0;
	while(1)
	{
		if( cur == nil ) break;
		if( i++ > 0 ) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

int main(void)
{
	int key, n, i;
	char com[12];
	
	scanf("%d",&n);
	init();
	for( i = 0 ; i <= n-1 ; i++ )
	{
		scanf("%s%d",com, &key);
		if( com[0] == 'i' ) insert(key);
		else if( com[0] == 'd' )
		{
			if(strlen(com) > 6)
			{
				if( com[6] == 'F' ) deleteFirst();
				else if( com[6] == 'L' ) deleteLast();
			}
			else deleteKey(key);
		}
	}
	
	printList();

	return 0;
}

Measured memory_bytes: 33820
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)

const ll INF = 1LL << 60;


signed main() {

	ll h, n;
	cin >> h >> n;

	ll a;
	ll sum = 0;

	rep(i, n) {
		cin >> a;
		sum += a;
	}
	if (sum >= h)cout << "Yes";
	else {
		cout << "No";
	}
}


Measured memory_bytes: 256
def time(s):
    h = s // 3600
    s = s - h * 3600

    m = s // 60
    s = s - m * 60
    return str(h), str(m), str(s)

def main():
    t = int(input())
    h, m, s = time(t)
    print('{}:{}:{}'.format(h,m,s))


main()


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k, t;
  cin >> k >> t;
  
  vector<int> a(t);
  int keep = -1;
  for (int i = 0; i < t; i++) {
    cin >> a.at(i);
    if (a.at(i) > k / 2) keep = a.at(i);
  }
  
  if (keep == -1) {
    cout << "0\n";
    return 0;
  }
  
  int ans = 0;
  keep -= (k + 1) / 2;
  if (k % 2 == 1) ans = keep * 2;
  else {
    ans = 1;
    keep--;
    ans += keep * 2;
  }
  
  cout << ans << '\n';
}

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

M1=sum(A)-sum(A[1::2])*2

arr=[]
M=sum(A)-sum(A[1::2])*2
print(M,end=" ")
for i in range(N-1):
    print(A[i]*2-M,end=" ")
    M=A[i]*2-M

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

using ll = long long;

int main() {
string s;
  cin >> s;
  int k=s.size();
  vector<char> pattern_a(k);
  vector<char> pattern_b(k);
  for(int i=0;i<k;i++){
  if(i%2 ==0)pattern_a[i]='1';
    else pattern_a[i]='0';
  
  }
    for(int i=0;i<k;i++){
  if(i%2 ==0)pattern_b[i]='0';
    else pattern_b[i]='1';
  
  }
  int cnt_a=0,cnt_b=0;
  for(int i=0;i<k;i++){
  if(s[i] != pattern_a[i])cnt_a++;
      if(s[i] != pattern_b[i])cnt_b++;
  
  }
  cout << min(cnt_a,cnt_b) <<endl;
}



Measured memory_bytes: 3772
n, k = [int(i) for i in input().split(" ")]

c = n // k if k % 2 == 1 else n // (k // 2)

if k % 2 == 0:
    if c % 2 == 0:
        print(2 * (c//2)**3)
    else:
        print((c//2)**3 + (c//2 + 1)**3)
else:
    print(c**3)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    char x[10];
    gets(x);
    if(x[0]==x[1] && x[2]==x[3] && x[0]==x[2])
        printf("No\n");
    else if(x[0]==x[1] && x[2]==x[3])
        printf("Yes\n");
    else if(x[0]==x[2] && x[1]==x[3])
        printf("Yes\n");
    else if(x[0]==x[3] && x[1]==x[2])
        printf("Yes\n");
    else
        printf("No\n");

}


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

void solve(){


	int n,q ;
	cin>>n>>q  ;

	unordered_map<int,int> mp ;

	rep(i,q){

		int x ;
		cin>>x ;

		rep(i,x){
			int c ;
			cin>>c ;
			mp[c]++ ;
		}

	}

	int count=0 ;

	for(int i=1;i<=n;i++){
		if(mp.find(i)==mp.end()){
			count++ ;
		}
	}

	cout<<count ;


}

int main(){

	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

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

int main()
{
  string s, p;
  cin >> s >> p;
  s += s;
  if (s.find(p) != string::npos)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first;
        int p;
        cin >> p;
        v[i].second.first = -p;
        v[i].second.second = i+1;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        cout << v[i].second.second << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int n, tmp;
	long long ans;
	ans = 0;
	int *a;
	
	scanf("%d", &n);
	a = (int*)calloc(n+1, sizeof(int));
	for(int i = 1;i < n + 1;i++)
	{
		scanf("%d", &tmp);
		if(tmp+i<n)a[i+tmp]++;
		if(i>tmp) ans += (long long)a[i-tmp];
	}
	printf("%lld\n", ans);
	free(a);
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> v(n), c(n);
  rep(i,n) cin >> v[i];
  rep(i,n) cin >> c[i];

  int x, cost, ans=0, toku;
  for (int bit = 0; bit < (1<<n); bit++) {
    x = 0; cost = 0;toku = 0;
    for (int i = 0; i < n; i++) {
      if (bit&(1<<i)) {
        x += v[i];
        cost += c[i];
      }
    }
    toku = x - cost;
    ans = max(ans, toku);
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 3640
#include<map>
#include<cstdio>

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		map<int,int> num;
		for(int i=0;i<n;i++){
			int c;	scanf("%d",&c);
			num[c]++;
		}

		int ans=-1;
		map<int,int>::iterator it;
		for(it=num.begin();it!=num.end();it++){
			if(2*it->second>n){ ans=it->first; break; }
		}

		if(~ans)	printf("%d\n",ans);
		else		puts("NO COLOR");
	}

	return 0;
}

Measured memory_bytes: 1852
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
using namespace std;


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

	int N, x;
	cin >> N >> x;
	vector<int>a(N);
	rep(i, N)cin >> a[i];

	//table[i][j]:=スライムiを飼うのに、魔法をj回唱えるとしてかかる秒数-魔法をj回唱えるのに要する秒数
	vector<vector<int>>table(N, vector<int>(N));
	rep(i, N)rep(j, N)table[i][j] = a[(i - j + N) % N];
	
	int answer = 0x1111111111111111LL;
	vector<int>min_table(N, 0x1111111111111111LL);
	rep(i, N) {
		rep(j, N)min_table[j] = min(min_table[j],table[j][i]);
		int ans_i = 0;
		rep(j, N)ans_i += min_table[j];
		answer = min(answer, ans_i + x * i);
	}
	cout << answer << endl;
		
}



Measured memory_bytes: 31616
#include<iostream>
#include<functional>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef unsigned long long ll;
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    int sum=0;
    rep(i,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int ave=sum/n;
    int ansless=0;
    int ansmore=0;
    rep(i,n)
    {
        ansless+=pow(a[i]-ave,2);
        ansmore+=pow(a[i]-(ave+1),2);
    }
    cout<<min(ansless,ansmore);

}

Measured memory_bytes: 256
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func joinInts(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func divUp(x, y int64) int64 {
	return (x + y - 1) / y
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	S := nextLine()
	ans, _ := strconv.ParseInt(S, 10, 64)
	for n := 1; n < len(S); n++ {
		ans += addPlus(S, n, 1, 1)
	}
	out(ans)
}

func addPlus(S string, n, m, j int) int64 {
	var sm int64
	for i := j; i < len(S); i++ {
		if S[i-1] != '+' && S[i] != '+' {
			S2 := S[:i] + "+" + S[i:]
			if m == n {
				sm += sum(strings.Split(S2, "+"))
			} else {
				sm += addPlus(S2, n, m+1, i+1)
			}
		}
	}
	return sm
}

func sum(ss []string) int64 {
	var ans int64
	for _, s := range ss {
		n, _ := strconv.ParseInt(s, 10, 64)
		ans += n
	}
	return ans
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void)
{
	char roman[128];
	
	while (scanf("%s", roman) != EOF){
		int i;
		int num = 0;
		for (i = 0; roman[i] != 0; i++){
			switch (roman[i]){
				case 'I':
					if (roman[i + 1] == 'V'){
						num += 4;
						i++;
					}
					else if (roman[i + 1] == 'X'){
						num += 9;
						i++;
					}
					else {
						num++;
					}
					break;
				case 'V':
					num += 5;
					break;
				case 'X':
					if (roman[i + 1] == 'L'){
						num += 40;
						i++;
					}
					else if (roman[i + 1] == 'C'){
						num += 90;
						i++;
					}
					else {
						num += 10;
					}
					break;
				case 'L':
					num += 50;
					break;
				case 'C':
					if (roman[i + 1] == 'D'){
						num += 400;
						i++;
					}
					else if (roman[i + 1] == 'M'){
						num += 900;
						i++;
					}
					else {
						num += 100;
					}
					break;
				case 'D':
					num += 500;
					break;
				case 'M':
					num += 1000;
					break;
			}
		}
		printf("%d\n", num);
	}
	
	return 0;
}

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


int main(){
    int N;
    cin>>N;
    vector<int64_t> A,B;
    for(int i=0;i<N;i++){
        int64_t a,b;
        cin>>a>>b;
        A.push_back(a);
        B.push_back(b);
    }
    int64_t cnt = 0;
    for(int i=N-1;i>=0;i--){
        A[i]+=cnt;
        int64_t c = A[i]%B[i];
        if(c){
            c = B[i] - c;
            cnt+=c;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
typedef long long ll;
ll x;
int main()
{
    scanf("%lld", &x);
    for (ll i = -130; i <= 130; i++) {
        for (ll j = -130; j <= 130; j++) {
            ll u = i * i * i * i * i, v = j * j * j * j * j;
            if(u - v == x) {
                printf("%lld %lld\n", i, j);
                return 0;
            }
        }
    }
}


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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	while(cin >> n >> k){
		int cont[n+5] = {};
		int sum = 0;
		f(n){
			cin >> cont[i];
			sum += cont[i];
		}	
		vector<int>fac;
		for(int i = 1 ; i <= sqrt(sum) ; i++){
			if(sum%i)continue;
			if(i * i == sum){
				fac.pb(i);
			}
			else{
				fac.pb(i);
				fac.pb(sum/i);
			}
		}
		sort(fac.begin(),fac.end());
		reverse(fac.begin(),fac.end());
		for(auto i:fac){
			vector<int>rem;
			int tot=0;
			int u = 0;
			fr(j,0,n){
				rem.pb(cont[j]%i);
				tot += i - (cont[j]%i);
			}
			sort(rem.begin(),rem.end());
			for(auto j:rem){
				u += j;
				tot -= i - j;
				if(tot == u && u<=k){
					cout<<i<<endl;
					exit(0);
				}
			}
		}
	}
}

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

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);
		int M = Integer.parseInt(Ws[1]);

		W = in.readLine();
		Ws = W.split(" ");
		long[] A = new long[Ws.length];
		long sum = 0;
		for (int i = 0; i < Ws.length; i++) {
			A[i] = Long.parseLong(Ws[i]);
			sum+=A[i];
		}

		Arrays.sort(A);
		String ans = "Yes";
		for(int i=0;i<M;i++){
			if(A[N-1-i]/(1.0*sum) < (1.0/(4*M))){
				ans = "No";
				break;
			}
		}
		System.out.println(ans);

	}
}


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

#define INF 0x33433433
using LLI = long long int;

int N;
int M;
int W;
int T;
int P[114];
int V[114];
int L[114];
int X[114];
int Y[114];
int Q[114][114];
char buf[114514];
LLI dp[1 << 9][11451];
LLI dp2[1 << 9][114];
LLI dp3[11451];

string S[114];
string R[114][114];
map<string, int> rev;

int Dist(int u, int v) {
  return abs(X[u]-X[v]) + abs(Y[u]-Y[v]);
}

int main() {
  scanf("%d%d%d%d", &N, &M, &W, &T);
  for (int i=0; i<M; i++) {
    scanf("%s%d%d", buf, &V[i], &P[i]);
    S[i] = buf;
    rev[S[i]] = i;
  }

  for (int i=0; i<N; i++) {
    scanf("%d%d%d", &L[i], &X[i], &Y[i]);
    for (int j=0; j<L[i]; j++) {
      scanf("%s%d", buf, &Q[i][j]);
      R[i][j] = buf;
    }
  }

  int lim = 1 << N;
  for (int st=0; st<lim; st++) {
    map<string, int> vs;
    for (int i=0; i<N; i++) {
      if (!(st >> i & 1)) continue;
      for (int j=0; j<L[i]; j++) {
        if (!vs.count(R[i][j])) vs[R[i][j]] = Q[i][j];
        else vs[R[i][j]] = min(vs[R[i][j]], Q[i][j]);
      }
    }

    for (auto &itr : vs) {
      string s = itr.first;
      int w = V[rev[s]];
      int p = P[rev[s]] - itr.second;

      for (int i=0; i<=W-w; i++) {
        dp[st][i+w] = max(dp[st][i+w], dp[st][i]+p);
      }
    }

    for (int i=0; i<W; i++) {
      dp[st][i+1] = max(dp[st][i+1], dp[st][i]);
    }
  }

  fill(dp2[0], dp2[lim], INF);
  dp2[0][N] = 0;
  for (int st=0; st<lim; st++) {
    for (int v=0; v<=N; v++) {
      for (int i=0; i<=N; i++) {
        int nst = st;
        if (i != N) nst |= (1 << i);
        dp2[nst][i] = min(dp2[nst][i], dp2[st][v] + Dist(i, v));
      }
    }
  }

  for (int t=0; t<T; t++) {
    for (int st=0; st<lim; st++) {
      int nt = t+dp2[st][N];
      if (T < nt) continue;
      dp3[nt] = max(dp3[nt], dp3[t] + dp[st][W]);
    }
  }

  LLI ans = 0;
  for (int t=0; t<=T; t++) {
    ans = max(ans, dp3[t]);
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 14112
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    a, s, c = map(str, input().split())
    print('A'+s[0]+'C')

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

int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if((e-a)>k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    int n,R[200000]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>R[i];
    }
    int maxv=-1000000000,minv=R[0];
    for(int j=1;j<n;j++){
        maxv=max(maxv,R[j]-minv);
        minv=min(minv,R[j]);
    }
    cout<<maxv<<endl;
}


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

int main(){
int x, y;
while(1){
 cin >> x >> y;
 if(x==0 && y==0) break;
 if(x > y){
   cout << y << " " << x << endl; }else{
   cout << x << " " << y << endl; }
 }
return 0;
}
 



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    ll N;
    cin >> N;
    ll ans = 10e12;

    for(int i=1;i<=sqrt(N);i++){
        if(N%i==0){
            ans = min(N/i+i-2,ans);
        }
    }

    cout << ans << endl;
}



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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    vector<int> p(3);
    mint ans = 1;
    for (int i=0;i<N;i++){
        bool changed = false;
        int num = 0;
        for (int x=0;x<3;x++){
            if (!changed && p[x] == A[i]) {
                p[x]++;
                num++;
                changed = true;
            } else if (p[x] == A[i]) {
                num++;
            }
        }
        ans *= num;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3680
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	String S;
	StringBuilder T = new StringBuilder();
	String P[] = {"dream", "dreamer", "erase", "eraser"};

	public void run() {
		Scanner sc = new Scanner(System.in);
		S = sc.next();

		ArrayDeque<Integer> stack = new ArrayDeque<Integer>();
		stack.push(0);
		boolean ans = false;
		while(!stack.isEmpty()) {
			int i = stack.pop();
			if(i == S.length()) {
				ans = true;
				break;
			}
			for(int j=0; j<4; j++) {
				if(i+P[j].length() <= S.length() && P[j].equals(S.substring(i, i+P[j].length()))) {
					stack.push(i+P[j].length());
				}
			}
		}

		if(ans) System.out.println("YES");
		else System.out.println("NO");

		sc.close();
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int p1 = 1;
  int p2 = 1;
  for (int i=n; n-2<i; i--) {
    p1 *= i;
  }
  for (int i=m; m-2<i; i--) {
    p2 *= i;
  } 
  cout << p1/2 + p2/2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll H, W; int N; cin >> H >> W >> N;
  int tate[3] = {-1, 0, 1}, yoko[3] = {-1, 0, 1};
  map<pair<ll, ll>, ll> mp;
  rep(i, N){
    int a, b; cin >> a >> b; a--; b--;
    rep(j, 3){
      rep(k, 3){
        if(a+tate[j]<1 || a+tate[j]>H-2 || b+yoko[k]<1 || b+yoko[k]>W-2) continue;
        mp[{a+tate[j], b+yoko[k]}]++;
      }
    }
  }
  ll cnt[10] = {};
  rep(j, 9){
    for(auto p: mp){
      if(p.second==j+1){
        cnt[j+1]++;
      }
    }
  }
  ll sum = 0;
  rep(j, 9){
    sum+=cnt[j+1];
  }
  cnt[0] = (H-2)*(W-2)-sum;
  rep(i, 10){
    cout << cnt[i] << endl;
  }
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for (int i = 0; i < 1000; i++) {
			char[] cs = in.readLine().toCharArray();
			boolean isPass = true;
			for (int n = 1; n < cs.length && isPass; n++) {
				char now = cs[n - 1];
				char next = cs[n];
				isPass &= (now + 1 == next && (now != 'C' && now != 'F'))
						|| ('G' > now && ((char) (now + 3) == next))
						|| ('C' < now && now - 3 == next)
						|| (now - 1 == next && (now - 'A') % 3 != 0);
			}
			if (isPass) {
				System.out.println(cs);
			}

		}
	}
}

Measured memory_bytes: 21212
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------


void _main() {
	int N;
	cin >> N;
	int num;
	int highest;
	cin >> highest;
	int count = 1;
	for (int i = 2; i <= N; i++) {
		cin >> num;
		if (num >= highest) {
			count++;
			highest = num;
		}

	}
	cout << count << endl;
}

Measured memory_bytes: 256