akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long powl(long A, long B){
  long ans = 1;
  for(int i = 0; i < B; i++){
    ans *= A;
    ans %= 998244353;
  }
  return ans;
}
int main () {
  long N;
  cin >> N;
  vector<long> data(N);
  long a;
  for(int i = 0; i < N; i++){
    cin >> a;
    data.at(a)++;
    if(i == 0 && a != 0){
      cout << 0 << endl;
      return 0;
    }
  }
  long flag = 1;
  for(int i = 0; i < N; i++){
    if(flag == 1 && data.at(i) == 0)flag = 0;
    if((flag == 0 && data.at(i) != 0) || (data.at(0) == 0 || data.at(0) > 1)){
      cout << 0 << endl;
      return 0;
    }
  }
  long ans = 1;
  for(int i = 1; i < N - 1; i++){
    if(data.at(i) == 0)break;
    ans *= powl(data.at(i), data.at(i + 1));
    ans %= 998244353;
  }
  cout << ans % 998244353 << endl;
  return 0;
}

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

typedef pair<int,int> P;

int main(){
	vector<P> data(6);
	for(int i=0;i<6;i++){
		cin>>data[i].first>>data[i].second;
		if(data[i].first>data[i].second){
			swap(data[i].first, data[i].second);
		}
	}

	sort(data.begin(), data.end());
	//for(int i=0;i<6;i++)printf("(%d,%d)\n",data[i].first, data[i].second);

	if( data[0]!=data[1] || data[2]!=data[3] || data[4]!=data[5]){
		cout<<"no"<<endl;
		return 0;
	}

	vector<P> tmp(3);

	for(int flag=0;flag<8;flag++){
		tmp[0]=data[0];		tmp[1]=data[2];		tmp[2]=data[4];
		for(int i=0;i<3;i++){
			if((flag>>i)&1)swap(tmp[i].first, tmp[i].second);
		}
		//(x,y)(y,z)(x,z)になる時があるはず

		if(tmp[0].first==tmp[2].first
			&& tmp[0].second==tmp[1].first
				&& tmp[1].second==tmp[2].second){
					cout<<"yes"<<endl;
					return 0;
		}


	}


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



Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll ideg[100010];//入次数

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	ll vcnt,ecnt;
	E  e[200010];//適宜変える
	ll id[100010];//適宜変える
}G;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

G g;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[i].s=x;
		g.e[i].g=y;
		ideg[y]++;
	}
	g.vcnt=n;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);
//	qsort(g.e,g.ecnt,sizeof(E),csort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//一応番兵
}

ll st[100010],ptr;//トポソした結果
void toposo(){
	rep(i,0,g.vcnt)if(ideg[i]==0)st[ptr++]=i;
	rep(i,0,g.vcnt){
		ll v=st[i];
		rep(j,g.id[v],g.id[v+1]){
			ideg[g.e[j].g]--;
			if(ideg[g.e[j].g]==0)st[ptr++]=g.e[j].g;
		}
	}
}

int flag[100010];
int dp[100010];
ll calc(int k){
	if(flag[k])return dp[k];
	flag[k]=1;
	ll ans=0;
	rep(i,g.id[k],g.id[k+1]){
		ll temp=calc(g.e[i].g)+1;
		ans=max(ans,temp);
	}
	return dp[k]=ans;
}

int main(){
	readgraph();
	toposo();
	ll ans=0;
	rep(i,0,g.vcnt){
		ll temp=calc(st[i]);
		ans=max(ans,temp);
	}
//	rep(i,0,g.vcnt)printf("%d ",dp[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11232
a, b, c = [int(s) for s in input().split(' ')]

cnt5 = 0
cnt7 = 0
for num in [a, b, c]:
    if num == 5:
        cnt5 += 1
    if num == 7:
        cnt7 += 1

if cnt5 == 2 and cnt7 == 1:
    print('YES')
else:
    print('NO')

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

int main(){
  int N,M;cin>>N>>M;
  string S;cin>>S;
  int i=N;
  vector<int> ans;
  while(i!=0){
    int l=(i-M>0?i-M:0);
    while(S[l]=='1'){
      l++;
      if(l==i){cout<<-1;return 0;}
    }
    ans.push_back(i-l);
    i=l;
  }
  for(int j=ans.size()-1;j>=0;j--){
    cout<<ans[j]<<" ";
  }
}





Measured memory_bytes: 1144
n = int(input())

for h in range(1, 3501):
    for w in range(h, 3501):
        bns = n * h * w
        bnb = 4 * h * w - n * (h + w)
        if bnb >= 1 and bns % bnb == 0:
            print(h, w, bns // bnb)
            exit()


Measured memory_bytes: 8924
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e8;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-18;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int ldist[210][210];
int sdist[210][210];
int dp[210], dp2[210];

int main() {
	while (true) {
		int n, m;	cin >> n >> m;
		if (n == 0)	break;
		rep(i, n)	rep(j, n)	ldist[i][j] = sdist[i][j] = (i == j ? 0 : inf);
		rep(i, m) {
			int x, y, t;	char sl;	cin >> x >> y >> t >> sl;
			x--;	y--;
			if (sl == 'L')	ldist[x][y] = ldist[y][x] = min(ldist[x][y], t);
			else	sdist[x][y] = sdist[y][x] = min(sdist[x][y], t);
		}
		rep(k, n)	rep(i, n)	rep(j, n) {
			ldist[i][j] = min(ldist[i][j], ldist[i][k] + ldist[k][j]);
			sdist[i][j] = min(sdist[i][j], sdist[i][k] + sdist[k][j]);
		}
		int r;	cin >> r;
		vint z(r);
		rep(i, r) {
			cin	>> z[i];	z[i]--;
		}
		rep(i, n)	dp[i] = (i == z[0] ? 0 : inf);
		srep(i, 1, r) {
			rep(j, n)	dp2[j] = dp[j] + ldist[z[i - 1]][z[i]];
			rep(j, n)	rep(k, n) {
				dp2[j] = min(dp2[j], dp[k] + ldist[z[i - 1]][k] + sdist[k][j] + ldist[j][z[i]]);
			}
			rep(j, n)	dp[j] = dp2[j];
		}
		int ret = inf;
		rep(i, n)	ret = min(ret, dp[i]);
		cout << ret << endl;
	}
	return 0;
}

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

using namespace std;

long long modpow(long long a, long long n, long long mod){
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


int main(){
  long long int n;
  cin>>n;
  long long int loN=1000000007;
  long long int a[n];
  bool judge=true;
  for(int i=0; i<n; i++) cin>>a[i];
  sort(a,a+n);
  
  for(int i=0; i<n; i++){
    if(n%2!=0 and a[0]!=0){
      judge=false; 
      break;
    } else if(n%2!=0 and a[i]!=2*int((i+1)/2)){
      judge=false;
      break;
    }
    
    if(n%2==0 and a[i]!=2*int(i/2)+1){ 
      judge=false;
      break;
    }
  }

  if(judge) cout<<modpow(2, int(n/2), loN)<<endl;
  else cout<<0<<endl;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

bool a[26], b[26];
int cnt = 0;
set<string> st;

int main() {
  // 入力
  string s;
  cin >> s;

  for (char c : s) {
    if (!a[c-'a']) {
      a[c-'a'] = 1;
      cnt++;
    }
  }

  if (cnt == 26) {
    for (int i = 1; i < s.size(); i++) {
      b[s[i-1]-'a'] = 1;
      for (char c = s[i-1]; c <= 'z'; c++) if (!b[c-'a']) {
        if (s[i-1] < c) {
          char tmp = s[i-1];
          s[i-1] = c;
          st.insert(s.substr(0, i));
          s[i-1] = tmp;
          break;
        }
      }
    }
    if (st.size() == 0) {
      cout << -1 << endl;
    } else {
      cout << *st.begin() << endl;
    }
  } else {
    cout << s;
    for (char c = 'a'; c <= 'z'; c++) if (!a[c-'a']) {
      cout << c << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static List<Edge>[] list;
	static long[] dist;

	static class Edge {
		int to;
		long cost;
		public Edge(int to, long cost) {
			this.to = to;
			this.cost = cost;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		list = new ArrayList[n];
		dist = new long[n];
		for(int i = 0; i < n; i++) list[i] = new ArrayList<>();
		for(int i = 0; i < n - 1; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			long c = sc.nextLong();
			list[a].add(new Edge(b, c));
			list[b].add(new Edge(a, c));
		}
		int q = sc.nextInt();
		int k = sc.nextInt() - 1;
		dfs(k, -1, 0);
		for(int i = 0; i < q; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			System.out.println(dist[x] + dist[y]);
		}
	}

	static void dfs(int v, int p, long d) {
		dist[v] = d;
		for(Edge e : list[v]) {
			if(e.to != p) {
				dfs(e.to, v, d + e.cost);
			}
		}
	}

}


Measured memory_bytes: 183868
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
 
typedef long long ll;


int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	for(int i=0;i<s.size();++i){
		char tmp = 'A' +(((s[i] -'A') + n)%26);
		cout << tmp;
	}cout << endl;
	
	return 0;
}



Measured memory_bytes: 256
import math

k = int(input())
gusu = math.floor(k/2)
kisu = math.ceil(k/2)

# n個からr個を選ぶ組み合わせを算出する
def combinations_count(n, r):
   return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = combinations_count(gusu,1)*combinations_count(kisu,1)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

void solve()
{
    char a;
    cin>>a;
    if(a>='A' && a<='Z')
    {
        cout<<'A'<<endl;
    }
    else
    {
        cout<<'a'<<endl;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3804
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;

typedef long long LL;
int add(int a, int b, int c) {
    int res = a + b;
    return (res >= c ? res - c : res);
}

int mod_neg(int a, int b, int c) {
    int res; if(abs(a-b) < c) res = a - b;
    else res = (a-b) % c;
    return (res < 0 ? res + c : res);
}

int mul(int a, int b, int c) {
    LL res = (LL)a * b;
    return (res >= c ? res % c : res);
}

template <typename T>T power(T e, T n, T m) {
    T x = 1, p = e;
    while(n) {
        if(n & 1) x = mul(x, p, m);
        p = mul(p, p, m);
        n >>= 1;
    }
    return x;
}

template<typename T> T extended_euclid(T a, T b, T &x, T &y) {
    T xx = 0, yy = 1; y = 0; x = 1;
    while(b) {
        T q = a / b, t = b;
        b = a % b; a = t;
        t = xx; xx = x - q * xx;
        x = t; t = yy;
        yy = y - q * yy; y = t;
    }
    return a;
}

template<typename T> T mod_inverse(T a, T n) {
    T x, y, z = 0; 
    T d = extended_euclid(a, n, x, y);
    return (d > 1 ? -1 : mod_neg(x, z, n));
}

int main() 
{
    int n,p;
    scanf("%d %d",&n,&p);
    int cnt0=0,cnt1=0;
    for(int i=1;i<=n;i++)
    {
        int a;
        scanf("%d",&a);
        if(a%2)
        {
            cnt1++;
        }
        else
        {
            cnt0++;
        }
    }
    if(p==1&&cnt1==0)
    {
        printf("0\n");
        return 0;
    }
    LL ans1=1ll<<(max(0,cnt1-1));
    LL ans2=1ll<<(cnt0);
    printf("%lld\n",ans1*ans2);
    return 0;
}

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

int main(void)
{
    char s[150] = {0};
    int len = 0;
    scanf("%s",s);
    len = strlen(s);
    printf("%c%d%c\n",s[0],len-2,s[len-1]);
    
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <climits>
#include <string>
#include <vector>

using namespace std;

int main () {
    int n = 0;
    long long y = 0;
    cin >> n >> y;
    y /= 1000;
    for (int i=0; i<=n; i++) {
        for (int j=0; j<=n; j++) {
            if (i + j > n) continue;
            if (i * 10 + j * 5 + (n - i - j) == y) {
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

int n, m;

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

	cin >> n >> m;

	int ans = 100*(n-m) + 1900*m;

	cout << ans * pow(2, m) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int n;
    cin >> n;
    map<int,int> m;
    vector<int> v(n);              
    rep(i,n){
        int tmp;
        cin >> tmp;
        v[i] = tmp;
        m[tmp]++;
    }
    ll ans=0;
    
    for (auto w:m){
        ans+=(ll)(w.second)*(w.second-1)/2;
        //printf("ans %lld w %d\n",ans,w.first);
    }

    //cout << ans << endl;
    rep(i,n){
        ll tmp = ans;
        if (m[v[i]] == 2) {
            tmp--;
        }else{
            tmp -= ll(m[v[i]] - 1);
        }
        cout << tmp << endl;
    }


    
    return 0;
    
}

Measured memory_bytes: 9984
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 1e5 + 5;
struct Node {
    int val, id;
    bool operator < (const Node &rhs) const {
        return val < rhs.val;
    }
}a[maxn];

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read();
    rep(i, 1, n) {
        a[i].val = read();
        a[i].id = i;
    }
    sort(a + 1, a+ 1 + n);
    rep(i, 1, n) {
        printf("%d ", a[i].id);
    }
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;
string so[10]=
  {
    "* = ****",
    "* =* ***",
    "* =** **",
    "* =*** *",
    "* =**** ",
    " *= ****",
    " *=* ***",
    " *=** **",
    " *=*** *",
    " *=**** "
  };

int main() {
  string s;
  char start[8][6] = {
    "*****",
    "     ",
    "=====",
    "     ",
    "*****",
    "*****",
    "*****",
    "*****"
  };
  
  char grid[8][6];
  bool blink = 0;
  while(cin >> s) {
    if(blink) cout << endl;
    blink = 1;
    for(int i=0; i<8; i++)
      for(int j=0; j<6; j++)
	grid[i][j] = start[i][j];
    
    int const size = s.size();
    int const OFFSET = 5-s.size();
    
    for(int j=0; j<5-OFFSET; j++)
      for(int i=0; i<8; i++)
	grid[i][j+OFFSET] = so[(int)(s[j]-'0')][i];
    
    for(int i=0; i<8; i++) {
      cout << grid[i] << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1184
l, r = list(map(int,input().split()))
mod = 2019
min = 2019
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        if min > (i * j) % mod:
            min = (i * j) % mod
        if min == 0:
            print(0)
            exit()
print(min)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
	int m,d; cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= m; i++){
		for (int j = 1; j <= d; j++){
			int k1 = j%10, k2 = j/10;
			if (k1 >= 2 && k2 >= 2 && k1*k2 == i){
				ans++;
			}

		}
	}
	cout << ans << endl;
}
 


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
def main():
    N = I()
    s_list = []
    for i in range(N):
        s = S()
        s_list.append(s)
    c = Counter(s_list)
    a = max(c.values())
    ans_list = []
    for key in c.keys():
        if c[key] == a:
            ans_list.append(key)
    ans_list.sort()
    for ans in ans_list:
        print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 148132
#演習2-24
import sys
sys.setrecursionlimit(10**6)

def dfs(x,y):
    c[x][y] = 0
    for dx in range(-1,2):
        for dy in range(-1,2):
            nx = x + dx
            ny = y + dy
            
            if 0 <= nx < h and 0 <= ny < w and c[nx][ny] == "1":
                dfs(nx,ny)
                

while 1:
    w,h = map(int,input().split())
    c = [input().split() for _ in range(h)]
    
    if w == 0 and h == 0:
        break
    cnt = 0
    for i in range(h):
        for j in range(w):
            if c[i][j] == "1":
                dfs(i,j)
                cnt += 1

    print(cnt)
    



Measured memory_bytes: 7988
#include <stdio.h>
int main(void){
    char str;

    for( int i = 0 ; i <= 1200 ; i++ ){
        scanf( "%c" , &str);
        if( str == '\n'){ break; }
        if( 'A' <= str && str <= 'Z' ){
            str += 32;
        }else if( 'a' <= str && str <= 'z' ){
            str -= 32;
        }
        printf( "%c" , str );
    }
    printf("\n");
}


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

int main() { 
int K, s;
string S;
cin >>K >>S;
s =S.size();
  if(s<=K)cout <<S<<endl;
 else{
   for(int i=0;i<s;i++){
   cout <<S.at(i);
     if(i==K-1){
     cout << "..."<<endl;
     break;
     }
   }
  }
}

Measured memory_bytes: 3628
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int a, b; cin >> a >> b;
	cout << a * b << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
long long int lucas(int n){
	long long int l=2,l2=1,cnt=1,L;
	if(n==1)return 1;
	
	while(cnt != n){
		L = l + l2;
		l = l2;
		l2 = L;
		cnt++;
	}
	
	return L;

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

	cout<< lucas(n) <<endl;

	return 0;
}


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

using namespace std;

#define intt long long

const int N = 15;
const int M = 1005;

int n, m, k;
int a[N][M];
int cur[N], tmp[N];

int main() {

	cin >> n >> m >> k;

	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			char x;
			cin >> x;
			a[i][j] = int(x) - '0';
		}
	}

	int ans = INT_MAX;

	for (int mask = 0; mask < (1 << (n - 1)); mask ++) {

		int cuts = __builtin_popcount(mask);
		bool flag = true;
		memset(cur, 0, sizeof(cur));

		for (int j = 0; j < m && flag; j ++) {

			int idx = 0;
			memset(tmp, 0, sizeof(tmp));

			for (int i = 0; i < n; i ++) {
				tmp[idx] += a[i][j];

				// difference here
				if (mask & (1 << i)) {
					idx ++;
				}
			}

			for (int i = 0; i < n; i ++) {
				if (tmp[i] > k) {
					flag = false;
					break;
				}
			}

			bool mark = 0;
			for (int i = 0; i < n; i ++) {
				if (cur[i] + tmp[i] > k) {
					mark = 1; // if sum is more than k, then, cut there
				}
			}
			cuts += mark;
			if (mark) {
				for (int i = 0; i < n; i ++) {
					cur[i] = tmp[i]; // if we cut here, then, the total sum starts from here's sum
				}
			}
			else {
				for (int i = 0; i < n; i ++) {
					cur[i] += tmp[i]; // if we don't cut there, then, we increase its prefix sum
				}
			}
		}
		if (flag) {
			ans = min(ans, cuts);
		}
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
4 2
5 2
2 1
8 3

output:
13
"""

import sys
from collections import namedtuple


def solve():
    for i, item in enumerate(item_list, 1):
        for cp in range(1, real_cp + 1):
            if item.w <= cp:
                # if item.v + values[i - 1][cp - item.w] > values[i - 1][cp]:
                #     values[i][cp] = item.v + values[i - 1][cp - item.w]
                #     # chosen[i][cp] = True
                # else:
                values[i][cp] = max(values[i - 1][cp], item.v + values[i - 1][cp - item.w])
                # chosen[i][cp] = False
            else:
                values[i][cp] = values[i - 1][cp]
                # chosen[i][cp] = False
    return values[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_items, real_cp = map(int, _input[0].split())
    items = map(lambda x: x.split(), _input[1:])

    Item = namedtuple('Item', 'v w')
    # item_list = [Item(v=-1, w=-1)] + [Item(v=int(v), w=int(w)) for v, w in items]
    item_list = [Item(v=int(v), w=int(w)) for v, w in items]

    # chosen = [[False] * (real_cp + 1) for _ in range(c_items + 1)]
    values = [[0] * (real_cp + 1) for _ in range(c_items + 1)]
    ans = solve()
    print(ans)

Measured memory_bytes: 27840
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int t[250000]={0},m=0,n;
	while(cin>>n){
		t[n]++;
		if(t[n]>m)m=t[n];
	}
	for(int i=0;i<250000;i++){
		if(t[i]==m)cout<<i<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
long long n, s[104];
 
void solve(){
    cin>>n;
    for(int i = 0; i < n; i++)
        cin>>s[i];
    int cnt = 0;
    
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++)
            for(int k = j+1; k < n; k++)
                if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i] && s[i]+s[j]+s[k] > 2 * max(s[i], max(s[j], s[k])) )
                    cnt++;
    cout<<cnt;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TC;
    //cin>>TC;
    TC=1;
    while(TC--){
        solve();
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll a,b;
    cin >> a >> b;
    if (a <= 5)
    {
        cout << 0 << endl;
    }
    else if (a <= 12)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << b << endl;
    }
}

Measured memory_bytes: 256
N,K=map(int, input().split(" "))
s=input().split(" ")
i=N

while i < 10*N:
    j = list(str(i))
    if not set(j).isdisjoint(set(s)): #NがSを含むとき
        i += 1
    else:
        print(i)
        break

Measured memory_bytes: 9080
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int main() {

  int n;
  cin >> n;
  vector<ll> a(n);
  for (ll& x : a) cin >> x;
  sort(a.rbegin(), a.rend());

  // 1 4 2 5 3
  // 1 4 2 5 3 6
  ll ans = 0;
  rep(i, 0, n - 1) ans += a[(i + 1) / 2];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4824
A,B,C,X = [int(input()) for x in range(4)]

count = 0
for a in range(0, A+1):
    Xa = X - 500 * a
    if Xa < 0:
        break
    for b in range(0, B+1):
        Xab = Xa - 100 * b
        if Xab < 0:
            break
        for c in range(0, C+1):
            if Xab - 50 * c == 0:
                count += 1
                break
print(count)

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

int N, M, Q, A[50], B[50], C[50], D[50];

int rec(int nowD, int retsu[10], int tsugi)
{
	int ans = 0;
	if (nowD == N)
	{
		int nowans = 0;
		for (int i = 0; i < Q; ++i)
		{
			if (retsu[B[i] - 1] - retsu[A[i] - 1] == C[i])
			{
				nowans += D[i];
			}
		}
		return nowans;
	}
	else
	{
		for (int i = tsugi; i <= M; ++i)
		{
			retsu[nowD] = i;
			ans = max(rec(nowD + 1, retsu, i), ans);
			retsu[nowD] = 0;
		}
	}
	return ans;
}

int main()
{
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; ++i)
	{
		cin >> A[i] >> B[i] >> C[i] >> D[i];
	}
	int retsu[10] = {1,2,3,4,5,6,7,8,9,10};
	cout << rec(0, retsu, 1) << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int H, W, N;
    cin >> H;
    cin >> W;
    cin >> N;
    int t = max(H, W);
    if (N % t == 0) {
        cout << N/ t << endl;
    } else {
        cout << N / t + 1 << endl;
    }
}

Measured memory_bytes: 256
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)1e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

int dp[N], a[N], n, k;
int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        n = Int, k = Int;
        for(int i = 0 ; i < n ; ++i)a[i] = Int, dp[i] = inf;
        dp[0] = 0 ;
        for(int i = 0 ; i < n ; ++i){
            for(int j = 1 ; j <= k ; ++j){
                if(i + j < n)dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j])) ;
            }
        }
        cout << dp[n - 1] << '\n' ;
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




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

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int m = ni(), n = ni();

        long MOD = 1000000007;

        Modulo mo = new Modulo(MOD);

        out.println(mo.pow(m, n));
    }

    class Modulo {
        long m;

        Modulo(long m) {
            this.m = m;
        }

        long add(long a, long b) {
            return (a + b) % m;
        }

        long sub(long a, long b) {
            return (a - b + m) % m;
        }

        long mlt(long a, long b) {
            return (a * b) % m;
        }

        long rev(long a) {
            return pow(a, m - 2);
        }

        long pow(long a, long x) {
            long ans = 1;
            while (x > 0) {
                if ((x & 1) != 0) {
                    ans = (ans * a) % m;
                }
                x >>= 1;
                a = (a * a) % m;
            }
            return ans;
        }

        long det(long[][] a) {
            int n = a.length;
            long det = 1;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    while (a[j][i] != 0) {
                        long r = a[i][i] / a[j][i];
                        for (int k = i; k < n; k++) {
                            long t = (a[i][k] - r * a[j][k]) % m;
                            a[i][k] = a[j][k];
                            a[j][k] = t;
                        }
                        det = -det;
                    }
                }
                det = (det * a[i][i]) % m;
            }
            return det;
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24508
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

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

  long ans = 0;
  for(int i=1; i<n; i++) {
    ans += a[i / 2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4052
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef map<ll,ll> M;

#define REP(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define FOR(i,j,n) for(ll (i) = (j); (i) < (n); ++(i))
#define REPR(i,n) for(ll (i) = (n); (i) >= 0; --i))


signed main(){
    int y1,m1,d1,y2,m2,d2;
    cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
    --m1;--d1;--m2;--d2;
    V turn = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    V turn2 = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    int ans = 0;

    int age1 = 3000 - y1;
    int age2 = 3000 - y2;
    REP(i,12){
        REP(j, turn[i]){
            ans = max(ans, abs(age1 - age2));
            if((m1 == i && d1 == j) || (m1 == 2 && d1 == 29 && i == 3 && j == 1))
                ++age1;
            if((m2 == i && d2 == j) || (m2 == 2 && d2 == 29 && i == 3 && j == 1))
                ++age2;
            ans = max(ans, abs(age1 - age2));
        }
    }

    age1 = 3000 - y1;
    age2 = 3000 - y2;
    REP(i,12){
        REP(j, turn2[i]){
            ans = max(ans, abs(age1 - age2));
            if(m1 == i && d1 == j)
                ++age1;
            if(m2 == i && d2 == j)
                ++age2;
            ans = max(ans, abs(age1 - age2));
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3168
S = "keyence"
ss = gets.chomp.split('')
len = ss.length
ans = false
(0...len).each do |i|
  (i...len).each do |j|
    if (ss[0..i] + ss[j...len]).join == S
      ans = true
      break
    end
  end
  break if ans
end
puts ans ? "YES" : "NO"


Measured memory_bytes: 2300
#include <iostream>
using namespace std;
int main(){
	int a,b; int count=0;
	while(1){
		cin >> a >> b ;
		if(a==0 && b==0) break;
		if(count++) cout << '\n' ;
		int* ans=new int[(b-a+1)/4];int n=0;
		for(int i=a;i<=b;i++) if((i%4==0 && i%100!=0) || i%400==0) ans[n++]=i;
		if(n==0) cout << "NA\n" ;
		else for(int j=0;j<n;j++) cout << ans[j] << '\n';
	};
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmax(T &a,const T b){if(a < b){a=b; return true;} return false;}
template<typename T> bool chmin(T &a,const T b){if(a > b){a=b; return true;} return false;}

int main(){
    int n; cin >> n;
    vi h(n);
    for(auto &x: h) cin >> x;
    int ans=0;
    for(int i=0; i<n; i++){
        int pos=i+1;
        while(pos < n && h[pos] <= h[pos-1]){
            pos++;
        }
        ans=max(ans, pos-i-1);
        i=pos-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
//#define int long long
int get(string &s1, string &s2){
	int ans = 0;
	for(int i=0; i < sz(s1); i++){
		ans += s1[i] != s2[i];
	}
	return ans;
}
int32_t main()
{
   string s; cin >> s;
   string t; cin >> t;
   int st = sz(t);
   int ans = 1e9 ;
   // cout << s.substr(1,2);
   for(int i=0; i < sz(s)- sz(t) + 1; i++){
   	// dbg(i);
   	string temp = s.substr(i,(int)sz(t));
   	int val = get(t,temp);
   	ans = min(ans, val) ;
   }
   cout << ans;nl;

}

Measured memory_bytes: 3624
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

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

  if(S.at(S.size()-1)=='s') cout << S << "es" << endl;
  else cout << S << "s" << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, x;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x;
		a.push_back(x);
	}

	sort(a.begin(), a.end());
	for (int i = 1; i < n; i++){
		if (a[i] == a[i-1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1528
from heapq import heappush, heappop

def prim(G):
    n = len(G)
    heap = []
    s = 0
    for v, c in G[s].items():
        heappush(heap, (c, v))
    added = set()
    added.add(s)
    cost = 0
    while len(added) < n:
        cu, u = heappop(heap)
        if u in added:
            continue
        added.add(u)
        cost += cu
        for v, c in G[u].items():
            if v in added:
                continue
            heappush(heap, (c, v))
    return cost

n = int(raw_input())
G = {}
for i in range(n):
    if i not in G:
        G[i] = {}
    row = map(int, raw_input().strip().split(' '))
    for j in range(n):
        if row[j] == -1:
            continue
        G[i][j] = row[j]
        if j not in G:
            G[j] = {}
        G[j][i] = row[j]


cost = prim(G)
print cost

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

int main() {
	int n;
	cin >> n;
	vector<int> dp(3, 0);
	for(int i = 0; i < n; i++){
		vector<int> new_dp(3, 0);
		int c[3];
		for(int j = 0; j < 3; j++){
			cin >> c[j];
		}
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(i != j){
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
				}
			}
		}
		dp = new_dp;
	}
	cout << *max_element(dp.begin(), dp.end()) << "\n";
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

    int N = Integer.parseInt(sc.next());

    int[] p = new int[N];
    for (int i = 0; i < N; i++) {
      p[i] = Integer.parseInt(sc.next());
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (p[i] != i+1) {
        cnt++;
      }
    }

    System.out.println(cnt <= 2 ? "YES" : "NO");
  }
}

Measured memory_bytes: 23764
//  IT'S NEVER TOO LATE...

		    #include <bits/stdc++.h>
			#include <complex>
		    #define ll long long

			#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
			#define forn(i, n) fore(i, 0, n)
			#define fori(i, l, r) fore(i, l, (r) + 1)
			#define sz(v) int((v).size())
			#define all(v) (v).begin(), (v).end()
			#define pb push_back
			#define mp make_pair
		    #define ff first
		    #define ss second
		    
			//#define C complex<int>
			#define X real()
			#define Y imag()

		    using namespace std; 

		    const double PI = atan(1)*4;
		    #define inf 1e9
		    const int mod=1e9+7;


		    /*struct matrix
		    {
		    	int k;
		    	vector<vector<ll>> data;
		    	matrix(int x)
		    	{
		    		k=x;
		    		data.resize(x);
		    		forn(i,x)
		    		data[i].resize(x);
		    	}

		    	matrix operator *(matrix m1)
		    	{
		    		int n=m1.data.size();
		    		matrix m2(n);

		    		forn(i,n)
		    		{
		    			forn(j,n)
		    			{
		    				forn(k,n)
		    				{
		    					m2.data[i][k]+=((m1.data[i][j]%1000000007)*(data[j][k]%1000000007))%1000000007;
		    					m2.data[i][k]%=1000000007;
		    				}
		    			}
		    		}


		    		return m2;
		    	}
		    };*/

		    /*bool comp(pair<int,int> a,pair<int,int> b)
		    {
		    	return ((double)a.ff/a.ss) < ((double)b.ff/b.ss) ;
		    }

		    int dp[100][100],val[100],wt[100];
		    int knapsack(int n,int cap)
		    {
		    	if(n==0 || cap==0)
		    		return 0;
		    	if(dp[n][cap])
		    		return dp[n][cap];
		    	if(wt[n-1]<=cap)
		    	{
		    		return dp[n][cap]=max(knapsack(n,cap-wt[n-1]) + val[n-1], knapsack(n-1,cap));
		    	}
		    	else
		    		return dp[n][cap]= knapsack(n-1,cap);
		    }*/

		    int main()
		    {
		    	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		     
		    	#ifndef ONLINE_JUDGE
		        freopen("input.txt","r", stdin);
		        freopen("output.txt", "w", stdout);
		        #endif
		     
		    	int tt=1;
		    	//cin>>tt;
		    	
		    	while(tt--)
		    	{
		    		//matrix mat(n),m2(n);
		    		
		    		int n,x,t;
		    		cin>>n>>x>>t;

		    		cout<<(ll)ceil((float)n/x)*t;
		    	}
		    	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";

		    	return 0;
		    }
		    				//              NOW IT'S TIME TO WAKE UP... 

Measured memory_bytes: 3792
#include <iostream>
using namespace std;
int main(){
    int N,a=0;
    cin >> N;
    for(int i=1;i<N+1;i++){
        if(i<10)a++;
        else if(i>=100 && i<1000)a++;
        else if(i>=10000 && i<100000)a++;
    }
    cout << a;
}

Measured memory_bytes: 256
import math
import sys

def main():
    a = []
    s = 0
    for _ in range(5):
        n = int(input())
        a.append(n)
        s += math.ceil(n/10)*10
    ans = sys.maxsize
    for n in a:
        ans = min(ans,s - math.ceil(n/10)*10 + n)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060