akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <bitset>
#include <string>
#include <cmath>
#include <set>
#include <map>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
using namespace std;
typedef long long ll;
typedef double db;
const int N = 200005, mod = 1000000007;
int n, pos[N], sz, fl, X, Y, Z, s[N], st[N], top, w[N], vis[N];
ll ans = 1, res;
struct edge { int y, nex, z; } g[N * 2];
void init(int x, int y, int z) { g[++ sz] = (edge) { y, pos[x], z }, pos[x] = sz; }
ll power(ll x, int y) {
	ll z = 1;
	while (y) {
		if (y & 1) (z *= x) %= mod;
		y >>= 1; (x *= x) %= mod;
	}
	return z;
}
void dfs1(int x, int fa) {
	vis[x] = 2; st[++ top] = x;
	RepE(i, x) if (ev != fa) {
		if (vis[ev] == 2) {
			X = x, Y = ev, Z = g[i].z;
			int k = top;
			do {
				k --;
				if (w[k] > Z) X = st[k], Y = st[k + 1], Z = w[k];
			} while (st[k] != ev);
			// cout << top - k<<endl;
			fl ++;
		}
		if (!vis[ev]) w[top] = g[i].z, dfs1(ev, x);
	}
	vis[x] = 1; top --;
}
void dfs2(int x, int fa, int z) {
//	cout << x <<" - "<<s[x]<<endl;
	s[x] = 1;
	RepE(i, x) if (ev != fa && ev != X && (x != X || ev != Y)) {
		dfs2(ev, x, g[i].z);
		if (g[i].z < z) s[x] += s[ev];
	}
	(res *= power(s[x], mod - 2)) %= mod;
}
int main()
{
	scanf ("%d", &n);
	Rep(i, 1, n * 2) {
		int x, y;
		scanf ("%d%d", &x, &y);
		init(x, y + n, x + y);
		init(y + n, x, x + y);
	}
	n = n * 2;
	Rep(i, 1, n) ans = ans * i % mod;
	Rep(i, 1, n) if (!vis[i]) {
		fl = 0;
		dfs1(i, 0);
		if (fl != 1) { ans = 0; break ; }
		res = 1; dfs2(X, 0, Z);
		ll k = res;
		swap(X, Y);
		res = 1; dfs2(X, 0, Z);
		// cout << i<<" "<<k<<" " <<res<< endl;
		ans = ans * (k + res) % mod;
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
#include <sstream>
#include <vector>
#include <stack>
#include <memory>
using namespace std;

int n,pos;
vector<int> pre,in,post;
void rec(int l,int r);
void solve();
int main(){
    //freopen("/Users/mac/Desktop/C++?¨????/test/test.txt", "r", stdin);
    int k;
    cin>>n;
    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;
}

void rec(int l,int r)
{
    if (l>=r) {
        return;
    }
    int root=pre[pos++];
    int m=(int)distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m+1, r);
    post.push_back(root);
}
void solve()
{
    pos=0;
    rec(0, (int)pre.size());
    for (int i=0; i<n; i++) {
        if (i) {
            cout<<" ";
        }
        cout<<post[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3120
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int n;
// <next, cost>
vector<vector<pair<int, int> > > V(100001);
int res[100001];

void dfs(int now, int p, int c) {
  // 色を入れる
  res[now] = c;
  for (int i = 0; i < V[now].size(); i++) {
    // 子と親が同じ時
    if (V[now][i].first == p) continue;
    if (V[now][i].second % 2 == 0) {
      dfs(V[now][i].first, now, c);
    } else {
      dfs(V[now][i].first, now, 1 - c);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    V[u].push_back(make_pair(v, w));
    V[v].push_back(make_pair(u, w));
  }
  dfs(0, -1, 1);
  for (int i = 0; i < n; i++) {
    cout << res[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 9216
using System;

namespace ABC061B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int N = Int32.Parse(bufs[0]);
            int M = Int32.Parse(bufs[1]);

            int[] res = new int[N + 1];
            for (int i = 0; i <= N; i++)
            {
                res[i] = 0;
            }


            for (int i = 0; i < M; i++)
            {
                bufs = Console.ReadLine().Split(' ');
                int a = Int32.Parse(bufs[0]);
                int b = Int32.Parse(bufs[1]);

                res[a]++;
                res[b]++;
            }

            for (int i = 1; i <= N; i++)
            {
                Console.WriteLine(res[i]);
            }
        }
    }
}


Measured memory_bytes: 13140
n,m=map(int,input().split())
red=[0]*(n+1)
red[1]=1
balls=[1]*(n+1)
for i in range(m):
  x,y=map(int,input().split())
  if red[x]==1:
    red[y]=1
  balls[x]-=1
  balls[y]+=1
  if balls[x]==0:
    red[x]=0
print(sum(red))

Measured memory_bytes: 76224
#include<stdio.h>
#define Z 2000001
int a[Z],b[Z],c[Z];
main()
 {
  int i,j,k,l=0;
  scanf("%d", &k);
  for(i=0;i<k;i++)
    {
      scanf("%d", &a[i]);
      c[a[i]]+=1;  
      if(a[i] > l)
        {
	  l = a[i];
        }
    }  
  for(i=1;i<=l;i++)
    {
      c[i] = c[i] + c[i-1];
    }

  for(j = k-1;j>=0;j--)
    {
      b[c[a[j]]] = a[j];
      c[a[j]]--;
    }

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

Measured memory_bytes: 17896
#include <functional>
#include <iostream>

using namespace std;

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

	static int p[100'001];
	for(int i = 1; i <= N; i++) {
		cin >> p[i];
	}

	// Union-Find木！！！！　好き！！
	static int parent[100'001];
	for(int i = 1; i <= N; i++) {
		parent[i] = i;
	}

	function<int(int)> root = [&](int a) {
		if(a == parent[a]) {
			return a;
		}
		return parent[a] = root(parent[a]);
	};

	const auto unite = [&](int a, int b) {
		if(root(a) != root(b)) {
			parent[root(a)] = root(b);
		}
	};

	for(int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;

		unite(x, y);
	}

	int result = 0;
	for(int i = 1; i <= N; i++) {
		if(root(p[i]) == root(i)) {
			result++;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>
using namespace std;

int main() {
	int n, point;
	set<pair<pair<string, int>, int>> l;
	cin >> n;
	string s;
	for(int i = 0; i<n; i++){
		cin >> s >> point;
		l.insert({{s, - point}, i+1});
	}
	for(auto i: l){
		cout << i.second << '\n';
	}
}

Measured memory_bytes: 256
while 1:
	n,k = map(int,raw_input().split())
	if n == 0: break
	s = [0]*(n+1)
	c = sorted([int(raw_input()) for i in range(k)])
	p = 1 if c[0] == 0 else 0
	pre = 0
	for i in c[p:]:
		s[i] = s[i-1] + 1
		if p and s[i-1] == 0:
			if s[i-2] > 0:
				s[i] += s[i-2] + 1 - pre
				pre = s[i-2] + 1
			if s[i-2] == 0:
				pre = 0
	print max(s)

Measured memory_bytes: 10264
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        int flag=0;
        int z;
        z=x-r;
        if (0>z) {
        	flag=1;
        }
        z=x+r;
        if (w<z) {
        	flag=1;
        }
        z=y-r;
        if (0>z) {
        	flag=1;
        }
        z=y+r;
        if (h<z) {
        	flag=1;
        }
        if (flag==0) {
        System.out.println("Yes");
        }else{
        System.out.println("No");
        }
    }
}


Measured memory_bytes: 26348
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, W, w[105], v[105], sum = 0;
int f[100005];
void init(){
    n = read(), W = read();
    for (int i = 1; i <= n; ++i)
        w[i] = read(), v[i] = read(), sum += v[i];
}
void solve(){
    fill(f, f + sum + 1, W + 1);
    f[0] = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = sum; j >= v[i]; --j)
            if (f[j - v[i]] + w[i] <= W)
                f[j] = min(f[j], f[j - v[i]] + w[i]);
    int ans = 0;
    for (int i = 0; i <= sum; ++i){
        if (f[i] <= W) ans = i;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using pii = pair<intl,intl>;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl n;
intl a[200000];

void input_var(){
    cin >> n;
    rep(i,n)cin >> a[i];
}
//-------------------------------------------------------------------------------


signed main(){
    cout << fixed << setprecision(10);
    input_var();
    map<intl,intl> m;
    intl cnt = 0;
    rep(i,n){
        intl b = i - a[i];
        cnt += m[b];
        b = i + a[i];
        m[b]++;
    }
    cout << cnt << endl;
    return 0;
}

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

const long long MOD = 1000000007;

long long dp[100005][4];

void Main() {
  string s;
  cin >> s;

  char abc[3] = {'A', 'B', 'C'};

  dp[s.length()][0] = 0;
  dp[s.length()][1] = 0;
  dp[s.length()][2] = 0;
  dp[s.length()][3] = 1;

  for (int i = s.length() - 1; i >= 0; i--) {
    for (int j = 0; j < 3; j++) {
      if (s[i] == '?') {
        dp[i][j] = (3 * dp[i + 1][j] % MOD + dp[i + 1][j + 1] % MOD) % MOD;
      } else {
        dp[i][j] = dp[i + 1][j];
        if (s[i] == abc[j]) dp[i][j] = (dp[i][j] + dp[i+ 1][j + 1]) % MOD;
      }
    }
    if (s[i] == '?') dp[i][3] = (dp[i][3] + (dp[i + 1][3] * 3) % MOD) % MOD;
    else dp[i][3] = dp[i + 1][3];
  }

  cout << dp[0][0] << endl;
}

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



Measured memory_bytes: 3664
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
      	int ans = a;
      	if(a>b){
          ans = ans - 1;
        }
      	System.out.println(ans);
	}
}


Measured memory_bytes: 35812
#include <stdio.h>

int search(int A[], int n, int key) {
	int i = 0;
	A[n] = key;
	while (A[i] !=key)
	{
		i++;
	}
	return i != n;
}

int main()
{
	int i, n, A[10001], q, key, sum = 0;

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

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &key);
		if (search(A, n, key)) sum++;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2100
#include <cstdio>
#include <vector>
using namespace std;

const double EPS = 10e-9;

int main()
{
  int N, K, T, U, V, L;
  while (~scanf("%d %d %d %d %d %d", &N, &K, &T, &U, &V, &L)) {
    vector<int> D(N);
    for (int i = 0; i < N; ++i)
      scanf("%d", &D[i]);

    int carrot = 0, D_index = 0;
    double ans = 0.0, Us = 1.0 / U, Vs = 1.0 / V, ksk_time = 0.0;
    for (int i = 0; i < L; ++i) {
      if (i == D[D_index]) {
	if ((ksk_time <= EPS && carrot == 0) || carrot == K)
	  ksk_time = T;
	else
	  ++carrot;
	++D_index;
      }

      if (ksk_time <= EPS && carrot > 0) {
	--carrot;
	ksk_time = T;
      }

      if (ksk_time > EPS) {
	ans += Vs;
	ksk_time -= Vs;
      } else {
	ans += Us;
      }
    }
    printf("%.9f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  vi b(n);
  rep(i,n) cin >> b[i];
  vi c(n);
  rep(i,n) cin >> c[i];

  sort(a.begin(), a.end());
  //sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  
  ll ans = 0;
  rep(i,n) {
    ll na = lower_bound(rng(a), b[i]) - a.begin();
    ll nc = c.end() - upper_bound(rng(c), b[i]);
    //debug(na);
    //debug(nc);
    ans += na*nc;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys


def solve(b: str):
    if b == "A":
        print("T")
    elif b == "T":
        print("A")
    elif b == "C":
        print("G")
    else:
        print("C")
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    b = next(tokens)  # type: str
    solve(b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  vll A(n);
  FOR(i,0,m){
    ll a,b;
    ci(a>>b);
    A[a-1]++;
    A[b-1]++;
  }
  FOR(i,0,n){
    co(A[i])
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll N, L;
  cin >> N >> L;
  vector<string> S(N);
  REP(i,N){ cin >> S[i]; }
  sort(S.begin(), S.end());
  string res = "";
  REP(i,N){ res += S[i]; }
  cout << res << "\n";
  return 0;
}


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

#define MOD 1000000007
typedef unsigned long long ull;

int N = 0;
int K = 0;

long double expected_value(ull num) { return ((long double)num / 2.0) + 0.5; }

int main() {
  cin >> N >> K;
  ull P[N];

  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }

  ull sum = 0;
  ull max = 0;
  int start = 0;
  for (int i = 0; i <= N; i++) {
    if (i < K) {  // 最初は足し続ける
      sum += P[i];
    } else {
      if (max < sum) {
        max = sum;
        start = i - K;
      }
      sum -= P[i - K];
      sum += P[i];
    }
  }

  // cout << start << endl;

  long double expected = 0.0;
  for (int i = start; i < start + K; i++) {
    expected += expected_value(P[i]);
    // cout << expected << endl;
  }

  cout << std::setprecision(10) << expected;
}


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

int tab[3005][3005];
vector <char> wynik;

int main()
{   string u,v;
    int x,y,n,m;



    cin >> u >> v;
    for (int a=1;a<=u.size();a++)
        for (int b=1;b<=v.size();b++)
    {
        if (u[a-1]==v[b-1])
           tab[a][b]=1+tab[a-1][b-1];
        else tab[a][b]=max(tab[a-1][b],tab[a][b-1]);
    }

   //cout << tab[u.size()][v.size()];

   x=u.size();
   y=v.size();

   while((x>0)&&(y>0))
   {
    if(u[x-1]==v[y-1])
        {wynik.push_back(u[x-1]);x=x-1;y=y-1;}
    else if (tab[x-1][y]>tab[x][y-1])
        x=x-1;
    else y=y-1;
   }



   for (int i=wynik.size()-1;i>=0;i--)
        cout << wynik[i];

}


Measured memory_bytes: 35456
#include <stdio.h>

int main(void) {
	int N, M, i, a, b;
	int count[100001] = {0};
	scanf("%d%d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d%d", &a, &b);
		count[a]++;
		count[b]++;
	}

	for (i = 1; i <= N; i++) {
		if (count[i] % 2 != 0) {
			printf("NO\n");
			return 0;
		}
	}

	printf("YES\n");
	return 0;
}

Measured memory_bytes: 512
h, w = map(int, input().split())

ll = []
for _ in range(h):
  s = input()
  if s != '.'*w:
    ll.append([s[i] for i in range(w)])

lr = []
for i in range(w):
  if all(l[i] == '.' for l in ll):
    lr.insert(0, i)

for l in ll:
  for i in lr:
    l.pop(i)
  print(''.join(l))

Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int k;
    int x;
    cin >> k >> x;
    if(500*k>=x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 764
while 1:
    n = int(input())
    if n == -1:
        break
    fee = 1150
    if n > 30:
        fee += (n - 30) * 160 + 10 * 140 + 10 * 125
    elif n > 20:
        fee += (n - 20) * 140 + 10 * 125
    elif n > 10:
        fee += (n - 10) * 125

    print(4280-fee)



Measured memory_bytes: 5588
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
#include<algorithm>
#define llong long long
using namespace std;

const int N = 2e5;
const int P = 1e9+7;
llong fact[N+3],finv[N+3];
int c[N+3],a[N+3];
int mini[N+3];
int num[N+3];
int n,arga,argb; llong ans;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}
llong comb(llong x,llong y) {return x<0||y<0||x<y ? 0ll : fact[x]*finv[y]%P*finv[x-y]%P;}

int main()
{
	fact[0] = 1ll; for(int i=1; i<=N; i++) fact[i] = fact[i-1]*i%P;
	finv[N] = quickpow(fact[N],P-2); for(int i=N-1; i>=0; i--) finv[i] = finv[i+1]*(i+1)%P;
	scanf("%d%d%d",&n,&arga,&argb);
	for(int i=1; i<=n; i++) scanf("%d%d",&c[i],&a[i]);
	for(int i=1; i<=n; i++)
	{
		if(mini[c[i]]==0 || a[i]<a[mini[c[i]]]) {mini[c[i]] = i;}
	}
	int minic = 0,minic2 = 0;
	for(int i=1; i<=n; i++)
	{
		if(mini[i])
		{
			if(minic==0 || a[mini[i]]<a[mini[minic]]) {minic = i;}
		}
	}
	for(int i=1; i<=n; i++)
	{
		if(i==minic) continue;
		if(mini[i])
		{
			if(minic2==0 || a[mini[i]]<a[mini[minic2]]) {minic2 = i;}
		}
	}
//	printf("minic=%d minic2=%d\n",minic,minic2);
	if(minic==0) {puts("1"); return 0;}
	for(int i=1; i<=n; i++)
	{
		if(c[i]==minic)
		{
			if(i==mini[minic]) {num[c[i]]++;}
			else
			{
				if(a[i]+a[mini[minic]]<=arga || (a[i]+a[mini[minic2]]<=argb && a[mini[minic2]]+a[mini[minic]]<=argb))
				{
					num[c[i]]++;
				}
			}
		}
		else
		{
			if(a[i]+a[mini[minic]]<=argb || (a[i]+a[mini[c[i]]]<=arga && a[mini[c[i]]]+a[mini[minic]]<=argb))
			{
				num[c[i]]++;
			}
		}
	}
	llong ans = 1ll; int cur = 0;
	for(int i=1; i<=n; i++)
	{
		ans = ans*comb(cur+num[i],cur)%P;
		cur += num[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
using namespace std;
const int maxn = 1e6+5;
struct node
{
    int l, r;
}k[maxn];
int cmp(node a, node b)
{
    if(a.l == b.l)  return a.r < b.r;
    return a.l < b.l;
}
int main()
{
    int n, a, b;  cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a >> b;
        k[i].l = a - b;
        k[i].r = a + b;
    }
    sort(k+1, k+n+1, cmp);
    int l = k[1].l, r = k[1].r;
    int sum = 1;
    for(int i = 2; i <= n; i++) {
        if(r >= k[i].r) {
            r = k[i].r;
        }
        else if(k[i].l >= r) {
            sum++;
            l = k[i].l;
            r = k[i].r;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int> > g(n,vector<int>());
	for (int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i < n; i++){
		cout<<g[i].size()<<endl;
	}
	return 0;
}

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

int main() {
 string s;
 cin >> s;
 int ans = 0;
 for(int i = 0; i < s.size(); i++) {
     if(s[i] == '+') ans++;
     else ans--; 
 }

 cout << ans << endl;

   return 0;
}

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

const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int i){
    if (n < i) return 0;
    if (n < 0 || i < 0) return 0;
    return fac[n] * (finv[i] * finv[n - i] % mod) % mod;
}
 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);

    int n;
    cin>>n;
    long long ans[n+1]={};
    bool used[n+1]={};
    map<int,int> m;
    pair<int,int> p;
    
    for(int i=0;i<=n;i++){
        int a;
        cin>>a;
        if(used[a]){
            p = make_pair(m[a],i);
        }
        m[a]=i;
        used[a]=1;
    }
    COMinit();
    int a=p.first,b=p.second-p.first-1, c=n-p.second;
    //cerr<<a<<" "<<b<<" "<<c<<endl;
    for(int i=1;i<=n+1;i++){
        if(i==1){
            cout<<n<<endl;
            continue;
        }
        if(i==n+1){
            cout<<1<<endl;
            continue;
        }
        long long ans = COM(n-1,i) + COM(n-1,i-2) + 2*COM(n-1,i-1) - COM(a+c,i-1);
        ans += mod;
        ans %= mod;
        cout<<ans<<endl;

    }

}

Measured memory_bytes: 18688
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	FULL_MATCH,
	ELSE,
};

ll length;
ll num_array[20];
ll dp[20][10000][2][2];

ll getNUM(ll pre_num,ll next){
	return (10*pre_num+next)%10000;
}

bool is_OK(ll number){
	stack<ll> S;
	while(number > 0){
		S.push(number%10);
		number /= 10;
	}
	int index = 0;
	ll work[4];

	while(!S.empty()){
		work[index++] = S.top();
		S.pop();
	}

	return (work[0] == 5 && work[1] == 1 && work[3] == 3);
}

ll recursive(ll pre_num,ll digit,Type type,bool is_completed){

	if(digit == length){
		if(is_completed)return 1;
		else{
			return 0; //G数が成立しないならreturn 0;
		}
	}

	if(dp[digit][pre_num][type][is_completed] != -1){
		return dp[digit][pre_num][type][is_completed]; //計算済ならreturn
	}

	if(is_completed == true && type == ELSE){
		return dp[digit][pre_num][type][is_completed] = pow(10,length-digit);
	}

	ll ret = 0;
	ll limit;
	if(type == FULL_MATCH){
		limit = num_array[digit]-1;
	}else{
		limit = 9;
	}

	ll tmp;

	for(int next = 0; next <= limit; next++){
		tmp =  getNUM(pre_num,next);
		ret += recursive(tmp,digit+1,ELSE,is_completed||is_OK(tmp));
	}

	if(type == FULL_MATCH){
		tmp = getNUM(pre_num,num_array[digit]);
		ret += recursive(tmp,digit+1,FULL_MATCH,is_completed||is_OK(tmp));
	}

	return dp[digit][pre_num][type][is_completed] = ret;
}


int main(){

	ll N;
	scanf("%lld",&N);

	if(N <= 5102){
		printf("0\n");
		return 0;
	}

	stack<ll> S;

	//Nを桁別に分解する
	while(N > 0){
		S.push(N%10);
		N /= 10;
	}

	ll index = 0;

	while(!S.empty()){
		num_array[index++] = S.top();
		S.pop();
	}

	length = index;

	for(int digit = 0; digit <= length-1; digit++){
		for(int pre_num = 0; pre_num <= 9999; pre_num++){
			for(int p = 0; p <= 1; p++){
				for(int k = 0; k <= 1; k++){
					dp[digit][pre_num][p][k] = -1;
				}
			}
		}
	}

	printf("%lld\n",recursive(0,0,FULL_MATCH,false));

	return 0;
}




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

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

    int ans=0;
    if(a<b)
    ans+=a;
    else
    ans+=b;
    if(c<d)
    ans+=c;
    else
    ans+=d;

    cout << ans << "\n";
    return 0;
}

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

using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){

    int n; cin >> n;
    string s; cin >> s;
    int cnt=0;
    rep(i,n){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
    }

    cout << cnt << endl;
     return 0;
}

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

using namespace std;

int main() {
    long long int N, Y;
    cin >> N >> Y;
    
    vector<long long int> ans(3, 0);
    ans[0] = Y/10000;
    ans[1] = (Y-ans[0]*10000)/5000;
    ans[2] = (Y-ans[0]*10000-ans[1]*5000)/1000;
    
    bool flag=false;
    for(int i=ans[0]; i>=0; i--) {
        for(int j=ans[1]; j>=0; j--) {
            if(N==i+j+(ans[1]-j)*5+ans[2]) {
                flag=true;
                ans[2]+=(ans[1]-j)*5;
                ans[0]=i;
                ans[1]=j;
                break;
            }
        }
        if(flag) break;
        ans[1] += 2;
    }
    
    if(flag) {
        for(int i=0; i<3; i++) {
            cout << ans[i] << " ";
        }
        cout << endl;
    } else {
        cout << -1 << " " << -1 << " " << -1 << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n,ans=0;
  for(int i=0;i<3;i++){
    cin>>n;
    ans+=n;
  }
  if(ans > 21)
    cout<<"bust"<<endl;
  else
    cout<<"win"<<endl;
  return(0);
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a == 1) {
			a = 14;
		}
		if (b == 1) {
			b = 14;
		}
		if (a > b) {
			System.out.println("Alice");
		} else if (a < b) {
			System.out.println("Bob");
		} else {
			System.out.println("Draw");
		}
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i;
    string x;
    cin>>n;
    map<string,int>mp;
    for(i=1; i<=n; i++)
    {
        cin>>x;
        mp[x]++;
    }
    cout<<mp.size()<<endl;
    return 0;
}


Measured memory_bytes: 19148
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S;
  cin >> S;
  const char* s = S.c_str();
  bool is_n = false;
  bool is_s = false;
  bool is_e = false;
  bool is_w = false;
  REP(i, 0, S.size()) {
    switch (s[i]) {
      case 'N':
        is_n = true;
        break;
      case 'S':
        is_s = true;
        break;
      case 'E':
        is_e = true;
        break;
      case 'W':
        is_w = true;
        break;
    }
  }

  if ((is_n && is_s && is_e && is_w) ||
      (is_n && is_s && !is_e && !is_w) ||
      (!is_n &&!is_s && is_e && is_w)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define endl "\n"
#define mod 1000000000000000000



int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    ll val=1;
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i];
       	
       	
    }
    sort(arr,arr+n);
    if(arr[0]==0)
    {
    	cout<<"0";
    	return 0;
    }
    else
    {
    	for(ll i=0;i<n;i++)
    	{
    		if(arr[i]>mod/val)
    		{
    			cout<<"-1";
    			return 0;
    		}
    		else
    		{
    			val=val*arr[i];
    		}
    	}
    	cout<<val;
    }
	return 0;
}

Measured memory_bytes: 4428
using System;

namespace AtCoder {

    class Program {

        static void Main(string[] args) {

            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            var e = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());

            var result = true;

            if(Math.Abs(a - b) > k) {

                result = false;
            }
            if (Math.Abs(a - c) > k) {

                result = false;
            }
            if (Math.Abs(a - d) > k) {

                result = false;
            }
            if (Math.Abs(a - e) > k) {

                result = false;
            }
            if (Math.Abs(b - c) > k) {

                result = false;
            }
            if (Math.Abs(b - d) > k) {

                result = false;
            }
            if (Math.Abs(b - e) > k) {

                result = false;
            }
            if (Math.Abs(c - d) > k) {

                result = false;
            }
            if (Math.Abs(c - e) > k) {

                result = false;
            }
            if (Math.Abs(d - e) > k) {

                result = false;
            }
            Console.WriteLine(result ? "Yay!" : ":(");
        }
    }
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

int DP[3010][3010];

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s, t;
	cin >> s >> t;
	reverse(all(s));
	reverse(all(t));
	M00(i, 3010) {
		DP[0][i] = 0;
		DP[i][0] = 0;
	}
	MOO(i, 1, s.size()+1) {
		MOO(j,1,t.size()+1) {
			if(s[i-1] == t[j-1])
				DP[i][j] = DP[i-1][j-1] + 1;
			else 
				DP[i][j] = max(DP[i][j-1], DP[i-1][j]);
		}
	}
	int S = s.size(), T = t.size();
	while(S > 0 && T > 0) {
		if(DP[S][T] == DP[S-1][T]) S--;
		else if(DP[S][T] == DP[S][T-1]) T--;
		else {
			cout << s[S-1];
			S--; T--;
		}
	}
	cout << endl;

}


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

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

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

    int count = 0;
    int tmp1;
    int tmp2;
    for (int i= 0; i < n-1; i++){
        if(p[i] != i+1){
            tmp1 = p[p[i]-1];
            tmp2 = p[i];
            p[p[i]-1] = tmp2;
            p[i]      = tmp1;
            count++;
        }
    }

    if(count < 2) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


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

ll H, N;

ll dp[20002]; // dp[damage] = 最小のcost

int main(){
	cin >> H >> N;
	vector<pii> v(N);
	
	// first = damage, second = cost
	for ( int i = 0; i < N; i++ ){
		cin >> v[i].first >> v[i].second;
	}
	
	for ( int i = 0; i < 20002; i++ ){
		dp[i] = 100000001;
	}
	dp[0] = 0;
	
	
	for ( int i = 0; i < H; i++ ){
		for ( int j = 0; j < N; j++ ){
			int damage = v[j].first;
			ll cost = v[j].second;
			dp[i+damage] = min(dp[i+damage], dp[i]+cost);
			
			//cout << i+damage << " " << dp[i+damage] << endl;
		}
	}
	
	ll cost = LLONG_MAX;
	for ( int i = H; i < 20002; i++ ){
		cost = min( cost, dp[i] );
	}
	cout << cost << endl;
	
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dl;
const int iNF = 1e9 + 100;
const ll INF = 1e18 + 100;
typedef pair<int, int> pii;

int main() {
   int k;
   string s;
   cin >> k;
   cin >> s;
   if(s.length() <= k){
      cout << s << endl;
   }else{
      auto y = s.substr(0,k);
      y += "...";
      cout << y << endl;
   }
   
   return 0;
}

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

using namespace std;

const int N = 1e5 + 123;

int n;

int a[N], b[N], c[N], dp[N][5];

int main () {
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];
    for (int i = 2;i <= n;i ++) {
        dp[i][1] = a[i] + max (dp[i - 1][2], dp[i - 1][3]);
        dp[i][2] = b[i] + max (dp[i - 1][1], dp[i - 1][3]);
        dp[i][3] = c[i] + max (dp[i - 1][1], dp[i - 1][2]);
    }
    cout << max ({dp[n][1], dp[n][2], dp[n][3]});
}


Measured memory_bytes: 3328
/*      ###########################
            #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007  
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    return b==0?a:gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    // ll temp = eulerstotientfunction(m);
    return modpow(x,m-2,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
} 
int main()
{
    //fastio();
    ll a,b;
    cin >> a >> b;
    if(a==b)
        cout << 0 << endl; 
    for(ll i=0;i<=pow(10,9);i++)
    {
        if(abs(a-i)==abs(b-i))
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char c[10][10];
  int ans=0;
  rep(i,h) rep(j,w){
    cin>>c[i][j];
  }
  rep(bits1,1<<h){
    rep(bits2,1<<w){
      int cnt=0;
      rep(i,h){
	rep(j,w){
	  if(((bits1>>i)&1) || ((bits2>>j)&1)) continue;
	  if(c[i][j]=='#') {
	    cnt++;
	  }
	}
      }
      if(cnt==k) {
	ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3492
import sys
 
c1 = c2 = 0
for line in sys.stdin:
    a, b, c = map(int, line.split(','))
    if a**2 + b**2 == c**2:
        c1 += 1
    elif a == b:
        c2 += 1
print(c1)
print(c2)

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

int main() {
  string s;
  cin >> s;
  int a, b;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) == 'A') {
      a = i;
      break;
    }
  }
  for(int i = s.size()-1; i >= 0; i--) {
    if(s.at(i) == 'Z') {
      b = i;
      break;
    }
  }
  cout << b - a + 1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D){
  	cout << "Left" << endl;
  }else if(A + B == C + D){
  	cout << "Balanced" << endl;
  }else{
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <random>
#include <iomanip>
#include <map>

using namespace std;

typedef long long ll;

int N;
double a[100];

int main() {
    cin >> N;
    double s = 0;
    for (int i = 0; i<N; i++) {
        cin >> a[i];
        s += a[i];
    }
    double m = s / N;
    double min = 100;
    int num = 0;
    for (int i = 0; i<N; i++) {
        if (abs(a[i] - m) < min) {
            min = abs(a[i] - m);
            num = i;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cassert>
#include<sstream>
#include<complex>
#include<cstdio>
#include<climits>
#include<cstdlib>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<ctime>
#include<cctype>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS) 
#define MAX 1000
using namespace std;
struct P
{
  string s;
  int h,b;
  P(string s="$$$",int h=-inf,int b=-inf):s(s),h(h),b(b){}
};

int L,H;
P is[MAX];
bool ch[MAX][10];
bool ok,fin;
string ans;

bool check(string s,bool fl)
{
  rep(i,H)
    {
      int hit,blow;
      hit = blow = 0;

      rep(j,s.size())
	{
	  if(s[j] == is[i].s[j])
	    {
	      hit++;
	      continue;
	    }
	  if(ch[i][s[j]-'0'])blow++;
	}

      if(!fl && hit >  is[i].h)return false;
      if( fl && hit != is[i].h)return false;

      if(!fl && blow >  is[i].b)return false;
      if( fl && blow != is[i].b)return false;
    }
  return true;
}


void dfs(int k,int used,string s)
{
  if(fin)return;
  if(!check(s,false))return;
  if(k >= L)
    {
      if(check(s,true))
	{
	  if(ok)
	    {
	      fin = true;
	      ok = false;
	    }
	  else
	    {
	      ok = true;
	      ans = s;
	    }
	}
      return;
    }

  rep(i,10)
    {
      if((used >> i) & 1)continue;
      dfs(k+1,used|(1<<i),s + string(1,(char)('0'+i)));
    }
}

int main()
{
  while(cin >> L >> H,L|H)
    {
      ok = fin = false;
      assert(H < MAX);
      rep(i,H)rep(j,10)ch[i][j] = false;
      rep(i,H)
	{
	  cin >> is[i].s >> is[i].h >> is[i].b;
	  rep(j,L)
	    ch[i][is[i].s[j]-'0'] = true;
	}
      dfs(0,0,"");
      cout << (ok?ans:"NO") << endl;
    }
  return 0;
}

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

int main() {

  int n,k;
  while(1) {
    cin >> n >> k;
    if(n == 0 && k == 0) break;

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

     int ck = -1;
    for(int i=0;i<=n-k;i++) {
      int t = 1;
      for(int j=0;j<k;j++) t*= a[j+i];
      if(ck <t) ck = t;
    }

    int ck2=-1;
    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
	if(i == j) continue;
	swap(a[i] ,a[j]);
	for(int l=0;l<=n-k;l++) {
	  int t = 1;
	  for(int m=0;m<k;m++) t*= a[m+l];
	  if(ck2 <t) ck2 = t;
	}
	swap(a[i],a[j]);
      }
    }

    // cout << ck <<" "<<ck2<<endl;
    //if(ck2-ck < 0 ) cout <<"NO GAME"<<endl;
     cout << ck2-ck <<endl;
  }
  return 0;  
}

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

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

  vector<int> C(N - 1), S(N - 1), F(N - 1);
  for (int i = 0; i < N - 1; i++)
  {
    cin >> C.at(i) >> S.at(i) >> F.at(i);
  }
  
  for (int i = 0; i < N; i++)
  {
    int t = 0;
    for (int j = i; j < N - 1; j++)
    {
      if (t < S.at(j)) t = S.at(j);
      else if (t % F.at(j) != 0) t += F.at(j) - t % F.at(j);
      
      t += C.at(j);
    }
    
    cout << t << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

if a[0] == 2:
    print(1)
else:
    count = 0
    i = a[0]
    flag = False
    for _ in range(n):
        count += 1
        if a[i-1] == 2:
            flag = True
            break
        i = a[i-1]
    if flag:
        print(count+1)
    else:
        print(-1)


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

int main()
{
	int n, k;
	cin>>n>>k;
	string a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a, a+n);
	for(int i=0;i<n;i++) cout<<a[i];
	cout<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int flag1 = 0; 			//用来计算含有多少个（
	int flag2 = 0;			//计算含有多少个）
	for(int i=0;i<s.size();i++)
	{
		if(s[i] == '(')
			flag1++;
		if(s[i] == ')')
		{
			if(flag1 > 0)
				flag1--;
			else
				flag2++;
		}
	}
	for(int i=0;i<flag1;i++)
		s = s + ')';
	for(int i=0;i<flag2;i++)
		s = '(' + s;
	cout << s << endl;		
	return 0;	
} 

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool compareHeight(const pair<lli,lli> &a,const pair<lli,lli> &b){
	return a.second > b.second;
}

signed main(){

	lli n,m;
	cin>>n>>m;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	vector<pair<lli,lli>> bc(m);
	REP(i,0,m){
		lli b,c;
		cin>>b>>c;
		bc[i] = make_pair(b,c);
	}
	sort(a.begin(),a.end());
	sort(bc.begin(),bc.end(),compareHeight);

	lli now=0;
	lli ans = 0;
	lli flag=0;
	for(lli i=0;i<m;i++){
		for(lli j=0;j<bc[i].first;j++){
			if(bc[i].second <= a[now+j]){
				flag=1;
				break;
			}
			a[now+j]=bc[i].second;
		}
		now+=bc[i].first;
		if(flag)break;;
	}

	REP(i,0,a.size()){
		if(DEBUG)cout<<a[i]<<endl;
		ans += a[i];
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2560