akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007;
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

int main() { 
  int n, m;
  cin >> n >> m;
  vll vx(n);
  vll vy(m);
  rep (i, n) {
    cin >> vx[i];
  }
  rep (i, m) {
    cin >> vy[i];
  }

  vll vxd(n);
  rep(i, n - 1) {
    vxd[i + 1] = abs(vx[i] - vx[i + 1]);
  }
  

  vll vyd(m);
  rep(i, m - 1) {
    vyd[i + 1] = abs(vy[i] - vy[i + 1]);
  }
  
  ll yoko = 0;
  int N = n - 1;
  for (int i = 1; i <= N; i++) {
    yoko += vxd[i] * i * (N - i + 1);
    yoko %= MOD;
  }

  ll tate = 0;
  int M = m - 1;
  for (int i = 1; i <= M; i++) {
    tate += vyd[i] * i * (M - i + 1);
    tate %= MOD;
  }

  ll ans = tate * yoko % MOD;

  D(ans);

  return 0;
}



Measured memory_bytes: 3328
N, K = map(int, input().split())
P = list(map(int, input().split()))

E = [0]
tmp = 0
for i in range(1, max(P) + 1):
    s = tmp + i
    E.append(s / i)
    tmp = s

PE = []
for p in P:
    PE.append(E[p])

m = 0
tmp = 0
for i in range(K-1, N):
    if i == K-1:
        s = sum(PE[0:i+1])
        m = s
        tmp = s
    else:
        s = tmp - PE[i - K] + PE[i]
        m = max(m, s)
        tmp = s

print(m)


Measured memory_bytes: 77448
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  string s; cin >> s;
  int ans = 0;
  rep(i,s.size()){
    char c = s.at(i);
    ans += s.at(i)-'0';
  }

  if(ans%9==0){
    puts("Yes");
  }else{
    puts("No");
  }
}


Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

char rot3(char c) {
    if (c == 'C') return 'Z';
    if (c == 'B') return 'Y';
    if (c == 'A') return 'X';
    return c - 3;
}

int main() {
    string s;
    cin >> s;
    REP(i, s.size() - 1) {
        cout << rot3(s[i]);
    }
    cout << rot3(s[s.size()-1]) << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main() {
    string s; cin >> s;
    int ans = count(all(s), '2');
    
    cout << ans << endl;
    return;
}

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

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
int a[maxn];
int n, ans;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		ans ^= a[i];
	}
	for(int i = 1; i <= n; ++i) cout << (ans ^ a[i]) << ' ';
	cout << endl;
	return 0;
}
 

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

int main(){
  int a[101];
  for(int i = 0;i < 101;i++){
    a[i] = 0; 
  }
  for(int i = 0;i < 3;i++){
    int b;
    cin >> b;
    a[b]++;
  }
  int sum = 0;
  for(int i = 0;i < 101;i++){
    if(a[i] != 0)
      sum++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n,k;
  cin>>n>>k;
  int ans = ((n-1)+k-2)/(k-1);
  cout<<ans<<endl;

  return 0;
}


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

const int maxn = 1e4 + 10;
const int INF = 0x3f3f3f3f;

struct edge { int a, b, w; }(G[maxn]);

int n, m, group[maxn];

bool cmp(const edge& a, const edge& b) { return a.w < b.w; }

int Find(int v) { return (group[v] == v)? v : group[v] = Find(group[v]); }
void Union(int a, int b) { group[Find(a)] = b; }


int main()
{
	while(scanf("%d%d", &n, &m) && (n || m)) {
		for(int i = 0; i < m; i++) scanf("%d%d%d", &G[i].a, &G[i].b, &G[i].w);

		sort(G, G+m, cmp);

		int mini = INF;
		for(int l = 0; l <= m-n+1; l++) {
			for(int i = 1; i <= n; i++) group[i] = i;

			int r, cnt = 0;
			for(r = l; r < m; r++) {
				int a = G[r].a, b = G[r].b;
				if(Find(a) != Find(b)) { Union(a, b); cnt++; }
				if(cnt == n-1) { mini = min(mini, G[r].w - G[l].w); break; }
			}
		}

		if(mini != INF) printf("%d\n", mini);
		else puts("-1");
	}

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<pair<int,int>> E[1010];
ll from[1010];
ll to[1010];
ll res[5030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y>>r;
		E[x-1].push_back({y-1,r});
	}
	FOR(i,N) from[i]=-1LL<<60;
	from[0]=0;
	memmove(to,from,sizeof(from));
	FOR(i,5020) {
		FOR(x,N) FORR(r,E[x]) to[r.first]=max(to[r.first],to[x]+r.second);
		res[i]=to[N-1];
		memmove(from,to,sizeof(to));
	}
	
	if(res[4000]<res[5000]) cout<<"inf"<<endl;
	else cout<<res[5000]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=5005;
struct Node{
	int cost,got;
}e[N];
int f[(1<<12)+1],n,m;
signed main(){
	n=read();m=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		e[i].cost=x;
		for(int j=1;j<=y;j++){
			int z=read();e[i].got|=1<<(z-1);
		}
	}
//	for(int i=1;i<=m;i++) cout<<e[i].cost<<" "<<e[i].got<<endl;
	memset(f,0x3f,sizeof f);
	f[0]=0;
	for(int i=0;i<=(1<<n)-1;i++)
		for(int j=1;j<=m;j++)
		f[i|e[j].got]=min(f[i|e[j].got],f[i]+e[j].cost);
	if(f[(1<<n)-1]>=1000000000) cout<<"-1";
	else cout<<f[(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())
for i in range(A*C):
  if i%2 == 0:
    C = C - B
  else:
    A = A - D
  if C <= 0 or A <= 0:
    break
if C <= 0 and A > 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func abs(i int) int {
	if i < 0 {
		i *= -1
	}
	return i
}

func min(l, r int) int {
	if l > r {
		l = r
	}
	return l
}

func main() {
	var n int
	var k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	h := make([]int, n, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		var e error
		sc.Scan()
		h[i], e = strconv.Atoi(sc.Text())

		if e != nil {
			fmt.Println("ERROR:", e)
			os.Exit(22)
		}
	}

	dp := make([]int, n, n)
	dp[0] = 0
	dp[1] = abs(h[1] - h[0])
	for i := 2; i < n; i++ {
		lowest := 2147483647
		for back := 1; back <= k && back <= i; back++ {
			lowest = min(lowest, dp[i-back]+abs(h[i]-h[i-back]))
		}
		dp[i] = lowest
	}

	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2816
#include <bits/stdc++.h> 
using namespace std; 
 
int main() 
{ 
    //データ入力
    int n,m;
    cin>>n>>m;

    vector<int> k(m);
    vector<vector<int>> s(m, vector<int>(n));
    for(int i=0;i<m;i++){
        cin>>k.at(i);
        for(int j=0;j<k.at(i);j++){
            cin>>s.at(i).at(j);
        }
    }

    vector<int> p(m);
    for(int i=0;i<m;i++){
        cin>>p.at(i);
    }

    //2^nを全探索する。
    //i番目のスイッチの点灯状況をチェック　：点灯個数%2==piの時に電球が点灯
    //全ての電球が点灯すればカウントアップ
    int result=0;
    for (int i=0;i<(1<<n);i++) {
        bitset<10> bit_sw(i);
        int light=0;
        for(int j=0;j<m;j++){
            int cnt=0;
            for (int tmp=0;tmp<k.at(j);tmp++) {
               if (bit_sw.test(s.at(j).at(tmp)-1))
                    cnt++;
            }
            if(cnt%2==p.at(j))
                light++;
        }
        if(light==m)
            result++;
    }

    cout<<result<<endl;

    return 0; 
} 


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split(" "))
    tree_height = []
    for _ in range(N):
        tree_height.append(int(input()))
    tree_height.sort()
    result = 10 ** 10
    for i in range(N - K + 1):
        result = min(result, tree_height[i + K - 1] - tree_height[i])
    print(result)


if __name__ == '__main__':
    main()

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

int main() {
  int n, m, i = 0, j = 0, ppl = 0;
  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> j >> m;
    for (j -= 1; j < m; j++) {
      ppl++;
    }
  }
  cout << ppl << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  char S[101];
  int i;
  int flag = 1;

  scanf ("%s", S);

  for (i = 0; i < 101; i += 2) {
    if (S[i] == 'L') flag = 0;
  }

  for (i = 1; i < 101; i += 2) {
    if  (S[i] == 'R') flag = 0;
  }

  if (flag == 1) printf ("Yes\n");
  else printf ("No\n");

  return 0;
}


Measured memory_bytes: 128
let S = readLine()!.characters.map{String($0)}
var (tile1, tile2) = (0, 0)
for i in 0..<S.count {
    if i % 2 > 0 {
        S[i]=="0" ? tile1++ : tile2++
    } else {
        S[i]=="1" ? tile1++ : tile2++
    }
}
print(min(tile1, tile2))

Measured memory_bytes: 7808
#include <iostream>

using namespace std;


int merge(int *arr,int left,int m,int right) {
	int n1 = m -left;
	int n2 = right -m;
	int *L = new int[n1];
	int *R = new int[n2];
	int index1 = 0,index2  =0;
	int cnt = 0;
	for (int i = left;i<right;i++) {
		if (i < m) {
			L[index1++] = arr[i];
		} else {
			R[index2++] = arr[i];
		}
	}
	index1 = 0;
	index2 = 0;
	for (int i = left;i<right;i++) {
		if (index1 >= n1) {
			cnt++;
			arr[i] = R[index2++];
		} else if (index2 >= n2) {
			cnt++;
			arr[i] = L[index1++];
		} else {
			if (L[index1] <= R[index2]) {
				arr[i] = L[index1++];
			} else {
				arr[i] = R[index2++];
			}
			cnt++;
		}
	}
	return cnt;
}

//包括left但不包括right 
int mergeSort(int *arr,int left,int right) {
	if (right - left > 1) {
		int m = (left + right) / 2;
		int a = mergeSort(arr,left,m);
		int b = mergeSort(arr,m,right);
		int c = merge(arr,left,m,right);
		return a +  b + c;
	} else {
		return 0;
	}
	
}
int main() {
	int n;
	cin >> n;
	int *arr = new int[n];
	for (int i=0;i<n;i++) {
		cin >> arr[i];
	}
	int x = mergeSort(arr,0,n);
	for (int i=0;i<n;i++) {
		cout << arr[i];
		if (i == n-1) {
			cout << endl;
		} else {
			cout << " ";
		}
	}
	cout << x << endl;
} 


Measured memory_bytes: 65616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
typedef long long ll;
using namespace std;
map<int,bool> mp;
int a[100001],b[100001];
int main()
{	int n,tot=0,maxn=0; cin>>n;
	for(rint i=1;i<=n;i++)
	{	cin>>a[i];
		if(mp[a[i]])
		{	mp[a[i]]=false;
			b[++tot]=a[i];
			continue;
		}
		mp[a[i]]=true;
	}
	for(rint i=1;i<=tot;i++) maxn=max(b[i],maxn);
	int ans=maxn; bool bb=false; maxn=0;
	for(rint i=1;i<=tot;i++)
	{	if(b[i]==ans&&bb==false) {bb=true;continue;}
		maxn=max(maxn,b[i]);
	}
	cout<<(ll)ans*maxn<<endl;
 	return 0;
}


Measured memory_bytes: 5376
n, m = map(int,input().split())
h = list(map(int,input().split()))
n_ans=[1]*n

for i in range(m):
    a, b = map(int,input().split())
    if h[a-1] <= h[b-1] and n_ans[a-1] == 1:
        n_ans[a-1] = 0
    if h[b-1] <= h[a-1] and n_ans[b-1] == 1:
        n_ans[b-1] = 0
print(sum(n_ans))



Measured memory_bytes: 84988
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var s string
	fmt.Scan(&s)

	counts := make([]int, len(s))

	// LR で一区切りしてカウントするので、最後のシーケンスを見逃さないよう
	// R を末尾に追加する (右端は必ず L なので LR になる)。
	s += "R"

	rSeqs := 1
	lSeqs := 1
	lastL := -1
	for i := 1; i < len(s); i++ {
		prev := s[i-1]
		cur := s[i]
		if prev == 'R' && cur == 'R' {
			counts[i-1] = 0
			rSeqs += 1
		}
		if prev == 'R' && cur == 'L' {
			counts[i-1] = rSeqs/2 + rSeqs%2
			counts[i] = rSeqs / 2
			rSeqs = 1
			lastL = i
		}
		if prev == 'L' && cur == 'L' {
			counts[i] = 0
			lSeqs += 1
		}
		if prev == 'L' && cur == 'R' {
			counts[lastL-1] += lSeqs / 2
			counts[lastL] += lSeqs/2 + lSeqs%2
			lSeqs = 1
		}
	}

	w := bufio.NewWriter(os.Stdout)
	fmt.Fprint(w, counts[0])
	for i := 1; i < len(counts); i++ {
		fmt.Fprintf(w, " %d", counts[i])
	}
	fmt.Fprintln(w)
	w.Flush()
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,ans=1;
    cin>>n;
    for(int i=1;i<=n/2;i++){
        for(int j=2;j<=10;j++){
            int expo=pow(i,j);
            if(expo<=n){
                ans=max(ans,expo);
            }
        }
    }
    cout<<ans<<endl;
}

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

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

	int a = 200000, z = 0;
	int i;
	for( i = 0; i < s.length(); i++ ){
		if ( s[i] == 'A' ){
			a = i;
			break;
		}
	}
	for( i = s.length() - 1; i > -1; i-- ){
		if ( s[i] == 'Z' ){
			z = i;
			break;
		}
	}
	
	std::cout << z - a + 1 << std::endl;

	return 0;
}

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

#define MAX_N (100000)

int main(int argc, char *argv[]) {
  // read inputs
  int N, x;
  scanf("%d %d", &N, &x);

  // solve
  if (x == 1 || x == 2 * N - 1) {
    printf("No\n");
  } else {
    int anss[2 * MAX_N - 1];
    for (int cnt = 0; cnt < 2 * N - 1; cnt++) {
      anss[(N - 1 + cnt) % (2 * N - 1)] = (x + cnt - 1) % (2 * N - 1) + 1;
    }
    printf("Yes\n");
    for (int i = 0; i < 2 * N - 1; i++) {
      printf("%d\n", anss[i]);
    }
  }

  return 0;
}


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

int main()
{

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

        sort(X, X+N);
        int min = X[0];
        int max = X[N-1];

        long long min_power = 0;
        for (int j = min; j <= max; ++j) {


                long long power = 0;
                for (int i = 0; i < N; ++i) {
                        power += pow((X[i] - j), 2);
                }
                if (j == min) {
                        min_power = power;
                }
                else if (min_power > power) {
                        min_power = power;
                }
        }
        cout << min_power << endl;











}


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

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < n; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)

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

    int m, n;
    cin >> n >> m;
    int a[n];
    int total = 0;
    rep(i, 0, n)
    {
        cin >> a[i];
        total += a[i];
    }
    int pick = 0;
    bool ok = false;
    rep(i, 0, n)
    {
        if (a[i] * 4 * m >= total)
        {
            pick++;
            if (pick >= m)
            {
                ok = true;
            }
        }
    }
    if (ok)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

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

int main(){
	int N;cin>>N;
	vector<int>V(N);
	vector<int>C(N);
	int ans = 0;
	for(int i= 0;i<N;i++){
		cin>>V[i];
	}  
  
	for(int i= 0;i<N;i++){
      	cin>>C[i];
		if(V[i] - C[i] > 0)
			ans += (V[i] - C[i]);
	}
  
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k){
        cout << ":(" << endl;
    }
    else puts("Yay!");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S; 
  int sum=0;
  int N=S.size();
  for(int i=0;i<N/2;i++){
    if(S.at(i)!=S.at(N-1-i))
      sum++;
  }

  cout << sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  srep(i,l,r+1) if(i%d==0) ans++;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll vis[N], a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    int city = 1;
    int len = -1;
    if(k < 1e7){
        // k--;
        while(k--){
            city = a[city];
        }
        return cout << city, 0;
    }
    for(int i = 1; i <= n + n; i++){
        if(i == k) return cout << city, 0;
        if(vis[city]){
            k -= (vis[city] - 1);
            len = i - vis[city];
            break;
        }
        vis[city] = i;
        city = a[city];
    }
    assert(len != -1);
    k = k % len;
    while(k--){
        city = a[city];
    }
    cout << city;



    return 0;
}


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

int main() {
  string s;
  string t;
  int count =0;
  cin >> s >> t;
  for(int i=0;i<int(s.size());++i){
    if(s[i] != t[i]){
      count++;
    }
  }
    cout << count <<endl;
}


Measured memory_bytes: 3916
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {

    public static void main(String[] args) {

        try(var br = new BufferedReader(new InputStreamReader(System.in))) {

            var input = Long.parseLong(br.readLine());

            var result = new StringBuilder();
            while (input > 0) {
                result.insert(0, (char)((input - 1) % 26 + 97));
                input = (input - 1) / 26;
            }

            System.out.println(result.toString());

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 32424
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

const int MAX = 700000;
static const ll MOD = 1000000007;
//static const ll INF = 100000000;

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

int main() {
    ll answer;
    string S;

    // input
    cin >> S;

    // process
    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else if (S == "SAT") {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int input1 = scanner.nextInt();
		int input2 = scanner.nextInt();
		
		if (input1 == input2){
			System.out.println("Draw");
		}else if(input1 == 1 && input2 != 1){
			System.out.println("Alice");
		}else if(input2 == 1 && input1 != 1){
			System.out.println("Bob");
		}else if(input1 > input2){
			System.out.println("Alice");
		}else if(input1 < input2){
			System.out.println("Bob");
		}
		scanner.close();
	}
}


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

int main(){
  int N;
  int K;
  cin>>N>>K;
  vector<int> count(N);
  for(int i=1;i<N+1;i++){
    int j=i;
    while(j<K){      
      j=j*2;
      count.at(i-1)=count.at(i-1)+1;
    }
  }
  double ans=0;
  for(int i=1;i<N+1;i++){
    ans+=pow(0.5,count.at(i-1));
  }
  cout << fixed << setprecision(10);
  cout<<ans/N<<endl;
}

Measured memory_bytes: 640
N = int(input())
Ss = input()

used1s = [False] * 10
used2s = [False] * 100
used3s = [False] * 1000

for S in Ss:
    S = int(S)
    for x in range(100):
        if used2s[x]:
            used3s[x*10+S] = True
    for x in range(10):
        if used1s[x]:
            used2s[x*10+S] = True
    used1s[S] = True

ans = used3s.count(True)
print(ans)


Measured memory_bytes: 3188
#include <stdio.h>
int main(){
	int x,y,r,a;
	scanf("%d%d",&x,&y);
	if(x<y){
		a=x;
		x=y;
		y=a;
	}
	r=x%y;
	while(r!=0){
		x=y;
		y=r;
		r=x%y;
	}
	printf("%d\n",y);
	return 0;
}



Measured memory_bytes: 2104
// #pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma vector temporal
// #pragma simd
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>
#include<functional>
#include<complex>
#include<climits>

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vint vector<int>
#define SS stringstream
#define PQ priority_queue
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)
#define FIN(fname) freopen(fname,"r",stdin)
#define FOUT(fname) freopen(fname,"w",stdout)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define exp expexpexpexp
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#include"/home/edison/Coding/cpp/template/debug.cpp"
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#endif

void JIZZ(string output=""){cout<<output; exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-13;
const ll mod=1e9+7;

bitset<100005> v;
int d[100005];

int main(){
    CPPinput;
    int n; cin>>n;
    memset(d,0x3f,sizeof(d));
    deque<int> dq; 
    dq.push_back(1); d[1]=1;
    while(dq.size()){
        while(dq.size() && v[dq.front()])dq.pop_front();
        if(dq.empty())break;
        int now=dq.front(); dq.pop_front();
        v[now]=1;
        if(d[now*10%n]>d[now]){
            d[now*10%n]=d[now];
            dq.push_front(now*10%n);
        }
        if(now<n && d[(now+1)%n]>d[now]+1){
            d[(now+1)%n]=d[now]+1;
            dq.push_back((now+1)%n);
        }
        PDE(now,dq);
    }
    cout<<d[0]<<endl;
}


Measured memory_bytes: 896
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())
h = a[0]
ans = 0
for i in range(1, n):
    if a[i] < h:
        ans += h - a[i]
    elif a[i] > h:
        h = a[i]
print(ans)

Measured memory_bytes: 27892
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    map<string,int>p;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        p[s]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        string s;
        cin>>s;
        p[s]--;
    }
    int a,ans=0;
    for (auto x:p){
        a=x.second;
        ans=max(ans,a);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int par[100010],ran[100010],dw[100010];
void init(){
    rep(i,100010){
        par[i]=i;
        ran[i]=0;
        dw[i]=0;
    }
}
int find(int x){
    if(par[x]==x)return x;
    else{
        int r=find(par[x]);
        dw[x]+=dw[par[x]];
        return par[x]=r;
    }
}
int weight(int x){
    find(x);
    return dw[x];
}
void unite(int x,int y,int w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(ran[x]<ran[y]){
        par[x]=y;
        dw[x]=-w;
    }
    else{
        par[y]=x;
        dw[y]=w;
        if(ran[x]==ran[y])ran[x]++;
    }
}
bool same(int a,int b){
    return find(a)==find(b);
}
int diff(int x,int y){
    return weight(y)-weight(x);
}
int n,m,l,r,d;
signed main(){
	cin>>n>>m;
	init();
	rep(i,m){
		cin>>l>>r>>d;
		if(!same(l,r)){
			unite(l,r,d);
		}
		else if(diff(l,r)!=d){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
    return 0;
}

Measured memory_bytes: 2688
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(){

    long long int A, B, K;
    cin >> A >> B >> K;

    for(int i = 0; i < K; i++){
        if(i % 2 == 0){
            if(A % 2 == 1){
                A--;
                B += A/2;
                A /= 2;
            }else{
                B += A/2;
                A /= 2;
            }
        }else{
            if(B % 2 == 1){
                B--;
                A += B/2;
                B /= 2;
            }else{
                A += B/2;
                B /= 2;
            }

        }
        
    }

    cout << A << " " << B << endl;
 
    return 0;
}

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

template<typename itr, typename func>
func for_each_withindex(itr fi, itr l, func f){
	unsigned i{};
	for(; fi!=l; ++fi,++i){
		f(*fi,i);
	}
	return f;
}

int main(int argc, char const* argv[])
{
	unsigned n{};
	while (std::cin >> n,n != 0) {
		long long e{}, p{}, q{};
		bool isna{true};
		std::array<long long,4001> es{};
		std::array<bool,4001> esadup{};
		for (unsigned i = 0; i < n; i++) {
			std::cin >> e >> p >> q;
			es.at(e) += p * q;
			if (es.at(e) >= 1000000 && ! esadup.at(e)) {
				std::cout << e << std::endl;
				esadup.at(e) = true;
				isna = false;
			}
		}
		//for_each_withindex(es.begin(), es.end(), [&isna](long long sell,long long e){ 
		//		if (sell>=1000000) {
		//		std::cout << sell << ":";
		//		std::cout << e << std::endl;
		//		isna = false;
		//		}});
		if (isna) {
			std::cout << "NA" << std::endl;
		}

	}
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(3e3 + 5);
const int MAX_T = (int)(3e3 + 5);

int n, t;

vector<pair<int, int>> ab;

int dp_l[MAX_N][MAX_T];

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &t);

  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    ab.push_back(make_pair(a, b));
  }

  sort(ab.begin(), ab.end());

  for (int i = 0; i < n; ++i) {
    for (int c = 1; c <= t; ++c) {
      if (c < ab[i].first) {
        dp_l[i + 1][c] = dp_l[i][c];
      } else {
        dp_l[i + 1][c] = max(dp_l[i][c], dp_l[i][c - ab[i].first] + ab[i].second);
      }
    }
  }

  int ans = ab[0].second;

  for (int i = 1; i < n; ++i) {
    ans = max(ans, dp_l[i][t - 1] + ab[i].second);
  }

  ans = max(ans, dp_l[n - 1][t - 1] + ab[n - 1].second);

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 35584
n = int(input())

al = list(map(int, input().split()))

import collections

c = collections.Counter(al)

res = 0
temp =0
for i in range(1,n+1):
    if c[i] ==0:
        pass
    elif c[i] ==i:
        temp += c[i]
        pass
    else:
        temp += c[i]
        if c[i] >i:
            res += c[i]-i
        else :
            res +=c[i]

res += (n-temp)
print(res)

Measured memory_bytes: 18136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll K;
    cin >> K;
    ll x = (K+49)/50, y = 50*x-K;
    //すべてをx+49にした状態からy回進めた状態
    cout << 50 << endl;
    rep(i, y) cout << x+49-50+y-1 << ' ';
    rep(i, 50-y) cout << x+49+y << ' ';
    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;


vector<LL> convert_to_minus_binary_number(LL x) { 
	vector<LL> binary_num;
	while (x != 1) {
		if (x%-2 == -1) {
			binary_num.push_back(1);
			x = (x / -2) + 1;
		}
		else {
			binary_num.push_back(x % -2);
			x /= -2;
		}
	}
	binary_num.push_back(1); 
	return binary_num;
}



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

	if (N == 0) {
		cout << 0 << endl;
		return 0;
	}

	vector<LL> ans = convert_to_minus_binary_number(N);
	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << ans[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, K, x;
  cin >> N >> K;
  x = 1;
  
  for(int i = 0; i < N; i++){
      
    if(x >= K){
      x += K;
    }
    else{
      x *= 2;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define HEIGHT 12
#define WIDTH 6

int calcChain( void );
int deleteBlock( void );
int findGroup( int, int );
int findGroup_body( int, int, char, int, int );
void deleteGroup( int, int );
void deleteGroup_body( int, int, int, int );
void fallBlock( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ HEIGHT ][ WIDTH ];
const int dx[ 4 ] = { -1, 0, 1, 0 };
const int dy[ 4 ] = { 0, -1, 0, 1 };

int main( void ) {
	int i, j, n;

	scanf( "%d%*c", &n );
	while ( n-- ) {
		for ( i = 0; i < HEIGHT; i++ ) {
			for ( j = 0; j < WIDTH; j++ ) {
				scanf( "%c", &field[ i ][ j ].color );
				field[ i ][ j ].state = -1;
			}

			scanf( "%*c" );
		}

		printf( "%d\n", calcChain() );
	}

	return 0;
}

int calcChain( void ) {
	int chain;

	for ( chain = 0; ; chain++ ) {
		if ( !deleteBlock() )
			break;

		fallBlock();
	}

	return chain;
}

int deleteBlock( void ) {
	int i, j, deleted;

	deleted = 0;
	for ( i = 0; i < HEIGHT; i++ )
		for ( j = 0; j < WIDTH; j++ )
			if ( field[ i ][ j ].color != '.' && field[ i ][ j ].color != 'O' && field[ i ][ j ].state == -1 )
				if ( findGroup( i, j ) >= 4 ) {
					deleted = 1;
					deleteGroup( i, j );
				}

	return deleted;
}

int findGroup( int i, int j ) {
	int id = i * WIDTH + j;

	field[ i ][ j ].state = id;

	return findGroup_body( i, j + 1, field[ i ][ j ].color, id, 0 ) + findGroup_body( i + 1, j, field[ i ][ j ].color, id, 1 ) + 1;
}

int findGroup_body( int i, int j, char color, int id, int comeDir ) {
	int tmp, d;

	if ( i < 0 || i >= HEIGHT || j < 0 || j >= WIDTH || field[ i ][ j ].state == id || field[ i ][ j ].color != color )
		return 0;

	field[ i ][ j ].state = id;

	tmp = 0;
	for ( d = 0; d < 4; d++ )
		if ( d != comeDir )
			tmp += findGroup_body( i + dy[ d ], j + dx[ d ], color, id, d + 2 & 3 );
	
	return tmp + 1;
}

void deleteGroup( int i, int j ) {
	int id = i * WIDTH + j, d;

	field[ i ][ j ].color = '.';

	for ( d = 0; d < 4; d++ )
		deleteGroup_body( i + dy[ d ], j + dx[ d ], id, d + 2 & 3 );
}

void deleteGroup_body( int i, int j, int id, int comeDir ) {
	int d;

	if ( i < 0 || i >= HEIGHT || j < 0 || j >= WIDTH )
		return;

	if ( field[ i ][ j ].state != id ) {
		if ( field[ i ][ j ].color == 'O' )
			field[ i ][ j ].color = '.';

		return;
	}

	field[ i ][ j ].color = '.';
	field[ i ][ j ].state = -1;

	for ( d = 0; d < 4; d++ )
		if ( d != comeDir )
			deleteGroup_body( i + dy[ d ], j + dx[ d ], id, d + 2 & 3 );
}

void fallBlock( void ) {
	int i, j, cnt;

	for ( j = 0; j < WIDTH; j++ ) {
		cnt = 0;
		for ( i = HEIGHT - 1; i >= 0; i-- )
			if ( field[ i ][ j ].color == '.' )
				cnt++;
			else {
				field[ i + cnt ][ j ].color = field[ i ][ j ].color;
				field[ i + cnt ][ j ].state = -1;
			}

		for ( i = cnt - 1; i >= 0; i-- ) {
			field[ i ][ j ].color = '.';
			field[ i ][ j ].state = -1;
		}
	}
}

Measured memory_bytes: 596
fn main() {
    let s = {
        let mut s = String::new(); // バッファを確保
        std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
        s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
    };

    let (u, v) = {
            let mut ws = s.split_whitespace(); // 空白区切りの単語に分解する
            let u: i32 = ws.next().unwrap().parse().unwrap();
            let v: i32 = ws.next().unwrap().parse().unwrap();
            (u, v)
    };

    println!("{}", u + v / 2);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){
 
    ll x;
    cin >> x;
    ll ans= 100;
    ll i=0;
    while(ans<x){
        i++;
        ans = ans * 1.01;
    }

    cout << i;   


    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B;
scanf("%d %d",&A,&B);
    if(A==B)
    printf("Draw");
    else
    if(A==1)
    printf("Alice");
    else
    if(B==1)
    printf("Bob");
    else
    if(A>B)
    printf("Alice");
    else
    printf("Bob");

}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int n, Rt;
  int maxv = -2e9;
  int minv = 2e9;

  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) {
    scanf("%d", &Rt);
    maxv = maxv > Rt-minv ? maxv : Rt-minv;
    minv = minv < Rt ? minv : Rt;
  }

  printf("%d\n", maxv);

  return 0;
}


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

//int _; 

int a;
long long b,n;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> a >> b >> n;
	cout << a*min(n,b-1)/b << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;//Nは個数、Mは割引枚数
  cin >> N >> M;
  vector<int>a(N);
  for(int i = 0; i < N; i++)
  cin >> a.at(i);//入力完了
  priority_queue<int> pq;
  for(int i = 0; i < N; i++)
    pq.push(a.at(i));//投入完了
  long long memo = 0;
  for(int i = 0; i < M; i++){
    memo = pq.top();
    memo /= 2;
    pq.pop();
    pq.push(memo);
  }//割引処理終了
  long long sum = 0;
  for(int i = 0; i < N; i++){
    sum += pq.top();
    pq.pop();
  }
  cout << sum << endl;
}

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

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

  if (abs(a-c)<=d || abs(a-b)<=d && abs(b-c)<=d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = b * (c /a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

  ll ans = 0, s = 0;
  for (int i = 0, l = 0; i < N; ++i) {
    if (i == N-1) {
      s += A[i];
      ans += s/2;
    } else if (A[i] == 0) {
      ans += s/2;
      l = i;
      s = 0;
    } else {
      s += A[i];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#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 MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

namespace finp
{
	char buf[100005], *p0 = buf + 100000, *p1 = buf + 100000;
	char rchar()
	{
		if(p0 == p1) fread(p0 = buf, 1, 100000, stdin);
		return *(p0 ++);
	}
	int getint()
	{
		int ret = 0;
		char ch = rchar();
		while(ch == ' ' || ch == '\n') ch = rchar();
		do {
			ret = ret * 10 + ch - '0';
			ch = rchar();
		} while(ch != ' ' && ch != '\n');
		return ret;
	}
}
namespace foutp
{
	char buf[100005], *p0 = buf, *p1 = buf + 100000;
	void pchar(char ch)
	{
		if(ch == EOF) {
			fwrite(buf, 1, p0 - buf, stdout);
			return;
		}
		if(p0 == p1) fwrite(p0 = buf, 1, 100000, stdout);
		*(p0 ++) = ch;
	}
	char ib[100005];
	void putint(int x)
	{
		int cur = 0;
		do {
			ib[cur ++] = x % 10 + '0';
			x /= 10;
		} while(x > 0);
		reverse(ib, ib + cur);
		rep(i, cur) pchar(ib[i]);
	}
}
using finp::rchar;
using finp::getint;
using foutp::pchar;
using foutp::putint; 

int pos[100005];
int par[100005];
vector<int> G[100005];
int dfn[100005], dep[100005], tot;

void dfs(int v, int cd)
{
	dep[v] = cd;
	dfn[v] = tot ++;
	rep(i, G[v].size())
	dfs(G[v][i], cd + 1);
}

int main()
{
	int n, l, q;
	n = getint();
	rep(i, n) pos[i] = getint();
	l = getint();
	q = getint();
	int rp = 0;
	rep(i, n - 1) {
		while(rp < n && pos[rp] - pos[i] <= l) rp ++;
		par[i] = rp - 1;
	}
	rep(i, n - 1) G[par[i]].push_back(i);
	dfs(n - 1, 0);
	rep(i, q) {
		int a, b;
		a = getint();
		b = getint();
		a --; b --;
		if(a > b) swap(a, b);
		int ans = dep[a] - dep[b];
		if(dfn[a] < dfn[b]) ans ++;
		putint(ans);
		pchar('\n');
	}
	pchar(EOF);
	return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli a,b,c,x,y;
lli ans;

int main(){
  cin >> a >> b >> c >> x >> y;
  ans = x*a+y*b;
  ans = min(ans,max(x,y)*c*2);
  ans = min(ans,min(x,y)*c*2+(x-min(x,y))*a+(y-min(x,y))*b);
  ans = min(ans,x*a+y*c*2);
  ans = min(ans,x*c*2+y*b);
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] oisisa = new int[n];
		int sum = 0;
		for(int i = 0;i < n; i++) {
			oisisa[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i == j) {
					continue;
				}
				sum += oisisa[i] * oisisa[j];
			}
		}
		System.out.println(sum/2);
	}
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)

int main() {
    int n;
    cin >> n;
    int A[5][4][11] = {};

    REP(i, n) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }

    FOR(b, 1, 5) {
        if (b > 1)cout << "####################" << endl;
        FOR(f, 1, 4) {
            FOR(r, 1, 11) {
                cout << " " << A[b][f][r];
            }
            cout << endl;
        }
    }

}

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

int R;

int main () {
    cin>>R;
    if(R<1200)
        cout<<"ABC"<<endl;
    else{
        if(R<2800)
            cout<<"ARC"<<endl;
        else
            cout<<"AGC"<<endl;
    }
}

//hm

Measured memory_bytes: 3544
N = input()
A = list(map(int, input().split()))

is_even = lambda number: number % 2 == 0
is_odd = lambda number: not is_even(number)
is_dividable_by_3 = lambda number: number % 3 == 0
is_dividable_by_5 = lambda number: number % 5 == 0
is_dividable_by_3_or_5 = lambda number: is_dividable_by_3(number) or is_dividable_by_5(number)
is_approved = lambda number: is_odd(number) or (is_even(number) and is_dividable_by_3_or_5(number))

answer = 'APPROVED' if all([is_approved(Ai) for Ai in A]) else 'DENIED'

print(answer)


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

int main(){
    int n;
    cin>>n;
    int sum[n+1];
    for(int i=0;i<=n;i++){
        if(i==0||i==1){
            sum[i]=1;
        }
        else{
            sum[i]=sum[i-1]+sum[i-2];
        }
    }
    cout<<sum[n]<<endl;
    return 0;
}


Measured memory_bytes: 3096