akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int M = 1000000 + 5;
const int L = 14;

char H[M][L];

int getChar(char c){
  if(c == 'A')return 1;
  else if(c == 'C')return 2;
  else if(c == 'G')return 3;
  else if(c == 'T')return 4;
  else return 0;
}

long long getKey(char str[]){
  int len = strlen(str);
  long long sum = 0,p = 1;
  for(int i = 0;i < len; i++){
    sum += p*getChar(str[i]);
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1 + (key % (M - 1));
}

void insert(char str[]){
  long long key = getKey(str);
  for(int i = 0;; i++){
    int h = (h1(key) + i*h2(key))%M;
    if(strcmp(H[h],str) == 0)return;
    if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return ;
    }
  }
  return;
}

bool find (char str[]){
  long long key = getKey(str);
  for(int i = 0;; i++){
    int h = (h1(key) + i*h2(key))%M;
    if(strcmp(H[h],str) == 0)return true;
    else if(strlen(H[h]) == 0)return false;
  }
  return false;
}

int main(){
  int n;
  scanf("%d",&n);
  for(int i = 1;i <= n; i++){
    char s1[8],s2[14];
    scanf("%s%s",s1,s2);
    if(s1[0] == 'i'){
      insert(s2);
    }
    else{
      if(find(s2)){
        printf("yes\n");
      }
      else {
        printf("no\n");
      }
    }
  }
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)



typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
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;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////



ll SOLVE(){
    ll n;cin>>n;
    LL a[n];rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-1){
        if(a[i]==0){
            cout<<0<<endl;return 0;
        }
    }
    LL ans=1;
    rep(i,0,n-1){
        ans=ans*a[i];
        if(ans>(LL)1E18){cout<<-1<<endl;return 0;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;

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;
}

const ll MOD = 1000000007;

// auto mod int
// ref. https://github.com/atcoder-live/library/blob/master/mint.cpp
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

vector<ll> S;
vector<ll> T;

// dp[i][j] means the number of patterns for S[0..(i-1)] and T[0..(j-1)]
mint dp[2005][2005];

// ref. https://atcoder.jp/contests/abc130/submissions/5979094
int main(void) {
    ll N, M;
    cin >> N >> M;

    S.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    T.resize(M + 1, 0);
    for (int i = 0; i < M; i++) {
        cin >> T[i];
    }

    for (int i = 0; i <= N; i++) dp[i][0] = 1;
    for (int i = 0; i <= M; i++) dp[0][i] = 1;
    for (int i = 1; i <= N; i++) {
        mint sum = 0;
        for (int j = 1; j <= M; j++) {
            dp[i][j] = dp[i - 1][j];
            if (S[i - 1] == T[j - 1]) {
                // if S[i - 1] == T[j - 1], we can create a new common subsequence
                // by adding S[i - 1] at last into each subsequence counted in dp[i - 1][j - 1].
                sum += dp[i - 1][j - 1];
            }
            // dp[i][j] doesn't know the result between dp[i][0] to dp[i][j-1] yet, so add it
            dp[i][j] += sum;
        }
    }

    // for (int i = 0; i < N + 1; i++) {
    //     for (int j = 0; j < M + 1; j++) {
    //         printf("%lld ", dp[i][j].x);
    //     }
    //     printf("\n");
    // }

    cout << dp[N][M].x << endl;

    return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, k;
string s;
signed main() {
	cin >> n >> s >> k;
	k--;
	rep(i, n) {
		if (s[i] != s[k])s[i] = '*';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

char s[10];

scanf("%s", &s);

if(s[0]=='S'){
    printf("Cloudy\n");
    }
else if(s[0]=='R'){
    printf("Sunny\n");
}
else{
    printf("Rainy\n");
}
return 0;
}


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

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll a,b,c;
	cin >> a >> b >> c;
	ll k;
	cin >> k;
	ll i=1;
	while(i<=k)
	{
		while(b<=a && i<=k)
		{
			b*=2;
			i++;
		}
		while(c<=b && i<=k)
		{
			c*=2;
			i++;
		}
		break;
	}
	if(b>a && c>b)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;	
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int a,b;
	int d,r;
	double f;

	cin >> a >> b;

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	cout << d << " " << r << " " << flush;
	printf("%7f\n", f);
	return 0;
}

Measured memory_bytes: 1240
//lover~ crazy~
#include<bits/stdc++.h>
using namespace std;
int a[5]; 
int main() {
    for(int i=0;i<3;i++) cin>>a[i];
    sort(a,a+3);
    cout<<a[2]-a[0];
	return 0;
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;

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

		int n = scan.nextInt();
		double x[] = new double[3];
		double y[] = new double[3];

		for(int i = 0; i < n; i++){
			for(int j = 0; j < 3; j++){
				x[j] = scan.nextDouble();
				y[j] = scan.nextDouble();
			}
			double a = 2 * (x[1] - x[0]);
			double b = 2 * (y[1] - y[0]);
			double c = x[0]*x[0] - x[1]*x[1] + y[0]*y[0] - y[1]*y[1];
			double d = 2*(x[2]-x[1]);
			double e = 2*(y[2]-y[1]);
			double f = x[1]*x[1] - x[2]*x[2] + y[1]*y[1] - y[2]*y[2];

			double cx = (b*f - c*e)/(a*e - d*b);
			double cy = (a*f - c*d)/(b*d - a*e);

			double r = Math.sqrt((x[0]-cx)*(x[0]-cx) + (y[0]-cy)*(y[0]-cy));

			/*BigDecimal bdx = new BigDecimal(cx);
			BigDecimal bdy = new BigDecimal(cy);
			BigDecimal bdr = new BigDecimal(r);
			BigDecimal cx1 = bdx.setScale(3, BigDecimal.ROUND_HALF_UP);
			BigDecimal cy1 = bdy.setScale(3, BigDecimal.ROUND_HALF_UP);
			BigDecimal rn = bdr.setScale(3,BigDecimal.ROUND_HALF_UP);*/

			//System.out.println(cx1+ " " +cy1+ " " +rn);

			System.out.printf("%.3f %.3f %.3f\n", cx, cy, r);

		}
	}
}

Measured memory_bytes: 29036
/*
    Code written by Talant I.D.
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9	
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod 998244353

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
 
bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2) 
		if(n % i == 0) return false;
	return true;
}

int main(){
    do_not_disturb
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n, k = 1, cnt = 0, i;
	cin >> n;
	vector <int> v(n);
	for(i = 0; i < n; i++){
		cin >> v[i];
	}
	for(i = 0; i < n; i++){
		if(k == v[i]){
			k++;
		}
		else{
			cnt++;
		}
	}
	cout << (k == 1 ? -1 : cnt);
	
    return 0;
} // What is to be written here?


Measured memory_bytes: 1024
N = int(input())
A = [int(i) for i in input().split()]

x1 = 0
for i in range(N):
    if i % 2 == 0:
        x1 += A[i]
    else:
        x1 -= A[i]

print(x1, end=' ')
for i in range(N-1):
    x1 = 2 * (A[i] - x1//2)
    print(x1, end=' ')

print()





Measured memory_bytes: 14028
import itertools

def main():
    N, M, R = map(int, input().split())
    RR = tuple(map(int, input().split()))
    ABC = {tuple(map(int, input().split())) for _ in range(M)}

    dist = [[float('inf')] * (N + 1) for j in range(N + 1)]
    for a, b, c in ABC:
        dist[a][b] = dist[b][a] = c
        dist[a][a] = dist[b][b] = 0
    for k in range(1, N + 1):
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    ans = float('inf')
    for r in itertools.permutations(RR):
        move = 0
        for i in range(R - 1):
            a = r[i]
            b = r[i+1]
            move += dist[a][b]
        ans = min(ans, move)

    print(ans)

main()


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

int main() {
    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>());

    vector<int> ans;
    int now = A[0], active = 1;
    for (int i = 1; i < N; i++) {
        if (A[i] == now) {
            active++;
            if (active == 2) {
                if (ans.size() == 2) break;
                ans.push_back(now);
                active = 0;
            }
        } else {
            now = A[i];
            active = 1;
        }
    }
    if (ans.size() == 2)
        cout << (long long)ans[0] * ans[1] << endl;
    else
        cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(){
  int min,y,t1,t2,g;
  int a,b,p;
  while(1){
    scanf("%d",&min);
    if(min==0)break;
    scanf("%d %d %d %d",&y,&t1,&t2,&g);
    a=y/t1;
    b=0;
    if(a>g){
      a=g;
    }
    y-=a*t1;
    b=y/t2;
    y-=b*t2;
    while(min>a+b){
      if(a==0)break;
      a--;
      y+=t1;
      p=y/t2;
      y-=p*t2;
      b+=p;
    }
    if(a==0)printf("NA\n");
    else    printf("%d %d\n",a,b);
  }
  return 0;
}

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

int main(){
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	cout.tie(NULL);
	
	long long int h,a;
	cin>>h>>a;
	long long int ans=0;
	while(h>0){
	    h=h-a;
	    ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N;
    cin >> N;
    vector<ll> W(N);
    rep(i, N) cin >> W[i];

    vector<ll> sum(N);
    sum[0] = W[0];
    reps(i, 1, N) sum[i] = sum[i - 1] + W[i];

    // repv(sum) cout << *it << " ";
    // cout << endl;

    ll res = INF;
    rep(i, N) { chmin(res, abs((sum[N - 1] - sum[i]) - sum[i])); }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(void)
{
	unsigned long long a, b, x;
	unsigned long long ans = 0;
	
	scanf("%llu %llu %llu", &a, &b, &x);
	
	ans = b/x - a/x;
	
	if( (a % x) == 0 )
		ans++;
	
	printf("%llu", ans);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

long long power(long long n, long long ntime)
{
  long long result = 1;
  for(long long i = 0; i < ntime; i++) {
    result = result * n;
  }
  return result;
}

int main()
{
  long long a, b;
  scanf("%lld%lld", &a, &b);
  if(b == 100) {
    printf("%lld\n", 101*power(100, a));
  } else {
    printf("%lld\n", b * power(100, a));
  }
  return 0;
}


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

rain_sum=sum(a)  # 雨量の総和

ans=[]

t=0
for i in range(0,N-2,2):
    t += a[i]*2

Tn = rain_sum - t
T1 = a[N-1]*2 - Tn

ans.append(T1)

for i in range(N-1):
    k=a[i]*2-ans[i]
    ans.append(k)

print(*ans)


Measured memory_bytes: 14092
#include <stdio.h>

int main(void) {
	int N;
	int t_zihanki,h_zihanki,t_max;
	int t[100],h[100];
	int i;
	int zihanki_zankin;
	scanf("%d%d%d%d",&N,&t_zihanki,&h_zihanki,&t_max);
	for(i=0;i<N;i++)scanf("%d%d",&t[i],&h[i]);
	zihanki_zankin=0;
	for(i=0;;i=(i+1)%N) {
		if(t[i]>0) {
			t[i]--;
			t_zihanki++;
			zihanki_zankin+=10;
		} else if(h[i]>0) {
			h[i]--;
			h_zihanki++;
			zihanki_zankin+=100;
		} else {
			/* player i wins : he/she has no coins */
			break;
		}
		if(t_zihanki>t_max) {
			/* player i wins : the bender is broken */
			break;
		}
		if(zihanki_zankin>=90) {
			zihanki_zankin-=90;
			if(zihanki_zankin<100) {
				if(t_zihanki>=zihanki_zankin/10) {
					t_zihanki-=zihanki_zankin/10;
					t[i]+=zihanki_zankin/10;
				} else {
					/* player i wins : change can't be paid */
					break;
				}
			} else if(t_zihanki>=zihanki_zankin/10) {
				t_zihanki-=zihanki_zankin/10;
				t[i]+=zihanki_zankin/10;
			} else if(h_zihanki>0 && t_zihanki>=zihanki_zankin/10-10) {
				/* I think the change can't be 100 yen or more */
				h_zihanki--;
				t_zihanki-=zihanki_zankin/10-10;
				h[i]++;
				t[i]+=zihanki_zankin/10-10;
			} else {
				/* player i wins : change can't be paid */
				break;
			}
			zihanki_zankin=0;
		}
	}
	printf("%d\n",i+1);
	return 0;
}

Measured memory_bytes: 600
import sys
n, m = map(int,input().split())
a = [int(input()) for i in range(m)]
b = [0] * (m+1)
ans = 1
step = [0] * (n+1)
step[0] = 1
step[1] = 1
for i in range(2, n+1):
    step[i] = (step[i-1] + step[i-2]) % 1000000007
if m == 0:
    print(step[n])
    sys.exit()
for i in range(m-1):
    if a[i] + 1 == a[i+1]:
        print("0")
        quit()
if m > 0:
    b[0] = a[0] - 1
    b[m] = n - a[-1] - 1   
if m >= 2:
    for i in range(m-1, 0, -1):
        b[i] = a[i] - a[i-1] - 2
for i in b:
    ans = ans * step[i] % 1000000007
print(ans)

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

int main(){
  long N, X;
  cin >> N >> X;
  long L[N];
  for(int i=0; i<N; i++){
    cin >> L[i];
  }
  int count=0;
  int D=0;
  while(D<=X){
    D += L[count]; 
    count += 1;
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
int main(){
	long long n,m=0;
	string s,t;

    cin >> n;
    cin >> s >> t;

    for(long long i = n - 1; i >= 0; i--){
        if(s[n-1 - m] == t[i]){
            m++;
        }
    }

	cout << 2 * n - m << endl;
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, S;
    cin >> N >> K >> S;
    while(K > 0) {
            cout << S << " ";
            N--;
            K--;
    }
    while(N > 0){
        if (S >= 200000)
            cout << 1 << " ";
        else 
            cout << S + 200000 << " ";
        N--;
    }
    cout << endl;

    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  bool f = N % 2 == 0;
  for (int i = 0, l = 1, r = N; i < M; i++, l++, r--) {
    if (r - l <= N / 2 && f) {
      r--;
      f = false;
    }
    cout << l << " " << r << endl;
  }
}


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

int divisor(int n)
{
    int ret = 0;
    for (int i = 1; i <= n; i++)
    {
        if (n % i == 0)
            ret++;
    }
    return ret;
}

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 2 == 1 && divisor(i) == 8)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    array<int, 3> counter{};
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        const auto index = (p <= a ? 0 : p <= b ? 1 : 2);
        counter[index]++;
    }
    cout << *min_element(counter.begin(), counter.end()) << endl;
}


Measured memory_bytes: 256
n = int(input())
ps = list(map(int, input().strip().split()))

cum_min = [0] * n

min_p = 1e9
for i in range(n):
    cum_min[i] = min(min_p, ps[i])
    min_p = cum_min[i]

count = 0
for i in range(n):
    if cum_min[i] == ps[i]:
        count += 1

print(count)


Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[3];
  for(int i=0;i<3;i++)
  {
    cin>>a[i];
  }
  sort(a,a+3);
  int x = a[0]+a[1];
  int y = a[1]+a[2];
  int z = a[0]+a[2];
  
  int ans = min(x,min(y,z));
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
def main():
    N, T = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    score_list = [0 for _ in range(N)]
    min_price = A[0]
    for i in range(N):
        a = A[i]
        score_list[i] = a - min_price
        min_price = min(a, min_price)
    max_score = max(score_list)
    ans = 0
    for i in range(N):
        if score_list[i] == max_score:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

cnt = 0
flag = 1
while flag == 1:
    flag = 0
    for j in range(N-1,0,-1):
        if A[j] < A[j-1]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            flag = 1
            cnt += 1
print(" ".join([str(s) for s in A]))
print(cnt)
        



Measured memory_bytes: 5608
#include<stdio.h>
int main()
{
    int m;
    while(scanf("%d",&m)!=EOF){
        int key,i,j,x,A[150];
        for(i=0;i<m;i++)scanf("%d",&A[i]);
        for(i=0;i<m;i++){
            key=A[i];
            j=i-1;
                while(j>=0&&A[j]>key){
                A[j+1]=A[j];
                j--;
                A[j+1]=key;
 
            }
            for(x=0; x<m-1; x++)printf("%d ",A[x]);printf("%d\n",A[x]);
        }
    }return 0;
}


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

int main() {
    int n, x;
    
    cin >> n >> x;
    
    while(!(n == 0  && x == 0)){
        // 本処理
        int count = 0;
        
        for(int i = 1; i <= n - 2; i++){
            for(int j = i + 1; j <= n - 1; j++){
                int y = x - i - j;
                //cout << y << endl;
                if(y > j && y <= n) ++count;
            }
        }
        
        // 出力
        cout << count << endl;
        // 次入力   
        cin >> n >> x;
    } 

    
}


Measured memory_bytes: 3092
#include <cstdint>
#include <iostream>

using namespace std;

bool FirstWins(int64_t a, int64_t b)
{
    return abs(a - b) > 1;
}

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

    cout << (FirstWins(a, b) ? "Alice" : "Brown") << "\n";
    return 0;
}


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


int main(){
	int N,j=0;
	string S;
	cin >> N >> S;
	rep(i,N){
        if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
            j++;
            i+=2;
        }
	}
	cout << j << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  ll x = 0, y = 0;
  for (ll i = 0; i < N; i++)
  {
    for (ll j = i + 1; j < N; j++)
    {
      if (A.at(i) > A.at(j))
        x++;
      if (A.at(i) < A.at(j))
        y++;
    }
  }

  ll ans = (K * (K + 1) / 2 % MOD * x % MOD + (K - 1) * K / 2 % MOD * y % MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(10) << num << endl;
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    int a[n];
    vector<bool> v(8,0);
    int ans=0;
    int res=0;
    rep(i,n){
        cin >> a[i];
        if(a[i]>=3200) ans++;
        else v[a[i]/400]=1;
    }
    rep(i,8)if(v[i])res++;
    if(res==0) cout << 1 << " " << ans+res << endl;
    else cout << res << " " << ans+res << endl;
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main() 
{ int a;
  cin>>a; 
 string s; 
 cin>>s; 
 if(a&1) 
   cout<<"No"<<'\n'; 
 else 
 { string t=s.substr(0,a/2); 
   string p=s.substr(a/2);  
   if(t!=p) 
   cout<<"No"<<'\n'; 
    else 
     cout<<"Yes"<<'\n';   
 }
 return 0;  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>


typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple

using namespace std;
int const N = 100000;

int main()
{
	ull n;
	cin >> n; 
	cout << (n * (n - 1ull)) / 2ull;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,mo=1e9+7;
struct Edge{
	int next,to;
}edge[N*2];
int n,fi[N],se,f[N],ans[N],inv[N],fac[N],size[N];
inline void add_edge(int u,int v){edge[++se].next=fi[u],fi[u]=se,edge[se].to=v;}
inline void add(int u,int v){add_edge(u,v),add_edge(v,u);}
inline int C(int n,int m){return 1ll*fac[n]*inv[m]%mo*inv[n-m]%mo;}
inline int fC(int n,int m){return 1ll*inv[n]*fac[m]%mo*fac[n-m]%mo;}
int Pow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1ll*ans*a%mo;
		a=1ll*a*a%mo,b>>=1;
	}
	return ans;
}
void init(){
	fac[0]=inv[0]=inv[1]=1;
	for(int i=2;i<N;i++)
		inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	for(int i=1;i<N;i++)
		fac[i]=1ll*fac[i-1]*i%mo,
		inv[i]=1ll*inv[i-1]*inv[i]%mo;
}
void dfs(int x,int fa){
	f[x]=size[x]=1;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;if(v==fa)continue;
		dfs(v,x);size[x]+=size[v];
		f[x]=1ll*f[x]*C(size[x]-1,size[v])%mo*f[v]%mo;
	}
}
void dfs1(int x,int fa){
	int w=1ll*ans[fa]*fC(n-1,size[x])%mo*Pow(f[x],mo-2)%mo;
	if(!fa)ans[x]=f[x];
	else ans[x]=1ll*f[x]*C(n-1,size[x]-1)%mo*w%mo;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;if(v==fa)continue;
		dfs1(v,x);
	}
}
int main(){
	init();
	int u,v;scanf("%d",&n);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),add(u,v);
	dfs(1,0);
	dfs1(1,0);
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 10112
import java.util.*;
public class Main {
	public static void main(String args[]){
    	Scanner s = new Scanner(System.in);
    	int N = s.nextInt();
      	int K = s.nextInt();
      	int arr[] = new int[N];
      	for(int i=0;i<N;i++)
          	arr[i] = s.nextInt();
      	int ans = frog(arr,N,K);
      	System.out.println(ans);
    }
  	public static int frog(int[] arr, int N,int K){
    	if(N<=1)
          return 0;
      	int dp[] = new int[N];
      	dp[0] = 0;
      	for(int i=1;i<N;i++){
         	dp[i] = Integer.MAX_VALUE;
          	for(int k=1;k<=K && i-k>=0;k++){
      			dp[i] = Math.min(dp[i], Math.abs(arr[i]-arr[i-k])+dp[i-k]);
            }
        }
      	return dp[N-1];
    }
}

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

constexpr int INF = INT_MAX;

vector<vector<int> > g;
vector<int> d, dmax;

void dfs(int v){
    for(auto u : g[v]){
        if(d[u] > d[v]+1){
            d[u] = d[v]+1;
            dfs(u);
        }
    }
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    d.resize(n);
    dmax.resize(n);
    for(int i=0;i<n-1;i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int s = 0, t = 0;
    for(int i=0;i<3;i++){
        fill(d.begin(), d.end(), INF);
        d[s] = 0;
        dfs(s);
        int maxi = -1;
        for(int i=0;i<n;i++){
            if(d[i] > maxi){
                maxi = d[i];
                t = i;
            }
        }
        swap(s,t);
    }
    dmax = d;
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    dfs(s);
    for(int i=0;i<n;i++){
        dmax[i] = max(dmax[i], d[i]);
    }
    for(int i=0;i<n;i++){
        cout << 2*(n-1) - dmax[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 12312
import sys
a,b = map(int,input().split())

if not ( 1 <= a <= 9 and 1 <= b <= 9 ): sys.exit()
if not ( isinstance(a,int) and isinstance(b,int) ): sys.exit()

array_a = ''.join([ str(a) for z in range(b) ])
array_b = ''.join([ str(b) for z in range(a) ])
array = [array_a,array_b]
array.sort()

print(array[0])

Measured memory_bytes: 9100
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		char[][] c=new char[2][3];
		for(int i=0;i<2;++i) {
			c[i]=sc.next().toCharArray();
		}
		boolean flag=true;
		for(int i=0;i<2;++i) {
			for(int j=0;j<3;++j) {
				flag&=c[i][j]==c[1-i][2-j];
			}
		}
		System.out.println(flag?"YES":"NO");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main() {
	int a, num = 0, i,n;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a);
		if (i % 2 != 0 && a % 2 != 0)
		{
			num++;
		}
	}
	printf("%d", num);
	return 0;
}

Measured memory_bytes: 1736
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            var b = InputNumList();

            var a = new List<int>();

            a.Add(b[0]);
            a.Add(b[n - 2]);

            for (int i = 0; i < n - 2; i++)
            {
                int min = Math.Min(b[i], b[i + 1]);
                a.Add(min);
            }

            int ans = a.Sum();

            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <iostream>

using namespace std;

int roots[1000000];
long long int V[1000000];
int flags[1000000];

long long int get_value(int pos){
  if(!flags[pos]){
    V[pos]+=get_value(roots[pos]);
    flags[pos]=1;
  }
  return V[pos];
}

int main() {
  roots[0] = 0;
  flags[0] = 1;
  int N, Q;
  cin >> N >> Q;
  int a, b;
  for(int i=0;i<N-1;i++){
    scanf("%d%d",&a,&b);
    a-=1;
    b-=1;
    roots[b]=a;
  }
  //
  int p,x;
  for(int i=0;i<Q;i++){
    scanf("%d%d",&p,&x);
    p-=1;
    V[p]+=x;
  }
  //
  for(int i=0;i<N;i++){
    printf("%lld ", get_value(i));
  }
}

Measured memory_bytes: 11392
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long res = -1;
        if (a[0] % a[1] == 0) res = -1;
        else res = (a[1] - 1) * a[0];
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

	if (s.size() == 6 && s[2] == s[3] && s[4] == s[5])
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 256
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> > vi[100100];
int color[100100], visited[100100];
void dfs(int now, long long int cost)
{
    visited[now] = 1;
    if(cost % 2 == 0)
        color[now] = 0;
    else
        color[now] = 1;
    for(auto x : vi[now])
    {
        if(visited[x.first]) continue;
        dfs(x.first, cost + x.second);
    }
}
int main()
{
    int n,i,j,k,m,x,y,ans,curr,res,now;
    scanf("%d",&n);
    for(i=0;i<n-1;i++)
    {
        int cost;
        scanf("%d %d %d",&x,&y,&cost);
        vi[x].push_back(make_pair(y,cost));
        vi[y].push_back(make_pair(x,cost));
    }
    dfs(1, 0);
    for(i=1;i<=n;i++)
        printf("%d\n",color[i]);
    return 0;
}


Measured memory_bytes: 7936
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    if m==-1 or f==-1 or m+f<30:
        print('F')
    elif m+f<50:
        if r>=50:
            print('C')
        else:
            print('D')
    elif m+f<65:
        print('C')
    elif m+f<80:
        print('B')
    else:
        print('A')


Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    string S;
    cin>>S;
    int cnt=0,b=0;
    for(int i=1;i<=N;i++){
        if(S[i-1]=='c'){
            cout<<"No"<<endl;
        }
        if(S[i-1]=='a'){
            if(cnt<A+B){
                cnt++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }
        if(S[i-1]=='b'){
            b++;
            if(cnt<A+B&&b<=B){
                cout<<"Yes"<<endl;
                cnt++;
            }else{
                cout<<"No"<<endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    int N;
    double A;
    double ans = 0.0;
    std::cin >> N;

    for(int i = 0; i < N; i++){
        std::cin >> A;
        ans = ans + 1/A;
    }

    std::cout << setprecision(16) << 1/ans;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, k;
    cin >> n >> k;

    vector<pair<int64_t, int64_t>> x(n), y(n);
    for (auto i : irange(0L, n)) {
        cin >> x[i].first >> y[i].first;
        x[i].second = y[i].second = i;
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    vector<pair<int64_t, int64_t>> points(n);
    for (auto i : irange(0L, n)) {
        points[x[i].second].first = i;
        points[y[i].second].second = i;
    }

    vector<vector<int64_t>> s(n + 1, vector<int64_t>(n + 1));
    for (auto i : irange(0L, n)) {
        ++s[points[i].first + 1][points[i].second + 1];
    }

    for (auto i : irange(0L, n + 1)) {
        for (auto j : irange(0L, n)) {
            s[i][j + 1] += s[i][j];
        }
    }

    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, n + 1)) {
            s[i + 1][j] += s[i][j];
            assert(s[i + 1][j] <= n);
            assert(s[i + 1][j] >= 0);
        }
    }

    assert(s[n][n] == n);

    int64_t ans = numeric_limits<int64_t>::max();
    for (auto left : irange(0L, n)) {
        for (auto right : irange(left + 1, n)) {
            for (auto bottom : irange(0L, n)) {
                for (auto top : irange(bottom + 1, n)) {
                    auto num = s[right + 1][top + 1] - s[right + 1][bottom] -
                               s[left][top + 1] + s[left][bottom];

                    assert(num >= 0);
                    assert(num <= n);

                    // cerr << left << "-" << right << "x" << bottom << "-" <<
                    // top
                    //      << ":" << num << endl;
                    if (num >= k) {
                        ans = min(ans,
                                  (x[right].first - x[left].first) *
                                          (y[top].first - y[bottom].first));
                    }
                }
            }
        }
    }

    assert(ans != numeric_limits<int64_t>::max());

    cout << ans << endl;
}

Measured memory_bytes: 256
//A - ∴ (Therefore)
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  int n;
  scanf("%d", &n);
  if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9)printf("hon\n");
  if(n%10==0 || n%10==1 || n%10==6 || n%10==8)printf("pon\n");
  if(n%10==3)printf("bon\n");
  return 0;
}


Measured memory_bytes: 1660
N=int(input())
L=[str(i) for i in [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211,
    241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491,
    521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761,
    811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061,
    1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381]]
print(" ".join(L[:N]))


Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;


class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			in.nextInt();
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		LinkedList<Integer> tempNode;
		Iterator<LinkedList<Integer>> outer = adjList.iterator();
		int  rw = 0;
		while (outer.hasNext()) {
			tempNode = outer.next();
			Iterator<Integer> inner = tempNode.iterator();
			while(inner.hasNext()) {
				adjMatrix[rw][inner.next()] = 1;
			}
			rw++;
		}
			
		for(int i = 0; i<totalVertex;i++) {
			for (int j = 0; j < totalVertex; j++) {
				if (adjMatrix[i][j] != null) {
					System.out.print(adjMatrix[i][j]);
				} else {
					System.out.print(0);
				}
				if (j != totalVertex-1) {
					System.out.print(" ");					
				}				
			}
			System.out.println(); 
		}
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}



Measured memory_bytes: 34848
import math
inputs = input().split()
A, B, H, M = int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3])
num_diff = H*5+M/12 - M

ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(2 * math.pi * ( num_diff / 60 )))
print(ans)

Measured memory_bytes: 9580
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
int MOD=1000000000+7;
int INF=1e6;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n,a[300000];
    cin>>n;
    rep(i,n){
        scanf("%d",&a[i]);
    }
    int i=n-1;
    ll int ans=0,res=0;
    while(1){
        if(i==0){
            if(a[i]==0) {cout<<ans; break;}
            else {cout<<-1; break;}
        }
        if(res){
            if(a[i]<res-1) {cout<<-1; return 0;}
            if(a[i]>=res){ans+=a[i];}
        }
        else{ans+=a[i];}
        res=a[i];
        i--;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] m = new int[n];
		for (int i = 0; i < m.length; i++) {
			m[i] = sc.nextInt();
		}
		sc.close();

		int min = 1000;
		for (int i = 0; i < m.length; i++) {
			x -= m[i];
			min = Math.min(min, m[i]);
		}
		int ans = n + x / min;
		System.out.println(ans);
	}
}


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

int main(){
    int s;
    cin >> s;
    int count=1;
    while(s!=1&&s!=2&&s!=4){
        count++;
        if(s%2) s=3*s+1;
        else s/=2;
    }

    cout << count+3 << endl;
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  char a[2];
  
  rep(i,0,2){
    scanf("%c", &a[i]);
  }
  rep(i,0,2){
    if(a[i] == '9'){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
 
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a - b == 0) {
		cout << c << endl;
	} else if (c - b == 0) {
		cout << a << endl;
	} else {
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100;
    B *= 100;

    pair<int,int> ans;
    double m = -0.1;
    for(int a=0; a*A<=F; a++) {
        for(int b=0; a*A+b*B<=F; b++) {
            int water = a*A + b*B;
            for(int c=0; c*C<=water*E/100; c++) {
                for(int d=0; c*C+d*D<=water*E/100; d++) {
                    int sugar = c*C + d*D;
                    if(water + sugar > F) break;
                    if((double)sugar / (double)(water + sugar) > m) {
                        m = (double)sugar / (double)(water + sugar);
                        ans = make_pair(water+sugar, sugar);
                    }
                }
            }
        }
    }

    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a  = list(map(int,input().split()))

a.sort(reverse=True)
dic = {a[0]:1}
ans = 0

for i in range(1,n):
    h = a[i]
    max_h = next(iter(dic))
    
    
    
    if h == max_h:
        dic[h] += 1
        ans += h
    
    else:
        if h in dic:
            dic[h] += 2
            dic[max_h] -= 1
            ans += max_h
        
        else:
            dic[h] = 2
            dic[max_h] -= 1
            ans += max_h
        
        if dic[max_h] == 0:
            del dic[max_h]
    
    

print(ans)
            

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

using namespace std;

int64_t gcd(int64_t a, int64_t b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  else return gcd(a - b, b);
}

int64_t lcm(int64_t a, int64_t b) {
  int64_t d = gcd(a, b);
  return a / d * b;
}

int64_t power2(int64_t n) {
  int cnt = 0;
  for (; n % 2 == 0; n /= 2) {
    ++cnt;
  }
  return cnt;
}

int64_t solve() {
  int64_t n, m;
  cin >> n >> m;
  int64_t mul = 1;
  int64_t p2 = -1;
  for (int64_t i = 0; i < n; ++i) {
    int64_t a;
    cin >> a;
    if (p2 == -1) p2 = power2(a / 2);
    else if (p2 != power2(a / 2)) return 0;
    mul = lcm(mul, a / 2);
    if (mul > m) return 0;
  }
  return (m - mul) / (mul * 2) + 1;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << solve() << endl;
}


Measured memory_bytes: 384
#include <iostream>

int main () {
	std::string a,b, res;
  
  	std::cin >> a >> b;
  
  	if(a =="H") {
    	if(b=="H") {
          res = "H";
        } else {
          res = "D";
        }
    } else {
    	if (b=="H") {
          res = "D";
        } else {
          res = "H";
        }
    }
 	std::cout << res << std::endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1e9+7
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int A,B,ans=0;
    cin>>A>>B;
    int cnt=1;
    while(B-cnt>0){
        cnt--;
        cnt+=A;
        ans++;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define SIZE 10001

int main() {
    int n, i, j;
    int C[SIZE];
    scanf("%d", &n);
    //??????????????§???????????????????????????:(
    //int A[MAX], B[MAX];

    unsigned short *A, *B;
    A = malloc(sizeof(short) * n+1);
    B = malloc(sizeof(short) * n+1);
    
    //????????§1?????????????????????
    for (i = 0; i < n; i++) scanf("%hu", &A[i]);

    for (i = 0; i < SIZE; i++) C[i] = 0;

    for (j = 0; j < n; j++) C[A[j]]++;

    for (i = 1; i < SIZE; i++) C[i] = C[i] + C[i-1];

    for (j = 0; j < n; j++) {
	B[C[A[j]]] = A[j];
	C[A[j]]--;
    }

    for (i = 1; i < n+1; i++) {
	if (i > 1) printf(" ");
	printf("%d", B[i]);
    }
    printf("\n");
    return 0;

}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll N; cin >> N;
    while(true){
        string tmp = to_string(N);
        if(tmp[0] == tmp[1] && tmp[1] == tmp[2]){
            cout << N << endl;
            return 0;
        }
        N++;
    }
}

Measured memory_bytes: 256