akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI = vector<int>;
const static string el = "\n";

int main()
{
    long long nmax = 1e18;
    int n; cin >> n;
    vector<long long> v(n);
    for(int i = 0;i < n;i++) {
        long long tmp; cin >> tmp;
        if(tmp > nmax) {
            cout << -1 << el;
            return 0;
        }
        if(tmp == 0) {
            cout << 0 << el;
            return 0;
        }
        v[i] = tmp;
    }

    long long result = 1;
    int maeno_keta = 1;
    for(int i = 0;i < n;i++) {
        result *= v[i];
        // cout << maeno_keta << " kon " << (int)log10(v[i])+1 << " re  " << (int)log10(result)+2 << el;
        if(!((maeno_keta + (int)log10(v[i])+1 == (int)log10(result)+2) || (maeno_keta + (int)log10(v[i])+1 == (int)log10(result)+1))) {
            // cout << "huga " << el;
            cout << -1 << endl;
            return 0;
        }
        if(result > nmax) {
            cout << -1 << el;
            return 0;
        }
        maeno_keta = (int)log10(result)+1;
    }
    cout << result << el;
    return 0;
}

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

int main(){
  string first,second;
  string a,b;
  cin >> first >> second;
  int result=0;
  for (int i=0;i<3;i++){
    a = first[i];
    b= second[i];
    if(a==b){
      result++;
    }
  }


  cout <<result;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;
const ll N=1e5+9;

inline ll read()
{
	ll x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

inline void chkmin(ll &a,ll b){if(a>b)a=b;}
inline void chkmax(ll &a,ll b){if(a<b)a=b;}

int n;
int siz[N],fa[N],rt[3],rtop;
int to[N<<1],frm[N<<1],nxt[N<<1],w[N<<1],beg[N],tot;

inline void add(int u,int v,int c)
{
	to[++tot]=v;
	frm[tot]=u;
	w[tot]=c;
	nxt[tot]=beg[u];
	beg[u]=tot;
}

inline void dfs(int u)
{
	ll mx=0;siz[u]=1;
	for(int i=beg[u];i;i=nxt[i])
		if(to[i]!=fa[u])
		{
			fa[to[i]]=u;
			dfs(to[i]);
			chkmax(mx,siz[to[i]]);
			siz[u]+=siz[to[i]];
		}
	chkmax(mx,n-siz[u]);
	if((mx<<1)<=n)
		rt[++rtop]=u;
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	n=read();
	for(int i=1,a,b,c;i<n;i++)
	{
		a=read();b=read();c=read();
		add(a,b,c);add(b,a,c);
	}
	dfs(1);

	ll ans=0;
	if(rtop==2)
	{
		if(fa[rt[1]]==rt[2])
			swap(rt[1],rt[2]);
		for(int i=1;i<=tot;i+=2)
		{
			int x=frm[i],y=to[i];
			if(fa[x]==y)swap(x,y);
			ans+=2ll*min(n-siz[y],siz[y])*(ll)w[i];
			//printf("%d->%d:%lld\n",x,y,min(n-siz[y],siz[y]));
			if(x==rt[1] && y==rt[2])
				ans-=(ll)w[i];
		}
	}
	else
	{
		for(int i=1;i<=tot;i+=2)
		{
			int x=frm[i],y=to[i];
			if(fa[x]==y)swap(x,y);
			ans+=2ll*min(n-siz[y],siz[y])*(ll)w[i];
		}
		ll me=1e18;
		for(int i=beg[rt[1]];i;i=nxt[i])
			chkmin(me,w[i]);
		ans-=me;
	}

	printf("%lld\n",ans);
	return 0;
}


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

int main() {	
	int n,a,b;
	const int AMAX=100000;
	long long k,num[AMAX+1];
	
	cin>>n>>k;
	for(int i=0;i<AMAX;i++)num[i]=0;
	for(int i=0;i<n;i++){
		cin>>a>>b;;
		num[a-1]+=b;
	}
	for(int i=0;i<AMAX;i++){
		if(num[i]>=k){
			cout<<i+1<<endl;
			break;
		}
		k-=num[i];
	}
	return 0;
}

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

const int mN = 100100;
int n, mod;
vector<int> graph[mN];

typedef long long LL;
LL tmp[mN], cnt[mN], coef[mN];

int parent[mN];
void dfs(int u) {
    tmp[u] = coef[u] = 1;
    for (int v : graph[u]) if (parent[u] != v) {
        parent[v] = u;
        dfs(v);
        tmp[u] *= tmp[v] + 1;
        tmp[u] %= mod;
    }
    cnt[u] = tmp[u];
}

void reconsider(int u) {
    int id = 0;
    int num = graph[u].size() + 2;
    LL prefix[num], suffix[num];
    fill(prefix, prefix+num, 1);
    fill(suffix, suffix+num, 1);
    prefix[0] = 1;
    for (int j=0; j<graph[u].size(); j++) {
        int v = graph[u][j];
        if (parent[u] == v) continue;
        prefix[++id] = (prefix[id-1] * (tmp[v]+1)) % mod;
    }
//    cerr << "total = " << id << ".";
    suffix[id+1] = 1;
    for (int j=graph[u].size()-1; j>=0; j--) {
        int v = graph[u][j];
        if (parent[u] == v) continue;
        suffix[id] = (suffix[id+1] * (tmp[v]+1)) % mod;
        --id;
    }
//    cerr << "prepare for node " << u << " completed: ";
//    for (int i=0; i<=graph[u].size()+1; i++) cerr << "(" << prefix[i] << "," << suffix[i] << ") ";
//    cerr << "\n";
    for (int j=0; j<graph[u].size(); j++) {
        int v = graph[u][j];
        if (parent[u] == v) continue;
        LL u_as_child = (prefix[id++] * suffix[id+1]) % mod;
        u_as_child *= coef[u], u_as_child %= mod;
        coef[v] = u_as_child + 1;
        cnt[v] *= coef[v];
        cnt[v] %= mod;
        //tmp[v] = cnt[v];
        parent[v] = u;
        reconsider(v);
    }
    //cerr << u << " : " << cnt[u] << " (*=" << coef[u] << " ed)\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> n >> mod;
    for (int i=1,x,y; i<n; i++) {
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    fill(parent, parent+mN, 0);
    dfs(1);
    fill(parent, parent+mN, 0);
    reconsider(1);
    for (int i=1; i<=n; i++) cout << cnt[i] << "\n";
	return 0;
}


Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

u64 nCr(u64 n, u64 r) {
    u64 a = 1, b = 1;
    for (u64 i = 1; i <= r; i++) {
        a *= (n - i + 1); b *= i;
    }
    return a / b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N, M;
    cin >> N >> M;
    cout << nCr(N, 2) + nCr(M, 2) << endl;
}


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

using namespace std;

int countsmall_permutation(vector<int>& nv, vector<int>& p, vector<int>& q)
{
  int pa = 0, qa = 0;
  int pac = 0, qac = 0;
  do {
    bool pf = true, qf = true;
    for(int i = 0; i < nv.size(); ++i)
    {
      pf = pf && (nv[i] == p[i]);
      qf = qf && (nv[i] == q[i]);
    }
    ++pac; ++qac;
    if(pf) pa = pac;
    if(qf) qa = qac;
  }while(next_permutation(nv.begin(), nv.end()));
  return pa - qa;
}

int main()
{
  int n;
  cin >> n;
  vector<int> p(n), q(n), nv(n);
  int ans;
  for(int i = 0; i < n; ++i)
  {
    nv[i] = i + 1;
    cin >> p[i];
  }
  for(int i = 0; i < n; ++i)
  {
    cin >> q[i];
  }
  ans = countsmall_permutation(nv, p, q);
  cout << abs(ans) << endl;

return 0;
}


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

int h, w, k;
long long dp[105][10][10];
int inf = 1000000007;

int F(int n) {
    if (n <= 2) return 1;
    else return F(n - 1) + F(n - 2);
}

long long C(int a, int b) {
    if (b == 0 || b == w + 1) return 0;
    else if (min(b - 1, w - b) >= 2) return F(b) * F(a - b + 1);
    else if (b == 1 || b == a) return F(a);
    else return F(a - 1);
}

long long solve(int p, int q, int r) {
    if (dp[p][q][r] >= 0) return dp[p][q][r];
    else {
        dp[p][q][r] = 0;
        if (r == 0 || r == w + 1) return dp[p][q][r];
        if (p >= r - 1) dp[p][q][r] += C(q - 1, r - 1) * solve(p - 1, q, r - 1);
        if (p >= r) dp[p][q][r] += C(q, r) * solve(p - 1, q, r);
        if (p >= r + 1) dp[p][q][r] += C(q - 1, r) * solve(p - 1, q, r + 1);
    }
    if (dp[p][q][r] >= inf) dp[p][q][r] %= inf;
//    cout << p << "," << q << "," << r << " " << dp[p][q][r] << endl;
    return dp[p][q][r];
}

int main(void) {
    cin >> h >> w >> k;
    
    for (int r = 0; r <= w + 1; r++) dp[0][w][r] = 0;
    dp[0][w][1] = 1;
    for (int p = 1; p <= h; p++) {
        for (int r = 0; r <= w + 1; r++) {
            dp[p][w][r] = -1;
        }
    }
    cout << solve(h, w, k) << endl; 
    
//    for (int i = 0; i <= h; i++) {
//        for (int j = 0; j <= w + 1; j++) cout << dp[i][w][j] << " ";
//        cout << endl;
//    }
}



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

class Program
{
    static void Main(string[] args)
    {
        char[] S = Console.ReadLine().ToCharArray();
        if (!(S[0]==S[1]&&S[2]==S[3]&&S[1]==S[2])&&((S[0] == S[1] && S[2] == S[3]) || (S[0] == S[2] && S[1] == S[3]) || (S[0] == S[3] && S[1] == S[2])))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


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

int main()
{
    int k;
    std::string s;
    cin >> k;
    cin >> s;
    /*
    int a[n];
    std::vector<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    */
    
    if(s.size()<=k){
        cout << s << endl;
    }else{
        cout << s.substr(0, k) << "..." << endl;
    }
    
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int ans = 0;
		for(; n>0; n--) {
			int x = sc.nextInt();
			if(x < min) {
				ans++;
				min = x;
			}
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 43860
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main()
{
	int X, Y;
	cin >> X >> Y;

	int tmp = 0;
	for (int i = 0; i <= X; i++)
	{
		int tmp = 2 * i + 4 * (X - i);
		if (tmp == Y) {
			cout << "Yes" << endl;
			return 0;
		}

		
	}
	cout << "No" << endl;

}


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

int f(int x) {
  int count = 0;
  while(x % 2 == 0){
    x /= 2;
    count++;
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    ans += f(a);
  }
  
  cout << ans << endl;
}

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

typedef pair<int,int>pii;
#define MOD 1000000007
#define MAXN 1005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define pb push_back
#define f first
#define s second
#define debug(x) cout << "debug 1: " << x << "\n";
#define debug2(x, y) cout << "debug 2: " << x << " " << y << "\n";
#define debug3(x, y, z) cout << "debug 3: " << x << " " << y << " " << z << "\n";

int h,n;
int mana[MAXN],dmg[MAXN];
int tab[10005];
int solve(int v){
     if(tab[v]>=0)return tab[v];

    if(v<=0)return 0;

     int res=INF;
    for(int i=0;i<n;i++){
            int temp;
            if(dmg[i]>v){
                temp=mana[i];
            }
            else  temp=mana[i]+solve(v-dmg[i]);
            res=min(temp,res);
        }

    return tab[v]=res;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    memset(tab,-1,sizeof(tab));
    tab[0]=0;
    cin>>h>>n;

    for(int i=0;i<n;i++){
        cin>>dmg[i]>>mana[i];
    }
    solve(h);
    cout<<tab[h];
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;

// ■■■■■■■■■■■■■■■■headerここまで■■■■■■■■■■■■■■■■

int main() {

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

    return 0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
const int MAX = 2e5;

int n; // 都市の数
ll k; // テレポート回数
int a[MAX]; // 都市iのテレポート先
bool visited[MAX]; // 訪問状況
int ans;

int main() {
// input
    cin >> n >> k;
    rep(i, n) {
        cin >> a[i];
        a[i]--; // 0-indexedに修正
    }
// solve
    int pos = 0;
    int cnt = 0; // テレポート回数
    rep(i, n) {
        cnt++;
        visited[pos] = true; // 訪問済み
        pos = a[pos]; // 次のの都市
        if (visited[pos]) break; // 訪問した都市に戻ってくるとき終了
    }
    int loop_start = pos; // 最初に戻ってくる都市がループの始点
    if (cnt >= k) {
        pos = 0;
        rep(i, k) { // k回テレポートした先が答え
            pos = a[pos];
        }
        ans = pos;
    } else {
        pos = 0;
        rep(i, n) { // ループの始点までのテレポート回数
            if (pos == loop_start) break;
            pos = a[pos];
            cnt--;
            k--;
        }
        int loop_size = cnt; // ループの周期
        pos = loop_start;
        rep(i, k%loop_size) { // kを周期で割った余り分テレポートした先が答え
            pos = a[pos];
        }
        ans = pos;
    }
// output
    ans++; // 1-indexedに直す
    cout << ans << "\n";
}

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

#define M 1045627
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

// 文字列から数値へ変換して key を生成する
long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i = 0; i < strlen(str); 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));}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);  // 文字列を数値に変換
    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);  // 文字列を数値に変換
    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n;
    char str[L], com[9];
    for(i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", com, str);
        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 16072
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	vector<int> p(n);
	rep(i, n)cin >> p[i];
	int mn = p[0];
	int res = 0;
	rep(i, n)
	{
		if (p[i] <= mn)
		{
			++res;
			mn = p[i];
		}
	}
	cout << res << endl;
}


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

int main()
{
	unsigned int n,cnt,a[200];
	bool flg;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	cnt = 0;
	while (true) {
		flg = true;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 != 0) {
				flg = false;
			}
			a[i] = a[i] / 2;
		}
		if (flg) {
			cnt++;
		}
		else {
			break;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,k;
	cin>>a>>b>>k;
	if(a<=k)
	{
		k=k-a;
		a=0;
		if(b<=k)
		{
			b=0;
		}
		else
		{
			b=b-k;
		}
		cout<<a<<" "<<b<<endl;
	}
	else
	{
		cout<<a-k<<" "<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long min = 1_000_000_000_000_000_001L;
		for (int i = 0; i < 5; i++) {
			min = Math.min(min, sc.nextLong());
		}
		System.out.println(4 + n / min + ((n % min > 0) ? 1 : 0));
	}
}


Measured memory_bytes: 21844
s = input()
cnt = 0
l = 0
r = len(s) - 1
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        l += 1
        cnt += 1
    elif s[r] == 'x':
        r -= 1
        cnt += 1
    else:
        print(-1)
        exit()
print(cnt)

Measured memory_bytes: 3316
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

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

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/




int main(){
	FASTIO
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	
    return 0;
}

/*

*/


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
    	var sc = new Scanner();
    	int n = sc.NextInt();
    	int[] a = new int[n];
    	for (int i = 0; i < n; i++) a[i] = sc.NextInt();
    	Array.Sort(a);
    	int min = 1 << 30;
    	for (int i = a[0]; i <= a[n - 1]; i++)
    	{
    		int res = 0;
    		for (int j = 0; j < n; j++) res += (a[j] - i) * (a[j] - i);
    		if (res < min) min = res;
    	}
    	Console.WriteLine(min);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }
    
    public double NextDouble()
    {
    	CheckNext();
    	return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

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

int main() {
  int D, N;
  cin >> D >> N;
  if (N == 100) {
    if (D == 0) cout << 101 << endl;
    else if (D == 1) cout << 10100 << endl;
    else cout << 1010000 << endl;
  }
  else {
    if (D == 0) cout << N << endl;
    else if (D == 1) cout << 100 * N << endl;
    else cout << 10000 * N << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int first = Integer.parseInt(s.substring(0, 2));
        int second = Integer.parseInt(s.substring(2, 4));
        String r = null;
        if(1<=first && first<=12) {
            if(1<=second && second <= 12) {
                r = "AMBIGUOUS";
            }
            else {
                r = "MMYY";
            }
        }
        else {
            if(1<=second && second <= 12) {
                r = "YYMM";
            }
            else {
                r = "NA";
            }
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 21460
#include <stdio.h>

int main()
{
long int n;
scanf("%ld",&n);

if(n<10)
{
printf("%ld\n",n);
}
else if(n>=10 && n<100)
{
printf("9\n");
}
else if(n>=100 && n<1000)
{
printf("%ld\n",10+n-100);
}
else if(n>=1000 && n<10000)
{
printf("909\n");
}
else if(n>=10000 && n<100000)
{
printf("%ld\n",910+n-10000);
}
else if(n==100000)
{
printf("90909\n");
}
return 0;
}  

Measured memory_bytes: 1672
#include<cstdio>
const static long long INF = -3000000000000;

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int a[M], b[M], c[M];
	long long d[N];
	d[0] = 0;
	for (int i = 1; i < N; ++i) d[i] = INF;
	for (int i = 0; i < M; ++i){
		scanf("%d %d %d", a+i, b+i, c+i);
		a[i]--, b[i]--;
	}
	for (int i = 0; i < N; ++i){
		bool update = false;
		for (int j = 0; j < M; ++j){
			if(d[a[j]] != INF && d[b[j]] < d[a[j]] + c[j]){
				d[b[j]] = d[a[j]] + c[j];
				update = true;
			}
		}
		if(!update){
			printf("%lld\n", d[N-1]);
			return 0;
		}
	}
	long long score = d[N-1];
	for (int k = 0; k < 2; ++k){
		for (int i = 0; i < N; ++i){
			for (int j = 0; j < M; ++j){
				if(d[a[j]] != INF && d[b[j]] < d[a[j]] + c[j]) d[b[j]] = d[a[j]] + c[j];
			}
		}
	}
	if(d[N-1] > score) printf("inf\n");
	else printf("%lld\n", d[N-1]);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cstdarg>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

#if __cplusplus > 199711L
    void read(){}
    template<typename... T>
    void read(int& head, T&... tail) {scanf("%d",&head); read(tail...);}

    #define DB(args...) { cerr << __LINE__<< ": "; vector<string> _v = split(#args, ','); err(_v.begin(), args); }
    vector<string> split(const string& s, char c) {
        vector<string> v;stringstream ss(s);string x;
        while (getline(ss, x, c)) v.push_back(x);
        return move(v);
    }
    void err(vector<string>::iterator it) {cerr<<endl;}
    template<typename T, typename... Args>
    void err(vector<string>::iterator it, T a, Args... args) {
        cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << "  "; err(++it, args...);
    }
#else
    #define DB(e) cerr << __LINE__ << ": " << #e << " = " << e << endl;
    void read(int& head) {scanf("%d",&head);}
#endif

#define ll long long int
#define pb push_back
#define fr(i,n)     for(int i=0;i<n;i++)
#define init(mem,v) memset(mem,v,sizeof(mem))
typedef pair<int,int> pii;

bool allowed[10];

bool okay(int n){
    while(n){
        if(!allowed[n%10]) return false;
        n/=10;
    }
    return true;
}

int main(){
    int n,k;
    read(n,k);

    fr(i,10) allowed[i]=true;

    fr(i,k){
        int d;
        read(d);
        allowed[d]=false;
    }
    while(!okay(n)) ++n;
    printf("%d\n",n);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int X, Y;
    cin >> X >> Y;

    cout << (X + Y/2) << endl;

    return 0;
}


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

int main() {
  int n, m, sum = 0, count = 0;
  cin >> n >> m;
  double level = 1.0 / ( 4.0 * m );
  vector<int> goods(n);
  for(int i = 0; i < n; i++){
    cin >> goods.at(i);
    sum += goods.at(i);
  }
  
  for(int i = 0; i < n; i++){
    if(goods.at(i) >= (double)sum * level)
      count++;
  }
  
  if(count >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

const string YES = "Yes";
const string NO = "No";

int n, m;
int WA[105000];
bool AC[105000];

void solve(){
  cin >> n >> m;
  int WAnum = 0;
  int ACnum = 0;
  for(int i = 1; i <= n; i++){
    WA[i] = 0;
    AC[i] = false;
  }
  while(m--){
    int p;
    string s;
    cin >> p >> s;
    if(AC[p]) continue;
    if(s == "AC"){
      AC[p] = true;
      ACnum++;
      WAnum += WA[p];
    }else if(s == "WA"){
      WA[p]++;
    }
  }
  cout << ACnum << " " << WAnum << endl;
  return;
}





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

  solve();
  return 0;

}


Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

const int N=200005;
const ll inf=0x3f3f3f3f3f3f3f3f;
int n,q,a,b,x[N];
ll mn[3][N*4],tag[N*4];

void pushup(int x){
	for(int i=0;i<3;i++)
		mn[i][x]=min(mn[i][x<<1],mn[i][x<<1|1]);
}
void add(int x,ll y){
	for(int i=0;i<3;i++)mn[i][x]+=y;
	tag[x]+=y;
}
void pushdown(int x){
	if(tag[x]){
		add(x<<1,tag[x]);
		add(x<<1|1,tag[x]);
		tag[x]=0;
	}
}
void build(int x,int l,int r){
	if(l==r){
		mn[0][x]=mn[1][x]=mn[2][x]=inf;
		if(l==b)mn[0][x]=0,mn[1][x]=l,mn[2][x]=-l;
		return;
	}
	int mid=l+r>>1;
	build(x<<1,l,mid);
	build(x<<1|1,mid+1,r);
	pushup(x);
}
ll query(ll *mn,int x,int l,int r,int ql,int qr){
	if(l>=ql&&r<=qr)return mn[x];
	pushdown(x);
	int mid=l+r>>1;
	ll ans=inf;
	if(ql<=mid)ans=query(mn,x<<1,l,mid,ql,qr);
	if(qr>mid)ans=min(ans,query(mn,x<<1|1,mid+1,r,ql,qr));
	return ans;
}
void modify(int x,int l,int r,int p,ll v){
	if(l==r){
		if(v<mn[0][x]){
			mn[0][x]=v;
			mn[1][x]=v+l;
			mn[2][x]=v-l;
		}
		return;
	}
	pushdown(x);
	int mid=l+r>>1;
	if(p<=mid)modify(x<<1,l,mid,p,v);
	else modify(x<<1|1,mid+1,r,p,v);
	pushup(x);
}

int main(){
	scanf("%d%d%d%d",&n,&q,&a,&b);
	x[0]=a;
	build(1,1,n);
	for(int i=1;i<=q;i++){
		scanf("%d",x+i);
		ll tmp=min(query(mn[2],1,1,n,1,x[i])+x[i],query(mn[1],1,1,n,x[i],n)-x[i]);
		add(1,abs(x[i]-x[i-1]));
		modify(1,1,n,x[i-1],tmp);
	}
	printf("%lld\n",mn[0][1]);
	return 0;
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 2e5 + 7;

ll x,y;

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> x >> y; x += y;
    if ( x&1 ){
        cout << "IMPOSSIBLE";
    }
    else{
        cout << x/2;
    }
    return 0;
}


void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

const int Maxn = (int) 1e5 + 10;

ll sum[2][Maxn];

int n, k;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sum[0][i + 1] = sum[0][i] + x;
        sum[1][i + 1] = sum[1][i] + max(0, x);
    }

    ll ans = 0;
    for (int i = 0; i < n - k + 1; ++i) {
        ll score = sum[1][i] + sum[1][n] - sum[1][i + k];
        score += max(0LL, sum[0][i + k] - sum[0][i]);
        ans = max(ans, score);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
class Dice():
    def __init__(self,ary):
        self.top = ary[0]
        self.south = ary[1]
        self.east = ary[2]
        self.west = ary[3]
        self.north = ary[4]
        self.bottom = ary[5]

    def get_top(self):
        return self.top

    def rotate_north(self):
        self.top,self.south,self.north,self.bottom = self.south,self.bottom,self.top,self.north
    
    def rotate_south(self):
        self.top,self.south,self.north,self.bottom = self.north,self.top,self.bottom,self.south

    def rotate_west(self):
        self.top,self.west,self.bottom,self.east = self.east,self.top,self.west,self.bottom

    def rotate_east(self):
        self.top,self.west,self.bottom,self.east = self.west,self.bottom,self.east,self.top

dice = Dice(list(map(int,input().split())))
for i in input():
    if i == "N":
        dice.rotate_north()
    elif i == "E":
        dice.rotate_east()
    elif i == "W":
        dice.rotate_west()
    elif i == "S":
        dice.rotate_south()

top=dice.get_top()
print(top)

Measured memory_bytes: 7780
#include <iostream>
#include <vector>
#include <cmath>

int main() {
    int n;
    std::cin >> n;
    std::vector<long long> v;
    v.push_back(1);
    for (int i = 0; i < n; ++i) {
        int tmp;
        std::cin >> tmp;
        v.push_back(tmp);
    }
    long long amin, amax;
    amin = 2;
    amax = 2;
    for (int i = n; i >= 0; --i) {
        if(v[i] > amax) {
            std::cout << "-1\n";
            return 0;
        }

        amin = std::ceil(amin/double(v[i])) * v[i];
        if(amin > amax) {
            std::cout << "-1\n";
            return 0;
        }

        amax = v[i]* (amax/v[i]+1) -1;
//        std::cerr <<  amin << ' ' << amax << std::endl;
    }
    std::cout << amin << ' ' << amax << std::endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ame[2][N];
  for (int i = 0; i < 2; i++) {
    for (int j = 0;j < N; j++) {
      cin >> ame[i][j];
    }
  }
  int val[N] = {};
  val[0] = ame[0][0];
  for(int k = 0;k < N; k++){
    val[0] += ame[1][k];
  }
  for(int l = 1;l < N; l++){
    val[l] = val[l-1] - ame[1][l-1] + ame[0][l];
  }
  sort(val,val + N);
  cout << val[N -1] << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
ch = []
for i in range(N):
    ch.append(''.join(sorted(list(input()))))
cnt = 0
ch = sorted(ch)
# print(set(ch))
# print(len(ch)-len(set(ch)))
cnt = collections.Counter(ch)
# se = list(set(ch))
# print("se:"+str(se))
h={}
sum=0
for i in range(N):
    h[i]=sum+i
    sum+=i
sum = 0
for i in cnt.values():
    sum += h[i-1]
print(sum)

Measured memory_bytes: 34748
Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim a As Long = NextLong()
        Dim b As Long = NextLong()
        Dim x As Long = NextLong()

        Dim ans As Long = b \ x

        If a = 0 Then
            ans += 1
        Else
            ans -= (a - 1) \ x
        End If

        WriteLine(ans)
    End Sub

    Function NextLong() As Long
        Return CLng(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20432
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <tuple>
#include <limits>

using namespace std;

int a[200'000];
int amax[200'000];
int ramax[200'000];

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

    for (int i=0; i<n;i++){
        if (i==0){
            amax[i] = a[i];
            continue;
        }
        amax[i] = max(amax[i-1], a[i]);
    }

    for (int i=n-1;i>=0;i--){
        if (i==n-1){
            ramax[i] = a[i];
            continue;
        }
        ramax[i]= max(ramax[i+1], a[i]);
    }

    for (int i=0;i<n;i++){
        int m0 = i-1 >= 0 ? amax[i-1] : 0;
        int m1 = i+1 < n ? ramax[i+1] : 0;

        int result = max(m0, m1);
        cout << result << endl;
    }
    return 0;
}

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

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;
const ll lINF = 1l<<40;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    int low = d[n/2-1],high = d[n/2];
    cout << high - low << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int H,W,cnt,t[102][102],vis[102][102];
int dx[2][6]={  {-1, 0,0,-1,-1,1},{ 1,1,1,0,-1, 0} };
 
int dy[2][6]={  { 0,-1,1,-1, 1,0},{-1,0,1,1, 0,-1}};
void dfs(int y,int x){
  int nx,ny;

  t[y][x]=-1;
  for(int i=0;i<6;i++){
    nx=x+dx[y%2][i];
    ny=y+dy[y%2][i];
    if(nx<0||W+1<nx||ny<0||ny>H+1)continue;
    if(t[ny][nx]==1){
      cnt++;
    }
    if(t[ny][nx]==0){
      dfs(ny,nx);
    }
  }
}
int main(){
    cin>>W>>H;
    for(int i=0;i<102;i++){
      for(int j=0;j<102;j++){
    t[i][j]=0;
      }
    }
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
    cin>>t[i][j];
      }
    }
    cnt=0;
    dfs(0,0);
    cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1448
#include <bits/stdc++.h>
using namespace std;
								      
int main(){
  int X,Y;
  cin >> X >> Y;
  bool flag = false;
  for(int i=0; i<X+1; i++){
    if(i*2+(X-i)*4==Y)
      flag = true;
  }
  
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()

struct UnionFind{
	vi p;
	UnionFind(int s):p(s,-1){}
	void unite(int a,int b){
		a=root(a);b=root(b);
		if(a!=b){
			if(p[b]<p[a])swap(a,b);
			p[a]+=p[b];p[b]=a;
		}
	}
	bool same(int a,int b){return root(a)==root(b);}
	int root(int a){return p[a]<0?a:p[a]=root(p[a]);}
};

using data=tuple<int,int,int>;
int n,m;
vector<data> edge;
set<int> use;

int makeMST(int except=-1){
	int ret=0;
	UnionFind uf(n);
	rep(i,m){
		if(i==except) continue;
		int c,s,d; tie(c,s,d)=edge[i];
		if(!uf.same(s,d)){
			uf.unite(s,d);
			ret+=c;
			if(except==-1) use.insert(i);
		}
	}
	return ret;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	cin>>n>>m;
		
	rep(i,m){
		int s,d,c; cin>>s>>d>>c;
		edge.emplace_back(c,s-1,d-1);
	}
	sort(all(edge),[](data a,data b){return get<0>(a)<get<0>(b);});

	int target=makeMST(),value=0,index=0;
	for(auto u:use){
		if(target!=makeMST(u)){
			index++;
			value+=get<0>(edge[u]);
		}
	}
	cout<<index<<" "<<value<<endl;
	return 0;
}



Measured memory_bytes: 3816
#include <iostream>
#include <bitset>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 2000000;

bitset<MAX_N> sieve;
vector<int> primes;
void eratosthenes(){
	sieve[0] = sieve[1] = true;
	for(int i = 2; i < MAX_N; ++i){
		if(sieve[i]){ continue; }
		primes.push_back(i);
		for(int j = i + i; j < MAX_N; j += i){ sieve[j] = true; }
	}
}

int main(){
	eratosthenes();
	while(true){
		int n, p;
		cin >> n >> p;
		if(n == -1 && p == -1){ break; }
		int begin =
			upper_bound(primes.begin(), primes.end(), n) - primes.begin();
		vector<int> pp;
		for(int i = 0; i < 200; ++i){
			for(int j = 0; j <= i; ++j){
				pp.push_back(primes[begin + i] + primes[begin + j]);
			}
		}
		sort(pp.begin(), pp.end());
		cout << pp[p - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
from itertools import permutations as P
N, M = map(int, input().split())

web = [set() for _ in range(N)]
for _ in range(M):
	a, b = map(int, input().split())
	web[a-1].add(b-1)
	web[b-1].add(a-1)
way = list(P(range(1, N), N-1))
res = 0
for i in range(len(way)):
	if way[i][0] in web[0]:
		flag = True
		for j in range(1, N-1):
			if way[i][j] not in web[way[i][j-1]]:
				flag = False
				break
		if flag: res += 1

print(res)

Measured memory_bytes: 3572
#!/usr/bin/env python3
s = input()
if 0 < int(s[:2]) < 13 and 0 < int(s[2:4]) < 13:
    print('AMBIGUOUS')
elif 0 < int(s[:2]) < 13:
    print('MMYY')
elif 0 < int(s[2:4]) < 13:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int h[N];
bool flag[N];
int main() {
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>h[i];
	memset(flag,true,sizeof flag);
	while(m--){
	    int a,b;
	    cin>>a>>b;
	    if(h[a]<=h[b]) flag[a]=false;
	    if(h[a]>=h[b]) flag[b]=false;
	}
	
	for(int i=1;i<=n;i++){
	    if(flag[i]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4124
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    N, K = MI()
    return 2 * K - 1 <= N


if __name__ == "__main__":
    YESNO(main())


Measured memory_bytes: 5268
#include<iostream>
using namespace std;
int main()
{
  int N,M,C;
  int count = 0;
  cin >> N >> M >> C;
  int B[M];
  int A[N][M];
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  for(int i=0;i<N;i++){
    int result = 0;
    for(int j=0;j<M;j++){
	  result += A[i][j]*B[j];
    }
    result += C;
    if(result > 0)count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String text = sc.next();
	
		if(text.charAt(2) == text.charAt(3) && text.charAt(4) == text.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main(){
    string s; cin >> s;
    string ans;
    if(s=="Sunny")
        ans="Cloudy";
    else if(s=="Cloudy")
        ans="Rainy";
    else
        ans="Sunny";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def grid_components(A: int, B: int) -> list:
    K = 32
    grid = [
        ['#' if k < K else '.' for _ in range(2 * K)]
        for k in range(2 * K)]

    r, c = 0, 0
    for _ in range(A - 1):
        grid[r][c] = '.'

        c += 2
        if c >= 2 * K:
            r += 2
            c = 0

    r, c = 0, 0
    for _ in range(B - 1):
        grid[(2*K-1) - r][(2*K-1) - c] = '#'
        c += 2
        if c >= 2 * K:
            r += 2
            c = 0

    return grid


if __name__ == "__main__":
    A, B = map(int, input().split())
    ans = grid_components(A, B)
    h, w = len(ans), len(ans[0])
    print(h, w)
    for row in ans:
        print(''.join(row))


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int lc[1000010] = {};

int pow_mod(int n, int m){
	int ans = 1;
	while(m > 0){
		if(m & 1) ans = (ans * n) % MOD;
		n = (n * n) % MOD;
		m >>= 1;
	}
	return ans;
}

signed main(){
	int n;
	cin >> n;
	int a[100010];
	for(int i = 0;i < n;i++) cin >> a[i];


	for(int i = 0;i < n;i++){
		auto m = prime_factor(a[i]);
		for(auto e : m){
			chmax(lc[e.first], e.second); 
		}
	}

	int ll = 1;
	for(int i = 1;i <= 1000000;i++){
		ll = (ll * pow_mod(i, lc[i])) % MOD;
	}

	int ans = 0;

	for(int i = 0;i < n;i++){
		ans += (ll * pow_mod(a[i], MOD-2)) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll sp=0;
    ll sn=0;
    ll cntp=0;
    ll cntn=0;
    for(ll i = 0; i < n; i++) {
        sp+=a[i];
        sn+=a[i];
        if(i%2){
            if(sp>=0){
                cntp+=(1+sp);
                sp=-1;
            }
            if(sn<=0){
                cntn+=(1-sn);
                sn=1;
            }
        }
        else{
            if(sp<=0){
                cntp+=(1-sp);
                sp=1;
            }
            if(sn>=0){
                cntn+=(1+sn);
                sn=-1;
            }
        }
    }
//    cout << cntp << " " << cntn << "\n";
    cout << min(cntp,cntn) << "\n";
    return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n), b(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
    if(a[i] % 10 != 0) b.push_back(a[i]);
  }
  
  if(sum % 10 == 0){
    sort(b.begin(), b.end());
    for(int i = 0; i < b.size(); i++){
      if(b[i] % 10 != 0){
        sum -= b[i];
        break;
      }
    }
  }
  if(sum % 10 == 0) sum = 0;
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll d, g;
    cin >> d >> g;

    vl p(d), c(d);
    rep(i, d) {
        cin >> p[i] >> c[i];
    }

    ll ans = INF;
    rep(b, 1<<d) {  // bのiビット目が1のとき問題iを全て解く
        ll now = 0;  // いま解いた問題数
        ll point = 0;  // いまのポイント
        rep(i, d) {
            if(b & 1<<i) {
                now += p[i];
                point += 100*(i+1)*p[i] + c[i];
            }
        }
        for(ll i = d-1; i >= 0; i--) {
            if(b & 1<<i) {
                continue;
            }
            exrep(j, 0, p[i]-1) {
                if(point >= g) {
                    break;
                }
                point += 100*(i+1);
                now++;
            }
            break;
        }
        if(point >= g) {
            chmin(ans, now);
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256