akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int maxN = 1e5 + 10;
int n, k, h[maxN], dp[maxN];
int main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> h[i];
	for(int i = 1; i < n; i++)
	{
		int mn = 2e9;
		for(int j = 1; j <= k && i - j >= 0; j++) mn = min(mn, dp[i - j] + abs(h[i] - h[i - j]));
		dp[i] = mn;
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		uu[] t=new uu[n];
		for(int i=0; i<n; i++){
			String k= sc.next();
			int p=sc.nextInt();
			t[i]=new uu(i+1,k,p);
		}
		Arrays.sort(t,Comparator.comparing(uu::getP).reversed());
		Arrays.sort(t,Comparator.comparing(uu::getK));
		for(int i=0; i<n; i++){
			System.out.println(t[i].getNum());
		}
	}
	public static class uu{
		int num=0;
		String k="";
		int p=0;
		public uu(int num,String k,int p){
			this.num=num;
			this.k=k;
			this.p=p;
		}
		int getNum(){
			return this.num;
		}
		String getK(){
			return this.k;
		}
		int getP(){
			return this.p;
		}
	}
}


Measured memory_bytes: 27092
#include <stdio.h>
#include <math.h>

int main(){
	double a,b,area,length;
	scanf("%lf %lf",&a,&b);
	area = a * b;
	length = 2 * (a + b); 
	printf("%.0f %.0f\n",area,length);
	return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  cout<<((b-1)+a-2)/(a-1)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int N;
	while(cin>>N,N){
		vector<int>g;
	int a,cnt=0,cnt2=0;
	for(int i=0;i<N;i++)cin>>a,g.push_back(a);
	for(int i=0;i<N;i++)if(g[i]>=2)cnt++;
	for(int i=0;i<N;i++)if(g[i]==1)cnt2++;
	if(cnt==0)cout<<"NA"<<endl;
	else cout<<cnt+cnt2+1<<endl;
	g.clear();
	}
	
	return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
// o o o o o o o o 
// 7 5 3 1 1 3 5 7
// o o o o o o o o o
// 8 6 4 2 0 2 4 6 8
#define int long long
int INF = 1e9+7;
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    if(N%2 == 0) {
        vector<int>cnt(100001,0);
        for(int i = 0; i < N; i++) {
            cin >> A[i];
            if(A[i]%2 == 0) {
                cout << 0 << endl;
                return 0;
            }
            cnt[A[i]]++;
        }
        for(int i = 1; i <= N; i+=2) {
            if(cnt[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        int ans = 1;
        for(int i = 1;  i <= N/2; i++) {
            ans*=2;
            ans = ans%INF;
        }
        cout << ans << endl;
    }
    else {
        vector<int>cnt(100001,0);
        for(int i = 0; i < N; i++) {
            cin >> A[i];
            if(A[i]%2 == 1) {
                cout << 0 << endl;
                return 0;
            }
            cnt[A[i]]++;
        }
        for(int i = 2; i < N; i+=2) {
            if(cnt[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }
        if(cnt[0] != 1) {
            cout << 0 << endl;
            return 0;
        }
        int ans = 1;
        for(int i = 1;  i <= N/2; i++) {
            ans*=2;
            ans = ans%INF;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
n = gets
s = gets.chomp.split.map(&:to_i).sort!
q = gets
t = gets.chomp.split.map(&:to_i).sort!

c = 0
y = s.shift
t.each{|x|
	y = s.shift while y && y < x
	break unless y
	c += 1 if y == x
}
puts c

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  unordered_set<int> appeared;
  for (int i = 0; i < N; i++){
    int val;
    cin >> val;
    if (appeared.find(val) != appeared.end()){
      cout << "NO";
      return 0;
    }
    appeared.emplace(val);
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 2025
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

int cnt[maxn][maxn], n, k, red, blue, ans;
const int Mod = 1e9 + 7;
ll fact[maxn];

ll power(ll a, ll b)    //a is base, b is exponent
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    if (b % 2 == 1)
        return (power(a, b - 1) * a) % Mod;
    ll q = power(a, b / 2);
    return (q * q) % Mod;
}

ll modInv(ll base)
{
    return power(base, Mod - 2);
}

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

ll Choose(ll a, ll b)
{
    ll cur = fact[a];
    cur = mul(cur, modInv(fact[b]));
    cur = mul(cur, modInv(fact[a - b]));
    return cur;
}

void initFact()
{
    fact[0] = 1;
    for (int i = 1; i < maxn; i++) {
        fact[i] = (fact[i - 1] * i) % Mod;
    }
}
int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        initFact();
        cin >> n >> k;

        for (int i = 1; i <= k; i++) {
            int blue = k - i;
            int red = n - k - i + 1;
            if (red < 0) {
             cout << 0 << endl;
              continue;
          }

            ll ans = Choose(blue + i - 1, i - 1) * Choose(red + i, i);
            ans %= Mod;
            cout << ans << endl;
        }
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

int main() {
	int N, T, c, t, min = 1001;
	cin >> N >> T;
	for (int i = 1; i <= N; i++) {
		cin >> c >> t;
		if (c < min && t <= T) {
			min = c;
		}
	}
	if (min == 1001) cout << "TLE" << endl;
	else cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int r = scn.nextInt();
		int c = scn.nextInt();
		int[][] sum = new int[r + 1][c + 1];

		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sum[i][j] = scn.nextInt();
			}
		}
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sum[i][c] += sum[i][j];
				sum[r][j] += sum[i][j];
			}
			sum[r][c] += sum[i][c];
		}

		for (int i = 0; i < r + 1; i++) {
			for (int j = 0; j < c; j++) {
				System.out.print(sum[i][j] + " ");
			}
			System.out.println(sum[i][c]);
		}
	}
}



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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N;
    cin >> N;
    long long res = 1;
    vector<int> a(N, 1);

    for (int i = 2; i<= N; i++) {
        const auto &pf = prime_factorize(i);
        //for (auto p : pf) res *= p.second + 1;
        for (auto p : pf) a[p.first-1] += p.second;
    }
    for (int i = 1; i<N; i++)  {
        res *= a[i];
        res %= 1000000007;
    }
    cout << res << endl;
}



Measured memory_bytes: 3604
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
using namespace std;
//https://codeforces.com/contest/1213/problems
//https://codeforces.com/contest/1213/submit
int a[1000];
bool cmp(int a,int b){
return a > b;}
int main(){
    int n,k;
    s(n) s(k)
    for(int i = 0; i < n; i ++){
        s(a[i])
    }
    sort(a,a+n,cmp);
    int sum = 0;
    for(int i = 0; i < k; i ++){
        sum += a[i];
    }
    p(sum) pn
    return 0;
}


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

using namespace std;
string s;
long long su,n,dp[10009][100][2],mod=1e9+7;
int main()
{
    cin>>s>>n;
    for (int i=0;i<s[0]-'0';i++) dp[0][i%n][0]++;
    dp[0][(s[0]-'0')%n][1]++;
    for (int i=1;i<s.size();i++)
    {
        for (int j=0;j<=9;j++)
        {
            for (int k=0;k<n;k++)
            {
                dp[i][(k+j)%n][0]+=dp[i-1][k][0]%mod;
                dp[i][(k+j)%n][0]%=mod;
                if (j>s[i]-'0') continue;
                else if (j==s[i]-'0')
                {
                    dp[i][(k+j)%n][1]+=dp[i-1][k][1]%mod;
                    dp[i][(k+j)%n][1]%=mod;
                }
                else
                {
                    dp[i][(k+j)%n][0]+=dp[i-1][k][1];
                    dp[i][(k+j)%n][0]%=mod;
                }
            }
        }
    }
    cout<<(dp[s.size()-1][0][0]%mod+(dp[s.size()-1][0][1]%mod-1+mod)%mod)%mod;
    return 0;
}


Measured memory_bytes: 15872
n=int(input())
a=[]
b=[int(i) for i in input().split()]
a.append(b[0])
b_len=len(b)
for i in range(n-1):
  if i+1 < b_len:
    a.append(min(b[i],b[i+1]))
  else:
    a.append(b[i])
print(sum(a))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <functional>

using namespace std;

int main(){
  int A, P;
  cin >> A >> P;
  cout << (A * 3 + P) / 2 << endl;
  return 0;
}


Measured memory_bytes: 764
N,M=map(int,input().split())
li=[[list(map(int,input().split())),i] for i in range(M)]
li=sorted(li, key=lambda x:x[0][1])
counter=[0]*N
li_id=[]

for j in li:
    counter[int(j[0][0])-1]+=1
    x=str(j[0][0])
    y=str(counter[int(j[0][0])-1])
    ID=('0'*(6-len(x)))+x+('0'*(6-len(y)))+y
    li_id.append([j[1],ID])
li_id=sorted(li_id)
for k in li_id:
    print(k[1])

Measured memory_bytes: 100952
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    System.out.println("A" + s2.substring(0,1) + "C");
  }
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int gcd(int a, int b){
    if (a%b==0){
        return (b);
    }
    else{
        return (gcd(b,a%b));
    }
}

int lcm(int a, int b){
    return a*b/gcd(a,b);
}

int main() {
    int N,M; cin >> N >> M;
    vector<int> A(N);
    REP(i,N){
        cin >> A[i];
    }

    int a = A[0];
    int p = 0;
    while (a%2 == 0){
        a/=2;
        p++;
    }

    int evens = pow(2,p);

    REP(i,N){
        if(A[i]%evens!=0 || A[i]%(evens*2)==0){
            cout << 0 << endl;
            return 0;
        }
    }

    ll L = A[0];

    REP(i,N-1){
        L = lcm(L,A[i+1]);
    }

    L/=2;

    ll ans = M/L;
    if(ans%2 == 0){
        cout << ans/2 << endl;
    }else{
        cout << ans/2+1 << endl;
    }

    
    return 0;
}

Measured memory_bytes: 4160
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	int l = to_string(n).size();
	int ans = 0;
	switch (l) {
	case 1:
		ans = n;
		break;
	case 2:
		ans = 9;
		break;
	case 3:
		ans = 9 + n - 100 + 1;
		break;
	case 4:
		ans = 909;
		break;
	case 5:
		ans = 909 + n - 10000 + 1;
		break;
	case 6:
		ans = 90909;
		break;
	default:
		break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template <typename X>
struct Number{
  X n;
  vector<bool> prime;
  
  Number(X _n)
  {
    n = _n;
  }
  
  //nの約数を全列挙
  vector<X> divisor()
  {
    vector<X> res(0);
    for(X i=1;i*i<=n;++i){
      if(n%i==0){
	res.push_back(i);
	if(i != n/i) res.push_back(n/i);
      }
    }
    sort(res.begin(), res.end());
    return res;
  }
  
  //nを素因数分解
  map<X,int> prime_factor()
  {
    int nn = n;
    map<X,int> res;
    for(X i=2;i*i<=nn;++i){
      while(nn%i==0){
	res[i]++;
	nn /= i;
      }
    }
    if(nn!=1) res[nn] = 1;
    return res;
  }

  //n以下の素数を全列挙
  vector<X> sieve()
  {
    prime.assign(n+1,true);
    vector<X> res(0);
    if(n<=1) return res;
    prime[0] = prime[1] = false;
    for(X i = 2;i<=n;++i){
      if(prime[i]){
	res.push_back(i);
	X b = i*2;
	while(b<=n){
	  prime[b] = false;
	  b += i;
	}
      }
    }
    return res;
  }
  
};

int main()
{
  int n;
  cin >> n;
  Number<int> nb(n-1);
  vector<int> pri = nb.sieve();


  int x = n;
  while(1){
    bool f = true;
    rep(i,pri.size()){
      if(x%pri[i]==0){
	f =false;
	break;
      }
    }
    if(f){
      cout << x << "\n";
      break;
    }
    x++;
  }
  
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const int P=1E9+7;

struct Mat{
	ll a[3][3];

	Mat(){memset(a,0,sizeof a);}

	ll* operator [] (int x){return a[x];}
	const ll* operator [] (int x) const {return a[x];}

	Mat operator * (const Mat &rhs) const
	{
		Mat ret;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					ret[i][j]+=a[i][k]*rhs[k][j]%P;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				ret[i][j]%=P;
		return ret;
	}
}trans0,trans1;

Mat ksm(Mat a,ll b)
{
	Mat ret;
	ret[0][0]=ret[1][1]=ret[2][2]=1;
	for(;b;b>>=1,a=a*a)
		if(b&1)
			ret=ret*a;
	return ret;
}

int main()
{
	//not break
	trans0[0][0]=1;trans0[0][1]=1;trans0[0][2]=1;
	trans0[1][1]=1;trans0[1][2]=2;
	trans0[2][2]=1;
	//break
	trans0[2][0]+=1;trans0[2][1]+=1;trans0[2][2]+=1;
	//not break
	trans1[0][0]=1;trans1[0][1]=1;trans1[0][2]=1;
	trans1[1][1]=1;trans1[1][2]=2;
	trans1[2][2]=1;
	Mat res;
	res[0][0]=1;res[0][1]=1;res[0][2]=1;
	int n,m,x,lst=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		int dlt=x-lst-1;
		res=res*ksm(trans0,dlt)*trans1;
		lst=x;
	}
	res=res*ksm(trans0,n-lst-1);
	printf("%lld\n",res[0][2]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MD = 1000003;
int q;
ll x, d, n;
using ll = long long;
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MD) if(n%2) (res *= b) %= MD;
	return res;
}
ll a[MD] = {1};
int main(){
	for(int i = 1; i < MD; i++) a[i] = a[i-1] * i % MD;
	scanf("%d", &q);
	rep(i,q){
		scanf("%lld%lld%lld", &x, &d, &n);
		if(d == 0) printf("%lld\n", exp(x, n));
		else{
			x = x * exp(d, MD-2) % MD;
			if(x + n-1 >= MD) puts("0");
			else printf("%lld\n", exp(a[x-1], MD-2) * a[x+n-1] % MD * exp(d,n) % MD);
		}
	}
}

Measured memory_bytes: 8704
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
 int arr[N];
int main() {
    quick
int n; cin>>n;
for(int i=0;i<n;i++){cin>>arr[i];}
for(int i=n-1;i>0;i--){
if(arr[i]<arr[i-1]){ arr[i-1]--;}
}
    for(int i = 1; i < n; i++)
        if(arr[i-1] > arr[i])
            return cout <<"No", 0;

    cout<<"Yes";
}

Measured memory_bytes: 768
n = int(input())
lst = []
for i in range(n):
  s, p = input().split()
  p = int(p)
  lst.append((s, p, i+1))
lst_sorted = sorted(lst, key=lambda x: (x[0], -x[1], x[2]))
for _, _, num in lst_sorted:
  print(num)


Measured memory_bytes: 9184
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n;

void preParse (int u) {
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].left);
    preParse(T[u].right);
}

void inParse (int u) {
    
    if (u == NIL) return;
    inParse(T[u].left);
    printf(" %d", u);
    inParse(T[u].right);
}

void postParse (int u) {

    if (u == NIL) return;
    postParse( T[u].left);
    postParse(T[u].right);
    printf(" %d", u);
}

int main(void) {
    int i, v, l, r ,root = 0;
    scanf("%d", &n);
    for (i = 0 ; i < n ; i ++ ) T[i].parent = NIL;

    for ( i = 0 ; i < n ; i++ ) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if (l != NIL) T[l].parent = v;
        if (r != NIL) T[r].parent = v;
    }

    for ( i = 0 ; i < n ; i++ ) if (T[i].parent == NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);

    printf("\n");

    return 0;
}

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

int main(){
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(m==2){
        ans +=1;
    }else if(m>=3){
        ans += m*(m-1)/2;
    }
    if(n==2){
        ans+=1;
    }else if(n>=3){
        ans+=n*(n-1)/2;
    }
    cout<<ans<<endl;;
}

Measured memory_bytes: 256
s = input()

cnt1 = 0
cnt2 = 0
for i, char in enumerate(s):
    if i % 2 == 0:
        if char == '1':
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if char == '1':
            cnt2 += 1
        else:
            cnt1 += 1
print(min(cnt1,cnt2))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> Pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define first fs
#define second ss
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){

 
 int a,b;
 cin >> a >> b;
 int c = 1;
 int ans = 0; 
  while(true){
   if(c >= b){ 
    break;
   }
    c += (a-1);
    ans++;
  }
 
cout << ans <<endl;

}




Measured memory_bytes: 256
#include<stdio.h>


struct dice{
            int n[6];
            };

struct dice dice1;

void e(){
         int buff=0;
         buff=dice1.n[0];
         dice1.n[0]=dice1.n[3];
         dice1.n[3]=dice1.n[5];
         dice1.n[5]=dice1.n[2];
         dice1.n[2]=buff;
         }

void s(){
         int buff=0;
         buff=dice1.n[0];
         dice1.n[0]=dice1.n[4];
         dice1.n[4]=dice1.n[5];
         dice1.n[5]=dice1.n[1];
         dice1.n[1]=buff;
         }

void w(){
         int buff=0;
         buff=dice1.n[0];
         dice1.n[0]=dice1.n[2];
         dice1.n[2]=dice1.n[5];
         dice1.n[5]=dice1.n[3];
         dice1.n[3]=buff;
         }

void n(){
         int buff=0;
         buff=dice1.n[0];
         dice1.n[0]=dice1.n[1];
         dice1.n[1]=dice1.n[5];
         dice1.n[5]=dice1.n[4];
         dice1.n[4]=buff;
         }

int main(){
           int me,i;
           char muki[101];
           
                   for(i=0;i<6;i++){
                           scanf("%d",&me);
                           dice1.n[i]=me;
                                    }
                   scanf("%s",&muki);

                   for(i=0;i<101;i++){
                                      if(muki[i]=='\n')break;
                                      if(muki[i]=='E')e();
                                      if(muki[i]=='S')s();
                                      if(muki[i]=='W')w();
                                      if(muki[i]=='N')n();
                                      }
               printf("%d\n",dice1.n[0]);
                    
               return 0;
              }



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
int dp[102][100005];
vector<pair<int,int>>v;
int n, W;
int solve(int i, int w){
  if(i==n)
        return 0;
    if(dp[i][w]!=-1)
        return dp[i][w];
    int ans = 0;
    if(v[i].first<=w)
        ans = v[i].second + solve(i+1,w-v[i].first);
    ans = max(ans,solve(i+1,w));
    return dp[i][w]=ans;
 
}
int32_t main(){
  ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
  
  cin>>n>>W;
    for(int i=0;i<n;i++){
        pair<int,int> p;
        cin>>p.first>>p.second;
        v.push_back(p);
    }
    // ans = max(v[i] + dp[i+1][W-w[i]],dp[i+1][W]);
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,W);
 
    return 0;
}

Measured memory_bytes: 80000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int M[1000];
	
	while(true){
		int N, Q, d, ans;
		cin >> N >> Q;
		if(N == 0 && Q == 0){
			break;
		}
		for(int i = 0; i < 1000; i++){
			M[i] = 0;
		}
		int num;
		for(int loop = 0; loop < N; loop++){
			cin >> num;
			for(int i = 0; i < num; i++){
				cin >> d;
				M[d]++;
			}
		}
		ans = 0;
		for(int i = 0; i < 1000; i++){
			if(M[i] >= Q){
				ans = i;
				Q = M[i] + 1;
			}
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, in;
    int n, r; cin>>n>>r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100*(10-n) <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;long N=S.length();
  vector<long>A(N),B(N);
  for(long i=0;i<N;i++)A[i]=(i>0?A[i-1]:0)+2*(S[i]=='g')-1;
  for(long i=N-1;i>=0;i--)B[i]=min((i<N-1?B[i+1]:LONG_MAX),A[i]);
  long n=0,ans=0;
  for(long i=0;i<N;i++){
    if(B[i]-(n+2)>=0){ans++;n+=2;}
  }
  cout<<ans;
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<stack>
#include<iomanip>
#include<functional>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    ll n,m;
    cin>>n>>m;
    ll h=0;
    rep(i,m)
    {
        ll a;
        cin>>a;
        h+=a;
    }
    if(n-h>=0)
    {
        cout<<n-h;
    }
    else
    {
        cout<<-1;
    }
    
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 2e5 + 10, MOD = 1e9 + 7;
typedef long long ll;
#define int ll

int n, m, k, inv[MAXn], fact[MAXn], ans;

int comb(int kk, int nn) {
	return (fact[nn] * ((inv[nn-kk] * inv[kk]) % MOD)) % MOD;
}
int32_t main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> m >> k;
	inv[0] = fact[0] = inv[1] = fact[1] = 1;
	for (int i = 2; i < MAXn; i++) {
		fact[i] = (fact[i-1] * i) % MOD;
		inv[i] = ((MOD - MOD / i) * inv[MOD % i]) % MOD;
	}
	for (int i = 1; i < MAXn; i++)
		inv[i] = (inv[i] * inv[i-1]) % MOD;
//	cout << comb(2, 5) << endl;
	for (int i = 1; i <= n; i++) {
		ans += (i * ((((((i - 1) * m) % MOD) * m) * comb(k-2, n * m - 2)) % MOD)) % MOD;
		ans %= MOD;
		ans += ((MOD - i) * ((((((n - i) * m) % MOD) * m) * comb(k-2, n * m - 2)) % MOD)) % MOD;
		ans %= MOD;
	}
	for (int i = 1; i <= m; i++) {
		ans += (i * ((((((i - 1) * n) % MOD) * n) * comb(k-2, n * m - 2)) % MOD)) % MOD;
		ans %= MOD;
		ans += ((MOD - i) * ((((((m - i) * n) % MOD) * n) * comb(k-2, n * m - 2)) % MOD)) % MOD;
		ans %= MOD;
	}
	cout << ans;
}


Measured memory_bytes: 3328
S = input()
H = len(S) 
a = '0'
b = '1'
A = 0
B = 0
while len(a) < H:
    a = a + '1'
    if len(a) < H:
        a = a + '0'

        
while len(b) < H:
    b = b + '0'
    if len(b) < H:
        b = b + '1'

        
for i in range(H):
    if a[i] == S[i]:
        A = A + 1

for i in range(H):
    if b[i] == S[i]:
        B = B + 1

print(H - max(A,B))
    

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

using namespace std;
using boost::rational;
using boost::multiprecision::cpp_int;
int main(){

    cpp_int a, b, c;
    cin >> a >> b >> c;
//    cout << (c - a - b) * (c - a- b );
    if (c - a - b < 0) {
        cout << "No" << endl;
        return 0;
    }
    if ((c - a - b) * (c - a - b) > (4 * a * b)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
//#define mod 1e9+7 // was not working
//const int mod=1e9+7; //works kool
vector<int>S(100);

int main() {
    fast;
    int N, K;
    cin>>N>>K;
    vector<bool>dp(100001, false);

    for(int i=0;i<N;i++)
       cin>>S[i];

    for(int i=0;i<=K;i++){
        for(int j=0;j<N;j++){
            //cout<<i<<" "<<i-j<<endl; 
            if(i-S[j] >=0 && dp[i-S[j]]==0)
                dp[i]=1;
        }
    }
    //out<<dp[K]<<endl;
    if(dp[K])
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <cmath>
#include <random>
using namespace std;
typedef pair<int, int>p;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	long long sa = b - a;
	string ans="NO";
	for (int i = 0; i<n; i++) {
		int j = n - 1 - i;
		long long maxi = i*d - j*c;
		long long mini = i*c - j*d;
		if (maxi >= sa&&mini <= sa) {
			ans = "YES";
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int l[222];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 2*n; i++)cin >> l[i];
	sort(l, l + 2 * n);
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2)ans += l[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };


int main() {
	int time[5];
	for (int i = 0; i < 5;i++)scanf("%d", &time[i]);

	int minFirst = c_INF;

	for (int i = 0; i < 5; i++)
		if(time[i]%10 != 0)
			minFirst = min(minFirst, time[i] % 10);

	
	if (minFirst == c_INF)
		printf("%d", time[0] +time[1]+time[2]  + time[3] +time[4] );
	else printf("%d", ((time[0] + 9) / 10 + (time[1] + 9) / 10 + (time[2] + 9) / 10 + (time[3] + 9) / 10 + (time[4] + 9) / 10) * 10 -10 + minFirst);
	
}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <bits/stdc++.h>
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(void){

    int N;
    cin >> N;
    int a[2*N];

    REP(i,2*N){
        cin >> a[i];
    }

    sort(a,a+2*N);
    //REP(i,2*N) cout << a[i] << endl;
    int sum = 0;
    
    REP(i,2*N){
        //debug(a[i]);
        if(i % 2 == 0)
            sum += a[i];
    }

    cout << sum << endl;
    return 0;
}


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

int main() {
  int N;
  double x;
  string u;
  
  cin >> N;
  
  double sum = 0;
  for(int i=0; i<N; i++) {
    cin >> x >> u;
    if(u=="JPY") {
      sum += x;
    } else {
      sum += x * 380000;
    }
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1) cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1) cout<<#x<<":"<<x<<endl;
#define ll long long
 
//constant
const int MOD=1000000007;
const int INF=INT_MAX/3-1;
const double EPS=1e-9;
const int dx4[]={1,0,-1,0};
const int dy4[]={0,1,0,-1};
 
//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
 
int main(){
int a[3];
    cin>>a[0]>>a[1]>>a[2];
        int cf=0,cs=0;
            REP(i,3){
                    if(a[i]==5)
                                cf++;
                                        if(a[i]==7)
                                                    cs++;
 
                                                         }
                                                             if(cs==1&&cf==2)
                                                                     cout<<"YES"<<endl;
                                                                         else
                                                                                 cout<<"NO"<<endl;
 
 
                                                                                       return 0;
                                                                                      
                                                                                        }

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

using namespace std;
const int MOD = (int)1e9 + 7;
int add(int a, int b) {
	int c  = a + b;
	if (c >= MOD) c -= MOD;
	return c;
}
int main()
{

	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>> dp(n + 1, vector<int> (n + 2));

	dp[1][1]  = 1;
	for (int i = 2; i <= n; i++) {
		if (s[i - 2] == '>') {
			for (int j = i; j >= 1; j--) {
				dp[i][j] = add(dp[i][j + 1], dp[i - 1][j]);
			}
		} else {
			for (int j = 1; j <= i; j++) {
				dp[i][j] = add(dp[i][j - 1], dp[i - 1][j - 1]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) ans = add(ans, dp[n][i]);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 38616
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
    long long a,b,cnt=0,m=0;
    scanf("%lld%lld",&a,&b);
    long long k=__gcd(a,b);
    cnt++;
    for(long long i=2;i<=(int)sqrt(k);i++)
    {
        if(k%i==0)
        {
            cnt++;
        }
        while(k%i==0)
        {
            k/=i;
        }
    }
    if(k>1)
    {
        cnt++;
    }
    printf("%lld\n",cnt);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int dh[] = { 0,1,0,-1 };
int dw[] = { 1,0,-1,0 };
int cnv(int cur, int state) {
    if (state == 0) return cur;
    if (state == 1) return (cur + 1) % 4;
    if (state == 2) return (cur + 2) % 4;
    if (state == 3) return ((cur - 1) % 4 + 4) % 4;
    if (state == 4) return 4;
}

int cost_idx(int cur, int next) {
    if (cur == next) return 0;
    else if ((cur + 1) % 4 == next) return 1;
    else if ((cur + 2) % 4 == next) return 2;
    else return 3;
}
void solve() {
    int W, H; scanf("%d %d", &W, &H); if (W == 0 and H == 0) exit(0);
    vector<vector<int>> a(H, vector<int>(W));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) scanf("%d", &a[i][j]);
    int cost[4]; for (int i = 0; i < 4; i++) scanf("%d", &cost[i]);
    //現在の状態:: 0→右，1→下，2→左，3→上，4→停止
    using T = tuple<int, int, int, int>;
    priority_queue<T, vector<T>, greater<T>> pq;
    vector<vector<vector<int>>> d(H, vector<vector<int>>(W, vector<int>(4, inf)));
    d[0][0][0] = 0;
    pq.emplace(0, 0, 0, 0);
    while (!pq.empty()) {
        int c, h, w, cur; tie(c, h, w, cur) = pq.top();
        pq.pop();
        if (d[h][w][cur] < c) continue;
        int next = cnv(cur, a[h][w]);
        for (int i = 0; i < 4; i++) {
            int nh = h + dh[i];
            int nw = w + dw[i];
            if (nh < 0 or nh >= H or nw < 0 or nw >= W) continue;
            if (next == i) {
                if(chmin(d[nh][nw][i], d[h][w][cur])) pq.emplace(d[nh][nw][i], nh, nw, i);
            }
            else {
                if(chmin(d[nh][nw][i], d[h][w][cur] + cost[cost_idx(cur, i)])) pq.emplace(d[nh][nw][i], nh, nw, i);
            }
        }
    }
    int res = inf; for (int i = 0; i < 4; i++) chmin(res, d[H - 1][W - 1][i]);
    printf("%d\n", res);
}

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

    int kkt = 89;
    while (kkt) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3220
import heapq
import math
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
logof2=[0]*N
mi=0
buf=0
#print(A)
for i in range(N):
    A[i]=-A[i]
heapq.heapify(A)
for i in range(M):
    buf=heapq.heappop(A)
    buf=(-buf)//2
    buf=-buf
    heapq.heappush(A,buf)
    #print(A)
for i in range(N):
    mi=mi-math.floor(A[i])

print(mi)


Measured memory_bytes: 14380
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (A == B && B == C && C == A) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3540
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(){
    int n, d[100][2], i, j, flag = 1;

    scanf("%d", &n);

    for(i = 0;i < n;i++){
        for(j = 0;j < 2;j++){
            scanf("%d", &d[i][j]);
        }
    }

    for(i = 0;i < n - 2;i++){
        if(d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]){
            flag = 0;
        }
    }
    if(flag) puts("No");
    else puts("Yes");

    return 0;
}

Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int gcd(int x,int y){
    return y ? gcd(y,x%y) : x;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    string str = "";
    bool flag = false;
    rep(i,0,n){
        //if(i+1 >= n)break;
        if(str[str.size()-1]==s[i]){
            //ばか
        }else{
            str += s[i];
        }
    }
    cout << str.size() << endl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  int a, p; cin >> a >> p;
  cout << (3*a+p)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

using namespace std;
using PII = pair<int, int>;

const long long inf = 1e18;
// const long long inf = 100;

void show(vector<long long> &v) {
	for (auto x : v) {
		cout << x << " ";
	}
	cout << endl;
}

int main() {
	int n, m, l, r, d;
	cin >> n >> m;

	vector<vector<PII>> connect(n);

	for (int i = 0; i < m; i++) {
		cin >> l >> r >> d;
		l--;
		r--;
		connect[l].emplace_back(make_pair(r, d));
		connect[r].emplace_back(make_pair(l, -d));
	}

	vector<long long> place(n, inf);
	set<int> unused;
	for (int i = 0; i < n; i++) {
		unused.insert(i);
	}
	queue<int> que;

	while (!unused.empty()) {
		int st = *unused.begin();
		place[st] = 0;
		que.push(st);
		unused.erase(st);

		while (!que.empty()) {
			auto from = que.front();
			que.pop();
// printf("from %d\n", from);

			for (auto p : connect[from]) {
				int to = p.first;
				int dist = p.second;
// printf("to %d, %d\n", to, dist);
// show(place);
				if (place[to] == inf) {
					place[to] = place[from] + dist;
					que.push(to);
					unused.erase(to);
				} else if (place[to] != place[from] + dist) {
					cout << "No" << endl;
					return 0;
				}
// show(place);
			}
		}
	}
/*
	for (int i = 0; i < m; i++) {
		for (auto p: connect[i]) {
			if (place[i] != place[p.first] - p.second) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
*/

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


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int H,N;
    cin >> H>>N;
  int vec[N];
    int sum=0;
    REP(i,N){
        cin >> vec[i];
        sum+=vec[i];
     // cout << sum << endl;
    }
    if (sum >= H ){
        cout << "Yes"<< endl;
    }
    else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 640
#include<iostream>
#include<vector>

template<class T> inline void chmin(T& a, T b){
	if(a > b){
		a = b;
		return;
	}
	return;
}

const long long INF = 1ll << 60;

int main(){
	int n;
	long long W;
	std::cin >> n >> W;
	std::vector<long long> w(n), v(n);
	for(int i=0; i<n; i++){
		std::cin >> w[i] >> v[i];
	}

	std::vector<std::vector<long long>> dp(n+1, std::vector<long long>(100001, INF));
	dp[0][0] = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<100001; j++){
			chmin(dp[i+1][j], dp[i][j]);
			if(j-v[i] >= 0){
				chmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
			}
		}
	}

	long long ans = 0;
	for(int i=0; i<100001; i++){
		if(dp[n][i] <= W){
			ans = i;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 80384
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int len = s.size(), ans = len;
  for(int i = 0; i < len - 1; i++){
  	if(s[i] != s[i + 1]){
    	ans = min(ans, max(i + 1, len - i - 1));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
x, y = map(int, input().split())

a = set([4, 6, 9, 11])
b  =set([1, 3, 5, 7, 8, 10, 12])

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
    ll dp[100005]={0};
    for(i=2;i<100005;i++){
        for(j=2;j*i<100005;j++){
            dp[i*j]=1;
        }
    }
    cin>>n;
    for(i=n;;i++){
        if(dp[i]==0){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 4412
n, a, b = map(int, input().split())

if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    print(min(n-a, b-1, (a-1) + 1 + (b-(a-1)-1-1)//2, (n-b) + 1 + (n-(a+n-b+1))//2))


Measured memory_bytes: 3316
#include<stdio.h>
#define N 10000
#define Q 500
int main()
{
  int s[N],t[Q];
  int i,q,n,l=0,j;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
    scanf("%d",&s[i]);
    }
    scanf("%d",&q);

  for(i=0;i<q;i++){

    scanf("%d",&t[i]);
    for(j=0;j<n;j++){
      if(s[j]==t[i]){
        l++;
        break;
      }
    }
  }

  printf("%d",l);
  printf("\n");
    return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	int temp;
	if(a<b){
		temp=b;
		b=a;
		a=temp;
	}
	while(1){
		temp=a%b;
		if(temp==0){
			printf("%d\n",b);
			return 0;
		}
		a=b;
		b=temp;
	}
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, i;
	scanf("%d", &N);
	int *p = (int *)malloc(sizeof(int) * N);
	int *q = (int *)malloc(sizeof(int) * N);
	int *a = (int *)malloc(sizeof(int) * N);
	int *b = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &p[i]);
		p[i]--;
		q[p[i]] = i;
	}
	a[0] = 1 + q[0];
	for(i = 1; i < N; i++){
		a[i] = 1 + a[i - 1] + q[i];
	}
	b[N - 1] = 1 + q[N - 1];
	for(i = N - 2; i >= 0; i--){
		b[i] = 1 + b[i + 1] + q[i];
	}
	for(i = 0; i < N; i++){
		printf("%d ", a[i]);
	}
	printf("\n");
	for(i = 0; i < N; i++){
		printf("%d ", b[i]);
	}
	printf("\n");
	return 0;
}

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

#define ll long long int

#define Bit_off(val,pos)       (val & (~(1<<pos)))
#define Bit_on(val,pos)        (val | (1<<pos))
#define Bit_toggle(val,pos)    (val ^ (1<<pos))
#define Bit_check(val,pos)     (bool)(val & (1<<pos))
#define odd_even(val)          (bool)(val & 1)
#define koita_1_ase(val)       (__builtin_popcount(val))

ll ar[5000009],br[5000009],cr[5000009];
map<ll,ll>mp,mp1;
vector<ll>v;

//void seive()
//{
//    ll i,j;
//
//    for(i=3; i<=10000; i+=2)
//    {
//        if(Bit_check(status[i>>5],i%32)==0)
//        {
//            for(j=(i*i); j<=100000000; j+=(i<<1))
//            {
//                status[j>>5]=Bit_on(status[j>>5],j%32);
//            }
//        }
//    }
//    for(i=3; i<100000000; i+=2)
//    {
//        if(Bit_check(status[i>>5],i%32)==0)
//        {
//            ///Prime
//        }
//    }
//}
int main()
{
    ll a,b,c,i,j,k,x,y=99999999999999,z,f,g,h;
    string s,d;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        cin>>ar[i];
    }
    for(i=1;i<=10000;i++)
    {
        x=0;
        for(j=1;j<=a;j++)
        {
            x=x+(ar[j]-i)*(ar[j]-i);
        }
        y=min(y,x);
    }
    cout<<y<<endl;
}


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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	while(1){
		int n, m, p;
		cin >> n >> m >> p;
		if(n == 0 && m == 0 && p == 0) break;

		int sum = 0;
		int pick = -1;
		for(int i=1; i<=n; i++){
			int x;
			cin >> x;
			sum += x * 100;
			if(i == m) pick = x;
		}
		if(pick == 0){
			cout << 0 << endl;
			continue;
		}
		int ans = (sum - sum*p/100) / pick;

		cout << ans << endl;

	}
	
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
#define int long long int
signed main(){
  int n,k;
  cin>>n>>k;
  int ans=k;
  int i;
  for(i=1;i<=30;i++){
    if(ans>n)	break;
    ans*=k;
  }
  cout<<i<<endl;
  return 0;
}


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

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

using namespace std;

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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    bool eq = (4 * a * b == (c - a - b) * (c - a - b));
    if (eq) {
        cout << "No" << endl;
        return 0;
    }

    bool ans = sqrt((long double)a) + sqrt((long double)b) < sqrt((long double)c);
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256