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

void casea() {
  cout << "a" << endl;
}

void caseb(long long n, long long wsum, auto v, auto w) {
  cout << "b" << endl;
  vector<vector<long long>> dp(n+1,vector<long long> (wsum+1,0));
  dp.at(0).at(0)=0;
  for(long long i=0;i<n;i++) {
    for(long long j=0;j<wsum+1;j++) {
      if(w.at(i)<=j) {
        dp.at(i+1).at(j)=max(dp.at(i+1).at(j),dp.at(i).at(j-w.at(i))+v.at(i));
      }
      dp.at(i+1).at(j)=max(dp.at(i+1).at(j),dp.at(i).at(j));
    }
  }
  cout << dp.at(n).at(wsum) << endl;
}

void casec(long long n, long long wsum, auto v, auto w, long long vsum) {
  //cout << "c" << endl;
  vector<vector<long long>> dp(n+1,vector<long long> (vsum+1,1e18));
  dp.at(0).at(0)=0;
  for(long long i=0;i<n;i++) {
    for(long long j=0;j<vsum+1;j++) {
      if(v.at(i)<=j) {
        dp.at(i+1).at(j)=min(dp.at(i+1).at(j),dp.at(i).at(j-v.at(i))+w.at(i));
      }
      dp.at(i+1).at(j)=min(dp.at(i+1).at(j),dp.at(i).at(j));
    }
  }
  for(int i=vsum;i>-1;i--) {
    //cout << i << " " << dp.at(n).at(i) << endl;
    if(dp.at(n).at(i)<=wsum) {
      cout << i << endl;
      break;
    }
  }
}

int main() {
  long long n,wsum;
  cin >> n >> wsum;
  vector<long long> v(n);
  vector<long long> w(n);
  long long vsum=0;
  for(int i=0;i<n;i++) {
    cin >> w.at(i) >> v.at(i);
    vsum+=v.at(i);
  }
  if(n<=30) {
    //casea();
    //return 0;
  }
  /*
  for(int i=0;i<n;i++) {
    if(v.at(i)>1000) {
      caseb(n, wsum, v, w);
      return 0;
    }
  }*/
  casec(n, wsum, v, w, vsum);
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 2e5 + 5;
ll n, k, ans, frq[N];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for(int i = 1;i <= n;++i)
        ++frq[i % k];
    for(int i = 1;i <= n;++i)
    {
        ll rem = k - i;
        rem %= k;
        rem += k;
        rem %= k;
        if((rem * 2) % k == 0)
            ans += frq[rem] * frq[rem];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4436
import math
nums= [list(map(int,input().split(" "))) for _ in range(3)]
ans = "No"
N = int(input())
bs = [int(input()) for _ in range(N)]
for b in bs:
    for i in range(3):
        for j in range(3):
            if nums[i][j] == b:
                nums[i][j] = -1
# -1が3つ揃ったらビンゴ

for i in range(3):
    if nums[i][0] == nums[i][1] == nums[i][2] == -1:
        ans ="Yes"

for i in range(3):
    if nums[0][i] == nums[1][i] == nums[2][i] == -1:
        ans ="Yes"
for i in range(3):
    if nums[0][0] == nums[1][1] == nums[2][2] == -1:
        ans ="Yes"

for i in range(3):
    if nums[0][2] == nums[1][1] == nums[2][0] == -1:
        ans ="Yes"
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const ll inf = 1e16;

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) cin >> a[i];
  VL acc(n + 1);
  REP(i, 0, n) acc[i + 1] = acc[i] + 2 * a[i];
  VL tap(n + 1, inf), ris(n + 1, inf);
  ll glmi = inf;
  REP(i, 1, n) {
    ll ma = -inf, mi = inf;
    ll sum = acc[i] / 2;
    int idx = lower_bound(acc.begin(), acc.begin() + i, sum) - acc.begin();
    REP(delta, -2, 4) {
      int u = idx + delta;
      if (u > 0 && u < i) {
        tap[i] = min(tap[i], abs(acc[u] - sum));
      }
    }
    ma = max(ma, sum + tap[i]);
    mi = min(mi, sum - tap[i]);
    sum = (acc[n] - acc[i]) / 2;
    idx = lower_bound(acc.begin() + i, acc.end(), sum + acc[i]) - acc.begin();
    REP(delta, -2, 4) {
      int u = idx + delta;
      if (u > i && u < n) {
        ris[i] = min(ris[i], abs(acc[u] + sum - acc[n]));
      }
    }
    ma = max(ma, sum + ris[i]);
    mi = min(mi, sum - ris[i]);
    glmi = min(glmi, ma - mi);
  }
  cout << glmi / 2 << endl;
}


Measured memory_bytes: 6528
X = int(input())
import math

A = X * 100
B = A / 108

C = math.ceil(B)
D = C * 108
E = D // 100

F = math.floor(B)
G = F * 108
H = G // 100


if X == E or X == H:
	print(C)
else:
	print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    ll ans = 0, tmp=1;
    while (tmp < b) {
        tmp--;
        tmp += a;
        ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    ll x;
    cin >> x;
    ll sum = 0;
    REP(i, 1, 200000){
        sum += i;
        if(sum >= x){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 10**10
for i in range(m):
    x,y,c = map(int,input().split())
    x -= 1
    y -= 1
    ans = min(ans,a[x]+b[y]-c)
ans = min(ans,min(a)+min(b))
print(ans)

Measured memory_bytes: 67052
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli a,b;
    cin>>a>>b;
    if(a<b) cout<<min(b-a,a);
    else cout<<min(b-(a%b),a%b);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        String work = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        String[] work2 = work.split(", ");
        int k = sc.nextInt();

        // 処理
        String out = work2[k-1];

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 21332
fun main(args: Array<String>) {
    val (n, t) = readIntList()
    val p = readIntList()

    var ans = t.toLong()
    for (i in 1 until n) {
        ans += t
        if (p[i] - p[i - 1] < t) {
            ans -= (t - (p[i] - p[i - 1]))
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 63260
#include<stdio.h>
int main(){
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if(a >= k) printf("%d\n",k);
  else if(b >= k - a) printf("%d\n",a);
  else printf("%d\n",a - (k - a - b));
  return 0;
}

Measured memory_bytes: 1736
# https://atcoder.jp/contests/abc045/tasks/abc045_b
sa = list(input())
sb = list(input())
sc = list(input())

card = sa.pop(0)
while True:
    if card == "a":
        if len(sa) == 0:
            print("A")
            exit()
        card = sa.pop(0)
    elif card == "b":
        if len(sb) == 0:
            print("B")
            exit()
        card = sb.pop(0)
    elif card == "c":
        if len(sc) == 0:
            print("C")
            exit()
        card = sc.pop(0)


Measured memory_bytes: 3064
A,B,C,D,E,F = map(int, open(0).read().split())
ans = [0] * 3
for a in range(F//(100*A)+1):
    for b in range((F-(100*A)*a)//(100*B)+1):
        if a == 0 and b == 0:
            continue
        else:
            m = min(((A*a)+(B*b))*E,F-(100*((A*a)+(B*b))))
            sugar = 0
            for c in range(m//C+1):
                sugar = max(sugar,m-(m-C*c)%D)
                if sugar == m:
                    break
            temp = sugar / (100*((A*a)+(B*b))+sugar)
            if temp > ans[0]:
                ans[0] = temp
                ans[1] = 100 * ((A*a)+(B*b)) + sugar
                ans[2] = sugar
if ans[1] == 0:
    ans[1] = 100 * A
print(ans[1],ans[2])

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

int main() {
  int A, a, B, b, M;
  cin >> A >> B >> M;
  a=100000;
  b=100000;
  vector<int> vA(A+1);
  for (int i=1; i<=A; i++) {
    cin >> vA.at(i);
  }
  vector<int> vB(B+1);
  for (int i=1; i<=B; i++) {
    cin >> vB.at(i);
  }
  for (int i=1; i<A; i++) {
    a=min(a,vA.at(i));
  }
  for (int i=1; i<B; i++) {
    b=min(b,vB.at(i));
  }
  a+=b;
  for (int i=0; i<M; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    a = min(a, vA.at(x)+vB.at(y)-c);
  }
  cout << a << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
// #include <stack>
// #include <vector>
#include <cstring>
// #include <algorithm>
using namespace std;

const int M = 1002343;
const int L = 14;

char H[M][L];

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

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

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

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

long long h(int key, int i) {
    return (h1(key) + i * h2(key)) % M;
}

bool insert(char str[]) {
     long long key, i, hash;
    key = getKey(str);
    for (i = 0; ; i++) {
        hash = h(key, i);
        if (strcmp(H[hash], str) == 0) return true;
        if (strlen(H[hash]) == 0) {
            strcpy(H[hash], str);
            return false;
        };
    }
    return false;
}

bool find(char str[]) {
    long long key, i, hash;
    key = getKey(str);
    for (i = 0; ; i++) {
        hash = h(key, i);
        if (strcmp(H[hash], str) == 0) return true;
        if (strlen(H[hash]) == 0) return false;
    }
    return false;
}

int main() {
    for (int i = 0; i < M; i++) {
        H[i][0] = '\0';
    }
    
    int n;
    char com[9], str[L];
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        
        if (!strcmp(com, "insert")) {
            insert(str);
            continue;   
        }
        
        if (find(str)) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 16864
import collections
S = int(input().rstrip())
L = list(map(int,input().rstrip().split()))
c = collections.Counter(sorted(L))
key = list(c.keys())
ans = 0
num = len(c)
for i in range(num-2):
    for j in range(i+1,num-1):
        for k in range(j+1,num):
            if key[i]+key[j]>key[k]:
                ans += c[key[i]]*c[key[j]]*c[key[k]]
print(ans)

Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int l[n];
    int i,j;
    int tmp;
    for(i=0;i<n;i++){
        cin >> l[i];
    }
    for(i=0;i<n;i++){
        for(j=1;j+i<n;j++){
            if(l[i]<l[i+j]){
                tmp=l[i+j];
                l[i+j]=l[i];
                l[i]=tmp;
            }
        }
    }
    int sum=0;
    for(i=0;i<k;i++){
        sum+=l[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

int main(void){

  std::string s;
  std::cin >> s;

  bool a = false, b = false;

  for(int i=0; i<s.size(); i++){
    if(s[i]=='A') a=true;
    else          b = true;
  }

  if(a && b) std::cout << "Yes" << std::endl;
  else      std::cout << "No" << std::endl;
  
  return 0;
}


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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(){
    int n;
    cin >> n;
    vector<int>A(n);
    REP(i, n) cin >> A[i];
    int mcnt = 0;
    int mi = INF + 5;
    ll sum = 0;
    bool flag = false;
    REP(i, n){
        if(A[i] < 0) {
            mi = min(mi, -A[i]);
            mcnt++;
            sum += -A[i];
        }else if(A[i] == 0){
                flag = true;
            }
        else {
            mi = min(mi, A[i]);
            sum += A[i];
        }
    }
    if(mcnt % 2 == 0 || flag){
        print(sum);
    }else{
        print(sum - (2 * mi));
    }


}


Measured memory_bytes: 640
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const int big=1e8+10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}//a>b
int main(void){
	int i,j,n,m,ans=big;cin>>n>>m;
	vector<vector<int>> a(n);
	vector<int> bas(n);
	vector<int> spot(m);
	vector<bool> yame(m);
	for(i=0;i<n;i++){a[i].res(m);for(j=0;j<m;j++){cin>>a[i][j];a[i][j]--;}}
	for(i=0;i<n;i++){spot[a[i][0]]++;}
	for(i=0;i<m-1;i++){
		int it,maspo=0;
		for(j=0;j<m;j++){
			if(maspo<spot[j]){maspo=spot[j];it=j;}
		}
		mineq(ans,maspo);
		yame[it]=true;
		for(j=0;j<n;j++){
			spot[a[j][bas[j]]]--;
			while(yame[a[j][bas[j]]]){bas[j]++;}
			spot[a[j][bas[j]]]++;
		}
		
	}
	int it,maspo=0;
	for(j=0;j<m;j++){
		if(maspo<spot[j]){maspo=spot[j];it=j;}
	}
	mineq(ans,maspo);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
while 1:
    n = int(input())
    if n==0:break
    l = [0]*n
    list = input().split()
    for i in range(n):
        l[i] = int(list[i])
    m = sum(l)/n
    A = 0
    for j in range(n):
        A +=(l[j] - m)**2 / n
    print(A**.5)


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

using namespace std;

int main(void) {
    int m, nmin, nmax;
    while (cin >> m >> nmin >> nmax, m) {
        vector<int> v(m);
        for (int i = 0; i < m; i++)
            cin >> v[i];
        
        int gap = 0, ans;
        for (int i = nmin; i <= nmax; i++) {
            if (v[i - 1] - v[i] < gap) continue;
            gap = v[i - 1] - v[i];
            ans = i;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2996
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int a[] = new int[M];
		int b[] = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
		}
		
		int cnt = 0;
		outside : for(int i = 0; i < M; i++) {
			
			UnionFind union = new UnionFind();
			union.init(N);
			for(int j = 0; j < M; j++) {
				if(j != i) {
					union.unite(a[j], b[j]);
				}
			}
			for(int j = 1; j < N; j++) {
				if(!union.same(0, j)) {
					cnt++;
					continue outside;
				}
			}
		}
		
		System.out.println(cnt);
	}
}

class UnionFind {
	static int N;
	static int par[];
	static int rank[];
	public static void init(int n) {
		N = n;
		par = new int[N];
		rank = new int[N];
		for(int i = 0; i < N; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	//�؂̍������߂�
	public static int find(int x) {
		if(par[x] == x) {
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}
	
	//�A������
	public static void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
	
	public static boolean same(int x, int y) {
		return find(x) == find(y);
	}
}


Measured memory_bytes: 23636
program three_variables_game
  implicit none
  integer :: n, r(4) = 0, x(100001) = 0, i, j, p(2) = 0
  character(1) :: c(4) = (/ "A", "B", "X", "C" /)
  character(2) :: s
  read(*,*) n, r(1), r(2), r(4)
  if (sum(r) == 0) then
    write(*,'(a)') "No"
    stop
  end if
  do i = 1, n
    read(*,*) s
    x(i) = hash(s)
  end do
  if (sum(r) == 1) then
    j = maxloc(r,1)
    call simulate(.false.)
    r = 0
    r(j) = 1
    call simulate(.true.)
    stop
  end if
  call get_index(x(1),p)
  if (r(p(1)) == 0 .and. r(p(2)) == 0) then
    write(*,'(a)') "No"
    stop
  else
    write(*,'(a)') "Yes"
  end if
  do i = 1, n
    call get_index(x(i),p)
    j = 1
    if (sum(r) == 2 .and. r(p(1))*r(p(2)) == 1 .and. &
    & i < n .and. x(i) /= x(i+1) .and. p(2) == and(x(i),x(i+1))) then
      j = 2
    else if (r(p(1)) > r(p(2))) then
      j = 2
    end if
    r(p(j)) = r(p(j))+1
    r(p(3-j)) = r(p(3-j))-1
    write(*,'(a)') c(p(j))
  end do
contains
  integer function hash(s)
    character(2), intent(in) :: s
    select case (s)
      case ("AB")
        hash = 3
      case ("AC")
        hash = 5
      case ("BC")
        hash = 6
    end select
  end
  subroutine get_index(x,p)
    integer, intent(in) :: x
    integer, intent(out) :: p(2)
    integer :: i, k
    i = 0
    do k = 0, 2
      if (.not.btest(x,k)) cycle
      i = i+1
      p(i) = lshift(1,k)
    end do
  end
  subroutine simulate(out)
    logical, intent(in) :: out
    integer :: j
    if (out) write(*,'(a)') "Yes"
    do i = 1, n
      call get_index(x(i),p)
      if (r(p(1)) /= 0) then
        j = 2
      else if (r(p(2)) /= 0) then
        j = 1
      else
        write(*,'(a)') "No"
        stop
      end if
      r(p(3-j)) = r(p(3-j))-1
      r(p(j)) = r(p(j))+1
      if (out) write(*,'(a)') c(p(j))
    end do
  end
end program three_variables_game

Measured memory_bytes: 3280
# -*- coding: utf-8 -*-

def main():
    # 入力
    a, b, c, d = map(int, input().split())

    # 探索
    while True:
        c -= b
        if c <= 0:
            print("Yes")
            return

        a -= d
        if a <= 0:
            print("No")
            return


main()


Measured memory_bytes: 9168
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define ll long long 
#define il inline
const int maxn=200010;
int a[maxn],b[maxn];
int n;
int num[maxn<<1],tot,len;
int mp[maxn<<1];
int fa[maxn<<1],fb[maxn<<1];
int sa[maxn<<1],sb[maxn<<1];
int ans;
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;++i){
        scanf("%d%d",&a[i],&b[i]);
        num[++tot]=a[i]; num[++tot]=b[i];
    }
    sort(num+1,num+1+tot);
    len=unique(num+1,num+1+tot)-num-1;
    for (int i=1;i<=n;++i){
        a[i]=lower_bound(num+1,num+1+len,a[i])-num;
        b[i]=lower_bound(num+1,num+1+len,b[i])-num;
    }
    for (int i=1;i<=n;++i){
        fa[a[i]]++; fb[b[i]]++;
    }
    for (int i=1;i<=len;++i){
        sa[i]=sa[i-1]+fa[i];
    }
    for (int i=len;i>=1;--i){
        sb[i]=sb[i+1]+fb[i];
    }
    if (n%2){
        int l,r;
        for (l=1;sa[l]<(n+1)/2;++l);
        for (r=len;sb[r]<(n+1)/2;--r);
        //cout<<l<<" "<<r<<endl;
        ans=num[r]-num[l]+1;
    }else{
        int la,ra,lb,rb;
        for (la=1;sa[la]<n/2;++la);
        for (lb=1;sa[lb]<n/2+1;++lb);
        for (ra=len;sb[ra]<n/2;--ra);
        for (rb=len;sb[rb]<n/2+1;--rb);
        ans=num[ra]+num[rb]-(num[la]+num[lb])+1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 13004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n),b(n);
  vector<pll> c(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i] >> b[i];
    c[i]=pll(a[i],b[i]);
  }
  ll num=0;
  sort(c.begin(),c.end());
  for(ll i=0;i<n;i++){
    num+=c[i].second;
    if(num>=k) {
      cout << c[i].first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3328
W, H, N = [int(i) for i in input().split()]

AA = [list(map(int, input().split())) for i in range(N)]

import numpy as np

Z = np.zeros((H, W))

for i in AA:
    if i[2] == 1:
        Z[:, :i[0]] = 1
    
    elif i[2] == 2:
        Z[:, i[0]:] = 1
    
    elif i[2] == 3:
        Z[:i[1], :]= 1
        
    else:
        Z[i[1]:, :] = 1

print(W*H - np.count_nonzero(Z))

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

int main() {
  int n;
  while(cin >> n && n) {
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    int cnt=0;
    while(1) {
      map<int,int> m;
      for(int i=0; i<n; i++) {
	m[a[i]]++;
      }
      bool ck=true;
      for(int i=0; i<n; i++) {
	if(a[i]!=m[a[i]]) ck=false;
	a[i]=m[a[i]];
      }
      if(ck) break;
      cnt++;
    }
    cout << cnt << endl;
    for(int i=0; i<n; i++) {
      if(i!=0) cout << " ";
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}


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

#define In inline
#define Op operator
#define Rg register
#define St static

typedef long long ll;

const int mxN=1<<18;

int main()
{
    St ll a[mxN], b[mxN], c[mxN];
    int n, m;
    scanf("%d%d", &n, &m);
    for(Rg int i=1; i<=m; ++i)
    {
        scanf("%lld", a+i);
        b[i]=b[i-1]+a[i];
        c[i]=c[i-1]+n-a[i];
    }
    a[m+1]=n;
    Rg ll ans=max(n-a[1], a[m]);
    for(Rg int i=1; i<m; ++i)
    {
        Rg int j=min(i-1, m-i), k=min(i, m-i-1), l=min(i, m-i);
        ans=max(ans, max
        (
            max
            (
                2*(b[i-1]-b[i-j-1]+c[i+j]-c[i])+a[i],
                2*(b[i]-b[i-k]+c[i+k+1]-c[i+1])+n-a[i+1]
            )
            , 2*(b[i]-b[i-l]+c[i+l]-c[i])-min
            (
                a[i],
                n-a[i+1]
            )
        )
        );
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
     long long N;
     cin>>N;
     vector<long long> A;
     for(long long i=0; i<N;  i++){
         long long a;
         cin>>a;
         A.push_back(a);
     }
     
sort(A.begin(),A.end());

long long res=0;
long long ares=0;
long long bres=0;
if(N%2==0){
    for(long long i=N-1; i>=N-((N/2)-1); i--){
        res+=2*A[i];
    }
    for(long long i=0; i<=(N/2)-1-1; i++){
        res-=2*A[i];
    }
    res+=A[N-((N/2)-1)-1];
    res-=A[(N/2)-1-1+1];
    cout<<res<<endl;
}
else{
    for(long long i=N-1; i>=N-1-(N/2-1)+1; i--){
        ares+=2*A[i];
    }
    for(long long i=0; i<=(N/2)-1; i++){
        ares-=2*A[i];
    }
    ares+=(A[N-1-(N/2-1)]+A[(N-1-(N/2-1)-1)]);
    
      for(long long i=N-1; i>=N-1-(N/2)+1; i--){
        bres+=2*A[i];
    }
    for(long long i=0; i<=(N/2)-1-1; i++){
        bres-=2*A[i];
    }
    bres-=(A[(N/2)-1]+A[(N/2)]);
    res=max(ares,bres);
    cout<<res<<endl;
}


}


Measured memory_bytes: 1524
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)				(x).begin(),(x).end()
#define REP(i, n)			for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)		for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF					(ll)1e9
#define EPS					(double)1e-9
#define MOD					(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)			(((((x))+((n)-1))/(n)))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)			(((((x))+((n)-1))/(n))*(n))	/* Nの倍数に切り上げ */
#define FloorN(x, n)		((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)			(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)			(!IsOdd((x)))						
#define M_PI				3.14159265358979323846
typedef long long			ll;
typedef pair<ll, ll>		P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N;
	cin >> N;
	static int ketaCnt[10][10];
	REPN(i, 1, N + 1) {
		if (i < 10) {
			ketaCnt[i][i]++;
		} else {
			int a = i % 10;
			int b = i;
			while (10 <= b) {
				b /= 10;
			}
			ketaCnt[b][a]++;
		}
	}
		
		
	ll ans = 0;
	REPN(i, 1, 10) {
		REPN(j, 1, 10) {
			ll ansOne;
			ansOne = (ketaCnt[i][j] * ketaCnt[j][i]);
			ans += ansOne;
		}
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#define NMax 1005
using namespace std;
/*ifstream fin("maxflow.in");
ofstream fout("maxflow.out");*/

long long N,M,MaxFlow;
vector <long long> G[NMax];
queue <long long> Q;
long long C[NMax][NMax],Use[NMax],F[NMax][NMax],TT[NMax];
long long A[105], sum;
void Read()
{
    cin>>N;
    for(long long i=1; i<= N ; i++)
    {
        cin >> A[i];
    }
    for(long long i = 1; i <= N; i++)
    {

        if(A[i] <= 0)
        {
            G[1].push_back(i + 1);
            G[i + 1].push_back(1);
            C[1][i + 1] = -A[i];
        }
        else
        {
            sum += A[i];
            G[i + 1].push_back(N + 2);
            G[N + 2].push_back(i + 1);
            C[i + 1][N + 2] = A[i];
            for(long long j = 1; j < i; j++)
                if(i % j == 0 && A[j] <= 0)
                {
                    G[i + 1].push_back(j + 1);
                    G[j + 1].push_back(i + 1);
                    C[j + 1][i + 1] = 1000000005;
                }
        }

    }
}

long long BFS()
{
    memset(Use,0,sizeof(Use));
    Q.push(1); Use[1] = 1;

    while(!Q.empty())
    {
        long long Node = Q. front(); Q. pop();

        if(Node == N + 2) continue;

        for(unsigned long long i = 0; i < G[Node].size(); ++i)
        {
            long long Neighbour = G[Node][i];

            if(!Use[Neighbour] && C[Node][Neighbour]-F[Node][Neighbour]>0)
            {
                TT[Neighbour] = Node;
                Q.push(Neighbour);
                Use[Neighbour] = 1;
            }
        }
    }

return Use[N + 2];

}

void Solve()
{
    while(BFS())
    {

        for(unsigned long long k = 0; k<G[N + 2].size(); ++k)
        {

        long long Vecin = G[N + 2][k];

        if(!Use[Vecin] || C[Vecin][N + 2]-F[Vecin][N + 2] == 0) continue;

        TT[N + 2] = Vecin;

        long long Fmin = 1000000005;

        for(long long i = N + 2 ; i != 1 ; i = TT[i])
            Fmin = min(Fmin,C[TT[i]][i]-F[TT[i]][i]);

        MaxFlow += Fmin;

        for(long long i = N + 2 ; i != 1 ; i = TT[i])
        {
            F[TT[i]][i] += Fmin;
            F[i][TT[i]] -= Fmin;
        }

        }
    }
}

void Print()
{
    cout<<sum - MaxFlow<<"\n";
}

int main()
{
    Read();
    Solve();
    Print();
    return 0;
}



Measured memory_bytes: 4736
#include<stdio.h>
int main(){
  int n,m,s,i,j,a[20010],b[20010],r[20010]={0};
  while(scanf("%d %d",&n,&m),n||m){
    int t[20010]={-2};
    int v[20010]={0,1};
    for(i=1;i<=m;i++){
      r[i]=i;
      scanf("%d %d %d",&t[i],&a[i],&b[i]);
      for(j=i;t[r[j-1]]>t[i];j--)r[j]=r[j-1];
      r[j]=i;
    }
    for(i=1;i<=m;i++)v[b[r[i]]]|=v[a[r[i]]];
    for(i=s=0;i<=n;i++)s+=v[i];
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 996
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n,p;
  cin >> n >> p;
  ll odd = 0,even = 0;

  rep(i,n)
  {
    ll buf;cin >> buf;
   (buf % 2 == 0 ? even : odd) += 1;
  }
  Combi *combi = new Combi;
  ll ans = 0;

  for(ll i = 0; i <= even; ++i)
  {
    ans += combi->Combination(even, i);
  }

  ll st;
  if(p == 1)
  {
    st = 1;
  }
  else
  {
    st = 0;
  }

  ll odd_c = 0;
  for(ll i = st; i <= odd; i = i + 2)
  {
    odd_c += combi->Combination(odd, i);
  }
  
  cout << ans * odd_c << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

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

vector<map<char, int>> b;

void insert(int k, char c)
{
    k++;
    while (k <= b.size() - 1)
    {
        b[k][c]++;
        k += k & -k;
    }
}

void update(int k, char d, char c)
{
    k++;
    while (k <= b.size() - 1)
    {
        b[k][d]--;
        b[k][c]++;
        k += k & -k;
    }
}

void merge(map<char, int> &a, map<char, int> &b)
{
    for (auto p : b)
    {
        a[p.first] += p.second;
    }
}

map<char, int> get_m(int k)
{
    k++;
    map<char, int> ret;
    while (k > 0)
    {
        merge(ret, b[k]);
        k -= k & -k;
    }
    return ret;
}

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    b.resize(n + 1);
    for (int i = 0; i < n; i++)
    {
        insert(i, s[i]);
    }
    for (int i = 0; i < q; i++)
    {
        int code;
        cin >> code;
        if (code == 1)
        {
            int k;
            cin >> k;
            k--;
            char c;
            cin >> c;
            if (c != s[k])
            {
                update(k, s[k], c);
                s[k] = c;
            }
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            auto b = get_m(l - 1);
            auto a = get_m(r);
            for (auto p : b)
            {
                a[p.first] -= p.second;
            }
            int res = 0;
            for (auto p : a)
            {
                if (p.second > 0)
                    res++;
            }
            cout << res << endl;
        }
    }
}

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

int main(){
    int in, up2, down2;
    int flag_up2, flag_down2;
    cin >> in;
    up2 = in / 100;
    down2 = in - up2*100;

    if(1 <= up2 && up2 <= 12) flag_up2 =0;
    else flag_up2 =1;

    if(1 <= down2 && down2 <= 12) flag_down2 =1;
    else flag_down2 =0;
    
    if(flag_up2 == 0){
        if(flag_down2 == 0) cout << "MMYY" << endl;
        else cout << "AMBIGUOUS" << endl;
    }else if(flag_down2 == 1) cout << "YYMM" << endl;
        else cout << "NA" << endl;  
}

Measured memory_bytes: 256
N,C,K=map(int,input().split())
P=[]
for i in range(N):
    p=int(input())
    P.append(p)
    
P.sort()

ANS=1
B=1
T=P[0]
for j in range(1,N):
    if K<(P[j]-T):
        ANS+=1
        B=1
        T=P[j]
    elif B<C:
        B+=1
    elif B>=C:
        ANS+=1
        B=1
        T=P[j]

print(ANS)

Measured memory_bytes: 7384
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#define ll long long
using namespace std;
ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m;
struct node{
	ll a,b,c,s;
}mem[1000004];
ll ans,sum;
bool cmp(node x,node y)
{
	return x.s>y.s;
}
int main()
{
/*	a=read();b=read();
	if(b==100) ++b;
	if(a==0)
	{
		cout<<b;
	}
	else if(a==1)
	{
		cout<<b<<"00";
	}
	else 
	{
		cout<<b<<"0000";
	}*/
	/*n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		while(a[i]%2==0)
		{
			ans++;
			a[i]/=2;
		}
	}
	cout<<ans;*/
	n=read();m=read();
	for(int i=1;i<=n;++i)
	{
		mem[i].a=read();mem[i].b=read();mem[i].c=read();
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	for(int i=1;i<=n;++i)
	{
		mem[i].a=-mem[i].a;
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	for(int i=1;i<=n;++i)
	{
		mem[i].b=-mem[i].b;
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	for(int i=1;i<=n;++i)
	{
		mem[i].c=-mem[i].c;
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	for(int i=1;i<=n;++i)
	{
		mem[i].b=-mem[i].b;
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	for(int i=1;i<=n;++i)
	{
		mem[i].a=-mem[i].a;mem[i].b=-mem[i].b;
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	for(int i=1;i<=n;++i)
	{
		mem[i].c=-mem[i].c;
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	for(int i=1;i<=n;++i)
	{
		mem[i].c=-mem[i].c;mem[i].b=-mem[i].b;
		mem[i].s=mem[i].a+mem[i].b+mem[i].c;
	}
	sort(mem+1,mem+1+n,cmp);
	sum=0;
	for(int i=1;i<=m;++i)	sum+=mem[i].s;
	ans=max(ans,sum);
	
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a,b uint
	fmt.Scan(&a,&b)
	//a=864691128455135231
	//b=864691128455135232
	if a==b {
		fmt.Println(1)
		return
	}
	var i uint
	for i=60; i>=0; i-- {
		if ((a&(1<<i))>0) != ((b&(1<<i))>0){
			break
		}
	}
	var t uint=1<<i
	a&=(1<<(i+1))-1
	b&=(1<<(i+1))-1
	//fmt.Println(a,b,t)
	ans:=t-a
	B:=b
	for cnt,i:=0,60; i>=0; i-- {
		if (b&(1<<uint(i)))>0 {
			cnt++
			if cnt==2 {
				B=b|((1<<uint(i+1))-1)
				break
			}
		}
	}
	//fmt.Println(a,b,B,t)
	if B<t+a {
		ans+=(B-t+1)+(2*t-1-(t+a)+1)
	} else {
		ans+=2*t-1-t+1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
N = int (input ())
S = input ()
x = 0
for i in range (N-1):
  L = S[:i+1]
  R = S[i+1:]
  X = 0
  for i in range (len(L)):
    if R.count(L[i]) != 0 and L[:i].count(L[i]) == 0:
      X += 1
  if X > x:
    x = X
print (x)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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 int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  cout << (n >= 30 ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3624
import sys
import heapq


def main():
    n, k = [int(s) for s in sys.stdin.readline().strip().split()]
    a = [int(s) for s in sys.stdin.readline().strip().split()]
    f = [int(s) for s in sys.stdin.readline().strip().split()]
    # n, k = 3, 5
    # a = [4, 2,1]
    # f = [2, 3, 1]

    a.sort(reverse=True)
    f.sort()

    def possible(x1):
        improved = 0
        for i in range(n):
            before = a[i] * f[i]
            if before > x1:
                needed_to_be_reduced = before - x1
                if needed_to_be_reduced % f[i] == 0:
                    plus_one = 0
                else:
                    plus_one = 1
                improved += (needed_to_be_reduced // f[i]) + plus_one
                if improved > k:
                    return False
        return True

    def b_search():
        lo = 0
        hi = 10 ** 12
        # (lo, hi]
        # hi is always possible
        # lo might be possible

        while lo < hi:
            mid = (lo + hi) // 2
            if possible(mid):
                hi = mid
            else:
                lo = mid+1
        return hi

    ans = b_search()
    print(ans)


main()



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

int main(int argc, char const *argv[]) {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (size_t i = 0; i < 3; i++) {
        if (s[i] == t[i]) ++ans;
    }

    cout << ans << endl;
    return 0;
}


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

#define _ << " " <<
#define tr(x) cout << #x _ x << endl
#define fi first
#define se second

#ifdef _WIN32
#define LD "%I64d"
#else
#define LD "%ld"
#endif

using namespace std;

typedef long long ll;

const int maxn = 100100;

int n;
int a[maxn];

int read() {
    if (scanf("%d", &n) < 1) {
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    return 1;
}

void solve() {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i < a[i] && i == a[a[i]]) ans++;
    }
    printf("%d\n", ans);
}

int main(int argc, char *argv[]) {
    while (read()) {
        solve();
    }
}


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

int main() {
  int n;
  cin >> n;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  string s;

  rep(i,n) {
    cin >> s;
    if(s == "AC") {
      ac++;
    } else if(s == "WA") {
      wa++;
    } else if(s == "TLE") {
      tle++;
    } else if(s == "RE") {
      re++;
    }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(c, int(b/a));
    cout << endl;

}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a = iterator.next().unwrap();
    let b = iterator.next().unwrap();

    return if a == "H" && b == "H" || a == "D" && b == "D" {
        "H".to_string()
    } else {
        "D".to_string()
    };
}


Measured memory_bytes: 2016
#include<iostream>
using namespace std;
int main() {
	int n, x, tmp; cin >> n >> x;
	int ans = 1;
  	int z=0;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		z += tmp;
		if (z <= x)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
py = []
for i in range(m):
  py.append(list(map(int, input().split())) + [i])
  
py.sort(key=lambda x: x[1])
py.sort(key=lambda x: x[0])

bef = 0
state = 0

triple = [ ]
for i in py:
    if (i[0] != bef):
        bef = i[0]
        state = 1
        triple.append ( [ i[ 0 ], i[ 1 ], i[ 2 ], str ( i[ 0 ] ).rjust ( 6, '0' ) + str ( state ).rjust ( 6, '0' ) ] )
    else:
        state += 1
        triple.append ( [ i[ 0 ], i[ 1 ], i[ 2 ], str ( i[ 0 ] ).rjust ( 6, '0' ) + str ( state ).rjust ( 6, '0' ) ] )

triple.sort ( key=lambda x: x[ 2 ] )
for i in triple:
    print ( i[ 3 ] )

Measured memory_bytes: 43044
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;


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


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

    vector<ll> ans(10000005, 0);
    bool isOK = true;
    rep(i,N){
        ll now = ans.size();
        vector<pair<ll,ll>> pfs = prime_factorize(A[i]);
        for (auto pf : pfs) {
            if (ans[pf.first] > 0){
                isOK = false;
                break;
            }
            ans[pf.first]++;
        }
    }

    if (isOK){
        cout << "pairwise coprime" << endl;
    }
    else{
        ll entire_gcd = A[0];
        for(int i = 1; i < N; i++){
            entire_gcd = gcd(entire_gcd, A[i]);
        }

        if (entire_gcd == 1){
            cout << "setwise coprime" << endl;
        }
        else{
            cout << "not coprime" << endl;
        }
    }
}


Measured memory_bytes: 89252