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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int x_go[16010] = {0};
int y_go[16010] = {0};
int x_go2[16010] = {0};
int y_go2[16010] = {0};

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

  string S;
  int x, y;
  cin >> S >> x >> y;

  vector<int> xvec;
  vector<int> yvec;

  S = S + "T";

  int cnt_T = 0;
  int tmp_cnt = 0;
  for(int i = 0; i < S.length(); i++){
    if(S[i] == 'T'){
      if(tmp_cnt > 0){
        if(cnt_T % 2 == 0){
          xvec.push_back(tmp_cnt);
        }else{
          yvec.push_back(tmp_cnt);
        }
      }
      tmp_cnt = 0;
      cnt_T++;
    }else{
      tmp_cnt++;
    }
  }

  int K = 8000;// 0 -> -8000

  // xについて
  if(S[0] == 'T' && xvec.size() > 0){
    x_go[K+xvec[0]] = 1;
    x_go[K-xvec[0]] = 1;
  }else if(S[0] == 'T'){
    x_go[K] = 1;
  }else if(xvec.size() == 0){
    x_go[K] = 1;
  }else{
    x_go[K+xvec[0]] = 1;
  }

  if(yvec.size() == 0){
    y_go[K] = 1;
  }else{
    y_go[K+yvec[0]] = 1;
    y_go[K-yvec[0]] = 1;
  }

  for(int i = 0; i <= 16000; i++){
    x_go2[i] = x_go[i];
    y_go2[i] = y_go[i];
  }
  
  for(int i = 1; i < xvec.size(); i++){
    for(int j = 0; j <= 16000; j++){
      x_go2[j] = 0;
    }
    for(int j = 0; j <= 16000; j++){
      if(x_go[j] == 1){
        if(j+xvec[i] <= 16000){
          x_go2[j+xvec[i]] = 1;
        }
        if(j-xvec[i] >= 0){
          x_go2[j-xvec[i]] = 1;
        }
      }
    }
    for(int j = 0; j <= 16000; j++){
      x_go[j] = x_go2[j];
    }
  }
  
  for(int i = 1; i < yvec.size(); i++){
    for(int j = 0; j <= 16000; j++){
      y_go2[j] = 0;
    }
    for(int j = 0; j <=16000; j++){
      if(y_go[j] == 1){
        if(j+yvec[i] <= 16000){
          y_go2[j+yvec[i]] = 1;
        }
        if(j-yvec[i] >= 0){
          y_go2[j-yvec[i]] = 1;
        }
      }
    }
    for(int j = 0; j <= 16000; j++){
      y_go[j] = y_go2[j];
    }
  }

  if(x_go[K+x] == 1 && y_go[K+y] == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
 
typedef long long ll;
typedef long double f80;
 
const int mod = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while(b) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

set<int> g[2];
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    fr(i, 1, m) {
        int u, v;
        cin >> u >> v;
        if(u == 1 || v == 1)
            g[0].insert(v);
        if(u == n || v == n)
            g[1].insert(u);
    }
    for(int x : g[0]) {
        if(g[1].count(x)) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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 ll MOD = 1e9+7;
const ll INF = 1e13;

ll D[400][400];
ll D2[400][400];
int N, M, L;

void war(ll D[400][400]){
    REP(k,N){
        REP(i,N){
            REP(j,N){
                chmin(D[i][j], D[i][k] + D[k][j]);
            }
        }
    }
}

int main(){
    cin >> N >> M >> L;
    REP(i,N)
        REP(j,N){
            D[i][j] = INF;
            if(i == j) D[i][j] = 0;
        }

    REP(i,M){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        D[a][b] = c;
        D[b][a] = c;
    }

    war(D);

    REP(i,N)
        REP(j,N){
            D2[i][j] = INF;
            if(i == j) D2[i][j] = 0;
        }

    REP(i,N){
        REP(j,N){
            if(D[i][j] <= L){
                D2[i][j] = 1;
            }
        }
    }

    war(D2);

    int Q;
    cin >> Q;
    REP(q,Q){
        int s, t;
        cin >> s >> t;
        s--, t--;
        ll ans = D2[s][t] - 1;
        if(ans == INF-1) ans = -1;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2432
//  Created by liszt on 2019/07/22.解説AC
#include<bits/stdc++.h>
using namespace std;

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

int main(){
    int n,x; cin>>n >>x;
    
    vector<int> a(n);
    
    for(int i=0;i<n;i++)cin>>a[i];
    
    int ans=abs(x-a[0]);
    
    for(int i=1;i<n;i++){
        ans=gcd(ans,abs(x-a[i]));
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    vector<string> v;
    v.pb("Sunny");
    v.pb("Cloudy");
    v.pb("Rainy");

    string s;
    cin>>s;

    for(int i=0;i<3; i++){
        if(v[i] == s){
            cout<<v[(i+1)%3];
            return 0;
        }
    }
} 

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


S = input()
L = len(S)
mp = {}
for c in [chr(i) for i in range(97, 97+26)]:
    mp[c] = 0


for i in range(L):
    mp[S[i]] += 1

res = 0
for i in range(L):
    res += L - mp[S[i]]

res //= 2

print(res+1)


Measured memory_bytes: 9500
package main

import (
	"fmt"
	"math"
)

func main(){
	var n int
	var y, d1, d2, d3, d, di float64
	fmt.Scan(&n)
	x := make([]float64, n)
	for i:=0; i<n; i++{
		fmt.Scan(&x[i])
	}
	for i:=0; i<n; i++{
		fmt.Scan(&y)
		d = math.Abs(x[i] - y)
		d1 += d
		d2 += math.Pow(d, 2)
		d3 += math.Pow(d, 3)
		di = math.Max(d, di)
	}
	fmt.Println(d1)
	fmt.Println(math.Pow(d2, 1.0/2))
	fmt.Println(math.Pow(d3, 1.0/3))
	fmt.Println(di)
}


Measured memory_bytes: 1184
#include<cstdio>
#include<iostream>
using namespace std;
int n,a[300005],b[300005],c[300005],topb,topc,after[300005];
long long ans,tmp;
inline void merge_sort(int left,int right){
	if(left==right){
		return ;
	}
	int middle=(left+right)/2;
	merge_sort(left,middle);
	merge_sort(middle+1,right);
	int l=left,r=middle+1,p=left;
	while(l<=middle&&r<=right){
		switch(a[l]<=a[r]){
			case true:after[p]=a[l];l++;break;
			case false:after[p]=a[r];r++;ans+=middle-l+1;break;
		}
		p++;
	}
	while(l<=middle){
		after[p]=a[l];
		p++;l++;
	}
	while(r<=right){
		after[p]=a[r];
		p++;r++;
	}
	for(register int i=left;i<=right;i++){
		a[i]=after[i];
	}
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2!=i%2){
			printf("No\n");
			return 0;
		}
		switch(i%2){
			case 0:topc++;c[topc]=a[i];break;
			case 1:topb++;b[topb]=a[i];break;
		}
	}
	merge_sort(1,n);
	if(ans%3!=0){
		printf("No\n");
		return 0;
	}
	ans/=3;tmp=ans;
	ans=0;
	for(register int i=1;i<=topb;i++){
		a[i]=b[i];
	}
	merge_sort(1,topb);
	tmp-=ans;
	ans=0;
	for(register int i=1;i<=topc;i++){
		a[i]=c[i];
	}
	merge_sort(1,topc);
	tmp-=ans;
	switch(tmp){
		case 0:printf("Yes\n");break;
		default:printf("No\n");break;
	}
	return 0;
}

Measured memory_bytes: 7288
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;

  vector<pair<int,int>> st;
  for(int i=0; i<n; i++) {
    int tp; cin >> tp;
    st.push_back({tp, i+1});
  }

  sort(st.begin(), st.end());
  for(auto k: st) {
    cout << k.second << ' ';
  }
  cout << '\n';

  return 0;
}


Measured memory_bytes: 1780
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
x.sort()
dif = []
for i in range(m - 1):
    dif.append((x[i + 1] - x[i], i + 1))
dif.sort(key = lambda x: x[0], reverse = True)
split = set()
for i in range(n - 1):
    split.add(dif[i][1])
ans = x[-1] - x[0]
for i in split:
    ans -= x[i] - x[i - 1]
print(ans)

Measured memory_bytes: 20472
#abc129 c
mod=1000000007

n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]

dp=[1]*(n+2) #n段のときn+1個要素必要
dp[n+1]=0 #幻の７段目は０
for i in a:
    dp[i]=0
for i in range(n-1,-1,-1):
    if dp[i]==0:#階段壊れている
        continue
    dp[i]=dp[i+1]+dp[i+2]

ans=dp[0]%mod
print(ans)

Measured memory_bytes: 460020
#include<stdio.h>
#include<math.h>
#define max(a,b) a>b?a:b
int check(int x){
    int i;
    if(x==2)return 1;
    for(i=3; i<=sqrt(x); i+=2)if(x%i==0)return 0;
    return 1;
}
int main(){
    int i, j, n, a[10], num[10][1001]={0}, amax=0, nmax=0, ans=1;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
        amax=max(amax, a[i]);
    }
    for(i=2; i<=amax; i+=2){
        if(check(i)){
            for(j=0; j<n; j++){
                while(!(a[j]%i)){
                    a[j]/=i;
                    num[j][i]+=1;
                }
                nmax=max(nmax, num[j][i]);
            }
            for(j=0; j<nmax; j++)ans*=i;
            nmax=0;
        }
        if(i==2)i-=1;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main()
{
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for(auto i = 0; i <= a; ++i){
		if(i * 500 > x) break;
		for(auto j = 0; j <= b; ++j){
			if(i * 500 + j * 100 > x) break;
			for(auto k = 0; k <= c; ++k){
				int s = i * 500 + j * 100 + k * 50;
				if(s > x) break;
				if(s == x) ++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    int N, op=0, left=0, cnt=0;
    std::string res = "";
    std::cin >> N;
    std::cin >> res;

    int right=N-1;

    while(left < right)
    {
        for(left; left <= right; ++left)
            if(res[left] == 'W')
                break;

        for(right; right >= left; --right)
            if(res[right] == 'R')
                break;
    
        if(left < right)
        {
            op++;
            left++;
            right--;
        }
    }

    print(op);
    return 0;
}

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

int N, K;
vector<int> height(1e5+5);

int main(){

    int cnt = 0;

    cin >> N >> K;
    for (int i=0; i<N; i++){
        cin >> height.at(i);
    }

    for (int i=0; i<N; i++){
        if (height.at(i) >= K){
            cnt++;
        }
    }

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

Measured memory_bytes: 640
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$ans = $key->A;
$cnt=0;
while(1) {
  $ans = divide($ans);
  if ($ans==false) {
    break;
  }
  $cnt++;
}
printf("%d\n",$cnt);


function divide($arr) {
  $a = $arr[0];
  $b = $arr[1];
  $c = $arr[2];
  if (($a % 2)==1) return false;
  if (($b % 2)==1) return false;
  if (($c % 2)==1) return false;
  if (($a == $b) && ($b == $c)) {
    printf("-1\n");
    exit;
  }
  $a = $a / 2;
  $b = $b / 2;
  $c = $c / 2;
  $ans[]=$b+$c;
  $ans[]=$a+$c;
  $ans[]=$a+$b;
  return $ans;
}


Measured memory_bytes: 3956
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'





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


  int n,m;
  vector<int> ac(111111);
  vector<int> wa(111111);
  string sit;
  int p;
  int pen=0,acs=0;
  cin>>n>>m;

  while(m--){
    cin>>p>>sit;
    if(sit=="AC" and !ac[p]){
      ac[p]=1;
      pen+=wa[p];
    }else if(sit=="WA"){
      wa[p]++;
    }
  }
  fa(b,ac)acs+=b;
  cout<<acs<<' '<<pen<<endl;



}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
const int MAX = 1e6;
map<ll, list<ll>> adjList;
bool visited[MAX];
ll add;
ll sum[MAX];
ll sum_node[MAX];

void dfs(ll src, ll val){

	visited[src] = true;
	val += sum[src];
	sum_node[src] = val;
	for(auto i: adjList[src]){
		if(!visited[i]){
			dfs(i, val);
		}
	}
}



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll n, m;
cin >> n >> m;
for(int i =0; i<=n; i++){
	sum_node[i] = 0;
	sum[i] = 0;
}
for(int i =0; i<n-1; i++){
	ll a, b;
	cin >> a >>b;
	a--;
	b--;
	adjList[a].push_back(b);
	adjList[b].push_back(a);
}

for(int i =0; i<m; i++){
	ll u, v;
	cin >> u >> v;
	u--;
	sum[u] += v;
}

dfs(0, 0);

for(int i =0; i<n; i++){
	cout << sum_node[i] << " ";
}

return 0;
}



Measured memory_bytes: 50688
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<string>S(n);
    for(int i=0;i<n;i++)cin>>S[i];
    string ans="";

    for(char i='a';i<'z'+1;i++){
        int res=1LL<<10;
        for(int j=0;j<n;j++){
            int count=0;
            for(int k=0;k<S[j].size();k++){
            if(S[j][k]==i)count++;
            }
            res=min(res,count);
        }
        //cout<<res<<endl;
        for(int j=0;j<res;j++)ans+=i;
        

    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
using System;

namespace tst
{
    class Program
    {
        public static int n;
        public static void Res(int[] V)
        {
            for(int i=0; i<n; i++)
            {
                if (V[i] == -1) V[i] = 0;
            }
            if (V[0] == 0)
            {
                if (n != 1)//n=1でV[0]=0はok
                {
                    V[0] = 1;
                }
                Kumitate(V);
            }
            else
            {
                Kumitate(V);
            }
        }
        public static void Kumitate(int[] V)
        {
            int val = 0;
            for(int i=n; i>0; i--)
            {
                val += V[n - i] * (int)Math.Pow(10, i-1);
            }
            Console.WriteLine(val);
        }
        public static void Main()
        {
            string[] In1 = Console.ReadLine().Split(' ');
            n = int.Parse(In1[0]);
            int[] V = new int[n];
            for(int i=0; i<n; i++)
            {
                V[i] = -1;//-1で初期化
            }
            int m = int.Parse(In1[1]);//ヒントの数
            bool flag = true;
            if (m != 0)
            {
                for (int i = 0; i < m; i++)
                {
                    string[] In2 = Console.ReadLine().Split(' ');
                    int s = int.Parse(In2[0]);
                    int c = int.Parse(In2[1]);
                    if (s == 1 && c == 0 && n!=1) flag = false;//一番左が0はNG
                    if (V[s - 1] == -1)
                    {
                        V[s - 1] = c;
                    }
                    else
                    {
                        if (V[s-1]==c) { }//同じ数ならok
                        else flag = false;
                    }
                }
            }
            if (flag)
            {
                Res(V);
            }
            else
            {
                Console.WriteLine(-1);
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <queue>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;

struct state {
  int n, d;
  bool operator<(const state &s) const { return d > s.d; }
};

int N, A, B;
vector<int> E[100000];
int v[100000];

int main(void) {
  cin >> N;
  REP(i, 0, N - 1) {
    cin >> A >> B; A--; B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }

  REP(i, 0, N) v[i] = 0;
  v[0] = 1;
  v[N - 1] = 2;

  priority_queue<state> q;
  REP(i, 0, E[0].size()) q.push((state) { E[0][i], 1 });
  REP(i, 0, E[N - 1].size()) q.push((state) { E[N - 1][i], 2 });

  while(q.size()) {
    state c = q.top();
    q.pop();

    if(v[c.n]) continue;
    v[c.n] =  2 - c.d % 2;

    REP(i, 0, E[c.n].size()) {
      int nn = E[c.n][i];
      int nd = c.d + 2;
      if(!v[nn]) q.push((state) { nn, nd });
    }
  }

  int cnt[2] = { 0, 0 };
  REP(i, 0, N) cnt[v[i] - 1]++;
  cout << (cnt[0] > cnt[1] ? "Fennec" : "Snuke") << endl;

  return 0;
}


Measured memory_bytes: 6528
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String W = sc.next();
		int count = 0;
		
		while(true){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			if(T.length() != W.length()) continue;
			boolean tf = true;
			for(int i = 0; i < T.length(); i++){
				if(T.charAt(i) != W.charAt(i) && (T.charAt(i) - 'a' + 'A') != W.charAt(i) && T.charAt(i) != (W.charAt(i) - 'a' + 'A')){
					tf = false;
					break;
				}
			}
			if(tf){
				count++;
			}
			//System.out.println(T);
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26152
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int main()
{

	fast;
	long long int a,b,c,p=0,q=0;
	cin>>a>>b>>c;
	p = a-b;
	q = c-p;
	if(q <=0){
		q = 0;
	}
	cout << q <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vll x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}

//=======================================================================================================

int main()
{
    ll a, b;
    cin >> a >> b;
    ll k;
    k = (a+b)/2;
    if((a+b)%2 == 0) cout << k << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  val primeList = Array.fill[Boolean](1000001)(true)

  def construct = {
    primeList(0) = false
    primeList(1) = false
    for (i <- 2 until 1000001) {
      if (primeList(i)) {
        var j = 2
        while (i * j < 1000001) {
          primeList(i * j) = false
          j += 1
        }
      }
    }
  }

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      var count = 0
      for (i <- 2 to N / 2) {
        if (primeList(i) && primeList(N - i)) {
          count += 1
        }
      }
      println(count)
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    construct

    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 46744
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const long long MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
ll n,a,b,ans;
ll pow(ll a, ll b, ll m)
{
    ll ans = 1;
    a %= m;
    while(b)
    {
        if(b & 1)ans = (ans % m) * (a % m) % m;
        b /= 2;
        a = (a % m) * (a % m) % m;
    }
    ans %= m;
    return ans;
}
ll inv(ll x, ll p)//x关于p的逆元，p为素数
{
    return pow(x, p - 2, p);
}
ll C(ll n, ll m, ll p)//组合数C(n, m) % p = (n!/m!/(n-m)!)%mod = n!*inv(m!*(n-m)!)%mod = n!*(m!*((n-m)!)^(mod-2))%mod
{
    if(m > n)return 0;
    ll up = 1, down = 1;//分子分母;
    for(int i = n - m + 1; i <= n; i++)up = up * i % p;
    for(int i = 1; i <= m; i++)down = down * i % p;
    return up * inv(down, p) % p;
}
ll Lucas(ll n, ll m, ll p)
{
    if(m == 0)return 1;
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>a>>b;
	ll ans1=pow(2,n,MOD)-1+MOD;
	ans+=Lucas(n,a,MOD)+Lucas(n,b,MOD);
	ans%=MOD;
	ll res=(ans1-ans+MOD)%MOD;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

void print(priority_queue<P> pq) {
    while (!pq.empty()) {
        P cur = pq.top(); pq.pop();
        cout << cur.first << ' ' << cur.second << '\n';
    }
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<ll> a(n);
    priority_queue<P> b;
    rep(i,n) cin>>a[i];
    rep(i,m) {
        ll x,y; cin>>x>>y;
        b.emplace(y,x);
    }
    sort(a.begin(), a.end());

    rep(i,n) {
        if (b.empty()) break;
        P cur = b.top(); b.pop();
        if (a[i] < cur.first) {
            a[i] = cur.first;
            cur.second--;
        }
        if (cur.second > 0) b.push(cur);
    }

    cout << accumulate(a.begin(), a.end(), 0ll) << '\n';
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
int k,s;
cin>>k>>s;
int count = 0;
for(int x = 0; x<=k; x++){
    for(int y = 0; y<=k; y++){
        int z = s-x-y;
        if(z>=0&&z<=k){
            count++;
        }
    }
}
cout<<count<<endl;
return 0;
}

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

int main(){
  int H,n;
  cin >> H >> n;
  VI a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];
  
  VVI dp(n,VI(H+1,1001001001));
  
  rep(h,H+1){
    dp[0][h] = (h+a[0]-1)/a[0]*b[0];
  } 
    
  rep(i,n-1){
    rep(h,H+1){
      dp.at(i+1).at(h) = min( dp.at(i).at(h), dp.at(i+1).at(max(0,h-a[i+1]))+b[i+1] );
    }
  }

  /*
  rep(i,n){
    rep(j,H+1){
      cout << dp[i][j];
    }
    cout << endl;
  }
  */
  
  cout << dp[n-1][H] << endl;
  
  return 0;
}

Measured memory_bytes: 39424
#include<stdio.h>
 
int main(void)
{
	int n, C[10000], A[10000], B[10000];
	char a[10000];
	char b[10000];
	char c[10000];
	char tmpc;
	int i, j, k, l, tmp, minj = 0;
	int flag = 0;

	scanf("%d", &n);

	(void)getchar();

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

		scanf("%c", &a[i]);
		scanf("%d", &A[i]);
		(void)getchar();
	}
	
	for (i = 0;i < n;i++) {
		B[i] = A[i];
		C[i] = A[i];
		b[i] = a[i];
		c[i] = a[i];
	}

	for (i = 1;i < n;i++) {
		for (j = n - 1;j >= 0;j--) {
			if (C[j] < C[j - 1]) {
				
				tmp = C[j];
				tmpc = c[j];
				C[j] = C[j - 1];
				c[j] = c[j - 1];
				C[j - 1] = tmp;
				c[j - 1] = tmpc;
			}
		}
	}

	for (k = 0;k < n;k++) {
		printf("%c%d", c[k], C[k]);
		if (k != n - 1) {
			printf(" ");
		}else {
			printf("\n");
		}
	}


		printf("Stable\n");
	

	for (i = 0;i <= n - 1;i++) {
		minj = i;
		for (j = i;j <= n - 1;j++) {
			if (B[j] < B[minj]) {
				minj = j;
			}
		}
		if (minj != i) {
			tmp = B[i];
			tmpc = b[i];
			B[i] = B[minj];
			b[i] = b[minj];
			B[minj] = tmp;
			b[minj] = tmpc;
		}
	}

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

	for (i = 0; i < n - 1; i++) {
		if(c[i] != b[i]){
			flag++;
		}
	}

	if (flag != 0) {
		printf("Not stable\n");
	}
	else {
		printf("Stable\n");
	}




	return 0;
}
 



Measured memory_bytes: 1928
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn];
int exgcd(int a,int b,int& x,int &y){
	if(b==0){
		x = 1;y = 0;
		return a;
	}
	int d = exgcd(b,a%b,y,x);
	y -= (a/b)*x;
	return d;
}
ll inv(int i){
	int x,y;
	exgcd(i,mod,x,y);
	return (x+mod)%mod;
} 
int main()
{
	int n,k;cin>>n>>k;
	if(k==1){
		puts("0");
		return 0;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]); 
	}
	sort(a+1,a+1+n);
	ll ans = 0,cur = 1;
//	cout<<"!"<<inv(2)<<endl;
	for(int i=k;i<=n;i++){
		ans = (ans+a[i]*cur)%mod;
		ans = (ans-a[n-i+1]*cur)%mod;
		ans = (ans+mod)%mod;
		cur = (cur*i%mod*inv(i-k+1))%mod;
//		cout<<"!"<<cur<<endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define PI 3.141592653589

using namespace std;

bool check(ll mid, ll arr[], ll arr1[], ll k, ll n)
{
    ll req = 0;
    for(ll i=0;i<n;i++)
    {
        ll temp1 = (arr[i]*arr1[n-1-i]);
        if(temp1<=mid)
            continue;
        ll temp = min((ll)ceil((ld)arr[i] - mid/((ld)arr1[n-1-i])),arr[i]);
        req+=temp;
    }
    
    return req<=k;
}

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   ll arr1[n];
   for(ll i=0;i<n;i++)
        cin>>arr1[i];
   sort(arr,arr+n);
   sort(arr1,arr1+n);
   
   ll start = 0;
   ll end = 100000000000000;
   
   while(end - start > 1)
   {
       ll mid = start + (end - start)/2;
       bool temp = check(mid,arr,arr1,k,n);
       if(temp)
            end = mid;
       else start = mid + 1;        
   }
   
   bool temp = check(start,arr,arr1,k,n); 
   if(temp)
   cout<<start;
   else cout<<end;
   
   return 0;
}

Measured memory_bytes: 3328
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn gcd(a: u64, b: u64) -> u64 {
    assert!(a != 0 || b != 0);
    if a == 0 {
        b
    } else {
        gcd(b % a, a)
    }
}

fn main() {
    input! {
        n: u64, m: u64,
        s: chars,
        t: chars,
    }
    let gcd_ = gcd(n, m) as usize;
    let lcm_ = lcm(n, m) as usize;

    let n_ = n as usize / gcd_;
    let m_ = m as usize / gcd_;

    let mut flag = true;
    for i in 0..gcd_ {
        if s[n_ * i] != t[m_ * i] {
            flag = false;
            break;
        }
    }
    if flag {
        println!("{}", lcm_);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define COST first
#define ID second
using namespace std;
typedef pair<long long,int> pli;

int X,Y,Z,LIM;
long long ans,A[100010],B[100010],C[100010];

priority_queue<pli> qA,qB,qAB,qBA,dA,dB,dAB,dBA;

pli getTop(priority_queue<pli>& q,priority_queue<pli>& d)
{
    while(!d.empty() && q.top() == d.top()) q.pop(), d.pop();
    return q.top();
}

int main()
{
    int i;
    long long x,y;
    pli t;
    
    scanf("%d%d%d",&X,&Y,&Z);
    for(i=1;i<=X+Y+Z;i++)
    {
        scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);
        ans += C[i]; A[i] -= C[i]; B[i] -= C[i];
        qA.push(pli(A[i], i)); qB.push(pli(B[i], i));
    }
    
    LIM = X + Y;
    for(i=1;i<=LIM;i++)
    {
        if(X) x = getTop(qA,dA).COST;
        else x = getTop(qA,dA).COST + getTop(qAB,dAB).COST;
        if(Y) y = getTop(qB,dB).COST;
        else y = getTop(qB,dB).COST + getTop(qBA,dBA).COST;
        
        if(x > y)
        {
            ans += x;
            if(X) X--;
            else
            {
                t = qAB.top();
                dAB.push(t); qBA.push(pli(A[t.ID] - B[t.ID], t.ID));
                Y--;
            }
            t = getTop(qA,dA);
            dA.push(t); dB.push(pli(B[t.ID], t.ID));
            qAB.push(pli(B[t.ID] - A[t.ID], t.ID));
        }
        else
        {
            ans += y;
            if(Y) Y--;
            else
            {
                t = qBA.top();
                dBA.push(t); qAB.push(pli(B[t.ID] - A[t.ID], t.ID));
                X--;
            }
            t = getTop(qB,dB);
            dB.push(t); dA.push(pli(A[t.ID], t.ID));
            qBA.push(pli(A[t.ID] - B[t.ID], t.ID));
        }
    }
    
    printf("%lld",ans);
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  int counter = 0;
  int ma = -1;
  for (int j = 0;j<N;j++){
    if(H[j]>=ma) {
      counter = counter + 1;
      ma = H[j];
    }
  }
  cout<<counter<<endl;
}

Measured memory_bytes: 256
import Data.List

ans i =
  let j = zip i ['A'..]
      s = maximumBy (\(i,_) (j,_) -> compare i j) j
  in
    snd s

main = do
  l <- getLine
  let i = map read $ words l :: [Int]
      o = ans i
  putStrLn [o]



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

int main() {
	int a[200000]; int b[200000];
	
	long long n,k;
	cin >> n;
	for(long long i=0;i<n;i++) {
		cin >> k;
		a[i]=k;
		b[i]=k;
	}
	sort(a,a+n);
	for(long long i=0;i<n;i++){
	if(b[i]==a[n-1]) cout<< a[n-2]<<endl;
	else cout<< a[n-1]<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	int A, B, C, X;
	int ans = 0;

	cin >> A >> B >> C >> X;

	for (int i = 0; i <= A; i++)
	{
		for (int j = 0; j <= B; j++)
		{
			for (int k = 0; k <= C; k++)
			{
				if (500 * i + 100 * j + 50 * k == X)
				{
					ans++;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
$arr = explode(" ",trim(fgets(STDIN)));
for($i=$arr[1]-$arr[0]+1;$i<$arr[1]+$arr[0];$i++) {
    if($i>=-1000000 && $i<=1000000) {
        echo $i." ";
    }
}

?>


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

typedef long long LL;

int main()
{
    string n;
    cin >> n;
    LL sum = 0;
    string::iterator it;
    for(it=n.begin(); it!=n.end(); it++)
    {
        sum += (*it - 48);
    }
    if(sum%9==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}

Measured memory_bytes: 3804
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n,n){
		vint v(n);
		rep(i,n) cin>>v[i];
		sort(ALL(v));
		if(v.back()<2){
			cout<<"NA"<<endl;
		}
		else{
			int ans=0;
			rep(i,n){
				if(v[i]) ans++;
			}
			cout<<ans+1<<endl;
		}
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3244
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

static const ll MAX = 200000;
static const ll waz = 76543217;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int bubbleSort(int A[], int N) {
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j >= i + 1; --j) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = 1;
                ++sw;
            }
        }
    }
    return sw;
}

int main()
{
    IO;

    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    sw = bubbleSort(A, N);

    for (int i = 0; i < N; ++i) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;

}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long mdx(long long b, long long e, long long m){
	long long res=1;
	b%=m;
	while(e>0){
		if(e&1) res=(res*b)%m;
		b=(b*b)%m; e>>=1;
	}
	return res;
}
long long fact[1000000];
int main(){
	fact[0]=1;
	for(long long i=1; i<1000000; i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
	long long x, y; cin>>x>>y;

	if((2*x-y)%3!=0 || (2*y-x)%3!=0){
		cout<<0<<endl; return 0;
	}
	long long n=(2*x-y)/3;
	long long m=(2*y-x)/3;
	if(n<0 || m<0){
		cout<<0<<endl; return 0;
	}
	long long ans=fact[n+m];
	ans=(ans*mdx(fact[n], mod-2, mod))%mod;
	ans=(ans*mdx(fact[m], mod-2, mod))%mod;
	cout<<ans<<endl;
	return 0;
}
//1n+2m=x
//2n+1m=y
//n+m=(x+y)/3
//m=(2*x-y)/3
//n=(2*y-x)/3
//ans=(n+m)!/(n!m!)

Measured memory_bytes: 8192
T,H = 0,0
n = int(input())
for i in range(n):
    S1,S2 = input().split()
    if S1 < S2:
        H += 3
    elif S1 > S2:
        T += 3
    else:
        T += 1
        H += 1
print(T,H)


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

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if(A1+A2+A3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int n = scan.nextInt();
		int attack = 0;

		for (int i = 0; i < n; i++)
			attack += scan.nextInt();

		if (h <= attack) System.out.println("Yes");
		else System.out.println("No");

		scan.close();
	}
}

Measured memory_bytes: 49148
#include <stdio.h>

int main(void)
{
    int h, w;
    int i, j;
    int row;

    while (1){
        row = 1;
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0){
            break;
        /*when w is even*/
        }else if (w % 2 == 0){
            for (i = 1; i <= h; i++){
                /*odd row*/
                if (row % 2 == 1){
                    for (j = 1; j <= (w / 2); j++){
                        printf("#.");
                    }
                /*even row*/
                }else{
                    for (j = 1; j <= (w / 2); j++){
                        printf(".#");
                    }
                }
                /*go to next row*/
                printf("\n");
                row++;
            }
        /*when w is odd*/
        }else{
            for (i = 1; i <= h; i++){
                /*odd row*/
                if (row % 2 == 1){
                    for (j = 1; j <= ((w - 1) / 2); j++){
                        printf("#.");
                    }
                    printf("#");
                /*even row*/
                }else{
                    for (j = 1; j <= ((w - 1) / 2); j++){
                        printf(".#");
                    }
                    printf(".");
                }
                /*go to next row*/
                printf("\n");
                row++;
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1016
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args) {
            int[] a=new int[4];
            int[] b=new int[4];
            string str;
            while((str=Console.ReadLine())!=null){
                int hit=0;
                int blow=0;
                string[] s=str.Split();
                for(int i=0;i<4;i++){
                    a[i]=int.Parse(s[i]);
                }
                s = Console.ReadLine().Split();
                for(int i=0;i<4;i++){
                    b[i]=int.Parse(s[i]);
                }
                for(int i=0;i<4;i++){
                    for(int j=0;j<4;j++){
                        if(a[i]==b[j]){
                            if(i==j){
                                hit++;
                            }else{
                                blow++;
                            }
                        }
                    }
                }
                Console.WriteLine(hit + " " + blow);
            }
        }
    }
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a;
  cin >> a;
  if (a < 1200) cout << "ABC" << '\n';
  else if (a < 2800) cout << "ARC" << '\n';
  else cout << "AGC" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll N, Z, W; cin >> N >> Z >> W;
  vector<ll> a(N); rep(i, N) cin >> a[i];

  if (N >= 2){
    cout << max(abs(a[N - 1] - W), abs(a[N - 1] - a[N - 2])) << endl;
  }
  else cout << abs(a[0] - W) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void){
	
	double x1, y1, x2, y2, r;
	cin >> x1 >> y1 >> x2 >> y2;
	r = sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
	cout << fixed << setprecision(7);
	cout << r << "\n";
	cin >> r;
	return 0;
}

Measured memory_bytes: 3264
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  // 
  // val a, b = in.next().toInt
  // val s = in.next()

  val N = in.next().toInt
  val _a = new Array[(Int, Int)](N)

  for (i <- 0 until N) {
    val X, L = in.next().toInt

    _a(i) = (X+L, X-L)
  }

  val a = _a.sorted


  var edge = Int.MinValue

  var ans = 0
  for ((r, l) <- a) {
    if (l >= edge) {
      ans += 1
      edge = r
    }
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 52060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		String[] num = line.split(" ");
		int n = Integer.parseInt(num[0]);
		int a = Integer.parseInt(num[1]);
		int b = Integer.parseInt(num[2]);
		int t = n * a;

		if (t > b) {
			System.out.println(b);
		} else {
			System.out.println(t);
		}
	}
}


Measured memory_bytes: 21076