akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int mypow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x;
		}
		x = x * x;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
int mystoi(string x) {
	int res = 0;
	rep(i, x.size()) {
		res = res * 10 + x[i] - '0';
	}
	return res;
}
/*--------Library Zone!--------*/

string s, t;
map<char, char>mp, mp1;
signed main() {
	cin >> s >> t;
	rep(i, s.size()) {
		if ((mp[s[i]] && mp[s[i]] != t[i]) || (mp1[t[i]] && mp1[t[i]] != s[i])) {
			cout << "No" << endl;
			return 0;
		}
		mp[s[i]] = t[i];
		mp1[t[i]] = s[i];
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 776
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    

    class Program
    {
        
        static void Solve(int r_start, int r_end, int l_start, int l_end, int[] chil)
        {
            for(int i = r_start; i <= r_end; i++)
            {
                if((r_end - i) % 2 == 0)
                {
                    chil[r_end]++;
                    chil[i]--;
                }
                else
                {
                    chil[r_end + 1]++;
                    chil[i]--;
                }
            }

            for(int i = l_start; i <= l_end; i++)
            {
                if((l_end - i) % 2 == 0)
                {
                    chil[l_start]++;
                    chil[i]--;
                }
                else
                {
                    chil[l_start - 1]++;
                    chil[i]--;
                }
            }

        }
        

        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int[] chil = new int[S.Length];
            int N = S.Length;

            for(int i = 0; i < N; i++)
            {
                chil[i] = 1;
            }
            bool rl = false;
            int r_start = 0;
            int r_end = 0;
            int l_start = 0;
            int l_end = 0;

            for(int i = 0; i < S.Length; i++)
            {
                if(S[i] == 'R' && !rl)
                {
                    rl = true;
                    r_start = i;
                }
                if(S[i] == 'R' && i + 1 < N && S[i + 1] == 'L' && rl)
                {
                    r_end = i;
                    l_start = i + 1;
                }
                if(i + 1 == N || (rl && S[i] == 'L' && S[i + 1] == 'R'))
                {
                    l_end = i;
                    Solve(r_start, r_end, l_start, l_end, chil);
                    rl = false;
                }

               
            }

            Console.WriteLine(string.Join(" ", chil));
        }
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int>ai(N);
  for(int i=0;i<N;i++){
    cin >> ai.at(i);
  }
  int s=1;
  int count =0;
  for(int i=0;i<N;i++){
    s=ai.at(s-1);
    count++;
    if(s==2){
      cout << count << endl;
      break;
    }
    if(i==N-1){
      cout << "-1" << endl;
    }
  }
}


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

int main(){
  int n;
  cin>> n;
  string ans="No";
  for (int i=0; i<9; i++){
    for (int j=0; j<9; j++){
      if ((i+1)*(j+1)==n){
        ans="Yes";
        break;
      }
    }
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
N=int(input())

def factoring(M,n=2):
    for i in range(n,int(M**0.5)+1):
        if M%i==0:
            ret = factoring(M//i,i)
            ret[i] = ret.get(i,0)+1
            return ret
    return {M:1}

p = {2:0}
for i in range(2,N+1):
    for k,v in factoring(i).items():
        p[k] = p.get(k,0)+v

c = [0]*4
for n in p.values():
    if n>=24:c[3]+=1
    elif n>=14:c[2]+=1
    elif n>=4:c[1]+=1
    elif n>=2:c[0]+=1

ans = 0
ans += p[2]>=74
ans += c[3]*(sum(c)-1)
c[2] += c[3]
ans += c[2]*(c[1]+c[2]-1)
c[1] +=c[2]
ans += c[0]*c[1]*(c[1]-1)//2
ans += c[1]*(c[1]-1)*(c[1]-2)//2
print(ans)

Measured memory_bytes: 3064
n, m, x = map(int, input().split())
CA = [0 for i in range(n)]
for i in range(n):
    CA[i] = list(map(int, input().split()))

ans = 10 ** 7
for i in range(2 ** n):
    TCA = [0 for i in range(m + 1)]
    f = 0
    for j in range(n):
        if (i >> j) & 1 == 1:
            TCA = [x + y for (x, y) in zip(TCA, CA[j])]
        else:
            pass
    for j in range(1, m + 1):
        if TCA[j] < x:
            f = 1
            break
        else:
            pass
    if f == 0:
        ans = min(ans, TCA[0])
    else:
        pass
if ans == 10 ** 7:
    print(-1)
else:
    print(ans)

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

int main() {
  string n;
  cin >> n;
  for (int i=0; i<3; i++) {
    if (n.at(i) == '1') {
      n.at(i) = '9';
    }
    else {
      n.at(i) = '1';
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const firstLine = input[0].split(" ").map((val) => parseInt(val, 10));
const N = firstLine[0];
const Q = firstLine[1];

const S = input[1];

let left = 0;
let right = N - 1;

for (let i = Q + 1; i > 1; i--) {
  const t = input[i].charAt(0);
  const d = input[i].charAt(2);

  if (S.charAt(left - 1) === t && d === "R") {
    left--;
  } else if (S.charAt(left) === t && d === "L") {
    left++;
  }

  if (S.charAt(right) === t && d === "R") {
    right--;
  } else if (S.charAt(right + 1) === t && d === "L") {
    right++;
  }

  if (left > right) {
    break;
  }
}

console.log(right - left + 1);


Measured memory_bytes: 32716
#include<cstdio>
#include<iostream>

using namespace std;
typedef long long ll;

const ll INF = 1LL << 50;//极大值 


 int main() {
 	int h,w;
	 cin>>h>>w;
	 char pic[105][105];
	 for(int i=1;i<=h+2;i++){
	 	for(int j=1;j<=w+2;j++){
	 		if(j==1||i==1||j==w+2||i==h+2){
	 			pic[i][j]='#';
	 			continue;
			 }
			 cin>>pic[i][j];
		 }
	 } 
	 for(int i=1;i<=h+2;i++){
	 	for(int j=1;j<=w+2;j++){
	 		cout<<pic[i][j];
		 }
		 cout<<endl;
	 }
 	return 0;
 }

Measured memory_bytes: 256
class Node():
  def __init__(self):
    self.parent = -1
    self.left = -1
    self.right = -1

def get_depth(u, p):
  D[u] = p
  if result[u].right is not None:
    get_depth(result[u].right, p)
  if result[u].left is not None:
    get_depth(result[u].left, p+1)

def get_depth_1(u, p):
  i = u
  d = 0
  while result[u].parent != -1:
    u = result[u].parent
    d += 1
  D[i] = d

def get_hight(H, u):
  lh, rh = 0, 0
  if result[u].left != -1:
    lh = get_hight(H, result[u].left)+1
  if result[u].right != -1:
    rh = get_hight(H, result[u].right)+1

  H[u] = max(lh, rh)
  return H[u]

n = int(input())
node  = [list(map(int, input().split())) for _ in range(n)] 
result = [Node() for _ in range(n)]
D = [0 for _ in range(n)]
H = [0 for _ in range(n)]


def initiate(li):
  for l in li:
    n = l[0]
    left = l[1]
    right = l[2]
    if left != -1:
      result[left].parent = n
      result[n].left = left
    if right != -1:
      result[right].parent = n
      result[n].right = right


initiate(node)

for u in range(n):
  get_depth_1(u, 0)
  
for u in range(n):
    get_hight(H, u)

final = []

for i in range(n):
  node = i 
  parent = result[node].parent 
  depth = D[i]
  height = H[i]
  degree = 0
  if result[node].left == -1 and result[node].right == -1:
    typ = "leaf"
    degree = 0
  elif result[node].left >= 0 and result[node].right >= 0:
    typ = "internal node"
    degree = 2
  else:
    degree = 1
    typ = "internal node"

  if parent == -1:
    typ = "root"
  if result[parent].left == node:
    sibling = result[parent].right
  else:
    sibling = result[parent].left
  print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node, parent, sibling, degree, depth, height, typ))



Measured memory_bytes: 5624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class34
    {
        static void Main()
        {
            var HN = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Console.WriteLine(HN[0] <= A.Sum() ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 19808
// F.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

lolo myPow(lolo x, lolo n, lolo m)
{
	if ( n == 0 )
		return 1;
	if ( n % 2 == 0 )
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}


int main()
{
	lolo M, K;
	cin >> M >> K;


	
		lolo N = myPow(2, M, lolo(1e13));
		if ( M != 1 )
		{
			if ( K >= N )
			{
				cout << -1 << endl;
				exit(0);
			}
			FOR(i, N)
			{
				if ( i == K ) continue;
				cout << i << " ";
			}
			cout << K << " ";
			REV(i, N - 1, -1)
			{
				if ( i == K ) continue;
				cout << i << " ";
			}
			cout << K << endl;
		} else
		{

			if ( K == 0 )
			{
				FOR(i, N)
					cout << i << " ";
				REV(i, N-1, -1)
					cout << i << " ";

			} else
			{
				cout << -1 << endl;
			}
		}

	
}



Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	int n;
	cin>>n;
	map<string,int>mp;
	for(int i=1;i<=n;i++){
		string s;
		cin>>s;
		mp[s]++;
	} 
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<long long> S(5, 0);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s.at(0) == 'M') S.at(0)++;
    else if (s.at(0) == 'A') S.at(1)++;
    else if (s.at(0) == 'R') S.at(2)++;
    else if (s.at(0) == 'C') S.at(3)++;
    else if (s.at(0) == 'H') S.at(4)++;
  }
  long long ans = 0;
  vector<vector<int>> com = {
    { 0, 1, 2 }, { 0, 1, 3 }, { 0, 1, 4 }, { 0, 2, 3 }, { 0, 2, 4 },
    { 0, 3, 4 }, { 1, 2, 3 }, { 1, 2, 4 }, { 1, 3, 4 }, { 2, 3, 4 }
  };
  for (vector<int> c : com) ans += S.at(c.at(0)) * S.at(c.at(1)) * S.at(c.at(2));
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    int ans = 0;
    rep(i,n) {
        cin >> s[i];
        ans += s[i];
    }
    sort(ALL(s));
    if(ans % 10 != 0){
        cout << ans << endl;
        return 0;
    }
    rep(i,n){
        if(s[i] % 10 == 0) continue;
        else{
            cout << ans - s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        string s, t;
        cin >> s >> t;
        if(s == t.substr(0, s.length())){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
}

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

int x, y;
void solve(){
    for(int i = 0; i <= x; i++){
        int curr = i * 2;
        int rem = (x - i) * 4;
        if(curr + rem == y){
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> x >> y;
    solve();
    return 0;
}


Measured memory_bytes: 3632
n=int(input())
m=0
c=0
for _ in range(n):
	n1,n2=map(int,input().split())
	if n1==n2:
		c+=1
		m=max(m,c)
	else:
		m=max(m,c)
		c=0
if m>=3:
	print('Yes')
else:
	print('No')

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

const int MAXN = 102;
LL x[MAXN],y[MAXN];
vector<LL> vx,vy;
int n,K;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> K;
    for(int i = 0; i < n; ++i)
    {
        cin >> x[i] >> y[i];
        vx.push_back(x[i]);
        vy.push_back(y[i]);
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    LL res = 1LL<<62;
    for(int i = 0; i < vx.size(); ++i)
    {
        for(int j = i+1; j < vx.size(); ++j)
        {
            vector<LL> vz;
            for(int k = 0; k < n; ++k)
                if(x[k] >= vx[i] && x[k] <= vx[j])
                    vz.push_back(y[k]);
            sort(vz.begin(),vz.end());
            for(int k = 0; k <= (LL)vz.size()-K; ++k)
                res = min(res,(vx[j]-vx[i])*(vz[k+K-1]-vz[k]));
        }
    }
    cout << res <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}
//iはあまりでやるといいよ
//M/N=a…a→Na+a=M→M-a=Naだから、if()
int main() {
	llint n;
	cin >> n;
	llint ans = 0;
	for (llint i = 1; i * i < n; i++) {
		if (n % i == 0) {
			llint m = n / i - 1;
			if (n / m == n % m) {
				ans += m;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int MOD = 1e9 + 7;

using namespace std;

int main(){
  string K;
  cin >> K;
  
  int D;
  cin >> D;
  
  vector<vector<vector<long long>>> dp(K.size() + 1, vector<vector<long long>>(D, vector<long long>(2, 0)));
  dp[0][0][1] = 1;
  for(int i = 0; i < (int)K.size(); i++){
    for(int j = 0; j < D; j++){
      for(int k = 0; k < 10; k++){
        dp[i + 1][(j + k) % D][0] += dp[i][j][0];
        if(k < K[i] - '0'){
          dp[i + 1][(j + k) % D][0] += dp[i][j][1];
        }else if(k == K[i] - '0'){
          dp[i + 1][(j + k) % D][1] += dp[i][j][1];
        }
        dp[i + 1][(j + k) % D][0] %= MOD;
        dp[i + 1][(j + k) % D][1] %= MOD;
      }
    }
  }
  
  cout << ((dp[K.size()][0][0] + dp[K.size()][0][1] - 1) % MOD + MOD) % MOD << endl;
  
  return 0;
}

Measured memory_bytes: 58416
#include <iostream>
#include<algorithm>
#include<iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans = w*0.5*h;
    char way = '0';
    if(x==0.5*w && y==0.5*h)way = '1';
    cout<<fixed<<setprecision(10);
    cout<<ans<<' '<<way<<endl;

    return 0;
}

Measured memory_bytes: 3760
XS = list(map(int, open(0).read().split()))
for i in range(0, len(XS), 2):
    a = XS[i]
    b = XS[i+1]
    if a == 0 and b == 0:
        break
    if a < b:
        print("{} {}".format(a, b))
    else:
        print("{} {}".format(b, a))



Measured memory_bytes: 6096
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;

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

  int x,y; cin >> x >> y;

  if(x == 0) {
    int ans = signbit(y) + abs(y);
    cout << ans << endl;
    return 0;
  } else if(y == 0) {
    int ans = !signbit(x) + abs(x);
    cout << ans << endl;
    return 0;
  }

  int ans = 0;
  if(abs(x) < abs(y)) {
    if(signbit(x) && signbit(y)) {
      ans += 2;
    } else if(signbit(x) || signbit(y)) {
      ++ans;
    }
  } else {
    if(!signbit(x) && !signbit(y)) {
      ans += 2;
    } else if(!signbit(x) || !signbit(y)) {
      ++ans;
    }
  }

  ans += abs(abs(x) - abs(y));

  cout << ans << endl;
}

// -10 -20 -> 12
// -10  20 -> 11
//  10 -20 -> 11
//  10  20 -> 10
//   0  10 -> 10

// -20 -10 -> 10
//  20 -10 -> 11
// -20  10 -> 11
//  20  10 -> 12
//   0 -10 -> 11


Measured memory_bytes: 256
#include <iostream>

int main(){

  int n;

  std::cin >> n;

  int sum = 0;

  for(int i = 0; i < n; ++i){
    int l, r;
    std::cin >> l >> r;
    sum += r - l + 1;
  }

  std::cout << sum << std::endl;

  return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    ll x, y;
    cin >> x >> y;

    ll xm = -x;
    ll ym = -y;

    ll p1, p2, p3, p4;
    p1 = p2 = p3 = p4 = 0;

    if (x <= y) p1 = y - x;
    else p1 = LINF;

    if (xm <= y) p2 = y - xm + 1;
    else p2 = LINF;

    if (x <= ym) p3 = ym - x + 1;
    else p3 = LINF;

    if (xm <= ym) p4 = ym - xm + 2;
    else p4 = LINF;

    cout << min({p1, p2, p3, p4}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<iomanip>
using namespace std;


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

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

	vector<double> x(n), y(n), p(n);
	rep(i, n){
		cin >> x[i] >> y[i];
		p[i] = i;
	}

	double ans = 0;

	int count = 0;
	do{

		for(int i = 1; i < n;++i){
			double dx = x[p[i]] - x[p[i - 1]];
			double dy = y[p[i]] - y[p[i - 1]];
			ans += sqrt(pow(dx, 2) + pow(dy, 2));
		}
		count++;

	}while(next_permutation(p.begin(), p.end()));

	cout << fixed << setprecision(9) << ans / count << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
wa = [0 for _ in range(n+1)]
ac = 0
q = [False for _ in range(n+1)]

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s =="WA":
        if q[p]:
            continue
        else:
            wa[p] += 1
    else:
        if q[p]:
            continue
        else:
            q[p] = True
            ac += 1
p = 0
for i,j in zip(q,wa):
    if i:
        p += j
print(ac,p)       

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

int main() {
    int n, a, co = 0, minim = INT_MAX;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a);
        minim = min(a, minim);
        if(a <= minim) {
            co++;
        }
    }
    printf("%d\n", co);
}

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

int main(){
  int H, N;
  cin >> H >> N;
  
  int a;
  for(int i;i<N;i++){
  	cin >> a;
    H -= a;
  }
  
  if(H <= 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict as dd

N, M = map(int, input().split())
A = list(map(int, input().split()))

mods = dd(int)
mods[0] = 1

# 1-indexed
cuma = [0] * (N + 1)
for i in range(N):
    cuma[i + 1] = (cuma[i] + A[i]) % M

for i in range(N):
    mods[cuma[i + 1]] += 1

cnt = 0

for ci in set(cuma):
    m = mods[ci]
    cnt += m * (m - 1) // 2
print(cnt)


Measured memory_bytes: 62576
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define mod 1000000007
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) cin>>x>>y; f0(i,0,k){int x,y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int mon[501][501];
int cnt[501][501];

signed main()
{
    fast

    int n,m,k;
    cin>>n>>m>>k;

    int a[n],b[m];
    int x;
    f0(i,0,n){
        cin>>a[i];
    }
    f0(i,0,m){
        cin>>b[i];
    }
    int suma[n+1],sumb[m+1];
    suma[0] = sumb[0] = 0;
    f1(i,1,n){
        suma[i] = suma[i-1] + a[i-1];
    }
    f1(i,1,m){
        sumb[i] = sumb[i-1] + b[i-1];
    }

    int ans = 0;
    f1(i,0,n){
        int l = 0, r = m, mid;
        if(suma[i] > k) break;
        while(l<=r){
            mid = l+(r-l)/2;
            if(suma[i] + sumb[mid] <= k){
                ans = max(ans, i+mid);
                l = mid + 1;
            }
            else{
                r = mid - 1;
            }
        }
    }

    cout<<ans;
}

Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ABS(a) (((a) > 0) ? (a) : -(a))
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((ABS(a-b) <= d && ABS(b-c) <= d) || ABS(a-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
  
  int A[100],N,i,flag,n,x,count=0;
  
  scanf("%d",&n);
  
  for(i=0 ; i<n ; i++)
    {
      scanf("%d",&A[i]);
    }
  
  flag =1;
  while(flag!=0)
    {
      flag=0;
      for(i=n-1 ; i>0 ; i--)
	{
	  if( A[i] < A[i-1])
	    {
	      x=A[i];
	      A[i] = A[i-1];
	      A[i-1]=x;
	      flag=1;
	      count++;
	    }
	}
    }
  for(i=0 ; i<n ; i++){
    printf("%d",A[i]);
    if( i == n-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define PI 3.14159265359
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
typedef vector<pair<ll,ll> > vpii;
typedef vector<ll> vi;
const ll INF=1e14+7;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)cin>>a[i];
}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}
bool isprime(ll n){
    if(n==1)return false;
    if(n==2 || n==3)return true;
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}
//ll x[100001]={0};
ll a[200001]={0};
//ll b[200001]={0};
//ll b[200001]={0};
//bool c[100001]={0};
//vector<pair<ll,ll> > adj[100001];
//vector<ll> adj[100001];
//vpii edges;
//bool visited[100001]={0};
//bool color[100001]={0};
//ll dist[100001]={0};
ll binary_expon(ll a,ll b){
    ll res=1;
    while(b){
        if(b%2)res=(res*a)%INF;
        a=(a*a)%INF;
        b/=2;
    }
    return res%INF;
}

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)res*=i;
    return res;
}

double distance(ll x1,ll y1,ll x2,ll y2){
    return (sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

/*void tree_dfs(ll curr,ll prev){
    for(auto u:adj[curr]){
        if(u!=prev){
            tree_dfs(u,curr)+1;
        }
    }
}*/

/*void dfs(ll x,ll y){
    if(x<0 || y<0 || x>=n || y>=m)return;
    if(visited[x][y])return;
    visited[x][y]=true;
    dfs(x+1,y);dfs(x-1,y);dfs(x,y+1);dfs(x,y-1);
}*/

/*bool isVowel(char c){
    return(c=='a'||c=='e'||c=='i'||c=='o'||c=='u');
}*/
//ll grid[1001][1001]={0};

/*void dfs(ll s,bool colr){
    if(visited[s])return;
    visited[s]=true;
    color[s]=colr;
    for(auto u:adj[s]){
        dfs(u,!colr);
    }
}*/
//set<pair<ll,ll> >edges;
/*vector<ll> z(string s) {
    ll n=s.length();
    vector<ll> z(n);
    ll x=0,y=0;
    for(ll i=1;i<n;i++) {
        z[i]=max(0ll,min(z[i-x],y-i+1));
        while(i+z[i]<n&&s[z[i]]==s[i+z[i]]){
            x = i; y = i+z[i]; z[i]++;
        }
     }
    return z;
}*/

void solve(){
    ll x,n;
    cin>>x>>n;
    ll temp;
    set<ll> s;

    for(ll i=0;i<n;i++){
        cin>>temp;
        s.insert(temp);
    }
    ll ans=INF;
    ll c=0;
    for(ll i=0;i<=1000;i++){
        if(s.count(x+i)){}
        else{
            if((ll)abs(x-(x+i))<ans){
                ans=(ll)abs(x-(x+i));
                c=x+i;
            }
        }

        if(s.count(x-i)){

        }
        else{
            if((ll)abs(x-(x-i))<ans){
                ans=(ll)abs(x-(x-i));
                c=x-i;
            }
            else if((ll)abs(x-(x-i))==ans){
                c=x-i;
            }
        }
    }
    cout<<c;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //sieve(100001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define N 602
using namespace std;
typedef long long ll;
int n,now,a[N],sm;
int tag[N];
ll jie[N],dp[2][302][302];
const int mod=1e9+7;
inline void MOD(ll &x){x=x>=mod?x-mod:x;}
inline ll rd(){
    ll x=0;char c=getchar();bool f=0;
    while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return f?-x:x;
}
int main(){
    n=rd();
    sm=n*2;
    int cnt=0;
    for(int i=1;i<=sm;++i){
        a[i]=rd();
        if(a[i]!=-1)tag[a[i]]=1;
        if(i%2==0&&a[i]!=-1&&a[i-1]!=-1){
            tag[a[i]]=-1;
            tag[a[i-1]]=-1;
        }
        if(i%2==0&&a[i]==-1&&a[i-1]==-1)cnt++;
    }
    jie[0]=1;
    for(int i=1;i<=sm;++i)jie[i]=jie[i-1]*i%mod;
    dp[1][0][0]=1;
    int now=1,pre=0;
    for(int i=sm;i>=1;--i)if(tag[i]!=-1){
        swap(now,pre);
        memset(dp[now],0,sizeof(dp[now]));
        for(int j=0;j<=n;++j)
            for(int k=0;j+k<=n;++k)if(dp[pre][j][k]){
                if(tag[i]){
                  MOD(dp[now][j][k+1]+=dp[pre][j][k]);
                  if(j)MOD(dp[now][j-1][k]+=dp[pre][j][k]);
                }
                else{
                  MOD(dp[now][j+1][k]+=dp[pre][j][k]);
                  if(j)MOD(dp[now][j-1][k]+=dp[pre][j][k]);
                  if(k)MOD(dp[now][j][k-1]+=dp[pre][j][k]*k%mod);
                }
            }
    }
    printf("%lld",dp[now][0][0]*jie[cnt]%mod);
    return 0;
}

Measured memory_bytes: 1664
def main():
    n = int(input())
    edge = []
    for i in range(n):
        edge.append([])
    for i in range(n-1):
        abc = list(map(int, input().split()))
        edge[abc[0]-1].append((abc[1]-1, abc[2])) # zero index
        edge[abc[1]-1].append((abc[0]-1, abc[2])) # zero index
    q, k = map(int, input().split())
    k -= 1 # zero index
    xy = []
    for i in range(q):
        xy.append(list(map(int, input().split())))
        xy[-1][0] -= 1 # zero index
        xy[-1][1] -= 1 # zero index

    distance_from_k = []
    visited = []
    for i in range(n):
        distance_from_k.append(0)
        visited.append(False)
    st = [k]
    while st:
        now = st.pop()
        if visited[now]:
            continue
        visited[now] = True
        for x in edge[now]:
            if visited[x[0]]:
                continue
            distance_from_k[x[0]] = distance_from_k[now] + x[1]
            st.append(x[0])

    ans = []
    for i in range(q):
        ans.append(distance_from_k[xy[i][0]] + distance_from_k[xy[i][1]])

    for x in ans:
        print(x)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

const int N = 1e5 + 5;

int p[N];

int main(){
    vector<bool> f(N, true);
    for (int i = 2; i < N; ++i) {
        if (f[i]) {
            for (ll j = 1ll * i * i; j < N; j += i) {
                f[j] = false;
            }
        }
    }
    for (int i = 3; i < N; i += 2) {
        if (f[i] && f[(i + 1) / 2]) {
            p[i] = 1;
        }
    }
    for (int i = 1; i < N; ++i) p[i] += p[i - 1];
    int q;
    scanf("%d", &q);
    while (q--) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", p[r] - p[l - 1]);
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

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

pair<int, string> pairif[110000];

int N, M;
int WA[105000];
bool AC[105000];

void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for (int i = 1; i <= N; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while (M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        } else if (S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}

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

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
int n;
long long a[N],x;
long long minn[N][N];
long long dp[N];
long long ans;
int main()
{
	scanf("%d%lld",&n,&x);
	for(int i=1; i<=n; i++)
	{
		scanf("%lld",&a[i]);
	}
	memset(minn,127,sizeof(minn));
	for(int i=1;i<=n;i++)
	{
		minn[i][0]=a[i];
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		minn[i][j]=min(minn[i][j-1],a[((i-j+n-1)%n)+1]);
	}
	ans=1e15;
	for(int i=0;i<n;i++)
	{
		dp[i]=i*x;
		for(int j=1;j<=n;j++)
		{
			dp[i]+=minn[j][i];
		}
		ans=min(ans,dp[i]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int H,W,dx[]={-1,0,1,1,1,0,-1,-1},dy[]={1,1,1,0,-1,-1,-1,0};
map<int,map<int,char>> w;
int main(){
    cin>>H>>W;
    for(int i{};i<H;++i)
        for(int j{};j<W;++j)
            cin>>w[i][j];
    for(int i{};i<H;++i){
        for(int j{};j<W;++j){
            if(w[i][j]=='#'){
                cout<<'#';
                continue;
            }
            int cnt{};
            for(int k{};k<8;++k)
                if(w[i+dx[k]][j+dy[k]]=='#')
                    ++cnt;
            cout<<cnt;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 384
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int P, Q, R;
	cin >> P >> Q >> R;
	cout << min(P + Q, min(Q + R, R + P)) << endl;
	return 0;
}


Measured memory_bytes: 764
#include <stdio.h>

int main(void)
{
  int h1,h2;
  int m1,m2;
  int k;
  int time;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
  time = (60*h2+m2)-(60*h1+m1)-k;
  printf("%d\n", time);
  return 0;
}


Measured memory_bytes: 1732
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll bit_size(ll a){
    for(int i=0;i<63;i++){
        if(1<<i >= a){return i;}
    }
    return 63;
}

//1-index
template<typename T>
class BIT{
private:
    vector<T> bit;
    ll size;
    
public:
    BIT(vector<T> t){
        size=bit_size(t.size());
        bit.resize((1<<size)+1);
        for(int i=1;i<=t.size();i++){
            change(i,t[i-1]);
        }
    }
    
    BIT(ll s){
        size=bit_size(s);
        bit.resize((1<<size)+1);
    }
    
    BIT(ll s,T a){
        size=bit_size(s);
        bit.resize((1<<size)+1,a);
    }
    
    void add(ll where,T a){
        while(where<bit.size()){
            bit[where]+=a;
            where+=where&-where;
        }
    }
    
    //[1,r]
    T sum(ll r){
        T ret=0;
        while(r>0){
            ret+=bit[r];
            r=r&(r-1);
        }
        return ret;
    }
    
    //[l,r]
    T sum(ll l,ll r){
        T ret=sum(r);
        ret-=sum(l-1);
        return ret;
    }
};




int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    map<ll,ll> M;
    for(int i=0;i<n;i++){cin>>a[i]; M[a[i]]=0;}
    ll count=1;
    for(auto i=M.begin();i!=M.end();++i){i->second=count++;}
    for(int i=0;i<n;i++){a[i]=M[a[i]];}
    BIT<ll> T(n);
    ll ans=0;
    for(ll i=n-1;i>=0;i--){
        ans+=T.sum(a[i]);
        T.add(a[i],1);
    }
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 18924
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
int n, m, q;
vector<int> a, b, c, d;

int dfs(int depth, int pre, vector<int> cur) {
  int res = 0;
  if (depth == n) {
    // cout << cur << endl;
    rep(i, q) {
      int aa = cur[a[i]];
      int bb = cur[b[i]];
      if(bb - aa == c[i]) res += d[i];
    }
    return res;
  }

  for (int i = pre; i <= m; ++i){
    vector<int> next = cur;
    next.push_back(i);
    chmax(res, dfs(depth + 1, pre = i, next));
  }
  return res;
}

int main() {
  
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i, q) {
    int s, t;
    cin >> s >> t >> c[i] >> d[i];
    --s; --t;
    a[i] = s;
    b[i] = t;
  }
  vector<int> t;
  int ans = dfs(0, 1, t);
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	srand(time(0));
	int a, b;
	int k = rand() % 2;
	scanf("%d %d", &a, &b);
	if (k) printf("%d\n", gcd(a, b));
	else printf("0");
	return 0;
}

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


/*
vvl comb(int n, int r) {
vvl v(n + 1,vl(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v;
}
*/

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}


int main(){
	int n,k,s;
	cin>>n>>k>>s;
	int cnt=0;
	rep(i,0,n){
		if(cnt>=k){
			if(s==1000000000)cout<<s-1<<" ";
			else cout<<s+1<<" ";
		}else cout<<s<<" ";
		cnt++;
	}
}


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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  int n,ans,x[100001];cin>>n;
  REP(i,n+1) cin>>x[i];
  sort(x,x+n+1);
  ans=x[1]-x[0];
  REP(i,n) ans=gcd(ans,x[i+1]-x[i]);
  cout<<ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 998244353;
using namespace std;

int main() {
    string s;
    string t;
    cin >> s >> t;
    REP(i,3) {
        if (s[i] != t[2-i]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
const string s = "AABB";

bool dfs(const vector<vector<int>> &G, const string &S, vector<int> &V, vector<bool> &visited, int v, int t, int u){
  bool ret = false;
  V[v] |= (1<<t);
  visited[v] = true;
  t = (t+1)%4;
  for(size_t i = 0; i < G[v].size(); ++i){
    int v_ = G[v][i];
    if(S[v_] != s[t]) continue;
    if(v_ == u and not t) return true;
    //if(not t and V[v_]%2) return true;
    if((V[v_]>>t)&1) return true;
    //if((V[v_]>>t)&1) continue;
    ret |= dfs(G,S,V,visited,v_,t,u);
  }
  V[v] = 0;
  return ret;
}

int main(){
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  vector<vector<int>> G(N);
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  //assert(N <= 1000);
  bool f = false;
  vector<bool> visited(N,false);
  vector<int> V(N,0);
  for(int i = 0; i < N; ++i){
    if(S[i] != 'A') continue;
    if(visited[i]) continue;
    f |= dfs(G,S,V,visited,i,0,i);
    if(f){
      cerr << i << endl;
      break;
    }
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 29444
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, cnt int
	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		if len(strconv.Itoa(i))%2 != 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


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

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


Measured memory_bytes: 3552
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG arc/arc058/c.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int n, k;
vector<int> d;

bool func(int price){
    int a = log10(price);
    for(int i = a; i >= 0; i--){
        for(int j = 0; j < d.size(); j++){
            if(price / int(pow(10, i)) == d[j]){
                return false;
            }
        }
        price %= int(pow(10, i));
    }
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    cin >> n >> k;
    d.resize(k);
    rep(i, k){
        cin >> d[i];
    }

    for(int i = n; i < 100000; i++){
        if(func(i)){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin>>s>>t;
	if(s==t.substr(0,t.size()-1))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


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

#define ll long long

using namespace std;

int main(){

	string s1, s2;
	cin >> s1 >> s2;

	ll n1 = s1.length() + 1, n2 = s2.length() + 1;
	vector<vector<ll>> dp(n1, vector<ll>(n2, 0));

		
	for(int i = 1; i < n1; i++){
		for(int j = 1; j < n2; j++){
		
			if(s1[i-1] == s2[j-1]){
					dp[i][j] = dp[i-1][j-1] + 1;
			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
			
		}
	}

	int i=n1-1, j = n2-1;
	string val = "";

	while(i >0 && j > 0){    
    
		if(s1[i-1] == s2[j-1]){
			val += s1[i-1];
			i--;
			j--;	
		}
		else{
			if(dp[i-1][j] >= dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	reverse(val.begin(), val.end());
	cout << val << "\n";
	

	return 0;
}

Measured memory_bytes: 73724
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll x;
    cin >> x;
    ll kane =100;
    ll now = 0;
    while(1){
        ll risoku = kane/100;
        kane+=risoku;
        now++;
        if(x<=kane){
            cout<<now<<endl;
            return 0;
        }
    }
}
    



Measured memory_bytes: 3592