akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int a,b;
    cin>>a>>b;
    int cnt=a-2*b;
    if(cnt<0) cnt=0;
    cout<<cnt<<endl;
    
    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

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

using namespace std;

int main()
{
    int N;
    scanf("%d",&N);

    int sum=0;
    while(N--){
        int a=0,b=0;
        scanf("%d%d",&a,&b);
        sum+=b-a+1;
    }

        printf("%d",sum);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (b - a == c - b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int main() {
  int K, A, B;

  cin >> K;
  cin >> A >> B;

  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct edge { ll v, dist; };

struct state {
  ll v, p, cost;
  bool operator>(const state s) const { return cost > s.cost; }
};

vector<pll> dijkstra(vector< vector<edge> > &E, ll S) {
  vector<pll> dp(E.size(), pll(INF, 0));
  priority_queue<state, vector<state>, greater<state> > q;
  q.push((state) { S, -1, 0 });

  while(!q.empty()) {
    ll v = q.top().v, p = q.top().p, cost = q.top().cost;
    q.pop();

    if(dp[v].first < cost) continue;
    (dp[v].second += (p != -1 ? dp[p].second : 1)) %= MOD;

    if(dp[v].first <= cost) continue;
    dp[v].first = cost;

    REP(i, 0, E[v].size()) {
      ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
      if(dp[nv].first >= ncost) q.push((state) { nv, v, ncost });
    }
  }

  return dp;
}

int main(void) {
  ll N, M, S, T; cin >> N >> M >> S >> T; S--; T--;
  vector< vector<edge> > E(N);
  vector<ll> U(M), V(M), D(M);
  REP(i, 0, M) {
    cin >> U[i] >> V[i] >> D[i]; U[i]--; V[i]--;
    E[U[i]].push_back((edge) { V[i], D[i] });
    E[V[i]].push_back((edge) { U[i], D[i] });
  }

  vector<pll> dpS = dijkstra(E, S);
  vector<pll> dpT = dijkstra(E, T);
  ll dist = dpS[T].first, all = (dpS[T].second * dpS[T].second) % MOD;

  // cout << "dist: " << dist << endl;
  // cout << "all: " << all << endl;
  // cout << "dpS: ";
  // REP(i, 0, N) cout << "(" << dpS[i].first << ", " << dpS[i].second << "), ";
  // cout << endl;
  // cout << "dpT: ";
  // REP(i, 0, N) cout << "(" << dpT[i].first << ", " << dpT[i].second << "), ";
  // cout << endl;

  ll ans = 0;
  REP(i, 0, N) if(dpS[i].first + dpT[i].first == dist) {
    if(dpS[i].first == dpT[i].first) {
      ans += (((dpS[i].second * dpT[i].second) % MOD) * ((dpS[i].second * dpT[i].second) % MOD)) % MOD;
      ans %= MOD;
    }
  }
  // cout << "ans: " << ans << endl;
  REP(i, 0, M) {
    if(dpS[U[i]].first + dpT[V[i]].first + D[i] == dist) {
      if(dpS[U[i]].first + D[i] > dpT[V[i]].first && dpT[V[i]].first + D[i] > dpS[U[i]].first) {
        ans += (((dpS[U[i]].second * dpT[V[i]].second) % MOD) * ((dpS[U[i]].second * dpT[V[i]].second) % MOD)) % MOD;
        ans %= MOD;
      }
    }
    if(dpS[V[i]].first + dpT[U[i]].first + D[i] == dist) {
      if(dpS[V[i]].first + D[i] > dpT[U[i]].first && dpT[U[i]].first + D[i] > dpS[V[i]].first) {
        ans += (((dpS[V[i]].second * dpT[U[i]].second) % MOD) * ((dpS[V[i]].second * dpT[U[i]].second) % MOD)) % MOD;
        ans %= MOD;
      }
    }
  }
  // cout << "ans: " << ans << endl;
  cout << (all - ans + MOD) % MOD << endl;
}


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

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

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

  // 事前に小さい順にソートしておく
  sort(L.begin(), L.end());

  int count = 0;

  for (int i = 0; i < N; i++) {
    int a = L[i];

    for (int j = i + 1; j < N; j++) {
      int b = L[j];

      for (int k = j + 1; k < N; k++) {
        int c = L[k];

        if (c >= a + b) {
          break;
        }

        if (b - a < c) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <unordered_set>
#include <map>
#include <cstring>

using namespace std;

int Solve(string s, int k, int N) {
    vector<int> nums;
    int i = 0;
    for (int i = 0; i < N; i++) {
        int cnt = 1;
        while (i < N - 1 && s[i + 1] == s[i]) {
            i++;
            cnt++;
        }
        nums.push_back(cnt);
    }
    int start = 0, left = 0;
    int n = nums.size();
    int res = 0, cnt = 0;
    if (s[0] == '1') {
        cnt += nums[0];
        start = 1;
        left = 1;
    }
    for (int i = 0; i < k && start < n; i++) {
        cnt += nums[start];
        if (start < n - 1) {
            cnt += nums[start + 1];
        }
        start += 2;

    }
    res = cnt;
    while (start < n) {
        cnt += nums[start] - nums[left];
        if (left > 0) {
            cnt -= nums[left - 1];
        }
        if (start < n - 1) {
            cnt += nums[start + 1];
        }
        start += 2;
        left += 2;
        res = max(res, cnt);
    }
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    cout << Solve(S, K, N);
    return 0;
}


Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(void) {
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;

  vector<int> ac;
  for (int i = 0; i < n-1; i++) {
    if(s[i]=='A' && s[i+1]=='C'){
      ac.push_back(i+1);
    }
  }

  for (int t = 1; t <= q; t++) {
    int l,r;
    cin >> l >> r;

    auto it1 = lower_bound(ac.begin(), ac.end(), l);
    auto it2 = upper_bound(ac.begin(), ac.end(), r-1);

    cout << it2-it1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n;
int v[2001];
int f[2001];
int main()
{
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	sort(v + 1, v + 1 + n);
	int ans = 0;
	for (int i = n; i >= 3; i--)
	{
		for (int j = i - 1; j >= 2; j--)
		{
			for (int p = j - 1; p >= 1; p--)
			{
				if (v[i] < v[j] + v[p])
				{
					//cout << v[i] << " " << v[j] << " " << v[p] << "\n";
					ans++;
					
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations

n,c = map(int, input().split())
cln = list(range(0,c))
cpl = list(permutations(cln,3))

dl = []
for _ in range(c):
    row = list(map(int, input().split()))
    dl.append(row)

cl = []
for _ in range(n):
    row = list(map(int, input().split()))
    cl.append(row)


costs = [ [0]*c for _ in range(3) ]
for i in range(n):
    for j in range(n):
        for target_c in range(c):
            val3 = (i+j+2)%3
            orig_c = cl[i][j]-1
            cost = dl[orig_c][target_c]
            costs[val3][target_c] += cost


ans = 10**10
for cp in cpl:
    cost = costs[0][cp[0]] + costs[1][cp[1]] + costs[2][cp[2]]
    ans = min(ans,cost)

print(ans)

Measured memory_bytes: 95196
a = (input())
b = (input())
c = (input())
d = (input())
e = (input())
ary = [a,b,c,d,e]
ary_simo = []
ary_2 = []
for s in ary:
    if int(s[-1]) != 0:
        ary_simo.append(int(s[-1]))
        ary_2.append(int(int(s)/10)*10+10)
    else:
        ary_2.append(int(s))
try:
    print(sum(ary_2) - 10 + min(ary_simo))
except:
    print(sum(ary_2))


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NIL -1

int heap_size;

int parent(int i){
  return i/2;
}

int left(int i){
  return i*2;
}

int right(int i){
  return i*2+1;
}

void swap(int *a, int *b){
  int temp;

  temp = *a;
  *a = *b;
  *b = temp;

}

void maxHeapify(int *A, int i){
  int l, r, largest;

  l = left(i);
  r = right(i);

  if(l <= heap_size && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }

  if(r <= heap_size && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    swap(&A[i], &A[largest]);
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  int i;

  for(i = heap_size/2; i > 0; i--){
    maxHeapify(A, i);
  }

}

void heapIncreaseKey(int *A, int i, int key){

  if(key < A[i]){
    printf("output error in heapIncreaseKey\n");
  }

  A[i] = key;

  while(i > 1 && A[parent(i)] < A[i]){
    swap(&A[i], &A[parent(i)]);
    i = parent(i);
  }

}

void maxHeapInsert(int *A, int key){
  heap_size = heap_size+1;
  A[heap_size] = NIL;
  heapIncreaseKey(A, heap_size, key);
}

int HeapExtractMax(int *A){

  int max;

  if(heap_size < 1){
    printf("output error in HeapExtractMax\n");
  }

  max = A[1];
  A[1] = A[heap_size];
  heap_size--;
  maxHeapify(A, 1);

  return max;
}


int main(){
  int i, k;
  int A[2000000];
  char s[10];

  scanf("%s", s);
  
  while(strcmp(s, "end") != 0){

    if(strcmp(s, "insert") == 0){
      scanf("%d", &k);
      maxHeapInsert(A, k);
    }else{
      printf("%d\n", HeapExtractMax(A));
    }  

    scanf("%s", s);

  }

  return 0;
}

Measured memory_bytes: 5544
n, t = gets.chop.split.map(&:to_i)
co = []
ti = []
n.times do
  tmp = gets.chop.split.map(&:to_i)
  co << tmp[0]
  ti << tmp[1]
end
min = 10000
n.times do |i|
  next if ti[i] > t
  min = co[i] if co[i] < min
end
if min == 10000
  puts 'TLE'
else
  puts min
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int que=n,rem=0;
    while(1){
        rem += que%10;
        if(que < 10) break;
        que = que/10;
    }
    if(n%rem == 0) puts("Yes\n");
    else puts("No\n");
    }

    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  N<=9999;
  a=N/1000;
  b=(N%1000)/100;
  c=(N%100)/10;
  d=N%10;
  
  if(a==b && b==c && c==d){
    cout << "Yes" << endl;
  }else if((a==b && b==c) || (b==c && b==d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

ll expo(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

int cc(char c)
{
    return (c-'0');
}

bool vis[10];
int main()
{
    fastio;
    int n;cin>>n;
    string s;cin>>s;
    set<int> sec[10];
    set<int> ans;
    sec[cc(s[n-2])].insert(cc(s[n-1]));
    sec[cc(s[n-3])].insert(cc(s[n-2]));
    sec[cc(s[n-3])].insert(cc(s[n-1]));
    int fi=cc(s[n-3])*100+cc(s[n-2])*10+cc(s[n-1]);
    ans.insert(fi);
    vis[cc(s[n-3])]=vis[cc(s[n-1])]=vis[cc(s[n-2])]=true;
    for(int i=n-4;i>=0;i--)
    {
        rep(j,0,10)
        {
            for(auto x:sec[j])
            {
                fi=cc(s[i])*100+j*10+x;
                ans.insert(fi);
            }
        }
        rep(j,0,10)
            if(vis[j])
                sec[cc(s[i])].insert(j);

        vis[cc(s[i])]=true;
    }
    int siz=ans.size();
    cout<<siz;
}


Measured memory_bytes: 384
def pow_mod(x, n, p):
    ans = 1 % p
    while n > 0:
        if n % 2:
            ans = ans * x % p
        n //= 2
        x = x * x % p
    return ans

MOD = 10**9 + 7
L = int(input(),2)
K = L + 1
s = bin(K)[:1:-1]
M = s.count('1')
N = len(s)
ans = 0
for i in range(N):
    if s[i] == '0':
        continue
    else:
        M -= 1
        ans += pow_mod(2,M,MOD)*pow_mod(3,i,MOD) % MOD
        ans %= MOD
print(ans)

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

int main(){
    string s, t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i] == t[j]){
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            else{
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }
    string ans = "";
    int i = n, j = m;
    while(i > 0 && j > 0){
        if(s[i - 1] == t[j - 1]){
            ans = s[i - 1] + ans;
            i--;
            j--;
        }
        else if(dp[i][j - 1] >= dp[i - 1][j]){
            j--;
        }
        else{
            i--;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 35584
my ($n) = split(/\s/, <STDIN>);
my ($t, $a) = split(/\s/, <STDIN>);
my @h = split(/\s/, <STDIN>);

sub temp {
    my ($x) = @_;
    return $t-$x*0.006;
}

my $min = abs($a-temp($h[0]));
my $mini = 1;

for (1..scalar(@h)) {
    my $temp = temp($h[$_-1]);
    #print $temp, "\n";
    if ($min > abs($a-$temp)) {
	$min = abs($a-$temp);
	$mini = $_;
    }
}

print $mini, "\n";


Measured memory_bytes: 640
//#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<ll, ll>;
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; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<ll> x2(n), y2(n);
  REP(i,n){
    ll x,y; cin >> x >> y;
    x2[i] = x+y;
    y2[i] = x-y;
  }

  sort(ALL(x2));
  sort(ALL(y2));

  cout << max(x2.back()-x2[0], y2.back()-y2[0]) << endl;

  return 0;
}


Measured memory_bytes: 6356
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
	int N,p,a,b,c,d,e,f,s,m;
	char l[99];
	for(;scanf("%d",&N),N;puts("#")){
		vector<pair<double,string> >v;
		for(;N--;){
			scanf("%s%d%d%d%d%d%d%d%d%d",l,&p,&a,&b,&c,&d,&e,&f,&s,&m);
			a+=b+c,b=(d+e)*m,c=f*s*m;
			v.push_back(make_pair(-1.0*(c-p)/(a+b),l));
		}
		sort(v.begin(),v.end());
		for(N=0;N<v.size();N++)printf("%s\n",v[N].second.c_str());
	}
}

Measured memory_bytes: 1072
N = int(input())
K = "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".split(", ")
print(K[N-1])

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
	int k,s,ans=0;
	cin>>k>>s;
	
	for(int i=0; i<=k; i++){
		for(int j=0; j<=k; j++){
			int z = s-i-j;
			if(z<=k && 0<=z){
				ans++;
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
public class TM {
    public static void Main() {
        string[] read = new string[2];
        read = Console.ReadLine().Split(' ');
        int N = int.Parse(read[0]);
        int M = int.Parse(read[1]);
        string[,] A = new string[N,N];
        string[,] B = new string[M,M];
        for (int i = 0; i < N; i++) {
            string read2 = Console.ReadLine();
            for (int j = 0; j < N; j++) {
                A[i, j] = read2.Substring(j,1);
            }
        }
        for (int i = 0; i < M; i++) {
            string read2 = Console.ReadLine();
            for (int j = 0; j < M; j++) {
                B[i, j] = read2.Substring(j, 1);
            }
        }
        int shift = N - M;
        bool failed = false;
        bool cleared = false;
        for (int x = 0; x <= shift; x++) {
            for (int y = 0; y <= shift; y++) {
                failed = false;
                for (int i = 0; i < M; i++) {
                    for (int j = 0; j < M; j++) {
                        if (A[i + x, j + y] != B[i, j]) {
                            failed = true;
                            break;
                        }
                    }
                    if (failed) {
                        break;
                    }
                }
                if (failed == false) {
                    cleared = true;
                    break;
                }
            }
            if (cleared) {
                break;
            }
        }
        if (cleared) {
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }

    }
}

Measured memory_bytes: 13220
import sys
from collections import deque

input = sys.stdin.readline


def dfs(G, comp_id, comp_cnt):
    i = 0
    cnt = 0
    for v in range(len(G)):
        if comp_id[v] != -1:
            continue
        comp_id[v] = i
        cnt += 1
        stack = deque([v])
        while stack:
            v = stack.pop()
            for c in G[v]:
                if comp_id[c] != -1:
                    continue
                comp_id[c] = i
                cnt += 1
                stack.append(c)
        comp_cnt.append(cnt)
        cnt = 0
        i += 1


def main():
    N, M, K = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        G[A].append(B)
        G[B].append(A)
    B = [[] for _ in range(N)]
    for _ in range(K):
        C, D = map(int, input().split())
        C -= 1
        D -= 1
        B[C].append(D)
        B[D].append(C)

    # connected component
    comp_id = [-1] * N
    comp_cnt = []
    dfs(G, comp_id, comp_cnt)

    ans = [-1] * N
    for i in range(N):
        c_id = comp_id[i]
        n_neighbor = len(G[i])
        n_block = len(B[i])
        for j in B[i]:
            if c_id != comp_id[j]:
                n_block -= 1
        ans[i] = comp_cnt[c_id] - 1 - n_neighbor - n_block
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47116
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	sort(a, a + n);
	
	bool ans;
	if(n % 3 == 0) {
		int l = n / 3, m = l * 2;
		ans  = (a[0] == a[l - 1]);
		ans &= (a[l] == a[m - 1]);
		ans &= (a[m] == a[n - 1]);
		ans &= ((a[0] ^ a[l] ^ a[m]) == 0);
	} else {
		ans = (a[n - 1] == 0);
	}
	
	cout << (ans ? "Yes" : "No") << endl;	
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long double
//template

//main
signed main(){
  int N;cin>>N;
  std::vector<int> x(N),y(N);
  std::vector<char> q(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>q[i];
  char u,d,l,r;u='U';d='D';l='L';r='R';
  int uyM,uym,dyM,dym,lyM,lym;
  int lxM,lxm,rxM,rxm,uxM,uxm;
  uyM=dyM=lyM=lxM=rxM=uxM=-LINF;
  uym=dym=lym=lxm=rxm=uxm=LINF;
  for(int i=0;i<N;i++){
    if(q[i]==u){
      uyM=max(uyM,y[i]);
      uym=min(uym,y[i]);
      uxM=max(uxM,x[i]);
      uxm=min(uxm,x[i]);
    }
    if(q[i]==l){
      lyM=max(lyM,y[i]);
      lym=min(lym,y[i]);
      lxM=max(lxM,x[i]);
      lxm=min(lxm,x[i]);
    }
    if(q[i]==d){
      dyM=max(dyM,y[i]);
      dym=min(dym,y[i]);
      uxM=max(uxM,x[i]);
      uxm=min(uxm,x[i]);
    }
    if(q[i]==r){
      lyM=max(lyM,y[i]);
      lym=min(lym,y[i]);
      rxM=max(rxM,x[i]);
      rxm=min(rxm,x[i]);
    }
  }
  int yMult,yMudt,yMdlt;
  int ymult,ymudt,ymdlt;
  int xMrut,xMlut,xMrlt;
  int xmrut,xmlut,xmrlt;

  std::vector<int> t(2e7+15,0);
  t[0]=lym-uym;
  t[1]=(dym-uym)/2;
  t[2]=dyM-lyM;
  t[3]=(dyM-uyM)/2;
  t[4]=lxM-uxM;
  t[5]=(lxM-rxM)/2;
  t[6]=uxm-rxm;
  t[7]=(lxm-rxm)/2;
  t[8]=lyM-uyM;
  t[10]=dym-lym;
  t[12]=lxm-uxm;
  t[14]=uxM-rxM;
  for(int i=15;i<2e7+15;i++)t[i]=i*5;
  int ans=LINF;
  for(int i=0;i<2e7+15;i++){
    if(t[i]<0)continue;
    int xM=max({uxM,lxM-t[i],rxM+t[i]});
    int xm=min({uxm,lxm-t[i],rxm+t[i]});
    int yM=max({uyM+t[i],lyM,dyM-t[i]});
    int ym=min({uym+t[i],lym,dym-t[i]});
    ans=min(ans,(xM-xm)*(yM-ym));
  }
  cout<<fixed<<setprecision(12)<<ans<<endl;
}


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

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

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> d;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    d.push_back({a, b});
  }

  sort(d.begin(), d.end());
  ll ans = 0;
  int cnt = 0;
  rep(i, n) {
    if (cnt == m) break;
    int a = d[i].first;
    int b = d[i].second;
    while (cnt < m && b > 0) {
      ++cnt, --b;
      ans += (ll)a;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;

    if(c < a - b){
        cout << 0 << endl;
    }else{
        cout << c - (a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
int main(int argc, char *argv[]) {
  int N, L;
  std::cin >> N >> L;
  std::string s[101];
  for (int i = 0; i < N; ++i)
    std::cin >> s[i];

  std::sort(s, s + N);
  for (int i = 0; i < N; ++i)
    std::cout << s[i];
  std::cout << std::endl;
}


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

int main(){
  int N; double T, A;
  cin >> N >> T >> A;
  vector<double> H(N);
  for(int i=0; i<N; i++) cin >> H.at(i);
  double temp=601;
  for(int i=0; i<N; i++){
    temp=min(temp, abs(T-0.006*H.at(i)-A));
  }
  int i=0;
  while(temp!=abs(T-0.006*H.at(i)-A)) i++;

  cout << i+1 << endl;
}

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

int main(){
    double r;
    double c;
    double area;

    scanf("%lf",&r);
    c = r*2*M_PI;
    area = r*r*M_PI;
    printf("%.6f %.6f\n",area,c);

  return 0;
}

Measured memory_bytes: 652
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
	String s = sc.next();
    int n = 0;
    for(int i=0; i<s.length(); i++){
      n += Character.getNumericValue(s.charAt(i));
    }
    if(n%9==0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,cnt;

signed main() {
    cin >> n;
    rep1(i,n) {
        int tmp = i,c=0;
        while(tmp) {
            tmp/=10;
            c++;
        }
        if (c%2) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        if(a == 25){
            System.out.println("Christmas");
        }
        if(a == 24){
            System.out.println("Christmas Eve");
        }
        if(a == 23){
            System.out.println("Christmas Eve Eve");
        }
        if(a == 22){
            System.out.println("Christmas Eve Eve Eve");
        }

        
    }

}


Measured memory_bytes: 21844
S = int(input())
Z = 10 ** 9 + 7
if S < 3:
    print(0)
    exit()

from scipy.special import comb
# a = comb(n, r)


A = S // 3
c = 0
for a in range(1, A+1):
    if a == 1:
        c += 1
        continue

    k = S - 3 * a + (a-1)
    m = comb(k, a-1, exact=True)
    c += m
    c %= Z

print(c)


Measured memory_bytes: 42292
#include <iostream>
#include <vector>
#include <algorithm>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

  int a[N],ans = 0;
  REP(i,N){
    cin >> a[i];
    ans += a[i]-1;
  }

  cout << ans << endl;
}


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

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

  r = b+c;
  if (a+b <= a+c){
    if (a+b <= b+c) r = a+b;
  } else if (a+c <= b+c) r = a+c;

  cout << r << endl;
}

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        rem = N - (r * R + g * G)
        if rem == 0 or (rem > 0 and rem % B == 0):
            ans += 1
print(ans)


Measured memory_bytes: 40812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int H,W,A,B; cin >>H>>W>>A>>B;

    REP(i,H) {
        REP(j,W){
            if(i < B){
                if(j < A) cout << 0;
                else cout << 1;
            }else{
                if(j < A) cout << 1;
                else cout << 0;
            }
        }
        cout << endl;
    }

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N;
  cin >> N;
  int sum ;
  int n = N ;
  while(n>0){
    sum += n%10 ;
    n /= 10 ;
  }
  if(N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n, m, c;
	int b[20];
	int a[20][20];
	scanf("%d %d %d", &n, &m, &c);

	for (int i=0; i < m; i++)
		scanf("%d", &b[i]);
	long long sum = 0;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		sum = 0;
		for (int j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
			sum += (long long)a[i][j] * b[j];
		}
		sum += c;
		if (sum > 0)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

#define sc scanf
#define ls rt << 1
#define rs ls | 1
#define Min(x, y) x = min(x, y)
#define Max(x, y) x = max(x, y)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define MEM(x, b) memset(x, b, sizeof(x))
#define lowbit(x) ((x) & -(x))
#define P2(x) ((x) * (x))

typedef long long ll;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 100;
const ll INF = 0x3f3f3f3f3f3f3f3f;
inline ll fpow(ll a, ll b){ ll r = 1, t = a; while (b){ if (b & 1)r = (r*t) % MOD; b >>= 1; t = (t*t) % MOD; }return r; }

struct Edge
{
	ll v, w;
};
struct node
{
	ll id, w;
	bool operator < (const node &oth) const
	{
		return w > oth.w;
	}
}mid;
vector <Edge> e[MAXN << 1];
ll dis[MAXN], n, m;
bool vis[MAXN];
void dijkstra(int x) {
	priority_queue <node> q;
	MEM(dis, INF);
	q.push({ x, 0 }); dis[x] = 0;
	while (!q.empty()) {
		mid = q.top(); q.pop();
		ll ans = mid.id;
		if (vis[ans]) continue; 
		vis[ans] = true;
		for (auto it : e[ans]) {
			ll vi = it.v, wi = it.w;
			if (dis[vi] > dis[ans] + wi) {
				dis[vi] = dis[ans] + wi;
				q.push({ vi, dis[vi] });
			}
		}
	}
}

int main()
{
	cin >> n >> m;
	for (ll i = 2; i <= n; i++) e[i].push_back({ i - 1, 0 });
	for (ll i = 0; i < m; i++) {
		ll ui, vi, wi; sc("%lld %lld %lld", &ui, &vi, &wi);
		e[ui].push_back({ vi, wi });
	}
	dijkstra(1);
	if (dis[n] == INF) printf("-1\n");
	else printf("%lld\n", dis[n]);
	return 0;  // 改数组大小!!!
}

Measured memory_bytes: 18040
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

int main(){
    int N;
    float v[10000];
    cin >> N;
    for (int i=0;i<N;i++)cin>>v[i];
    float count;
    sort(v,v +N);
    count = (v[0] + v[1])/2;
    for(int i=2;i<N;i++){
        count = (count + v[i]) / 2;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<pair<int, int>> pv( N );
	for( int i = 0; i < N; ++i ) {
		cin >> pv[i].second >> pv[i].first;
	}
	sort( pv.begin(), pv.end() );

	string ans = "Yes";
	long t = 0;
	for( int i = 0; i < N; ++i ) {
		t += pv[i].second;

		if( t > pv[i].first ) {
			ans = "No";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int Y=sc.nextInt();
        int x=-1;
        int y=-1;
        int z=-1;
        Out:
        for(int i=0;i<=N;i++){
            for(int j=0;j<=N-i;j++){
                for(int k=0;k<=N-i-j;k++){
                    if(((i+j+k) == N) && ((10000*i+5000*j+1000*k) == Y)){
                        x=i;
                        y=j;
                        z=k;
                        break Out;
                    }
                }
            }
        }
        System.out.println(x+" "+y+" "+z);
    }
}

Measured memory_bytes: 21844
// review
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

ll n, s;

ll f(ll b, ll x) {
  if (x < b) {
    return x;
  }
  return f(b, floor(x/b)) + x % b;
}

void solve() {
  if (n == s)  {
    cout << n + 1 << endl;
    return;
  } else if (s > n) {
    cout << -1 << endl;
    return;
  }
  for (int i=2;i<=sqrt(n);i++) {
    if (f(i, n) == s) {
      cout << i << endl;
      return;
    }
  }
  for (int i=sqrt(n);i>0;i--) {
    if ((n-s) % i != 0) {
      continue;
    }
    if (f((n-s) / i + 1, n) == s) {
      cout << (n-s) / i + 1 << endl;
      return;
    }
  }
  cout << "-1" << endl;
}

int main() {
  cin >> n >> s;
  solve();
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

pdd operator - (pdd a, pdd b) {
	return pdd(a.first - b.first, a.second - b.second);
}
db ccw(pdd a, pdd b) {
	return a.first*b.second - a.second*b.first;
}

vector <pdd> Vch;
int main() {
	int N, L, i, j;
	scanf("%d %d", &N, &L);

	int st = 0;
	db s1 = 0, s2 = 0;
	Vch.emplace_back(s1, s2);
	for (i = 1; i <= N; i++) {
		ll T, V;
		scanf("%lld %lld", &T, &V);
		s1 -= T*V, s2 -= V;

		db mx = s2 + L;
		while (st + 1 < Vch.size()) {
			if (Vch[st + 1].second < mx) break;
			st++;
		}
		if (st + 1 != Vch.size()) {
			db x = (Vch[st + 1].first - Vch[st].first) / (Vch[st + 1].second - Vch[st].second);
			Vch[st].first = Vch[st + 1].first + x * (mx - Vch[st + 1].second);
			Vch[st].second = mx;
		}
		while (Vch.size() > st + 1) {
			pdd u1 = Vch[Vch.size() - 2];
			pdd u2 = Vch.back();
			pdd u3 = pdd(s1, s2);
			if (ccw(u1 - u3, u2 - u3) < 0) break;
			Vch.pop_back();
		}
		Vch.emplace_back(s1, s2);

		printf("%.20lf\n", (Vch[st].first - s1) / (Vch[st].second - s2));
	}
	return 0;
}

Measured memory_bytes: 23528
mod = 1000000007
s = input()[-1::-1] #入力のタイミングで文字列を反転してしまう
n = len(s)
dp = [[0]*4 for i in range(n+1)]
dp[0][0] = 1 #0文字から0文字選ぶ方法だけ1で初期化。他は0。
for i in range(n):
    for j in range(4):
        dp[i+1][j] = dp[i][j] % mod #とりあえず一つ前の値はコピー
    if s[i] == "?":
        dp[i+1][0] += (2*dp[i][0]) % mod #コピーしたものに2倍を足せば合計3倍。0だけは一項少ないので別扱い。
        for j in range(1, 4):
            dp[i+1][j] += (2*dp[i][j]+dp[i][j-1]) % mod
    else:
        index = "CBA".find(s[i])+1 #indexを1-originにするために1を加えている
        dp[i+1][index] += dp[i][index-1] % mod
print(dp[n][3] % mod)


Measured memory_bytes: 53852
#include <stdio.h>

int main(void)
{
    int m,d,i,j,cnt=0;
    scanf("%d %d",&m,&d);
    for(i=1;i<=m;i++)
    {
        if(d>99)
            d=99;
        for(j=22;j<=d;j++)
            if(j%10>=2 && j/10>=2 && ((j%10)*(j/10))==i)
                cnt++;
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 128
require 'prime'
n = gets.to_i
a = n.prime_division
s = 0
a.each { |e|
    a1 = e[0]
    a2 = e[1]
    i = 0
    while (true) do
        i += 1
        if (a2 - i < 0) then
            break
        end
        a2 = a2 - i
    end
    s += i -1
}
p s

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

int main()
{
    long long n, k,d ;
    cin>>n >>k >>d ;
    n=abs(n) ;
            long long z =n/d ;
    if(z>=k)
    {
        cout<< abs(n-k*d)<<endl ;
    }
    else
    {

        long long x =n-(z*d) ;
        k-=z ;
        if(k%2==0)
        {
            cout<< abs( x)<<endl ;
        }
        else
        {
             cout<< abs( x-d)<<endl ;
        }
    }

}



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

using namespace std;

class DisjointSet {
private:
	vector<int> rank, size, p;
	int num = 0;
public:
	DisjointSet() {}
	DisjointSet(int n) {
		num = n;
		rank.assign(n, 0);
		size.assign(n, 1);
		p.assign(n, 0);
		for (int i = 0; i < n; i++) p[i] = i;
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		num--;
		if (rank[x] > rank[y]) {
			p[y] = x;
			size[x] += size[y];
		}
		else {
			p[x] = y;
			size[y] += size[x];
			if (rank[x] == rank[y]) rank[y]++;
		}
	}

	int root(int x) {
		return p[x] == x ? x : p[x] = root(p[x]);
	}

	int get_size(int x) {
		return size[root(x)];
	}

	int forest_size() {
		return num;
	}
};

int main() {
	int n, m; cin >> n >> m;
	DisjointSet ds(n);
	for (int i = 0; i < m; ++i) {
		int x, y, z; cin >> x >> y >> z;
		ds.unite(x - 1, y - 1);
	}
	cout << ds.forest_size() << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="AC")
            ac++;
        if(s=="WA")
            wa++;
        if(s=="TLE")
            tle++;
        if(s=="RE")
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3592
def search(lower, upper, mod):
    min_remain = mod
    for i in range(lower, min(lower + mod - lower % mod, upper - 1) + 1):
        for j in range(i + 1, min(i + mod, upper) + 1):
            remain = i * j % mod
            if remain == 0:
                return 0
            if min_remain > remain:
                min_remain = remain
    return min_remain


l, r = map(int, input().split())
print(search(l, r, 2019))


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

int main() {
/*	int a[3];
	cin >> a[0] ;
	a[1] = 3;
	a[2] = a[0] * 10;

	cout << a[0] <<" " << a[1] <<" "<< a[2] << endl;
	
	for (int i = 0; i < 3; i++) {
		cout << a[i] << endl;
	}


	sort(a,a+5);
*//*
	int a[10];
	for (int i = 0; i < 10; i++) {
		cin >> a[i];
	}
	
	sort(a,a+10,greater<int>());

	for (int i = 0; i < 3; i++) {
		cout << a[i]<<endl;
	}

	int ans = 0;
	int a, b,c;
	while(cin>>a>>b) {
		ans = 0;
		c = a + b;

		if ( c==0   ) {
			ans = 1;
		}
		else{
			while (c > 0) {
				c /= 10;
				ans++;
			}
		}
		cout << ans << endl;
	}*/

	int N, a, b, c;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a >> b >> c;

		if (a*a + b*b == c*c) {
			cout << "YES" << endl;
		} else if (a *a == b * b + c * c) {
			cout << "YES" << endl;
		} else if (a * a + c * c == b * b) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}

	return 0;;
}

Measured memory_bytes: 3012
#include <iostream>
using namespace std;
int min(int x, int y, int z){
  if(x>=y&&z>=y) return y;
  else if(x>=z&&y>=z) return z;
  else return x;
}

int main(){
  int k;
  cin >> k;
  int s, sum=0;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        s = min(i,j,l);
        int y=1;
        for(int x=1;x<=s;x++){
          if(i%x==0&&j%x==0&&l%x==0) y=x;
        }
        sum += y;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
using ll = long long;

int main(){
    ll A, B, V, W, T; std::cin >> A >> V >> B >> W >> T;

    ll dx=abs(A-B), dv=(V-W)*T;
    if(dx<=dv){
        std::cout << "YES";
    }else{
        std::cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

int main(void) {
	std::string S;
	std::cin >> S;
	bool flag = true;
	for (int i = 0; (i < S.length()) && flag; i++) {
		if ((((i + 1) % 2 == 0) && (S[i] == 'R')) || (((i + 1) % 2 == 1) && (S[i] == 'L'))) {
			flag = false;
		}
	}
	if (flag) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,k,s; scanf("%d%d%d",&n,&k,&s);

	int ans[100000];
	rep(i,n){
		if(i<k) ans[i]=s;
		else    ans[i]=(s==1000000000?s-1:1000000000);
	}

	rep(i,n) printf("%d%c",ans[i],i<n-1?' ':'\n');

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    vector<int> c(N);
    rep(i, N) cin >> c[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x = v[i] - c[i];
        if (x > 0)
            ans += x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=chomp(readline())
    w_l=[0 for i in 1:n+1]
    e_r=[0 for i in 1:n+1]
    for i in 2:n+1
        w_l[i]=w_l[i-1]
        e_r[i]=e_r[i-1]
        if s[i-1]=='W'
            w_l[i]+=1
        end
        if s[n-i+2]=='E'
            e_r[i]+=1
        end
    end
    ans=10^9
    for i in 1:n
        ans=min(ans,w_l[i]+e_r[n-i+1])
    end
    println(ans)
end
main()

Measured memory_bytes: 126672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  string a;
  for(int i = 0; i < W + 2; i++){
  	cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H; i++){
  	cout << '#';
    cin >> a;
    cout << a;
    cout << '#' << endl;
  }
  for(int i = 0; i < W + 2; i++){
  	cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using static System.Math;

class P
{
  static long[] Input(){
    return Console.ReadLine().Split().Select(long.Parse).ToArray();
  }
  static void Main()
  {
    long[] XY = Input();
    long X = XY[0]; long Y = XY[1];
    long C = Y/X;
    long tmp = 1;
    int R = 0;
    for(int i=0;i < 100; i++){
      if(tmp>C){
        break;
      }
      tmp *= 2;
      R += 1;
    }

    var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    Console.SetOut(sw);
    Console.WriteLine(R);
    Console.Out.Flush();
  }
}


Measured memory_bytes: 13396
<?php
	$cnt = 0;
	while(true) {
		$stdin = trim(fgets(STDIN));
		
		if ($cnt === 0) {
			list($ninzu, $shurui) = explode(' ', $stdin);
			if($ninzu == 0 && $shurui == 0) {
				break;
			}
			$cnt++;
			continue;
		}
		$val = explode(' ', $stdin);

		if ($cnt == 1) {
			$ryo = $val;
			$kei = array();
			for ($i=0; $i < $shurui; $i++) { 
				$kei[$i] = 0;
			}
			$cnt++;
			continue;
		}
		for ($i=0; $i < $shurui; $i++) { 
			$kei[$i] += $val[$i];
		}
		$flg = true;
		if($cnt == $ninzu + 1) {
			for ($i=0; $i < $shurui; $i++) {
				if ($kei[$i] > $ryo[$i]) {
					$flg = false;
					break;
				}
			}
			if ($flg) {
				print("Yes\n");
			} else {
				print("No\n");
			}
			$cnt = 0;
			continue;
		}
		$cnt++;
	}

Measured memory_bytes: 15364
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

	int n, m;
	cin >> n >> m;
	if(n != m){
        cout << "No";
        return 0;
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256