akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

ll want, a, b;

ll solve() {
	if (a >= want) return 1;
	if (a <= b) return -1;
	ll d = a - b;
	ll left = want - a;
	ll t = (left + d - 1) / d;
	return 1 + 2 * t;
}

void run() {
	scanf("%lld%lld%lld", &want, &a, &b);
	printf("%lld\n", solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main(){
  int N;
  cin>>N;
  vector<int> C(N),S(N),F(N);
  
  for(int i=0; i<N-1; i++) cin>>C[i]>>S[i]>>F[i];
  
  for(int i=0; i<N; i++){    
    int tm = 0;
    
    for(int j=i; j<N-1; j++){
      if(S[j] > tm) tm = S[j];
      else if(tm % F[j] != 0){
        tm = tm + F[j]-tm%F[j];
      }
      tm += C[j];
    }
    
    cout<<tm<<endl;
  }

  return 0;
  
  
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, N) cin >> l.at(i);

    sort(l.begin(), l.end(), greater<int>());

    int sum = 0;
    rep(i, K)
    {
        sum += l.at(i);
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

int main() {
	long double a, b; //long double は10進数で約19桁の精度
	cin >> a >> b;
    b += (long double)pow(2, -60); //Bの丸め誤差は高々2^-60なので、下ブレが起きないように2^-60を足す
	cout << fixed << setprecision(0) <<  floor(b*a) << endl; //AとBの積を端数切り捨てで出力
}


Measured memory_bytes: 3748
data = input().split()
x = int(data[0])
y = int(data[1])

if y % 2 != 0:
	print("No")
elif (2*x - 0.5*y) >= 0 and (-1*x + 0.5*y)>= 0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 9172
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

Measured memory_bytes: 40668
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b,c;
    a=n/100;
    b=n/10%10;
    c=n%10;
    int ans;
    ans=a+10*b+100*c;
    if (ans==n)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  for(int i = 0; i < 1000; i++) {
    string s = "00" + to_string(i);
    s = s.substr(s.size()-3);
    bool found = true;
    for(int j = 0; j < 3; j++) {
      int pos;
      if(j == 0) pos = S.find(s[j]);
      else pos = S.find(s[j], pos+1);
      if(pos == string::npos) {
        found = false;
        continue;
      }
    }
    if(found) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

def main():
  input = sys.stdin.readline
  n, m, l = map(int, input().split())
  
  inf = pow(10, 10)
  towns = [[inf]*n for _ in range(n)]
  
  for _ in range(m):
    a, b, c = map(int, input().split())
    if c > l:
      continue
    towns[a-1][b-1] = c
    towns[b-1][a-1] = c
  
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if towns[i][j] > towns[i][k]+towns[k][j] and l >= towns[i][k]+towns[k][j]:
          towns[i][j] = towns[i][k]+towns[k][j]
  
  for i in range(n):
    for j in range(n):
      if towns[i][j] == inf:
        continue
      towns[i][j] = 0
  
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if towns[i][j] > towns[i][k]+towns[k][j]+1:
          towns[i][j] = towns[i][k]+towns[k][j]+1

  q = int(input())
  for _ in range(q):
    s, t = map(int, input().split())
    print(towns[s-1][t-1] if towns[s-1][t-1] != inf else -1)

if __name__ == "__main__":
  main()

Measured memory_bytes: 54876
#include <cstdio>
#include <algorithm>
using namespace std;
int m[101];
int main() {
  int a, mv = 0;
  while (~scanf("%d", &a)) {
    m[a]++;
    mv = max(m[a], mv);
  }
  for (int i = 1; i < 101; ++i) {
    if (m[i] == mv) printf("%d\n", i);
  }
}


Measured memory_bytes: 2564
#include<iostream>

using namespace std;

int main()
{
    long long int  a[10000],i,min=1000000000000001,m,n;
    cin>>n;
    for(i=0;i<5;i++)
    {
        cin>>a[i];
        if(min>a[i])
            min=a[i];
    }
    if(n%min==0)
        m=(n/min)+4;
    else
        m=(n/min)+5;
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
	var mem = input[0].split(" ").map(Number);
	const arr = new Array(100).fill(0);
	var a = input[1].split(" ").map(Number).sort(function(a,b){return a-b;});
	var b = input[2].split(" ").map(Number).sort(function(a,b){return a-b;});
	var c = input[3].split(" ").map(Number).sort(function(a,b){return a-b;});
	var sum = 0;
	var num = 0;
	while(mem[0]!=0||mem[1]!=0){
		if(a[a.length-1]>b[b.length-1]&&a[a.length-1]>c[c.length-1]&&mem[0]){
			sum += a[a.length-1];
			a.pop();
			mem[0]--;
		}else if(c[c.length-1]>b[b.length-1]){
			sum += c[c.length-1];
			c.pop();
			num++;
		}else{
			sum += b[b.length-1];
			b.pop();
			mem[1]--;
		}
		if(mem[0]==0) a = arr;
		if(mem[1]==0) b = arr;
		if(c.length==0) c = arr;
		if(mem[0]+mem[1]==num) break;
	}
	console.log(sum);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 56700
# https://atcoder.jp/contests/abc123/tasks/abc123_b
# B - Five Dishes

time_list = []

for _ in range(5):
    time_list.append(int(input().split()[0]))

# 10の倍数からの差が一番大きいやつを最後に頼んだ方が良い
ichi_list = [int(str(x)[-1]) for x in time_list]
sabun_list = [10 - int(str(x)[-1]) if int(str(x)[-1]) != 0 else 0 for x in time_list]

# print(ichi_list)
# print(sabun_list)

last_order_time = max(sabun_list)
last_order_time_index = sabun_list.index(last_order_time)

total = 0
i = last_order_time_index 
total = sum(time_list[:i] + time_list[i+1:])
total += sum(sabun_list[:i] + sabun_list[i+1:])
total += time_list[i]
print(total)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int blb=b,swb=0;
	while (blb) {
		swb++;
		blb/=10;
	}
	int sca=1;
	for (int i=1;i<=swb;i++) sca*=10;
	a=a*sca+b;
	int bj=sqrt(a);
	if (bj*bj==a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define MAX(A, B) ((A) > (B)? (A): (B))
#define MIN(A, B) ((A) < (B)? (A): (B))

int search(int x, int y, int pat);

int n;
bool tront[1000][1000];
int table[3][1000][1000];

int main() {
	int i, j;

	while (1) {
		int max = 0;
		memset(table, 0, sizeof(table));
		cin >> n;
		getchar();
		if (n == 0)
			break;
		for (i = 0; i < n; i++) {
			char str[1001];
			gets(str);
			for (j = 0; j < n; j++) {
				switch (str[j]) {
				case '.':
					tront[i][j] = 0;
					break;
				case '*':
					tront[i][j] = 1;
					break;
				}
			}
		}
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				if (!tront[i][j]) {
					int kmax = search(i, j, 0);
					max = MAX(max, kmax);
				}
			}
		}
		cout << max << endl;
	}
	return 0;
}

int search(int x, int y, int pat) {
	int cx = 1, cy = 1, cxy = 1;

	if (table[2][x][y])
		return table[2][x][y];

	if (x >= n || y >= n || tront[x][y])
		return 0;

	switch (pat) {
	case 0:
		cx += search(x+1, y, 1);
		cy += search(x, y+1, 2);
		cxy += search(x+1, y+1, 0);
		table[2][x][y] = MIN(cx, MIN(cy, cxy));
		return table[2][x][y];
		break;

	case 1:
		if (table[0][x][y])
			return table[0][x][y];
		cx += search(x+1, y, 1);
		table[0][x][y] = cx;
		return cx;
		break;

	case 2:
		if (table[1][x][y])
			return table[1][x][y];
		cy += search(x, y+1, 2);
		table[1][x][y] = cy;
		return cy;
		break;
	}
}

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

int main()
{
	map<string, string> next;
	next["Sunny"] = "Cloudy";
	next["Cloudy"] = "Rainy";
	next["Rainy"] = "Sunny";
	string ac;
	cin >> ac;
	cout << next[ac];
	return 0;
}

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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/
    
    long long n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    long long mn=min({a,b,c,d,e});
    cout<<(long long)(ceil(n*1.0/mn)+4);

    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

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

int main(void){
  int n, ans, b;
  scanf("%d", &n);
  vector<int> ds(n);
  rep(i, n) scanf("%d", &ds[i]);
  rep(i, n) {scanf("%d", &b); ds[i] -= b;}

  sort(all(ds));
  ll tot = accumulate(all(ds), 0LL);
  if (tot < 0){
    ans = -1;
  }else{
    ll sm = 0; ans = 0;
    for (int i = 0; i < n && ds[i] < 0; ++i) sm -= ds[i], ++ans;
    for (int i = n - 1; sm > 0; --i) sm -= ds[i], ++ans;
  }

  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    int answer = 0;
    int a = 0, b = 0, c = 0;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        for (int j = 0, length = s.length(); j < length - 1; ++j) {
            if (s[j] == 'A' && s[j + 1] == 'B') ++answer;
        }
        if (s[s.length() - 1] == 'A') ++a;
        if (s[0] == 'B') ++b;
        if (s[0] == 'B' && s[s.length() - 1] == 'A') ++c;
    }
    answer += min(a, b);
    if (a == b && b == c && a > 0) {
        --answer;
    }
    cout << answer << endl;
}


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

int kaisu(int n){
    int cnt = 0;
    while(n>0){
        if(n%2==0){
            n /= 2;
            cnt++;
        }else{
            break;
        }
    }

    return cnt;
}

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

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

Measured memory_bytes: 256
#include<stdio.h>
#define nothing -1
typedef struct{
    int parent;
    int right;
    int left;
}Node;
Node node[100002];
int DEPTH( int );
void LISTUP( int );

//-------------------------------------------------------------------
int main(){
  int n, c, k, l, r, id, i, j;

  //input
  scanf("%d",&n);
  for(i = 0; i<n; i++){
    node[i].parent = nothing; node[i].left = nothing; node[i].right = nothing;
  }
 //input children 
  for (i = 0; i<n; i++){
    scanf("%d%d",&id,&k);
    for (j = 0; j<k; j++){
      scanf("%d",&c);
      node[c].parent = id;
      if ( j == 0 ) node[id].left = c;
      else node[l].right = c;
      l = c;
    }
  }
  for(i = 0; i<10000; i++);
  //display
  for( i = 0; i<n; i++ ) LISTUP( i );
  
  return 0;
}
//--------------------------------------------------------------------------------
int DEPTH( int q ){
  int cnt=0;
  int i;

  for(;node[q].parent != nothing;){
    q = node[q].parent;
    cnt++;
  }
  for(i = 1000; i>0; i--);
  return cnt;
}
//--------------------------------------------------------------------------------
void LISTUP( int q ){
  int c, depthnum, i;
  
  //get a data of depth
  depthnum = DEPTH( q );
  printf("node %d: parent = %d, depth = %d, ", q, node[q].parent, depthnum);
  //print the type of the data
  if(node[q].parent == nothing) printf("root, ");
  else if(node[q].parent != nothing && node[q].left == nothing) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i = 0; i<5000; i++);
  //print the children
  if(node[q].left != nothing){
    printf("%d",node[q].left);
    c = node[q].left;
    while(node[c].right != nothing){
      printf(", %d",node[c].right);
      c = node[c].right;
    }
  }
  printf("]\n");
}



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

using namespace std;



int main(){
    int n,ans=0;
    cin>>n;
    for(int i=0,j=1;i<n;i++){
        int a;
        cin>>a;
        if(j==a)
            j++,ans++;
    }
    if(ans)
    cout<<n-ans<<endl;
    else
        cout<<-1<<endl;


    return 0;
}


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

int main() {
  int x;
  cin >> x;
  if (x==0) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a[2];
  int count;
  cin >> a;
  
  for(int i = 0; i < 3; i++){
    if(a[i] == '1'){
      count++;
    }
  }
  
  cout << count << endl; 
}

Measured memory_bytes: 256
n = int(input())
c = input()

ans = 0
lp = 0
rp = n-1
while True:
    if lp >= rp:
        break
    while lp < n and c[lp] != 'W':
        lp += 1
    while rp >= 0 and c[rp] != 'R':
        rp -= 1
    if lp >= rp:
        break
    lp += 1
    rp -= 1
    ans += 1
print(ans)


Measured memory_bytes: 9480
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int n, sum = 0;
double memo[40005] = {0};
int t[105] = {0};
int v[105] = {0};
int bf[105] = {0};
int af[105] = {0};
double now = 0, ans = 0;
vector<pair<int, pair<int, int>>> data;

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> t[i];
  for(int i = 0; i < n; ++i) cin >> v[i];
  for(int i = 0; i < n; ++i) {
    bf[i] = sum;
    sum += t[i];
    af[i] = sum;
    memo[(int)now * 2] =
        min(memo[(int)(now * 2)], (double)v[i]);
    while(now < sum) {
      now += 0.5;
      memo[(int)(now * 2)] = (double)v[i];
    }
  }
  memo[sum * 2] = 0;
  for(int i = 0; i < n; ++i)
    data.push_back(
        make_pair(v[i], make_pair(bf[i], af[i])));
  data.push_back(make_pair(0, make_pair(sum, 0)));
  sort(data.begin(), data.end());
  for(int i = 0; i <= n; ++i) {
    double nv = data[i].fi;
    now = data[i].se.fi;
    while(now > 0) {
      now -= 0.5;
      nv += 0.5;
      if(nv < memo[(int)(now * 2)])
        memo[(int)(now * 2)] = nv;
      else
        break;
    }
    nv = data[i].fi;
    now = data[i].se.se;
    while(now < sum) {
      now += 0.5;
      nv += 0.5;
      if(nv < memo[(int)(now * 2)])
        memo[(int)(now * 2)] = nv;
      else
        break;
    }
  }
  for(int i = 1; i <= sum * 2; ++i)
    ans += (memo[i] + memo[i - 1]) * 0.25;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;


int main()
{
	string S;
	cin >> S;
	string S_temp(S.size(), '0');
	for(int i = 0; i < S.size(); i++)
	{
		if(i % 2)
		{
			S_temp.at(i) = '1';
		}
	}

	int answer = 0;

	for(int i = 0; i < S.size(); i++)
	{
		if(S.at(i) != S_temp.at(i))
		{
			answer++;
		}
	}

	if(S.size() - answer < answer)
	{
		answer = S.size() - answer;
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 512
N = int(input())
P = [int(x) for x in input().split()]
Q = [int(x) for x in input().split()]

import itertools

p_index = 0
q_index = 0
base_list = sorted(P)
for i, v in enumerate(itertools.permutations(base_list, N)):
    v = list(v)
    if P == v:
        p_index = i
    if Q == v:
        q_index = i

print(abs(p_index-q_index))


Measured memory_bytes: 3060
x=input()
y=input()
if x==y:
    print('No')
else:
    s=list(x)
    t=list(y)
    s.sort()
    t.sort()
    t.reverse()

    a=''.join(s)
    b=''.join(t)
    l=[[a,1],[b,2]]
    l.sort()
    if l[0][1]<l[1][1]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import numpy as np

n, k = map(int, input().split())
a = np.zeros(n)

for i in range(k):
    d = input()
    temp = input()

    for j in range(int(d)):
        a[int(temp.split(' ')[j]) - 1] = 1

count = 0
for i in range(n):
    if a[i] == 0:
        count = count + 1

print(count)


Measured memory_bytes: 27000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int x;
int ans;

signed main() {
	cin >> x;
	ans += x / 500 * 1000;
	x %= 500;
	ans += x / 5 * 5;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector <vector <char>> g;
    vector <char> r(3);
    g.resize(2,r);
    for(int i=0;i<2;i++)
        for(int j=0;j<3;j++)
            cin>>g[i][j];
    bool f=1;
    for(int i=0;i<3;i++)
        if(g[0][i]!=g[1][2-i])
        {
            f=0;
            break;
        }
    if(f)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    
    return 0;   
}




 
 


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

int r, d, x;

int main() {
  cin >> r >> d >> x;
  int cur = x;
  for (int i = 0; i < 10; ++i) {
    cur = r * cur - d;
    cout << cur << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;

  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{
    cout << 1 << endl;
  }
}

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

long d[2222] = {1};
int main() {
    string s;
    cin >> s;
    int x = 0, t = 1;
    reverse(s.begin(), s.end());
    for(auto c : s) {
        (x += (c - '0') * t) %= 2019;
        (t *= 10) %= 2019;
        d[x]++;
    }
    long r = 0;
    for(int i = 0; i < 2019; i++)
        r += d[i] * (d[i] - 1) / 2;
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3740
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
int main() {
	int ans, c;
	string x;
	bool f = 1, ok, dame;
	cin >> x;
	ans = x.size();
	if (x.back() == '\n')x.pop_back();
	rep(i, 0, x.size()) {
		if (x[0] != x[i])break;
		else if (i == x.size() - 1) {
			puts("0");
			return 0;
		}
	}
	rep(i, 'a', 'z' + 1) {
		string a, b;
		a += x;
		b += x;
		c = 0;
		f = 1;
		while (1) {
			auto &t = f ? a : b, &t2 = f ? b : a;
			ok = true;
			dame = true;
			rep(i2, 0, t.size() - 1 - c) {
				if (t[i2] == (char)i || t[i2 + 1] == (char)i)t2[i2] = i, dame = false;
				else t2[i2] = 'A', ok = false;
			}
			f = !f;
			c++;
			//cout << (char)i << ':' << t2 << endl;
			if (dame)c = ans;
			if (ok || dame)break;
		}
		ans = min(ans, c);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#At coder 2020/3/27 C

# スペース区切りの整数の入力
K, N = map(int, input().split())
A = list(map(int, input().split())) 

mlen=K-A[N-1]+A[0]
for ii in range(N-1):
    len2=A[ii+1]-A[ii]
    mlen=max(mlen,len2)
ans=K-mlen


print(ans)

Measured memory_bytes: 26444
s = {}
l = {}
for si in ['a', 'b', 'c']:
    s[si] = list(input())[::-1]
    l[si] = len(s[si]) - 1
x = 'a'
while(True):
    if l[x] == -1:
        break
    xx = s[x][l[x]]
    l[x] -= 1
    x = xx
print(x.upper())


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
    int x,y,a=0,b=0;
    scanf("%d%d",&x,&y);
    if(x==4||x==6||x==9||x==11)a++;
    else if(x==2)a+=2;
    if(y==4||y==6||y==9||y==11)b++;
    else if(y==2)b+=2;
    puts(a-b?"No":"Yes");
    return 0;
}

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

using namespace std;

int cnt(vector< vector<char> > &s, int x, int y)
{
    return (s[x][y] == '#') ? 1 : 0;
}

int main()
{
    int h, w;
    cin >> h >> w;
    char c[] = "012345678";

    vector< vector<char> > s(h, vector<char>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') continue;
            int t = 0;
            if (i != 0) { 
                t += cnt(s, i-1, j);
                if (j != 0) t += cnt(s, i-1, j-1);
                if (j != w-1) t += cnt(s, i-1, j+1);
            }
            if (i != h-1) {
                t += cnt(s, i+1, j);
                if (j != 0) t += cnt(s, i+1, j-1);
                if (j != w-1) t += cnt(s, i+1, j+1);
            }
            if (j != 0) t += cnt(s, i, j-1);
            if (j != w-1) t += cnt(s, i, j+1);
            s[i][j] = c[t];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations, product

N,C = list(map(int, input().split()))
D = [[0]*(C+1)] + [[0] + list(map(int, input().split())) for _ in range(C)] #D[i][j]
c = [[0]*(N+1)] + [[0] + list(map(int, input().split())) for _ in range(N)] #c[i][j]

mod3 = [[0]*(C+1) for _ in range(3)]

for i,j in product(range(1,N+1), range(1,N+1)):
  mod3[(i+j)%3][c[i][j]] +=1

answer = 1000*500*500
for colors in permutations(range(1,C+1), 3):
  temp = sum([sum([D[i][colors[m]]*n for i,n in enumerate(mod3[m])]) for m in range(3)])
  answer = min(answer, temp)

print(answer)

Measured memory_bytes: 5108
<?php
fscanf(STDIN, "%d %d", $N, $K);

$ans = 0;

for ($i = $N; $i > 0; $i--) {
    $need = max(0, ceil(log ($K / $i, 2)));
    $ans += 1 / pow(2, $need);
}
echo $ans / $N;


Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	int n,l;
	string s[1000];
	cin >> n >>l ;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
   int N; cin >> N;
   int ans=0;
   if (N<105){
       cout << "0" << endl;
       return 0;
   }
   for (int i=105;i<=N;i+=2){
       int tmp = 0;
       for (int j=1;j<=N;j+=2){
           if (i%j==0) tmp++;
       }
       if (tmp==8) ans++; 
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k;
ll ans,t;
int main(){
	scanf("%d%d",&n,&k);
	ans=n/k;
	ans=ans*ans*ans;
	if(k%2==0)t=(n+k/2)/k,t=t*t*t;
	cout<<ans+t;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main() {
  int A,B,king=1;
  scanf("%d %d",&A,&B);
if(A>=1 && A<=13 && B>=1 && B<=13)
{


  if(A==king && B!=1)
  {
      printf("Alice\n");
  }

else if(B==king && A!=1)
{
    printf("Bob\n");

}

else if(A>B)
{
    printf("Alice\n");
}
else if(B>A)
{
    printf("Bob\n");
}
else

     printf("Draw\n");


}

  return 0;
}


Measured memory_bytes: 504
import sys
def input():
	return sys.stdin.readline()[:-1]

BASE, MOD = 1999849216943526259, (1<<61)-1

d = dict()
ans = 0
ss = [input()[::-1] for _ in range(int(input()))]
zero = [0 for _ in range(26)]
ss.sort(key=lambda x: -len(x))
for s in ss:
	n = len(s)
	if n == 1:
		ans += zero[ord(s[n-1])-97]
	else:
		hashes = [0 for _ in range(n-1)]
		hashes[0] = ord(s[0])
		for i in range(1, n-1):
			hashes[i] = (hashes[i-1] * BASE + ord(s[i])) % MOD
		if hashes[n-2] in d:
			ans += d[hashes[n-2]][ord(s[n-1])-97]
		alph = [0 for _ in range(26)]
		alph[ord(s[n-1])-97] = 1
		for i in range(n-2, 0, -1):
			alph[ord(s[i])-97] = 1
			if hashes[i-1] not in d:
				d[hashes[i-1]] = [0 for _ in range(26)]
			for j, a in enumerate(alph):
				d[hashes[i-1]][j] += a
		alph[ord(s[0])-97] = 1
		for j, a in enumerate(alph):
			zero[j] += a
print(ans)

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

using namespace std;

int main(){
    int n , H ;
    cin >> n >> H ;
    vector<int> a(n) , b(n) ;
    int nax = 0 ;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        nax = max(nax, a[i]) ;
    }
    priority_queue<int> q ;
    for(int i = 0; i < n; i++){
        if ( b[i] >= nax ) q.push(b[i]) ;
    }
    int ans = 0 ;
    while(not q.empty() && H > 0){
        H -= q.top() ; q.pop() ;
        ans++;
    }
    if ( H > 0 ){
        ans += (H + nax - 1) / nax ;
    }
    cout << ans << endl;

    return 0 ;
}


Measured memory_bytes: 1788
N, K = map(int, input().split())
o = []
e = []
if K % 2:
    for i in range(1, N + 1):
        if not i % K:
            o.append(i)
else:
    for i in range(1, N + 1):
        if not i % K:
            o.append(i)
        elif i % K == K // 2:
            e.append(i)
print(len(o) ** 3 + len(e) ** 3)


Measured memory_bytes: 11036
#include<stdio.h>
#define N_MAX 50

int F[N_MAX];
int fibonacci(int n);

int fibonacci(int n)
{
  int i;
  F[0]=1;
  F[1]=1;
  
  for(i=2 ;i<=n; i++){
    F[i] = F[i-2] + F[i-1];
  }

  return F[n];
}

int main()
{
  int n;
  scanf("%d", &n);
  printf("%d\n", fibonacci(n));
  
  return 0;
}

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

int main(){
	int n,m,ret;
	while(cin >> n && n){
		cin >> m;
		ret = 0;
		for(int i=n;i<=m;i++){
			int c = i;
			while(c%2==0){
				c/=2;
			}
			while(c%3==0){
				c/=3;
			}
			while(c%5==0){
				c/=5;
			}
			if(c==1)ret++;
		}
		cout << ret << endl;
	}
}

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

int main() {
  int N;
  int ai;
  int i, j=0, old=1000;

  cin >> N;

  for (i=0;i<N;i++){
    j = 0;
    cin >> ai;
    while (!(ai % 2)) {
      ai /= 2;
      j++;
    }
    if (old > j) {
      old = j;
    }
  }

  cout << old << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextInt();

        long answer = 0;

        if (k == 0)
        {
            Console.WriteLine(n * n);
            return;
        }

        for (long i = k + 1; i <= n; i++)
        {
            long tmpAnswer = (n / i) * (i - k);
            tmpAnswer += Math.Max(0, n % i - k + 1);
            answer += tmpAnswer;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27132
import fractions
#####segfunc######
def segfunc(x,y):
    return fractions.gcd(x,y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res
#input
n = int(input())
a = list(map(int, input().split()))

#####単位元######
ide_ele = 0
num =2**(n-1).bit_length() 
seg=[ide_ele]*(2*num - 1)
init(a)
ans = 0
for i in range(n):
    ans = max(ans, fractions.gcd(query(0,i), query(i+1, n)))
print(ans)

Measured memory_bytes: 91488
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int N, A, B, a = 0, ans = 0;
  int a0, a1, a2, a3, a4;
  cin >> N >> A >> B;

  for (int i = 1; i <= N; i++) {
    a0 = (i%10);
    a1 = ((i/10)%10);
    a2 = ((i/100)%10);
    a3 = ((i/1000)%10);
    a4 = ((i/10000)%10);

    a = a0 + a1 + a2 + a3 + a4;
    if (A <= a && a <= B) {
      ans += i;
    };
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int a,b;
    cin>>a>>b;
    cout<<((a+b)+1)/2<<endl;
    
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head

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

    int n, m;
    cin >> n >> m;
    
    priority_queue<ll, vector<ll>, greater<ll>> q;

    for(int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        q.push(a);
    }

    vector<pll> queries(m);
    for(int i = 0; i < m; i++) {
        ll b, c;
        cin >> b >> c;
        queries[i] = mp(c,b);
    }
    sort(all(queries));
    reverse(all(queries));

    for(int i = 0; i < m; i++) {
        pll p = queries[i];
        bool ok = false;
        ll b = p.second;
        while(b > 0 && p.first > q.top()) {
            q.pop();
            q.push(p.first);
            b--;
            ok = true;
        }
        if(!ok) break;
    }
    ll sum = 0;
    while(!q.empty()) {
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 2676
#include <iostream>
#include <queue>
#include <stdio.h>
using namespace std;


void calc(char* cs){
std::queue<char> qu;
int size;
for(int i=0;cs[i]!='\0';i++){
	qu.push(cs[i]);
}
int n,h;
scanf("%d",&n);
size=qu.size();
while(n--){
	scanf("%d",&h);
	for(int i=0;i<h;i++){
		int a=qu.front();
		qu.pop();
		qu.push(a);
	}
}
while(qu.empty()==false){
	printf("%c",qu.front());
	qu.pop();
}
printf("\n");
}


int main() {
// your code goes here
char cs[201];
while(1){
	scanf("%s",cs);
	if(cs[0]=='-')break;
	calc(cs);
}
return 0;
}

Measured memory_bytes: 3124
#include <iostream>

using namespace std;

int main() {
	long long N;
	long long A[210000];

	cin >> N;
	for(long long i = 0; i < N; i++) cin >> A[i];
	
	long long cnt = 0;
	if(A[0] != 0) {
		cout << "-1" << endl;
		return 0;
	}
	for(long long i = 1; i < N; i++) {
		if(A[i] - A[i - 1] > 1) {
			cout << "-1" << endl;
			return 0;
		}
		if(A[i] - A[i - 1] == 1) ;
		else cnt += A[i - 1];
	}
	cnt += A[N - 1];
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cmath>

#include <list>
#include <queue>
#include <algorithm>

#define INF 1000000000

using namespace std;
using ll = long long;

int main(void)
{
    int n, x, t;
    cin >> n >> x >> t;

    int q = n / x;
    int m = n % x;

    if (m == 0) {
        cout << q * t;
    } else {
        cout << (q + 1) * t;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
    int n, m;

    int t[51];

    for (int i = 0; i < 52; i++) {
        t[i] = 0;
    }

    int a, b;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        t[a]++;
        t[b]++;
    }

    for (int i = 1; i <= n; i++) {
        cout << t[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int s[2];
    REP(i,3)cin >> s[i];
    sort(s,s+2);
    int ans = s[0]*s[1]/2;
    cout << ans <<endl;

}


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

int main() {
	int N;
	cin >> N;
	vector<string> a(N);
	cout << 0 << endl;
	cin >> a.front();
	cout << N - 1 << endl;
	cin >> a.back();
	if (a.front() != "Vacant" && a.back() != "Vacant") {
		pair<int, int> b{ 0, N };
		while (true) {
			cout << (b.first + b.second) / 2 << endl;
			cin >> a[(b.first + b.second) / 2];
			if (a[(b.first + b.second) / 2] == "Vacant") break;
			if (a[b.first] == a[(b.first + b.second) / 2]) {
				if (((b.first + b.second) / 2 - b.first) % 2) b.second = (b.first + b.second) / 2;
				else b.first = (b.first + b.second) / 2;
			}
			else {
				if (((b.first + b.second) / 2 - b.first) % 2) b.first = (b.first + b.second) / 2;
				else b.second = (b.first + b.second) / 2;
			}
		}
	}
}

Measured memory_bytes: 1620
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use num::*;
use proconio::marker::*;
use proconio::*;

#[fastout]
fn main() {
    input! {
        k: i32,
    }
    // annotate for rust-analyzer
    let k: i32 = k;

    let mut ans = 0;
    for i in 1..=k {
        for j in 1..=k {
            for l in 1..=k {
                ans += i.gcd(&j).gcd(&l);
            }
        }
    }

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


Measured memory_bytes: 2200
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	 int n; cin >> n;
	 int a[n];
	 int sum = 0;
	 
	 for(int i=0;i<n;i++){
	 	cin >> a[i];
	 	sum += a[i];
	 }
	 
	 sort(a,a+n);
	 int flag = 0;
	 if(sum%10 != 0){
	 	cout << sum;
	 	return 0;
	 }
	 else{
	 	int i=0;
	 	while(i < n){
	 		sum -= a[i];
	 		if(sum%10 != 0){
	 			cout << sum;
	 			flag=1;
	 			return 0;
			 }
			 else{
			 	sum+=a[i];
			 	i++;
			 }
		 }
	 }
	 
	 if(!flag) cout <<0;
	 
	 return 0;
}

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

//#define HOST
#ifdef HOST
#include"data_structure.h"
#include"common_algorithm.h"
#endif

ll inf = 1e9+7;

ll modularInverse(ll x, ll y, ll m)
{
    vector<ll> dp(x+1, 1);
    for (int i = 2; i <= x; i++)
        dp[i] = dp[m % i] *
               (m - m / i) % m;

    return (dp[x]*y)%m;
}

struct qqq
{
    ll a;
    ll b;
    ll c;
};

int main() {
    ll n, k, d, m;
    cin >> n >> k >> d >> m;
    vector<ll> a(n,0);
    vector<ll> b(k,0);
    vector<ll> c(d,0);
    vector<ll> a1(n,0);
    vector<ll> b1(k,0);
    vector<ll> c1(d,0);
    for(ll i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    for(ll i = 0; i < k; i++)
    {
        cin >> b.at(i);
    }
    for(ll i = 0; i < d; i++)
    {
        cin >> c.at(i);
    }
    sort(c.begin(), c.end());

    priority_queue<pair<ll, int> > an;
    for(ll i = 0 ;i < n; i++)
    {
        for(ll j = 0; j < k; j++)
        {
            an.push(make_pair(a.at(i) + b.at(j) + c.at(d-1),d-1) );
        }
    }

    for(ll i = 0; i < m; i++)
    {
        pair<ll, int> top = an.top();
        an.pop();
        cout << top.first << endl;
        if(top.second > 0)
        {
            top.first += c.at(top.second-1) - c.at(top.second);
            top.second--;
            an.push(top);
        }
    }

    return 0;
}


Measured memory_bytes: 18668
program main
  implicit none
  character(len=1) :: b

  read(*,*) b

  if (b=='A') then
     write(*,'(A)') 'T'
  elseif (b=='T') then
     write(*,'(A)') 'A'
  elseif (b=='C') then
     write(*,'(A)') 'G'
  elseif (b=='G') then
     write(*,'(A)') 'C'
  end if
  stop
end program main


Measured memory_bytes: 768
#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 X,Y;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>Y;
	FOR(i,X+1) {
		if(2*i+4*(X-i)==Y) return _P("Yes\n");
	}
	_P("No\n");
	
}


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);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;


void solve(string S)
{
    int ans = 0;
    vector<char> v;
    for (auto &c: S) {
        v.push_back(c);
        if (v.size() >= 2) {
            int n = v.size();
            if (v[n-1] != v[n-2]) {
                v.pop_back();
                v.pop_back();
                ans += 2;
            }
        }
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

int main() {
	int n, item;
  	int expensive = 0;
  	int bill = 0;	
  
  	cin >> n;
   	for (int i = 0; i < n; ++i) {
   		cin >> item;
      	if (item > expensive) {
        	expensive = item;
        }
      	bill += item;
   	}
  	bill -= (expensive / 2);
  	cout << bill << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	ll a, b;
	string s;
	cin >> a >> b >> s;
	for (ll i = 0; i < s.size(); i++) {
		if (s[i] == '-'&&i != a) {
			cout << "No" << endl;
			exit(0);
		}
	}
	if (s.size() == a + b + 1 && s[a] == '-') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}

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

int main(){
    
    string s; cin >> s;
    int t1 = 0, t2 = 0;
    for(int i = 0; i < (int)s.size(); i++){
        char hoge = '0';
        char huga = '1';
        if(i % 2 == 0) swap(hoge, huga);
        t1 += s[i] == hoge;
        t2 += s[i] == huga;
    }
    cout << min(t1,t2) << endl;

    return 0;
}

Measured memory_bytes: 512
<?php
$n = explode(" ", trim(fgets(STDIN)));

asort($n);
$nn = array_values($n);

if ($nn[0] == 1 && $nn[1] == 4 && $nn[2] == 7 && $nn[3] == 9) {
    echo "YES\n";
} else {
    echo "NO\n";
}

Measured memory_bytes: 4728
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
n, m = map(int, input().split())

l = 0
r = n+1

for i in range(m):
    _l, _r = map(int, input().split())
    l = max(l, _l)
    r = min(r, _r)

print(max(r-l+1, 0))


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

const long long int MOD = 998244353;
const int MAX_N = 1000000;
long long int sum[MAX_N + 1], sum2[MAX_N + 1], D[MAX_N + 1];

vector<pair<int, int> > V[MAX_N + 1];

void func(int N, int idx, int p) {
    if (idx == V[N].size()) {
        sum[p] = (sum[p] + N) % MOD;
        sum2[p] = (sum2[p] + 1ll * N * N) % MOD;
    }
    else {
        func(N, idx + 1, p);
        for (int j = 0; j < V[N][idx].second; j++) {
            p *= V[N][idx].first;
            func(N, idx + 1, p);
        }
    }
}

long long int pow(long long int a, long long int r) {
    long long int ans = 1;
    while (r > 0) {
        if (r & 1)
            ans = ans * a % MOD;
        a = a * a % MOD;
        r /= 2;
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= MAX_N; i++) {
        sum[i] = sum2[i] = 0;
        D[i] = 1;

        int T = i;
        for (int j = 2; j * j <= T; j++) {
            if (T % j == 0) {
                int cnt = 0;
                while (T % j == 0)
                    cnt++, T /= j;
                V[i].emplace_back(j, cnt);
                D[i] *= (1 - j);
            }
        }
        if (T > 1) {
            V[i].emplace_back(T, 1);
            D[i] *= (1 - T);
        }
        if (D[i] < 0)
            D[i] += MOD;
    }

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        func(k, 0, 1);
    }

    long long int ans = 0;
    for (int i = 1; i <= MAX_N; i++) {
        long long int P1 = (sum[i] * sum[i] - sum2[i] + MOD) % MOD * D[i] % MOD;
        long long int P2 = 2 * i;
        ans = (ans + P1 * pow(P2, MOD - 2)) % MOD;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 89728
open List


let read () =  
  let open Scanf in
  let rec reads n ls =
    if n = 1 then scanf "%s\n" (fun x -> float_of_string x :: ls)
    else let x = scanf "%s " float_of_string in reads (n - 1) (x :: ls) in
  let n = scanf "%s\n" int_of_string in
  let ts = rev @@ reads n [] in
  let vs = rev @@ reads n [] in n, ts, vs

let rec mkfs ts vs t_cur =
  match ts, vs with
  | [], [] -> []
  | t::ts, v::vs -> 
    (fun x -> if x < t_cur then v +. t_cur -. x
      else if x > t_cur +. t then v -. t_cur -. t +. x 
      else v) :: mkfs ts vs (t_cur +. t)
  | _, _ -> failwith "die"

let () =
  let n, ts, vs = read () in
  let t_sum = fold_left (+.) 0. ts in
  let fs = (fun x -> x) :: ((mkfs ts vs 0.) @ [fun x -> t_sum -. x]) in 
  let calc_min x fs = fold_left (fun acc f -> min acc (f x)) 500. fs in
  let rec calc x sum vo vn =
    if x +. 0.5 > t_sum then sum else
      calc (x +. 0.5) (sum +. 0.25 *. (vo +. vn)) vn (calc_min (x +. 1.0) fs) in 
  calc 0. 0. 0. (calc_min 0.5 fs) |> print_float; print_newline ()


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
string s;
  cin>>s;
  ll count=0;
  ll countw=0;
  ll countb=0;
  ll flag=0;
  for(ll i=0;i<s.size();i++){
if(s[i]=='B'){
  if(flag==2){
  count+=countb*countw;
  }
  countb++;
flag=1;
}
    if(s[i]=='W'){
            if(flag==1){
        countw=0;
      }
      if(i==s.size()-1){
      count+=countb*(countw+1);
      }

      countw++;
      flag=2;
    }
  }
  cout<<count;
  return 0;
}



Measured memory_bytes: 640