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

const long long MOD = 1000000007;

void solve(long long N)
{
    long long pow = 1;
    for (long long i = 1; i <= N; i++)
    {
        pow *= i;
        pow %= MOD;
    }
    cout << pow << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    string s,t;
    cin >> s >> t;
    if (s + t.at(t.length() - 1) == t ) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 1002

typedef long long ll;

int max(int a,int b){
    if(a>b) return a;
    else return b;
}

int min(int a,int b){
    if(a<b) return a;
    else return b;
}

/*qsort(array,num_of_index,sizeof(int),compare_int); */
 int compare_int(const void *a,const void *b){
     return *(int*) a - *(int *) b; 
 } 
 
int b_search(int* array,int left,int right,int key){
    int mid = left + (right - left)/2;
     if( right - left == 1){
         if(array[mid]==key)
             return mid;
          else
               return -1;
     }
     if(array[mid]==key)
         return mid;
     else if(array[mid]>key)
         b_search(array,left,mid,key);
     else if(array[mid]<key)
         b_search(array,mid,right,key);
}

/*lower_bound(key以上のイテレータを返す)*/
 /*例えば,2,2,5,5,9でkey=2なら(2),2,5,5,9を返す*/
 int lower_bound(int  *array,int left,int right,int key){
     if(right-left==1)
         return left;
     int mid = left + (right - left)/2;
     if(array[mid]<key)
         return lower_bound(array,mid,right,key);
     else
         return lower_bound(array,left,mid,key);
 }

int main(){
    char S[MAX],T[MAX];
    scanf("%s",S);
    scanf("%s",T);
    int ans = strlen(T);
    for(int i=0;i<=strlen(S) - strlen(T);i++){
        char buf[MAX];
        strncpy(buf,S+i,(size_t)strlen(T));
        int ans_buf = 0; 
        for(int j=0;j<strlen(T);j++){
            if(T[j] != buf[j])
                ans_buf++;
        }
        ans = min(ans,ans_buf);
            
    }
    printf("%d",ans);
}


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

int main() {
  int N;
  cin >> N;
  
  int answer = 1;
  
  for (int i = 0; i < N; i++) {
    if (N < answer) break;
    else answer *= 2;
  }
  
  cout << answer/2 << endl;
  
}

Measured memory_bytes: 256
//h08-3 ダーツ
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#include<boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -21474836487
#define INT_MAX 2147483647
#define LL_MIN -922337203685477580
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)




int main(){
    ROOP(){
        LL N,M;//Mを超えちゃだめ
        cin >> N >> M;
        if(N==0 && M==0) break;

        vector<LL> P;
        P.push_back(0);
        for(LL i=0; i<N; i++){
            LL tmp;
            cin >> tmp;
            if(tmp <= M) P.push_back(tmp);
        }

        vector<LL> f;
        for(LL i=0; i<P.size(); i++){
            for(LL j=0; j<P.size(); j++){
                LL tmp = P[i] + P[j];
                if(tmp <= M) {
                    f.push_back(tmp);
                    //cout << tmp << endl;
                }
            }
        }
        //cout << "=" << endl;

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

        LL ans = 0;     
        for(LL i=0; i<f.size(); i++){
            LL tmp = M - f[i];
            auto itr = upper_bound(f.begin(),f.end(),tmp);
            itr--;
            ans = max(ans , f[i] + *itr);
        }
        cout << ans << endl;
        //cout << "==" << endl;
        
    }
    
}


Measured memory_bytes: 18888
program coprime
  implicit none
  integer :: n, m, c, p, i
  integer, allocatable :: a(:), b(:)
  character(8), parameter :: x = 'pairwise', y = 'setwise ', z = 'not     '
  read(*,*) n
  allocate(a(n))
  read(*,*) a
  m = maxval(a(1:n))
  allocate(b(m))
  b = 0
  do i = 1, n
    c = a(i)
    p = 2
    do while (p * p <= c)
      if (mod(c, p) == 0) then
        b(p) = b(p) + 1
        do while (mod(c, p) == 0)
          c = c / p
        end do
      end if
      p = p + 1
    end do
    if (c /= 1) b(c) = b(c) + 1
  end do
  write(*,'(a)') trim(merge(x, merge(y, z, all(b < n)), all(b < 2))) // ' coprime'
end program coprime

Measured memory_bytes: 10832
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

class BIT {
	int[] data;
	this(int n) {
		data = new int[n+1];
	}
	BIT dup() {
		BIT ret = new BIT(to!int(data.length));
		ret.data = data.dup;
		return ret;
	}
	void add(int i, int x=1) {
		i++;
		while (i) {
			data[i] += x;
			i -= i&-i;
		}
	}
	int sum(int i) {
		int ret = 0;
		i++;
		while (i < data.length) {
			ret += data[i];
			i += i&-i;
		}
		return ret;
	}
}

void main() {
	int n;
	scanf("%d\n", &n);
	int[] b = new int[n];
	int[] w = new int[n];
	int m = n*2;
	foreach (i; 0..m) {
		char c;
		int a;
		scanf("%c %d\n", &c, &a);
		if (c == 'B') {
			b[a-1] = i;
		} else {
			w[a-1] = i;
		}
	}

	int[][] dp = new int[][](n+1,n+1);
	foreach (i; 0..n+1) dp[i][] = to!int(1e9);
	dp[0][0] = 0;

	BIT bit = new BIT(m);
	foreach (i; 0..n+1) {
		BIT _bit = bit.dup();
		foreach (j; 0..n+1) {
			if (i < n) dp[i+1][j] = min(dp[i+1][j], dp[i][j]+_bit.sum(b[i]));
			if (j < n) dp[i][j+1] = min(dp[i][j+1], dp[i][j]+_bit.sum(w[j]));
			if (j < n) _bit.add(w[j]);
		}
		if (i < n) bit.add(b[i]);
	}
	writeln(dp[n][n]);
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s;
    cin >> s;
    vector<int> alpha(26, 0);

    string ans = "None";
    int n = s.size();
    rep(i, n)
    {
        int num = s[i] - 'a';
        alpha[num]++;
    }

    rep(i, 26)
    {
        if (alpha[i] == 0)
        {
            ans = char(i + 'a');
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int a, b;
bool ok() {
  if ((b - 2 * a) % 2 != 0) return false;
  int y = (b - 2 * a) / 2;
  int x = a - y;
  return x >= 0 && y >= 0;
}

int main() {
  cin >> a >> b;
  cout << (ok() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3588
N = int(input())
m = dict()

prev = input()
m[prev] = True
flg = True

for _ in range(N - 1):
  s = input()
  flg = flg and s not in m
  flg = flg and prev[len(prev) - 1] == s[0]
  m[s] = True
  prev = s

print("Yes" if flg else "No")

Measured memory_bytes: 9188
//region Template
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
template<typename T> void debug_out(string name, T arg) { cerr<<name<<"="<<arg<<endl; }
template<typename T1, typename... T2> void debug_out(string name, T1 arg, T2... args) {
    cerr<<name.substr(0, name.find(','))<<"="<<arg<<", ";
    debug_out(name.substr(name.find(',') + 1), args...); }
#define debug(...) debug_out(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion



int main() {
    FASTIO

    int k,a,b; cin>>k>>a>>b;

    if(a%k==0 || b/k > a/k) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;

    

}

Measured memory_bytes: 3604
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 200000;

int n;
ll a[MAXN];

int cnt[18 + 1][18 + 1];

ll solve() {
	REPE(i, 18) REPE(j, 18) cnt[i][j] = 0;
	REP(i, n) {
		ll x = a[i];
		int cnt2 = 0; while (x % 2 == 0) x /= 2, ++cnt2;
		int cnt5 = 0; while (x % 5 == 0) x /= 5, ++cnt5;
		//printf("%lld: (%d,%d)\n", a[i], cnt2, cnt5);
		cnt2 = min(cnt2, 18); cnt5 = min(cnt5, 18);
		++cnt[cnt2][cnt5];
	}
	ll ret = 0;
	REPE(i, 18) REPE(j, 18) REPE(ii, 18) REPE(jj, 18) {
		if (ii < i || ii == i && jj < j) continue;
		if (i + ii < 18 || j + jj < 18) continue;
		if (ii != i || jj != j) {
			ret += (ll)cnt[i][j] * cnt[ii][jj];
		} else {
			ret += (ll)cnt[i][j] * (cnt[i][j] - 1) / 2;
		}
	}
	return ret;
}

void run() {
	scanf("%d", &n);
	REP(i, n) {
		char s[100]; scanf("%s", s); int slen = strlen(s);
		a[i] = 0; int ndecimal = 0; bool havepoint = false; REP(j, slen) if (s[j] == '.') havepoint = true; else { a[i] = 10 * a[i] + s[j] - '0'; if (havepoint) ++ndecimal; } assert(ndecimal <= 9); REP(j, 9 - ndecimal) a[i] *= 10;
	}
	printf("%lld\n", solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 5280
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

vi ans(1e6);
vector<bool> used(1e6, false);
vector<ll> A(1e6);
vector<vi> graph(1e6);

void dfs (int from, int cur, vll& dp){
    // update dp table
    auto it = lower_bound(ALL(dp), A[cur]);
    int rev = *it;
    *it = A[cur];

    ans[cur] = lower_bound(ALL(dp), inf) - dp.begin();

    // go to next nodes
    for(auto e: graph[cur]) {
        if (used[e]) continue;
        used[e] = true;
        dfs(cur, e, dp);
    }

    // revert
    *it = rev;
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    REP(i, N) cin >> A[i];

    REP(i, N - 1) {
        int u, v;
        cin >> u >> v, u--, v--;

        graph[u].pb(v);
        graph[v].pb(u);
    }

    vll dp(N, inf);
    used[0] = true;
    dfs(-1, 0, dp);

    REP(i, N) {
        print(ans[i]);
    }
    
}


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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;






void one_case() {
    ll x, y;
    cin >> x >> y;
    int res = 1;
    while (2 * x <= y) {
        x *= 2;
        ++res;
    }

    cout << res << "\n";
}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n, m, i, k, c = 0, j;
	int cut = 0, cut2 = 0;
	int *card, *damy, *riffle, *riffle2;

	cin >> n >> m;
	card = new int[n * 2];
	damy = new int[n * 2];
	riffle = new int [n];
	riffle2 = new int [n];

	for(i = 0; i < n * 2; i++){
		card[i] = i + 1;
	}
	for(i = 0; i < m; i ++){
		cin >> k;
		if(k != 0){
			for(j = 0; j < k; j ++){
				damy[j] = card[j];
			}
			for(j = k; j < n * 2; j ++){
				card[cut] = card[j];
				cut ++;
			}
			for(j = cut; j < n * 2; j ++){
				card[j] = damy[cut2];
				cut2 ++;
			}
			cut = 0; cut2 = 0;
		}
		else if(k == 0){
			for(j = 0; j < n; j ++){
				riffle[j] = card[j];
			}
			for(j = n; j < n * 2; j ++){
				riffle2[cut] = card[j];
				cut ++;
			}
			cut = 0;
			for(j = 0; j < n * 2; j ++){
				if(j % 2 == 0){
					card[j] = riffle[cut];
					cut ++;
				}
				else{
					card[j] = riffle2[cut2];
					cut2 ++;
				}
			}
			cut = 0; cut2 = 0;
		}
	}

	for(i = 0; i < n * 2; i ++){
		cout << card[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int a,b;cin>>a>>b;
    cout<<100<<" "<<100<<endl;
    rep(i,0,50){
        rep(j,0,100){
            if(i%2==0&&(i+j)%2==0&&a>1){
                cout<<'.';a--;
            }else cout<<'#';
        }cout<<endl;
    }
    rep(i,0,50){
        rep(j,0,100){
            if(i%2==1&&(i+j)%2==0&&b>1){
                cout<<'#';b--;
            }else cout<<'.';
        }cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, c, i, count;

  scanf("%d %d %d", &a, &b, &c);
  count = 0;
  for (i = a; i <= b; i++)
    if (c % i == 0)
      count++;
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int cnt[N + 5];
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0;i < n; ++i){
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	int maks = 0;
	for(int i = 0;i < N; ++i){
		int x = (i == 0) ? 0 : cnt[i-1];
		int y = cnt[i];
		int z = (i == N - 1) ? 0 : cnt[i + 1];
		maks = max(maks, x + y + z);
	}
	printf("%d\n", maks);
	return 0;
}

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

int main()
{
 int a,b;
 cin>>a>>b;
    if (a>b)
    {
        if((a-b)%2!=1)
        {
            cout<<b-((b-a)/2);
        }
        else
        {
            cout<<"IMPOSSIBLE";
        }
    }
    if (b>a)
    {
        if((b-a)%2!=1)
        {
            cout<<b-((b-a)/2);
        }
        else
        {
            cout<<"IMPOSSIBLE";
        }
    }
 
 return 0;
}

Measured memory_bytes: 256
a=input()
b=input()
al=len(a)
bl=len(b)
mn=1000
cnt=0
for i in range(0,al-bl+1):
    cnt=0
    for j in range(0,bl):
        if a[i+j]!=b[j]:
            cnt=cnt+1
    if mn>cnt:
        mn=cnt
print(mn)

Measured memory_bytes: 9028
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
using namespace std;
char mp[2][55];
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	str A, B, C;
	ios::sync_with_stdio(false); cin.tie(0);
	scanf("%lld %s %s", &a, mp[0], mp[1]);
	for (j = a; j >= 1; j--) {
		mp[0][j] = mp[0][j - 1];
		mp[1][j] = mp[1][j - 1];
	}
	if (mp[0][1] == mp[1][1]) b = 3;
	else b = 6;
	for (i = 2; i <= a; i++) {
		if (mp[0][i] != mp[1][i]) {
			if (mp[0][i - 1] != mp[1][i - 1] && mp[0][i - 1] != mp[0][i]) b = (b * 3) % mod;
			else if (mp[0][i - 1] == mp[1][i - 1]) b = (b * 2) % mod;
		} else {
			if (mp[0][i - 1] == mp[1][i - 1] && mp[0][i - 1] != mp[0][i]) {
				b = (b * 2) % mod;
			} 
		}
	}
	printf("%lld\n", b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    string s;
    cin >> s;
    int m[4] = {0};
    for(int i = 0; i < s.size(); i++){
        switch(s[i]){
            case 'N': m[0]++; break;
            case 'S': m[1]++; break;
            case 'W': m[2]++; break;
            case 'E': m[3]++; break;
        }
    }
    if(!(m[0] > 0 && m[1] > 0 || m[0] == 0 && m[1] == 0)){
        cout << "No" << endl;
    }else if(!(m[2] > 0 && m[3] > 0 || m[2] == 0 && m[3] == 0)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
V<int> e[N];
ll memo[2][N];
ll dfs(bool z, int a, int p){
  if(memo[z][a] >= 0) return memo[z][a];
  ll ret = 1;
  for(int b: e[a]) if(b != p){
    if(!z){
      ret = ret * (dfs(0, b, a) + dfs(1, b, a)) % MOD;
    }else{
      ret = ret * dfs(0, b, a) % MOD;
    }
  }
  return memo[z][a] = ret;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  Fill(memo, -1);
  FOR(i, 0, n-1){
    int x, y;
    cin >> x >> y;
    x--; y--;
    e[x].pb(y);
    e[y].pb(x);
  }
  cout << (dfs(0, 0, -1) + dfs(1, 0, -1)) % MOD << endl;
}

Measured memory_bytes: 15616
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endN "\n"

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

bool solve(){
  auto f=prime_table(55555);
  vector<ll>a;
  rep(i,55555){
    if(i%5!=1)continue;
    if(f[i])a.emplace_back(i);
  }
  ll n;cin>>n;
  rep(i,n)cout<<a[i]<<" ";
  cout<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, X, T;
    cin >> N >> X >> T;
    for (int i = 1; i < 1e5 + 5; i++) {
        // X * 2 = 24 6 *2 = 12
        if(N <= X * i) {
            cout << T * i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
from fractions import Fraction

N,M = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
sums = 0

for _ in range(N):
  sums += A[_]


for i in range(N):
  a = Fraction(A[i],sums)
  b = Fraction(1,4*M)
  if a >= b:
    ans += 1
  else:
    pass
  
  
  

if ans >= M:
  print('Yes')
  
else:
  print('No')
  

Measured memory_bytes: 5340
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, now = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a.at(i);
    for(int i = 0; i < n; i++){
        if(a[i] == now+1)now++;
    }
    if(now == 0)cout << -1;
    else cout << n-now;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vint etime(5);
int ans=0;
int endtime=0;

int main(){
    rep(i,5){
        cin>>etime[i];
        ans+=ceil((float)etime[i]/10)*10;
        if(etime[i]%10==0)continue;
        else endtime=max(endtime,10-etime[i]%10);
    }
    cout<<ans-endtime<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long LL;
const LL maxn=1e6+9,up=(1ll<<60ll);
LL n,ans;
LL a[maxn],lg[maxn],g[maxn];
int main(){
	scanf("%lld",&n);
	for(LL i=0;i<=n;++i){
		scanf("%lld",a+i);
	}
	LL flag(1);
	g[0]=1-a[0];
	for(LL i=1;i<=n;++i){
		g[i]=(g[i-1]<<1ll);
		g[i]=std::min(g[i],up);
		if(g[i]<a[i]){
			flag=0;
		}else g[i]-=a[i];
	}
	if(!flag || (!n && a[0]>1)){
		puts("-1");
		return 0;
	}else if(!n){
		printf("%lld\n",a[0]);
		return 0;
	}
	//lg[0]=1; for(LL i=1;i<=50;++i) lg[i]=(lg[i-1]<<1ll);
	LL nw=0;
	//for(LL i=0;i<=n;++i) printf("%lld ",g[i]); puts("");
	for(LL i=n;i>=0;--i){
			if(nw>g[i]) nw=g[i];
		nw+=a[i];
		ans+=nw;
		//printf(" #%lld\n",nw);
	}
	printf("%lld\n",ans);
}

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

using namespace std;


typedef long long ll;
#define loop(i, init, val) for(i = init; i < val; i++)
#define srt(v) sort(v.begin(), v.end())

int main(){
	int i, j, k;
	int h, n;
	cin >> h >> n;
	vector<pair<int, int>> e(n);
	loop(i, 0, n)	cin >> e[i].first >> e[i].second;

	int maxb = 0;
	loop(i,0,n)	maxb = max(maxb, e[i].second);
	vector<int> dp(h+maxb, -1); dp[0] = 0;

	loop(i, 1, h+maxb){
		 loop(j, 0, n){
			 int index = i - e[j].first;
			 if(index < 0 || dp[index] == -1)	continue;

			 if(dp[i] == -1) 	dp[i] = dp[index] + e[j].second;
			 else	dp[i] = min(dp[i], dp[index] + e[j].second);
		 }
	}

	int ans = INT_MAX;
	loop(i, h, h+maxb)	if(dp[i] != -1) ans = min(ans, dp[i]);
	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt() , y = sc.nextInt(), z = sc.nextInt();
		int temp = x ;
		x = y ;
		y = temp ;
		int temp2 = x;
		x = z ;
		z =temp2;
		System.out.println(x+" "+y+" "+z);
				
	}

}


Measured memory_bytes: 23508
#include <iostream>


using namespace std;

int main() {
    int n,sum1=0,sum2=0,sum=0,k;
    cin>>n;
    char str[n];
    cin>>str;
    for(int i=0;i<n;i++){
        if(str[i]=='W'){
            sum++;
        }
    }
    k=n;
    
    
	for(int i=0;i<n;i++){
	    if(str[i]=='W'){sum2++;}
	    
	    if(sum1+n-(i+1)-(sum-sum2)<k){ k=sum1+n-(i+1)-(sum-sum2);
	        k=sum1+n-(i+1)-(sum-sum2);
	    }
	    sum1=sum2;
	    
	}

	cout<<k;
}

Measured memory_bytes: 512
s = int(input())
A = []
A.append(s)
B = []
i = 2

while(1):
  if(A[-1]%2 == 0):
    a = A[-1]//2
  else:
    a = 3*A[-1] + 1
  A.append(a)

  B = list(set(A))
  if(len(A) != len(B)):
    m = i
    break
  i += 1
  
print(m)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int min_route(int i, int j, int X, int Y) {
  int min_route = j-i;
  min_route = min(min_route, abs(X-i) + 1 + abs(Y-j));
  return min_route;
}
int main()
{
  int N, X, Y;
  cin >> N >> X >> Y;
  int *ans = new int[N];
  for (int i = 0; i < N; i++) ans[i] = 0;
  
  for (int i = 1; i <= N-1; i++) {
    for (int j = i+1; j <= N; j++) {
      int k = min_route(i, j, X, Y);
      ans[k]++;
    }
  }
  
  for (int k = 1; k <= N-1; k++) {
    cout << ans[k] << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MAX_DIGIT = 60;
long long dp[100][2];

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << a * b / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {

	double N;
	cin >> N;
	double n=2,nn=1;
	vector<int> x(N);
	vector<int> y(N);
	
	rep(i, N) {
		cin >> x[i] >> y[i];
	}
	auto dis = [&](int i, int j) {
		double dx = x[i] - x[j];
		double dy = y[i] - y[j];

		return sqrt(dx * dx + dy * dy);
	};
	double len = 0;
	rep(i, N) {
		rep(j, i) {
			len += dis(i, j);
		}
	}
	for (int i = N - 1; i >= 1; --i)n *= i;
	for(int i = N; i >= 1; --i)nn *= i;
	double X = n;

	printf("%.10f\n", (X*len)/nn);
	return 0;
}

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

using namespace std;

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    string s = s1.substr(0, 1) + s2.substr(0, 1) + s3.substr(0, 1);
    transform(s.begin(), s.end(), s.begin(), ::toupper);
    cout << s << endl;

//    char diff = 'A' - 'a';
//    printf("%c%c%c\n", s1[0] + diff, s2[0] + diff, s3[0] + diff);
    return 0;
}

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

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

    char nb = n.back();
    if(nb == '3') cout << "bon" << endl;
    else if(nb == '0' || nb == '1' || nb == '6' || nb == '8') cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int n, x;

	cin >> n >> x;

	int sum = 0;
	int ans = 0;
	for(int i = 0; i < n; ++i)
	{
		int l;
		cin >> l;
		if(sum + l <= x)
		{
			ans = i + 1;
		}

		sum += l;
	}

	cout << ans + 1 << endl;
}

Measured memory_bytes: 384
a=[0]*26
w='abcdefghijklmnopqrstuvwxyz'
try:
    while True:
        s=list(raw_input().upper())
        for i in s:
            if i=='A':
                a[0]+=1
            elif i=='B':
                a[1]+=1
            elif i=='C':
                a[2]+=1
            elif i=='D':
                a[3]+=1
            elif i=='E':
                a[4]+=1
            elif i=='F':
                a[5]+=1
            elif i=='G':
                a[6]+=1
            elif i=='H':
                a[7]+=1
            elif i=='I':
                a[8]+=1
            elif i=='J':
                a[9]+=1
            elif i=='K':
                a[10]+=1
            elif i=='L':
                a[11]+=1
            elif i=='M':
                a[12]+=1
            elif i=='N':
                a[13]+=1
            elif i=='O':
                a[14]+=1
            elif i=='P':
                a[15]+=1
            elif i=='Q':
                a[16]+=1
            elif i=='R':
                a[17]+=1
            elif i=='S':
                a[18]+=1
            elif i=='T':
                a[19]+=1
            elif i=='U':
                a[20]+=1
            elif i=='V':
                a[21]+=1
            elif i=='W':
                a[22]+=1
            elif i=='X':
                a[23]+=1
            elif i=='Y':
                a[24]+=1
            elif i=='Z':
                a[25]+=1 

except EOFError:
    pass

for i in range(26):
    print w[i:i+1], ':', str(a[i])

Measured memory_bytes: 6504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int h, w, ans = 0;
    cin >> h >> w;
    int c[10][10];
    int a[h][w];
    rep(i, 10) rep(j, 10) cin >> c[i][j];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    rep(i, h) rep(j, w)
    {
        if (a[i][j] != -1)
        {
            ans += c[a[i][j]][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	int i,j;
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	for(i=0;i<3;i++){
		for(j=2;j>i;j--){
			if(a[i]>a[j]){
				swap(a[i],a[j]);
			}
		}
	}
	for(i=0;i<3;i++){
		if(i!=0){
			cout<<" ";
		}
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
#define inl inline
#define re register
#define MAXN 10100
using namespace std;

int n,m;
int main()
{
	cin>>n>>m;
	int y=n*3+m;
	cout<<y/2;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> A[i][j];
    vector<vector<int>> G(H * W + 1);
    vector<int> dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
    rep(i, H) rep(j, W) rep(k, 4) {
        if (0 <= i + dx[k] && i + dx[k] < H && 0 <= j + dy[k] && j + dy[k] < W) {
            G[i * W + j].push_back((i + dx[k]) * W + j + dy[k]);
        }
    }
    rep(i, H) rep(j, W) {
        if (A[i][j] == '#') {
            G[H * W].push_back(i * W + j);
            G[i * W + j].push_back(H * W);
        }
    }
    vector<int> dist(H * W + 1, -1);
    dist[H * W] = 0;
    queue<int> q;
    q.push(H * W);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v : G[u]) {
            if (dist[v] == -1) {
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
    int ans = 0;
    rep(i, H * W) ans = max(ans, dist[i]);
    cout << ans - 1 << "\n";
    return 0;
}


Measured memory_bytes: 83436
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}

int main() {
    char a, b;
    cin >> a >> b;
    if (a == b) cout << 'H' << endl;
    else cout << 'D' << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc,char* argv[]){
  int a[4],b[4],i,j,hit,blow;
  
  while(scanf("%d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3]) != EOF){
    hit = blow = 0;
    for(i = 0;i < 4;i++){
      for(j = 0;j < 4;j++){
	if(b[i] == a[j]){
	  if(i == j){
	    hit++;
	    break;
	  }else{
	    blow++;
	    break;
	  }
	}
      }
    }
    
    printf("%d %d\n",hit,blow);
    
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int H, W;

void mineDetect(int cor[52][52], vector<string> S){
   for(int i = 1; i < H+1; i++){
     for(int j = 1; j < W+1; j++){
       if(i*j*(i-H-1)*(j-W-1)!= 0){
         if(S[i][j-1]=='#'){
           cor[i][j] = -9;
           cor[i-1][j-1] += 1;
           cor[i-1][j] += 1;
           cor[i-1][j+1] += 1;
           cor[i][j-1] += 1;
           cor[i][j+1] += 1;
           cor[i+1][j-1] += 1;
           cor[i+1][j] += 1;
           cor[i+1][j+1] += 1;
         }
       }
     }
   }

   for(int i = 1; i < H+1; i++){
     for(int j = 1; j < W+1; j++){
       if(cor[i][j]<0) cout << '#';
       else cout << cor[i][j];

       if(j==W) cout << "\n";
     }
   }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない


  cin >> H >> W;

  int cor[52][52];

  for(int i = 0; i < H+2; i++){//配列の初期化
    for(int j = 0; j < W+2; j++){
      cor[i][j] = 0;
    }
  }

  vector<string> S;
  S.push_back("NULL");

  for (int i = 0; i < H;i++){
    string buff;
    cin >> buff;
    S.push_back(buff);
  }

  mineDetect(cor,S);

}


Measured memory_bytes: 256
//package _1169;



import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	class arrow {

		LinkedList<Integer> from = new LinkedList<Integer>();

	}



	void run() {

		for (;;) {

			int n = sc.nextInt();

			int a = sc.nextInt();

			int s = sc.nextInt();

			int g = sc.nextInt();

			if ((n | a | s | g) == 0) {

				break;

			}

			int[] x = new int[a];

			int[] y = new int[a];

			String[] lab = new String[a];

			for (int i = 0; i < a; i++) {

				x[i] = sc.nextInt();

				y[i] = sc.nextInt();

				lab[i] = sc.next();

			}

			String[][] dp = new String[n][n * 6+241];

			boolean[][] visited = new boolean[n][n * 6+241];

			for (int i = 0; i < n; i++) {

				for (int j = 0; j < n * 6; j++) {

					dp[i][j] = "";

				}

			}

			visited[s][0] = true;

			for (int i = 0; i < n * 6+241; i++) {

				for (int st = 0; st < n; st++) {

					for (int k = 0; k < a; k++) {

						if (st == x[k]) {

							if (i - lab[k].length() < 0)

								continue;

							if (!visited[x[k]][i - lab[k].length()]) {

								continue;

							}

							if(!visited[y[k]][i]){

								dp[y[k]][i] = dp[x[k]][i - lab[k].length()]

														+ lab[k];	

								visited[y[k]][i] = true;

							}

							if (dp[y[k]][i].compareTo(dp[x[k]][i

									- lab[k].length()]

									+ lab[k]) > 0) {

								dp[y[k]][i] = dp[x[k]][i - lab[k].length()]

										+ lab[k];

							}

						}

					}

				}

			}

			String min = "";

			boolean f = false;

			for (int j = 0; j < n * 6+241; j++) {

				if (visited[g][j]) {

					if (!f) {

						min = dp[g][j];

						f = true;

					}

					if (min.compareTo(dp[g][j]) > 0) {

						min = dp[g][j] ;



						if(j >= n*6){

							f = false;

							break;

						}

					}

				}

			}

			if (!f) {

				System.out.println("NO");

			} else {

				System.out.println(min);

			}

		}



	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 27000
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var result = string.Empty;

            foreach (var c in s) 
            {
                var cc = c + n;

                while (90 < cc)
                {
                    cc -= 26;
                }

                result += (char)cc;
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 34772
from sys import stdin


def main():
    N, M, X = [int(x) for x in stdin.readline().rstrip().split()]
    Ai = [int(x) for x in stdin.readline().rstrip().split()]
    spam = [1 if i in Ai else 0 for i in range(N + 1)]
    print(min(sum(spam[:X]), sum(spam[X + 1:])))


if __name__ == '__main__':
    main()


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,w[102],mini=INT_MAX;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
   

    cin>>n;
    cin>>w[1];
    rep(i,2,n)
        cin>>w[i],w[i]+=w[i-1];
    rep(i,1,n)
    {
        mini=min(mini,abs(w[i]-(w[n]-w[i])));
    }
    cout<<mini;
    
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  int t = std::stoi(s);
  int a = t/100, b = t-a*100;
  if (0 < a && a < 13) {
    if (0 < b && b < 13) {
      std::cout << "AMBIGUOUS" << std::endl;
    } else {
      std::cout << "MMYY" << std::endl;
    }
  } else {
    if (0 < b && b < 13) {
        std::cout << "YYMM" << std::endl;
    }else{
        std::cout << "NA" << std::endl;
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  int H[30];
  for (int i = 0; i < N; i++) cin >> H[i];

  int ans = 1;
  int maxh = H[0];
  for (int i = 1; i < N; i++) {
    if (H[i] >= maxh) {
      maxh = H[i];
      ans++;
    }
  }

  cout << ans << endl;
}

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

using namespace std;
int main() {
    int a, b;
    int juice[1005];
    cin >> a >> b;
    for(int i = 0; i < a; ++i) {
        cin >> juice[i];
    }
    sort(juice, juice + a);
    int ans = 0;
    for(int i = 0; i < b; ++i) {
        ans += juice[i];
    }
    cout << ans << "\n";
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    string s;
    cin >> s;

    if (s[s.size() - 1] == '3') {
        cout << "bon" << endl;
    } else if (s[s.size() - 1] == '0' || s[s.size() - 1] == '1' || s[s.size() - 1] == '6' || s[s.size() - 1] == '8') {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3652
import sys
input=sys.stdin.readline
from collections import deque
n=int(input())
A=["dammy"]+[deque(list(map(int,input().split()))) for _ in range(n)]
Q,planned,day=deque([_ for _ in range(1,n+1)]),[0]*(n+1),[0]*(n+1)
cnt=0

while Q:
    x=Q.popleft()
    if not A[x]:
        pass
    else:
        y=A[x].popleft()
        if planned[y]==x:
            day[x],day[y]=max(day[x],day[y])+1,max(day[x],day[y])+1
            cnt+=1
            planned[x],planned[y]=0,0
            Q.append(x)
            Q.append(y)
        else:
            planned[x]=y

if cnt!=(n*(n-1))//2:
    print(-1)
else:
    print(max(day))

Measured memory_bytes: 37988
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	map<string, int>mp;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string S;
		cin >> S;
		mp[S]++;
	}
  	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		string T;
		cin >> T;
		mp[T]--;
	}
	int max_v = -100000000000;
	for (auto p : mp) {
		int x = p.second;
		max_v = max(max_v, x);
	}
  	if(max_v<0){cout<<0<<endl; return 0;}
	cout << max_v << endl;
  	
}









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

int main()
{

  int h,r;

  cin >> h >> r;

  if(h > 0 && r <= h)
    {
      cout << 1 << endl;
    }
  if(h < 0 && r < (-1*h))
    {
      cout << -1 << endl;
    }
  if(h < 0 && r == (-1*h))
    {
      cout << 0 << endl;
    }
  if(h == 0)
    {
      cout << 1 << endl;
    }
  if(h > 0 && r > h)
    {
      cout << 1 << endl;
    }
  if(h < 0 && r > (-1*h))
    {
      cout << 1 << endl;
    }
}



Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		int[][] v = new int[h + 1][w + 1];
		for (int i = 0; i < k; i++) {
			sa = br.readLine().split(" ");
			int r = Integer.parseInt(sa[0]);
			int c = Integer.parseInt(sa[1]);
			v[r][c] = Integer.parseInt(sa[2]);
		}
		br.close();

		long[][][] dp = new long[h + 1][w + 1][4];
		for (int x = 1; x <= h; x++) {
			for (int y = 1; y <= w; y++) {
				for (int z = 1; z <= 3; z++) {
					dp[x][y][z] = Math.max(dp[x][y - 1][z], dp[x][y - 1][z - 1] + v[x][y]);
				}
				long ue = max(dp[x - 1][y]);
				dp[x][y][0] = Math.max(dp[x][y - 1][0], ue);
				dp[x][y][1] = Math.max(dp[x][y][1], ue + v[x][y]);
			}
		}
		System.out.println(max(dp[h][w]));
	}

	static long max(long[] a) {
		long ret = 0;
		for (int i = 0; i < a.length; i++) {
			ret = Math.max(ret, a[i]);
		}
		return ret;
	}
}


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

using namespace std;
using ll = long long;

int main() {
    ll n, x; cin >> n >> x;
    ll a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    ll ans = 0;
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }

    for (int i = 1; i < n; i++) {
        ll s = a[i - 1] + a[i];
        if (s <= x) continue;
        ll d = s - x;
        a[i] -= d;
        ans += d;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4380