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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
//No change above here

const ll maxi = 2 * 1e5 + 5;
ll mod = 5;
double pi = 3.141592653589793238;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

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

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

ll max_subarray(vector<int>& v)
{
	if (v.empty())
		return 0;
	ll glob = v[0], loc = v[0];
	for (int i = 1; i < v.size(); ++i)
	{
		loc = max(v[i] + 0LL, loc + v[i]);
		glob = max(loc, glob);
	}
	return glob;
}

long long num_digits(long long x)
{
	long long ans = 0;
	while (x)
	{
		++ans;
		x /= 10;
	}
	return ans == 0 ? 1 : ans;
}

vector<int> topological_sort(vector<vector<int>>& graph, int n, vector<int>& indegree)
{
	vector<int> ans;
	stack<int> s;
	for (int i = 0; i < n; ++i)
		if (indegree[i] == 0)
			s.push(i);
	while (!s.empty())
	{
		int x = s.top();
		s.pop();
		ans.push_back(x);
		for (auto& adj : graph[x])
			if (--indegree[adj] == 0)
				s.push(adj);
	}
	return ans;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }


//declare needed things here


int main()
{
	IOS;
	ll n, d,x,y,ans=0;
	cin >> n >> d;
	while (n--)
	{
		cin >> x >> y;
		if (x * x + y * y <= d * d)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int i, j, k, s, X, A, B, C;
    s = 0;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&X);
    for(i=0;i<=A;i++)
        for(j=0;j<=B;j++)
            for(k=0;k<=C;k++)
               if(i*500+j*100+k*50==X)
                  s++;
    printf("%d",s);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int main() {
	int n, ans = 0;
	vector<int> a;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (a[a[i] - 1] - 1 == i)
			ans++;
	}
	cout << ans / 2 << endl;
	//cin >> n;
	return 0;
}

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

int main() {
  int i, count;
  string W;
  string T;

  count = 0;
  cin >> W;

  for (i = 0; i < W.size(); i++) {
    if (isupper(W[i])) {
      W[i] = tolower(W[i]);
    }
  }

  while (1) {
    cin >> T;
    if (T == "END_OF_TEXT") {
      break;
    }
    for (i = 0; i < T.size(); i++) {
      if (isupper(T[i])) {
        T[i] = tolower(T[i]);
      }
    }
    if (T == W) {
      count++;
    }
  }

  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	char n; cin >> n;
	
	char ans = 'A';
	
	if ('a' <= n && n <= 'z') ans = 'a';
	
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  if (N == 1) cout << 1 << endl;
  
  else if (N == 2) {
    int a, b;
    cin >> a >> b;
    if (abs(a - b) <= 2) cout << 2 << endl;
    else cout << 1 << endl;
  }
  
  else {
    vector<int> X(100000);
    for (int i = 0; i < N; i++) {
      int a;
      cin >> a;
      X.at(a) += 1;
    }
    int ans = 0;
    for (int i = 0; i < N - 2; i++) {
      ans = max(ans, X.at(i) + X.at(i + 1) + X.at(i + 2));
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 640
#include <cstdio>
#define N 100000

void exchange(int A[], int index, int r) {
    int tmp = A[index];
    A[index] = A[r];
    A[r] = tmp;
}

int Partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j<r; j++) {
        if (A[j] <= x) {
            i++;
            exchange(A, i, j);
        }
    }
    exchange(A, i+1, r);
    return i + 1;
}


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

    int r = Partition(A, 0, n-1);
    for(int i=0; i<n; i++) {
        if (i == r) printf("[%d]", A[i]);
        else printf("%d", A[i]);
        if (i == n-1) printf("\n");
        else printf(" ");
    }

    return 0;
}

Measured memory_bytes: 1424
#include<bits/stdc++.h>
using namespace std;
long long n;
long long A[1000000],dp1[1000000],dp2[1000000],S[1000000];
int main() {
	cin>>n;
	n=(long long)pow(2,n);
	for(int i=0;i<n;i++) {
      scanf("%lld",&A[i]);
      dp1[i] = 0;
      dp2[i] = 0;
    }
	for(int i=0;i<n;i++) {
      for(int j=i;j>0;j=(j-1)&i) {
        if (dp1[i] >= A[j]) {
          dp2[i] = max(dp2[i], A[j]);
        } else {
          dp2[i] = dp1[i];
          dp1[i] = A[j];
        }
      }
      if (dp1[i] >= A[0]) {
        dp2[i] = max(dp2[i], A[0]);
      } else {
        dp2[i] = dp1[i];
        dp1[i] = A[0];
      }
    }

    S[0] = dp1[0] + dp2[0];
	for(int i=1;i<n;i++) {
      S[i] = dp1[i] + dp2[i];
      S[i] = max(S[i-1], S[i]);
    }
	for(int i=1;i<n;i++)printf("%lld\n",S[i]);
	return 0;
} 

Measured memory_bytes: 12440
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    if(a <= b){
        cout << a << endl;
    }else{
        cout << a-1 << 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);

        int n = sc.nextInt();
        if (n == 1)
            System.out.println("Hello World");
        else if (n == 2) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a + b);
        }
    }
}


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

int main() {
  int a,b,c; cin>>a>>b>>c;
  if(b-a == c-b) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

using namespace std;

int ar[6];
int ck[]={1,9,7,4};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	for(int i=0;i<4;i++)
		cin>>ar[i];
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<4;j++)
		{
			if(ck[i]==ar[j])
				break;
			if(j==3)
			{
				cout<<"NO";
				return 0;
			}
		}
	}
	cout<<"YES";
	return 0;
}

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

int gcd(int, int);

int main()
{
	int x, y;
	cin >> x >> y;
	if(x < y) swap(x, y);
	cout << gcd(x, y) << endl;
	return 0;
}

int gcd(int x, int y)
{
	if((x % y) == 0)
	{
		return y;
	}
	else
	{
		return gcd(y, (x % y));
	}  
}


Measured memory_bytes: 3108
from collections import deque

N, M = map(int, input().split())
ab = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

visit = [-1]*N
visit[0] = 0
q = deque()
q.append([0, 0])
while len(q) > 0:
    v, c = q.popleft()
    for u in ab[v]:
        if visit[u] < 0:
            visit[u] = v
            q.append([u, v])

ok = True
for i in range(1, N):
    if visit[i] < 0:
        ok = False

if ok:
    print("Yes")
    for i in range(1, N):
        print(visit[i]+1)
else:
    print("No")


Measured memory_bytes: 100836
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[9],n=3;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	a[2]*=10;
	cout<<a[0]+a[1]+a[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int h,w,n,ans=inf; cin>>h>>w>>n;
    rep(i,h+1)rep(j,w+1){
        if(h*w-(h-i)*(w-j)>=n) ans=min(ans,i+j);
    }
    cout<<ans<<endl;
}


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

int main ()
{
  int H,W;
  while(1)
    {
      cin >> H >> W;
      if(H==0&&W==0)   break;
      for(int i=0;i<H;i++)
        {
          for(int j=0;j<W;j++)
            {
              if(i==0||j==0||j==W-1||i==H-1)   cout << "#";
              else   cout << ".";
            }
          cout << endl;
        }
      cout << endl;
    }
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double value = v[0];
    for (int i = 1; i < N ; i++)
    {
        value = (value + v[i]) / 2;
    }
    
    cout << value << endl;
    return 0;
    
}

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

using namespace std;

struct Combination {
    vector<int64_t> fact, rfact;
	const int64_t MOD = 1000000007;

    Combination(int sz) : fact(sz + 1), rfact(sz + 1) {
        fact[0] = 1;
        for(int i = 1; i < fact.size(); i++){
            fact[i] = fact[i - 1] * i % MOD;
        }
        rfact[sz] = inv(fact[sz]);
        for(int i = sz - 1; i >= 0; i--){
            rfact[i] = rfact[i + 1] * (i + 1) % MOD;
        }
    }
    int64_t inv(int x) const {
        return pow(x, MOD - 2);
    }
    int64_t pow(int64_t x, int64_t n) const {
        int64_t ret = 1;
        while (n > 0) {
            if (n & 1) { (ret *= x) %= MOD; }
            (x *= x) %= MOD;
            n >>= 1;
        }
        return (ret);
    }

    int64_t P(int n, int r) const {
        if (r < 0 || n < r) { return 0; }
        return (fact[n] * rfact[n - r] % MOD);
    }

    int64_t C(int p, int q) const {
        if (q < 0 || p < q) { return 0; }
        return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
    }

    int64_t H(int n, int r) const {
        if (n < 0 || r < 0) { return 0; }
        return (r == 0 ? 1 : C(n + r - 1, r));
    }
};

int main() {
	const Int MOD = 1e9 + 7;
	Int N, K;
	cin >> N >> K;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	Combination cb(N * 2);
	sort(a.begin(), a.end());
	Int ans = 0;
	for (int i = 0; i < N; ++i) {
		Int ma = cb.C(i, K - 1) * a[i] % MOD;
		Int mi = cb.C(N - i - 1, K - 1) * a[i] % MOD;
		(ans += (ma + MOD - mi) % MOD) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}



Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        int[] dp = new int[X+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        int[] types = {100,101,102,103,104,105};
        for (int i = 0; i <= X; i++) {
            if (dp[i] == Integer.MAX_VALUE) {
                continue;
            }
            for (int j = 0; j < 6; j++) {
                if (X < i + types[j]) {
                    continue;
                }
                dp[i + types[j]] = 1;
            }
        }
        System.out.println(dp[X] == 1 ? 1 : 0);
    }
}


Measured memory_bytes: 23764
//abc170

#include <bits/stdc++.h>
using namespace std;

int main() {
  int x,y;
  string ans = "No";
  cin >> x >> y;

  for(int i=0 ; i<=x ; i++){
    if(i*2 + (x-i)*4 == y){
      ans = "Yes";
      break;
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 3460
import java.io.*;
import java.math.*;
import java.util.*;



public class Main {

    static MyScanner ob = new MyScanner();
    static   PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    static int N ;
    static int [] A;
     static char[][] arr = new char[100][1000];
    public static void main(String args[]) throws IOException {
       int N = ob.nextInt();
       long [] arr = new long[N];
       boolean zero = false;
       for(int i=0;i<N;i++){
           arr[i] = ob.nextLong();
           if(arr[i]==0){
               zero = true;
           }
       }
       long max = 10;
       for(int i=0;i<17;i++){
           max*=10;
       }
       if(zero){
           pw.println(0);
       }else{
           boolean overflow = false;
           long prod = 1;
        for(int i=0;i<N;i++){
            if(arr[i]<=max/prod){
                prod*=arr[i];
            }else{
                overflow = true;
            }
        }
        pw.println(overflow?"-1":prod);
       }    
    
        pw.flush();
    }


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

Measured memory_bytes: 49240
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  if(N%K==0)  cout << 0 << endl;
  else  cout << 1 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()

bool isPrime(ll x) {
    if (x == 1) return false;
    if (x == 2) return true;
    for (int i = 3; i < x; i += 2) {
        if (x % i == 0) return false;
    }
    return true;
}

int main(void) {
    ll x;
    cin >> x;
    while (!isPrime(x)) x++;
    cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
using namespace std;
// using namespace atcoder;
void Main()
{
    ll H, W, K;
    cin >> H >> W >> K;

    ll sx, sy;
    cin >> sy >> sx;
    sx--;
    sy--;
    ll gx, gy;
    cin >> gy >> gx;
    gx--;
    gy--;

    vector<string> S(H);
    rep(i, H) cin >> S[i];
    
    // BFS
    ll INF = 1e18;
    vector<vector<ll>> d(H, vector<ll>(W, INF));
    
    typedef pair<ll, ll> P;
    queue<P> que;
 
    que.push(P(sx, sy));
    d[sy][sx] = 0;

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

    // BFS: グリッドの最短路
    while (que.empty() == false) {
        P q = que.front();
        ll x = q.first;
        ll y = q.second;
        que.pop();

        rep(i, 4) {
            repi(j, K+1) {
                ll x2 = dx[i] * j + x;
                ll y2 = dy[i] * j + y;
                if (x2 < 0 || W <= x2 || y2 < 0 || H <= y2) {
                    break;
                }
                if (S[y2][x2] == '@') {
                    break;
                }
                if (d[y2][x2] <= d[y][x]) {
                    break;
                }
                if (d[y2][x2] != INF) {
                    // already visited
                    continue;
                }
                d[y2][x2] = d[y][x] + 1;
                que.push(P(x2, y2));
            }
        }
    }

    ll res = d[gy][gx];
    if (res == INF) {
        put(-1);
    }
    else {
        put(res);
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 20032
l = [int(i) for i in input().split()]

a = float(l[0])
b = float(l[1])

d = round(a/b,5)

#print(str(int(l[0]/l[1])) + " " + str(l[0]%l[1]) + " " + str(d))
print(int(l[0]/l[1]),l[0]%l[1],d)

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	vi v(n);
	REP(i, n) {
		cin >> v[i];
	}
	vvl dp(n + 1, vl(n+1, INF*INF));
	dp[0][0] = 0;
	REP(i, n) {
		ll m = *min_element(dp[i].begin(), dp[i].begin() + v[i]);
		dp[i + 1][v[i]] = m;
		REP(j, v[i])dp[i + 1][j] = dp[i][j] + a;
		FOR(j, v[i] + 1, n + 1) dp[i + 1][j] = dp[i][j] + b;
	}
	cout << *min_element(ALL(dp[n])) << endl;
}

Measured memory_bytes: 195840
dice   = gets.split.map(&:to_i)
action = gets.chomp
upper  = dice[0]
side   = [ dice[4], dice[2], dice[1], dice[3] ]
bottom = dice[5]
action.chars do |str|
  b = bottom
  u = upper
  case str
  when "N"
    upper   = side[2]
    bottom  = side[0]
    side[2] = b
    side[0] = u
  when "E"
    upper   = side[3]
    bottom  = side[1]
    side[3] = b
    side[1] = u
  when "S"
    upper   = side[0]
    bottom  = side[2]
    side[0] = b
    side[2] = u
  when "W"
    upper   = side[1]
    bottom  = side[3]
    side[1] = b
    side[3] = u
  end
end
puts upper

Measured memory_bytes: 6112
IDENTIFICATION DIVISION.
PROGRAM-ID. ABC150_A.

ENVIRONMENT DIVISION.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 A1 PIC 9(15).
01 A2 PIC 9(15).
01 A3 PIC 9(15).
01 INPUT_LINE PIC X(15).
01 P1 PIC 9 VALUE 1.
01 P2 PIC 9.

PROCEDURE DIVISION.
MAIN.
    ACCEPT INPUT_LINE.

    PERFORM VARYING P2 FROM 1 BY 1
        UNTIL INPUT_LINE(P1 + P2:1) = SPACE
    END-PERFORM
    MOVE INPUT_LINE(P1:P2) TO A1
    ADD P2+1 TO P1

    PERFORM VARYING P2 FROM 1 BY 1
        UNTIL INPUT_LINE(P1 + P2:1) = SPACE
    END-PERFORM
    MOVE INPUT_LINE(P1:P2) TO A2
    ADD P2+1 TO P1

    PERFORM VARYING P2 FROM 1 BY 1
        UNTIL INPUT_LINE(P1 + P2:1) = SPACE
    END-PERFORM
    MOVE INPUT_LINE(P1:P2) TO A3
      
    IF A1 + A2 + A3 <= 21 THEN
        DISPLAY "win"
    ELSE
        DISPLAY "bust"
    END-IF

    STOP RUN.


Measured memory_bytes: 384
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;
int g[16][110][110];
int G[110][110];
int v[7];
int s[5];
int t[5];
int u[5];
int dp[5][110][16][7];
int main(){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		if(i!=j)G[i][j]=99999999;
	}
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);
		G[p][q]=G[q][p]=1;
	}
	
	for(int i=0;i<c;i++){
		scanf("%d%d%d",s+i,t+i,u+i);
	}
	for(int i=0;i<(1<<c);i++){
		for(int j=0;j<a;j++)for(int k=0;k<a;k++){
			g[i][j][k]=G[j][k];
		}
		for(int j=0;j<c;j++)if(i&(1<<j)){
			g[i][s[j]][t[j]]=g[i][t[j]][s[j]]=1;
		}
		for(int l=0;l<a;l++)for(int j=0;j<a;j++)for(int k=0;k<a;k++)
			g[i][j][k]=min(g[i][j][k],g[i][j][l]+g[i][l][k]);
	}
	for(int i=0;i<c;i++)v[i]=u[i];
	v[c]=d;v[c+1]=e;
	int n=c+2;
	for(int i=0;i<5;i++)for(int j=0;j<110;j++)for(int k=0;k<16;k++)for(int l=0;l<7;l++)
		dp[i][j][k][l]=999999999;
	int st=0;
	for(int i=0;i<c;i++)if(v[i]==d)st+=(1<<i);
	dp[0][0][st][c]=0;
	for(int i=0;i<=4;i++){
		for(int j=0;j<=f;j++){
			for(int k=0;k<(1<<c);k++){
				for(int l=0;l<n;l++){
					if(dp[i][j][k][l]>99999999)continue;
					if(i<4){
						dp[i+1][0][k][c]=min(dp[i+1][0][k][c],dp[i][j][k][l]+1);
					}
					for(int m=0;m<n;m++){
						if(j+g[k][v[l]][v[m]]<=f){
							int to=k;
							if(m<c)to|=(1<<m);
							dp[i][j+g[k][v[l]][v[m]]][to][m]=min(dp[i][j+g[k][v[l]][v[m]]][to][m],dp[i][j][k][l]+g[k][v[l]][v[m]]);
						}
					}
				}
			}
		}
	}
	int ret=999999999;
	for(int i=0;i<5;i++)for(int j=0;j<=f;j++)for(int k=0;k<(1<<c);k++)for(int l=0;l<n;l++){
		if(v[l]==e){
		//	printf("%d %d %d %d: %d\n",i,j,k,l,dp[i][j][k][l]);
			ret=min(ret,dp[i][j][k][l]);
		}
	}
	if(ret>99999999)ret=-1;
	printf("%d\n",ret);
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  int ans=0;
  rep(i,1,n+1){
    if(i%2==0) continue;
    int c=0;
    rep(j,1,n+1){
      if(i%j==0) c++;
    }
    if(c==8) ans++;
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N,B,A,C;
  ll count=0;
  cin>>N;
  C=0;
  rep(i,0,N) {
    cin>>B;
    C=max(C,B);
    
    if(C==B) {
      count+=1;
    }
  }

  cout<<count<<endl;
  
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

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

    for(ll i=a; i<a+k; i++){
        if(i>b) break;
        else cout << i << endl;
    }

    for(ll i=b-k+1; i<=b; i++){
        if(i <= a+k-1) continue;
        else cout << i << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    long long a,b,c,d;

    scanf("%lld%lld%lld",&a,&b,&c);
    d=c-a-b;

    if(d>0&&d*d>4*a*b)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fo(i, a, b) for (ll i = a; i < ll(b); i++)
#define fr(i, a, b) for (ll i = b - 1; i >= ll(a); i--)
#define al(x) begin(x), end(x)
#define I(x) ll x; cin >> x;
#define ar array
#define vc vector
#define pb push_back
#define rs resize
#define is insert
#define vl vc<ll>
#define endl "\n"
#ifdef DEBUG
#include "../debug.h"
#else
#define dbg(x)
#define cerr if(false) cerr
#endif
using namespace std;
using ll = long long;
using ld = long double;
using pa = array<ll, 2>;
using ve = ar<ll,3000>;
using mt = ar<ve,3000>;
using pr = pair<ll, ll>;
using bt = bitset<64>;
const ll M = 998244353;
void in(auto &v) {
  for (auto &x : v) {
    cin >> x;
  }
}
int main() {
	ios::sync_with_stdio(false);
	cin.exceptions(ios::badbit | ios::failbit);
	I(n);I(m);
	string s,t;
	cin>>s>>t;
	unordered_map<ll,char> c;
	ll l=(n*m)/__gcd(n,m);
	fo(i,0,n){
		c[(l/n)*i]=s[i];
	}
	bool ok = 1;
	fo(i,0,m){
		ll x = (l/m)*i;
		if(c.count(x) && c[x] != t[i]){ok=0;}
	}
	cout<<(ok?l:-1)<<endl;
}

Measured memory_bytes: 4260
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())

    S = sum(A)
    Acount = [0] * (10 ** 5 + 1)
    for i in A:
        Acount[i] += 1

    for _ in range(Q):
        B, C = map(int, input().split())

        S += (C - B) * Acount[B]
        Acount[C] += Acount[B]
        Acount[B] = 0

        print(S)


if __name__ == '__main__':
	main()

exit()


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

int main(){
  long long a, b, x;
  cin >> a >> b >> x;
  long long total = 0;
  
  if(a==0)total++;
  if(a>0)a--;
  
  long long all = b/x;
  long long not_included = a/x;
  total+=(all-not_included);
  
  cout << total;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll ans = INF;
    for(ll i=0;i<26;++i){
        ll sum = 0;
        ll sa = 0;
        for(ll j=0;j<s.size();++j){
            if(s[j] == i + 'a'){
                sum = max(sum, sa);
                sa = 0;
            }else{
                sa++;
            }
        }
        sum = max(sum, sa);
        ans = min(ans, sum);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
import numpy as np

b = np.array(a)
total = []
for i in range(2**n):
    eff = np.array([0 for i in range(m)])
    money=0
    for j in range(n):
        if ((i >>j ) & 1):
            eff += b[j,1:]
            money+= b[j,0]
            if len(eff[eff>=x])==m:
                total.append(money)                
if len(total)==0:
    print(-1)
else:
    print(min(total))

Measured memory_bytes: 27724
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
#define f first
#define s second
typedef pair<int,int> pii;
const int N=2e5+5;
const int mod=1e9+7;
int add(int a,int b)
{
    a+=b;
    if(a>=mod)
        a-=mod;
    return a;
}
int mul(int a,int b)
{
    return ((ll)a*b)%mod;
}
struct Matrix{
    int n;
    vector<vector<int> > mat;
    Matrix(int nn)
    {
        n=nn;
        mat.resize(n,vector<int>(n));
    }
    void make_one()
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                mat[i][j]=(i==j);
    }
};
Matrix mul(Matrix a,Matrix b)
{
    int n=a.n;
    Matrix sol(n);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int ans=0;
            for(int k=0;k<n;k++)
            {
                ans=add(ans,mul(a.mat[i][k],b.mat[k][j]));
            }
            sol.mat[i][j]=ans;
        }
    }
    return sol;
}
Matrix pwrmod(Matrix x,ll k)
{
    Matrix ans(x.n);
    ans.make_one();
    for(;k;k>>=1,x=mul(x,x))
        if(k&1)
            ans=mul(ans,x);
    return ans;
}

int main()
{
    int n;
    ll k;
    scanf("%d%lld",&n,&k);
    Matrix m(n);
    forn(i,0,n-1){
        forn(j,0,n-1){
            scanf("%d",&m.mat[i][j]);
        }
    }
    m=pwrmod(m,k);
    int ans=0;
    forn(i,0,n-1){
        forn(j,0,n-1){
            ans=add(ans,m.mat[i][j]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int l[100],n,i,j=1,x,s=0;
    scanf("%d%d",&n,&x);
    for(i=0;i<n;i++)
    {
        scanf("%d",&l[i]);

    //for(i=0;i<n;i++)
    //{
        s=s+l[i];
        if(s<=x)
            j++;
    //}
    }
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 128
operands = ["+","-","*"]
symbols = raw_input().split()
ans = 0
i = 0
while True:
    if len(symbols) == 1:
        break
    if symbols[i] in operands:
        a = int(symbols.pop(i-2))
        b = int(symbols.pop(i-2))
        o = symbols.pop(i-2)
        if o == "*":
            symbols.insert(i-2,a*b)
        elif o == "+":
            symbols.insert(i-2,a+b)
        elif o == "-":
            symbols.insert(i-2,a-b)
        else:
            "This operand is invalid."
            break
        i-=1
    else:
        i+=1
print symbols[0]

Measured memory_bytes: 6448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

ll dp[1100][22000];

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

    ll N; cin >> N;
    vll w(N), s(N), v(N);
    vector<pll> vec;
    rep(i,N) {
        cin >> w[i] >> s[i] >> v[i];
        vec.emplace_back(w[i]+s[i], i);
    }
    sort(vec.begin(), vec.end());

    for(ll i = 1; i <= N; i++) {
        ll idx = vec[i-1].second;
        rep(j, 22000) {
            dp[i][j] = dp[i-1][j];
            if(j-w[idx] >= 0 && j-w[idx] <= s[idx]) chmax(dp[i][j], dp[i-1][j-w[idx]] + v[idx]);
        }
    }
    ll ans = 0;
    rep(j, 22000) chmax(ans, dp[N][j]);
    cout << ans << endl;
}


Measured memory_bytes: 174208
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 2e5+5;
ll d[M],c[M];
int pos[20];
pair<ll,ll> solve(ll s,ll d,ll n)
{
	vector<ll> v,val;
	memset(pos,-1,sizeof(pos));
	int cyc = 0;
	while(1)
	{
		ll z = s+d;
		ll vl = 1;
		if(z>9)
		{
			vl++;
			z = (1+z%10);
		}
		if(pos[z]!=-1)
		{
			cyc = pos[z];
			break;
		}
		val.pb(vl);
		pos[z] = sz(v);
		v.pb(z);
		s=z;
	}
	ll res = 0;
	for(int i=0;i<cyc;i++)
	{
		res += val[i];
		n--;
		if(n==0)
			return {res,v[i]};
	}
	int len = (sz(v)-cyc);
	int ret = -1;
	for(int i=cyc;i<cyc+(n%len);i++)
	{
		res+=val[i];
		ret = v[i];
	}
	// if(d==1)
	// 	cout<<res<<endl;
	ll sum=0;
	for(int i=cyc;i<sz(v);i++)
		sum+=val[i];
	if(ret==-1)
		ret = v[sz(v)-1];
	res += sum*(n/(ll)len);
	return {res,ret};
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int m;
	cin>>m;
	for(int i=1;i<=m;i++)
		cin>>d[i]>>c[i];
	int cur;
	ll ans = 0;
	for(int i=1;i<=m;i++)
	{
		if(i==1)
		{
			cur = d[i];
			if(c[i]>1)
				c[i]--;
			else
				continue;
		}
		auto rval = solve(cur,d[i],c[i]);
		ans += rval.ff;
		cur = rval.ss;
		// cout<<ans<<" "<<cur<<endl;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 6664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

ll a[200010];
ll dp[200010];
ll nstart[200010][50];

int main(void){
  ll n,k;
  scanf("%lld %lld", &n, &k);
  for(int i = 0;i < n;++i){
    scanf("%lld", &a[i]);
  }
  map<ll, int> last;
  dp[n] = 0;
  for(int i = n-1;i >= 0;--i){
    if(last.find(a[i]) == last.end()){
      dp[i] = a[i];
    }else{
      ll p = last[a[i]];
      dp[i] = dp[p+1];
    }
   last[a[i]] = i;
  }
  
  /*
  for(int i = 0;i < n;++i){
    cout << a[i] << " ";
  }
  cout << endl;
  for(int i = 0;i < n;++i){
    cout << dp[i] << " ";
  }
  cout << endl;
  cout << endl;
  */
  
  fill(nstart[0],nstart[0]+200010*20, -1);
  for(int i = n-1;i >= 0;--i){
    nstart[a[i]][0] = dp[i+1];
  }
  nstart[0][0] = dp[0];
  for(int i = 1;i < 50;++i){
    for(int j = 0;j < 200010;++j){
      if(nstart[j][i-1] != -1){
        nstart[j][i] = nstart[nstart[j][i-1]][i-1];
      }
    }
  }

  /*
  for(int i = 0;i < 3;++i){
    for(int j = 0;j < 10;++j){
      cout << nstart[j][i] << " ";
    }
    cout << endl;
  }
  */

  int start = 0;
  ll cnt = k-1;
  for(int i = 50;i >= 0;--i){
    if((cnt >> i) & 1){
      start = nstart[start][i];
    }
  }
  int begin = 0;
  if(start != 0){
    begin = 1;
    while(a[begin-1] != start && begin <= n){
      ++begin;
    }
  }
  set<ll> has;
  vector<ll> res;
  for(int i = begin;i < n;++i){
    if(has.find(a[i]) == has.end()){
      has.insert(a[i]);
      res.push_back(a[i]);
    }else{
      while(res.back() != a[i]){
        ll tmp = res.back();
        has.erase(tmp);
        res.pop_back();
      }
      has.erase(a[i]);
      res.pop_back();
    }
  }
  if(!res.empty()){
    for(int i = 0;i < (int)res.size();++i){
      if(i != 0){
        printf(" ");
      }
      printf("%lld", res[i]);
    }
    printf("\n");
  }
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

//{{{ Graph
typedef int Weight;
struct Edge {
	int src, dst, rev;
	Weight weight;
	Edge(int src, int dst, Weight weight=1,int rev=-1) :
		src(src), dst(dst), weight(weight), rev(rev) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
		e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
//typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct Graph:vector<Edges>{
	Graph(){}
	Graph(const int &n){this->assign(n,Edges());}
	//add bi-directional edge
	void addBiEdge(int from ,int to, Weight w=1){
		while(this->size()<max(from,to)+1)this->push_back(Edges());
		this->at(from).push_back(Edge(from,to,w,this->at(to).size()));
		this->at(to).push_back(Edge(to,from,w,this->at(from).size()-1));
	}
	//add directional edge
	void addEdge(int from ,int to, Weight w=1){
		while(this->size()<from+1)this->push_back(Edges());
		this->at(from).push_back(Edge(from,to,w));
	}
};
#ifdef DEBUG
#include"graph/graphviz.h"
#endif
//}}}

int N,M,Q;

Graph G;
vector<vector<int> > q;
vector<int> largest,col;

void dfs(int v,int d,int c){
	if(d<=largest[v])return;
	largest[v] = d;
	if(col[v]==-1)col[v] = c;
	if(d==0)return;
	for(auto &e:G[v]){
		dfs(e.dst,d-1,c);
	}
}

int main(){
	cin>>N>>M;
	G.assign(N,Edges());
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G.addBiEdge(a,b);
	}
	col.assign(N,-1);
//	r.assign(N,vector<int>(11,-1));
//	REP(u,N)r[0][u] = 0;
	largest.assign(N,-1);
	cin>>Q;
	REP(i,Q){
		int v,d,c;
		cin>>v>>d>>c;
		v--;
		q.push_back({v,d,c});
	}
	reverse(ALL(q));
	for(const auto &v:q){
		dfs(v[0],v[1],v[2]);
	}
	REP(u,N){
		if(col[u]==-1)col[u] = 0;
		cout<<col[u]<<endl;
	}
	return 0;
}



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

int main()
{
  string X;
  cin >> X;
  stack<char> S;
  for (int i = 0; i < X.size(); i++)
  {
    if (X.at(i) == 'S')
      S.push('S');
    else if (!S.empty() && S.top() == 'S')
      S.pop();
    else
      S.push('T');
  }
  cout << S.size() << endl;
}


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

#define MAX 40
vector<int> pre, in, post;
int n, pos;

void rec(int l, int r){
    if(l >= r)  return;
    int next = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), next));
    rec(l, m);
    rec(m+1, r);
    post.push_back(next);
}

void solve(){
    pos = 0;
    rec(0, pre.size());
    for(int i = 0; i < post.size(); i++){
        if(i)   cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main(){
    cin >> n;

    int k;
    for(int i = 0; i < n; i++){
        cin >> k;
        pre.push_back(k);
    }

    for(int i = 0; i < n; i++){
        cin >> k;
        in.push_back(k);
    }

    solve();

    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
string s;
int cnt[200];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	for (int i=0;i<s.size();++i) ++cnt[s[i]];
	for (int i='a';i<='z';++i)
		if (cnt[i]>1)
		{
			cout<<"no";
			return 0;
		}
	cout<<"yes";
	return 0;
}

Measured memory_bytes: 256
#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 N;
	cin >> N;
	cout << N * 800 - (N/15) * 200 << endl;
	return 0;
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

ll a, b, c, k;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c >> k;
    ll one = min(a,k);
    k -= one;
    ll nul = min(b,k);
    k -= nul;
    ll neg = min(c,k);
    k -= neg;
    cout << one - neg << '\n';
    return 0;
}

Measured memory_bytes: 3668
S = str(input())
l = len(S)
if l%2 == 1:
    print("No")
else:
    k = 1
    for i in range (l//2):
        if S[2*i] != "h":
            k = 0
        if S [2*i + 1] != "i":
            k = 0
    if k == 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int n,k,q,i,x;
    scanf("%d%d%d",&n,&k,&q);
    int t[n],cnt=n;
    for(i=0;i<n;i++) t[i]=0;//q-k+1;
    for(i=0;i<q;i++){
        scanf("%d",&x);
        t[x-1]++;
    }
    for(i=0;i<n;i++){
        if(t[i]>=q-k+1) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;

    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
P = list(map(lambda v: int(v) - 1, input().split()))
grp = []
for i in range(0, N):
	grp.append(i)
for i in range(0, M):
	X, Y = map(lambda v: int(v) - 1, input().split())
	rootX = X
	que1 = []
	while True:
		if grp[rootX] == rootX:
			break
		que1.append(rootX)
		rootX = grp[rootX]
	for j in range(0, len(que1)):
		grp[que1.pop(0)] = rootX
	rootY = Y
	que2 = []
	while True:
		if grp[rootY] == rootY:
			break
		que2.append(rootY)
		rootY = grp[rootY]
	for j in range(0, len(que2)):
		grp[que2.pop(0)] = rootY
	grp[rootX] = rootY
cnt = 0
for i in range(0, N):
	root1 = i
	que1 = []
	while True:
		if grp[root1] == root1:
			break
		que1.append(root1)
		root1 = grp[root1]
	for j in range(0, len(que1)):
		grp[que1.pop(0)] = root1
	root2 = P[i]
	que2 = []
	while True:
		if grp[root2] == root2:
			break
		que2.append(root2)
		root2 = grp[root2]
	for j in range(0, len(que2)):
		grp[que2.pop(0)] = root2
	if root1 == root2:
		cnt += 1
print(cnt)

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

int main(){
    int h, w, n;
    std::cin >> h >> w >> n;

    int max = std::max(h, w), ans = n / max;
    if(0 != n % max){
        ++ans;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second > secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vector<vpll> path; vll A;
//***********//
int main() {
	
	cin >> X;
	if (X >= 30) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  ll ans = 0;
  rep(b,1<<(n-1)){
    ans += [&]{
      ll res = 0, t = 0;
      rep(i,n){
        t = t*10+(s[i]-'0');
        if(b>>i&1){
          res += t;
          t = 0;
        }
      }
      return res += t;
    }();
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620