akhauriyash/Code-Regression huggingface dataset:
//C - Multiple Clocks: 8Min;
//Assunto: Math/ MMC;
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll mmc(ll x, ll y) {
    ll aux = __gcd(x, y), a;
    a = (x / aux) * y;
    return a;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    ll ans = 1, x;
    cin >> n;
    loop(i, 0, n) {
        cin >> x;
        ans = mmc(ans, x);
    }
    cout << ans << "\n";
}

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

int main() {
  int a, b ,c ,d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d){
    cout << "Left" << endl;
  }
  if (a + b < c + d){
    cout << "Right" << endl;
  }
  if (a + b == c + d){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    d = defaultdict(int)
    sum = 0
    for i in a:
        sum += i
        d[i] += 1
    q = int(ipt())
    for _ in range(q):
        b,c = map(int,ipt().split())
        sum += d[b]*(c-b)
        print(sum)
        d[c] += d[b]
        d[b] = 0
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 91296
def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    i = 1
    j = N - 1
    x = sum(A)
    while j > 0:
        if (x - A[j]) * 2 >= A[j]:
            i += 1
        else:
            break
        x -= A[j]
        j -= 1
    print(str(i))

main()

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

#define int long long

int32_t main(){
	int n , m ;
	cin >> n >> m; 
	pair<int,int> ans[n+1] = {} ;
	for(int i = 0 ; i < m ; i++){
		int x ;
		string y ;
		cin >> x >> y ;
		if(ans[x].first == 1) continue ;
		if(y == "AC") ans[x].first = 1 ;
		else ans[x].second++ ;
	}
	pair<int,int> v = {};
	for(int i = 1 ; i < n+1 ; i++){
		if(ans[i].first){
			v.first++ ;
			v.second += ans[i].second ;
		}
	}
	cout << v.first << " " << v.second ;
	return 0 ;
}



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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll K; cin >> K;
  ll a[50];
  for(int i=0;i<50;i++) a[i] = 49;
  for(int i=0;i<50;i++){
    a[i] += K / 50;
  }
  for(int i=0;i<(K %50);i++){
    for(int j=0;j<50;j++){
      if(j == i) a[j] += 50;
      else a[j]--;
    }
  }
  cout << 50 << endl;
  for(int i=0;i<50;i++){
    cout << a[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pa;
const int maxn=1e5+10;

inline ll rd(){
    ll x=0;char c=getchar();int neg=1;
    while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*neg;
}

int a[maxn],b[maxn],c[maxn],N;
int rnk[maxn];

inline bool cmp(int x,int y){return c[x]-a[x]<c[y]-a[y];}

struct Splay{
	int fa[maxn],ch[maxn][2],rt,pct,siz[maxn];
	int val[maxn];
	ll sum[maxn];
	
	inline void update(int p){
		siz[p]=siz[ch[p][0]]+siz[ch[p][1]]+1;
		sum[p]=val[p]+sum[ch[p][0]]+sum[ch[p][1]];
	}
	
	inline bool isrc(int p){return p==ch[fa[p]][1];}
	
	inline void rotate(int p){
		int f=fa[p],ff=fa[f];bool b=isrc(p);
		fa[p]=ff;if(ff) ch[ff][isrc(f)]=p;
		ch[f][b]=ch[p][!b];if(ch[p][!b]) fa[ch[p][!b]]=f;
		fa[f]=p,ch[p][!b]=f;
		update(f),update(p);
	}
	
	inline void splay(int p,int tf){
		while(fa[p]!=tf&&fa[fa[p]]!=tf){
			if(isrc(p)==isrc(fa[p])) rotate(fa[p]);
			else rotate(p);rotate(p);
		}if(fa[p]!=tf) rotate(p);
		if(!tf) rt=p;
	}
	
	inline int findkth(int k){
		int x=rt;
		while(1){
			int w=siz[ch[x][0]];
			if(k<=w) x=ch[x][0];
			else if(k==w+1) return x;
			else x=ch[x][1],k-=w+1;
		}
	}
	
	inline void insert(int v){
		int x=rt;
		while(1){
			if(!ch[x][v>=val[x]]){
				ch[x][v>=val[x]]=++pct;
				fa[pct]=x,sum[pct]=val[pct]=v,siz[pct]=1;
				splay(pct,0);break;
			}else x=ch[x][v>=val[x]];
		}
	}
	
	inline int findv(int v){
		int x=rt;
		while(1){
			if(v<val[x]) x=ch[x][0];
			else if(v>val[x]) x=ch[x][1];
			else return x;
		}
	}
	
	inline void erase(int v){
		int p=findv(v);
		splay(p,0);
		int l=ch[p][0];
		while(ch[l][1]) l=ch[l][1];
		splay(l,0),splay(p,l);
		ch[l][1]=ch[p][1],fa[ch[p][1]]=l;
		update(l);
	}
	
	inline ll getsum(int k){
		int p=findkth(k+1);
		splay(p,0);
		return sum[p]-sum[ch[p][1]]+1e9;
	}
	
	Splay(){
		rt=pct=1;siz[1]=1;
		sum[1]=val[1]=-1e9;
	}
}ab,cb;

inline ll calc(int m){
	return -ab.getsum(m)-cb.getsum(m-1);
}

int main(){
    //freopen("","r",stdin);
    int x=rd(),y=rd(),z=rd();
	N=x+y+z;
	for(int i=1;i<=N;i++){
		a[i]=rd(),b[i]=rd(),c[i]=rd();
	}
	for(int i=1;i<=N;i++) rnk[i]=i;
	sort(rnk+1,rnk+N+1,cmp);
	ll sb=0,ans=-1e18;
	for(int i=1;i<=N;i++) cb.insert(-c[rnk[i]]+b[rnk[i]]),sb+=b[rnk[i]];
	
	for(int i=1;i<=N;i++){
		ab.insert(-a[rnk[i]]+b[rnk[i]]);
		cb.erase(-c[rnk[i]]+b[rnk[i]]);
		if(i>=x&&N-i>=z) ans=max(ans,-ab.getsum(x)-cb.getsum(z));
	}
	printf("%lld\n",ans+sb);
    return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    int m = INF;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x < m){
            ans++;
            m = x;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD   = 1000000007;
const int MAXN  = 200005;

int64 a[MAXN];

void run() {
    int64 n;
    cin >> n;
    int64 u, v;
    int64 ans = 0;
    for (int64 l = 1; l <= n; l++) {
        ans += (n - l + 1) * l;
    }
    for (int64 i = 1; i < n; i++) {
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        ans -= u * (n - v + 1);
    }
    cout << ans << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}


Measured memory_bytes: 3548
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  Scanner sc=new Scanner(System.in);
	 int a=sc.nextInt();
	 int b=sc.nextInt();
	 int c=sc.nextInt();
	 int s=0;
	 for (int i=a;i<=b;i++) {
		 if(c % i==0) {
			 s++;
		 }
		 else {
		 }
	 }
	 System.out.println(s);
	  sc.close();
  }
}


Measured memory_bytes: 26416
// finish date: 2019/1/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    int H, N;
    cin >> H >> N;
    vi A(N), B(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
    }
    vvl dp(N + 1, vl(H + 10000 + 1, INFll));
    rep(i, N + 1) dp[i][0] = 0;
    FOR(i, 1, N + 1) {
        rep(j, A[i - 1]) {
            dp[i][j] = dp[i - 1][j];
        }
        FOR(j, A[i - 1], dp[0].size()) {
            dp[i][j] = min(dp[i - 1][j], dp[i][j - A[i - 1]] + B[i - 1]);
        }
    }
    ll mi = INFll;
    FOR(i, H, dp[0].size()) {
        mi = min(mi, dp[N][i]);
    }
    cout << mi << endl;


    return 0;
}


Measured memory_bytes: 160640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin >> n >> m;
  vector<int> c(m),t(100005);
  map<int,int> mp;
  for(int i=0;i<n;i++){
    int x;cin >> x;
    c[x%m]++;
    mp[x]++;
  }
  for(int i=1;i<=100000;i++){
    t[i]=mp[i]/2;
  }
  int ans=0;
  for(int i=0;i<=m/2;i++){
    if(i==0){
      ans+=c[0]/2;
      c[0]=1;
    }
    else if(i==m/2&&m%2==0){
      ans+=c[m/2]/2;
      c[m/2]=1;
    }
    else{
      int k=min(c[i],c[m-i]);
      ans+=k;
      c[i]-=k;
      c[m-i]-=k;
    }
  }
  for(int i=1;i<=100000;i++){
    if(c[i%m]/2>=t[i]){
      ans+=t[i];
      c[i%m]-=t[i]*2;
    }
    else{
      ans+=c[i%m]/2;
      c[i%m]=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<pair<ll, ll>> c;
    rep(i, 0, n) {
        cin >> a[i] >> b[i];
        c.emplace_back(a[i], i);
        c.emplace_back(b[i], i + n);
    }
    ll ans = min(accumulate(a.begin(), a.end(), 0ll), accumulate(b.begin(), b.end(), 0ll));
    sort(c.begin(), c.end());
    vector<int> x(n);
    ll sum = 0;
    rep(i, 0, n) {
        sum += c[i].first;
        x[c[i].second % n]++;
    }
    rep(i, 0, n) {
        if (x[i] != 1) {
            cout << sum << endl;
            return 0;
        }
    }
    ll dif = 1e18;
    rep(i, 0, n) {
        ll tmp = -min(a[i], b[i]);
        if (i != c[n].second % n)
            tmp += c[n].first;
        else
            tmp += c[n + 1].first;
        dif = min(dif, tmp);
    }
    cout << min(sum + dif, ans) << endl;
    return 0;
}


Measured memory_bytes: 7920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int r = in.nextInt();
		if(r<1200) {
			System.out.println("ABC");
		}else if(r<2800) {
			System.out.println("ARC");
		}else {
			System.out.println("AGC");
		}
	}

}


Measured memory_bytes: 22608
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1167&lang=jp

#include<iostream>
#include<fstream>

#define Max_Len 1000000

using namespace std;

int triCalc(int num){
	static int count[Max_Len];
	static int triangle[Max_Len];
	static bool f = true;
	if (f){//初期化
		for (int i = 0; i < Max_Len; i++)
			count[i] = triangle[i] = Max_Len;
		f = false;
	}
	int triNum;

	int i = 1;
	while (i * (i + 1) * (i + 2) / 6 <= num)i++;
	i--;
	triNum = i * (i + 1) * (i + 2) / 6;

	if (triNum == num)return 1;
	while (num / 5 < triNum){
		if (triangle[num - triNum] == Max_Len){
			if (count[num] > triCalc(num - triNum) + 1)
				count[num] = triCalc(num - triNum) + 1;
		}
		else if (count[num] > triangle[num - triNum] + 1)
			count[num] = triangle[num - triNum] + 1;

		i--;
		triNum = i * (i + 1) * (i + 2) / 6;
	}
	return triangle[num] = count[num];
}

int oddCalc(int num){
	static int count[Max_Len];
	static int triangle[Max_Len];
	static bool f = true;
	if (f){//初期化
		for (int i = 0; i < Max_Len; i++)
			count[i] = triangle[i] = Max_Len;
		f = false;
	}
	int triNum;

	int i = 1;
	while (i * (i + 1) * (i + 2) / 6 <= num)i++;
	i--;
	while ((i * (i + 1) * (i + 2) / 6 )% 2 == 0)i--;
	triNum = i * (i + 1) * (i + 2) / 6;

	if (triNum == num)return 1;
	while (i > 0){
		if (triangle[num - triNum] == Max_Len){
			if (count[num] > oddCalc(num - triNum) + 1)
				count[num] = oddCalc(num - triNum) + 1;
		}
		else if (count[num] > triangle[num - triNum] + 1)
			count[num] = triangle[num - triNum] + 1;

		i--;
		while ((i * (i + 1) * (i + 2) / 6) % 2 == 0)i--;
		triNum = i * (i + 1) * (i + 2) / 6;
	}
	return triangle[num] = count[num];
}

int main(){

	int n;

	while (true){
		cin >> n;
		if (n == 0)break;

		cout << triCalc(n) << " " << oddCalc(n) << endl;
	}

	return 0;
}

Measured memory_bytes: 16788
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell{
	public static class Program{
		public static void Main(){
			string s = Console.ReadLine();
			int max = 0;
			int ct = 0;
			for (int i = 0; i < 3; i++){
				if (s.Substring(i,1).Equals("R")){
					ct++;
					if(max<ct)max = ct;
				}
				else{
					ct = 0;
				}
			}		
			Console.WriteLine(max);
		}
	}
}

Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;

void solve()
{
    int n; cin >> n;
    int digit = n % 10;

    if(digit == 2 || digit == 4 ||digit == 5 || digit == 7 || digit == 9)
        cout << "hon\n";
    else if(digit == 0 || digit == 1 || digit == 6 || digit == 8)
        cout << "pon\n";
    else
        cout << "bon\n";
}

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

    //freopen("input.txt", "r", stdin);
    // int t; cin >> t;
    // while(t--)
        solve();
}

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

int n, a, b;

int main() {
    ll res = 0;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        std::string s = std::to_string(i);
        ll sum = 0;
        for (int i = 0; i < s.size(); i++) {
            sum += (s[i] - '0');
        }
        if (sum >= a && sum <= b) {
            res += i;
        }
    }
    cout << res << std::endl;
}



Measured memory_bytes: 256
n=int(input())
x=0
i=0
building=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
while x<n:
    b,f,r,v = map(int, input().split())
    building[b-1][f-1][r-1]+=v
    x += 1
for build in building:
    for floor in build:
        print("",*floor)
    if i<3:
        print("#"*20)
        i+=1
    else:
        i+=1



Measured memory_bytes: 5624
#define MAX 101
#include <stdio.h>

typedef struct  {
  int num;
  int val;
  int tonum;
} graph;

int main(int argc, char const *argv[]) {

  int i,j,u;
  int res[MAX][MAX] = {0};
  graph adj[MAX];

  scanf("%d",&u);
  for (i = 0; i < u; i++) {
    scanf("%d%d",&adj[i].num,&adj[i].val);
    for (j = 0; j < adj[i].val; j++) {
      scanf("%d",&adj[i].tonum);
      res[adj[i].num][adj[i].tonum] = 1;
    }
  }
  for (i = 0; i < u; i++) {
    for (j = 0; j < u-1; j++) {
      printf("%d ",res[adj[i].num][adj[j].num]);
    }
    printf("%d",res[adj[i].num][adj[u-1].num]);  
    printf("\n");
  }


  return 0;
}

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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (!H && !W) break;
    bool sharp;
    for (int i{}; i < H; ++i) {
      sharp = i % 2 == 0;
      for (int j{}; j < W; ++j) {
        cout << (sharp ? '#' : '.');
        sharp = !sharp;
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3076
main = do
  s <- getLine
  k <- readLn
  putStrLn $ f s k
  
f [s] k = [s]
f (s1:s2:sx) k
  | k == 1 = [s1]
  | s1 == '1' = f (s2:sx) (k-1)
  | otherwise = [s1]

Measured memory_bytes: 508
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    n, m = map(int, read().split())
    cities = sorted([[int(j) for j in read().split()] + [i] for i in range(m)])
    p, x = 0, 1
    a = [(0, "") for _ in range(m)]
    for i, c in enumerate(cities):
        if c[0] == p:
            x += 1
        else:
            p = c[0]
            x = 1
        a[i] = (c[2], "{:0>6}{:0>6}".format(p, x))
    for _, ai in sorted(a):
        print(ai)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38736
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;


int main() {
	int d, g;
	int tab[10][2];
	cin >> d >> g;
	rep(i, 0, d) {
		int p, c;
		cin >> p >> c;
		tab[i][0] = p;
		tab[i][1] = c;
	}
	int m = 99999;
	rep(i, 0, 1 << d) {
		int gg = g;
		int s = 0;
		rep(j, 0, d) {
			if (i >> j & 1) {
				gg -= 100 * (j + 1) * tab[j][0] + tab[j][1];
				s += tab[j][0];
			}
		}
		if (gg > 0) {
			repr(j, d, 0) {
				if (!(i >> j & 1)) {
					if (gg < 100 * (j + 1) * tab[j][0]) {
						s += gg / (100 * (j + 1)) + (gg % (100 * (j + 1)) != 0);
					}
					else {
						s = 99999;
					}
					break;
				}
			}
		}
		m = min(m, s);
	}
	cout << m << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    cout << lcm(n,2) << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int a[N];
  for (int i=0;i<N;i++) cin>>a[i];
  sort(a,a+N);
  int temp=a[0];
  bool flag=1;
  while(flag==1){
    flag=0;
  for (int i=0;i<N;i++){
    if(a[i]==temp){
      continue;
    }
    a[i]=a[i]%temp;
    if((!(a[i]==0))&&(a[i]<temp)){
      flag=1;
      temp=a[i];
    }
  }
  }
  cout<<temp<<endl;
  return 0;
}
  
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint l(n);
    rep(i, n) cin >> l[i];
    sort(rall(l));

    int ans = 0;
    rep(i, k) ans += l[i];

    cout << ans << endl;
    return 0;
}

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

const int MAX_N = 2e5+10;
int N, D, A;
pair<ll,ll> v[MAX_N];
ll damage[MAX_N];

void solve()
{
	sort(v,v+N);
	ll ans = 0;
	for(int i=0;i<N;++i){
		if(i>0) damage[i]+=damage[i-1];
		if(damage[i]>=v[i].second) continue;
		const ll b = 1LL*(v[i].second-damage[i]+A-1)/A;
		ans += b;
		int j = upper_bound(v, v+N, make_pair(v[i].first+2LL*D,1LL<<60))-v;
		damage[i]+=b*A, damage[j]-=b*A;
	}
	cout<<ans;
}

int main()
{
	cin >> N >> D >> A;
	for(int i=0;i<N;++i) cin >> v[i].first >> v[i].second;
	solve();
	return 0;
}

Measured memory_bytes: 8324
#include<iostream>
#include<vector>
using namespace std;
int main(){
	string s;
	cin>>s;
	long long int k;
	cin>>k;
	int cnt=0,ans,flg=0;
	for(int i=0;i<s.size();i++){
		if(flg==0&&s[i]=='1'){
			cnt++;
		}else if(flg==0){
			ans=s[i]-'0';
			flg=1;
		}
	}
	if(k<=cnt){
		cout<<1<<endl;
	}else{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
int n;
struct Card {
	int value;
	char mark;
	bool operator!=(const Card& card) {
		return value != card.value || mark != card.mark;
	}
};
Card A[MAX_N], S[MAX_N];


int Partition(int p, int r) {
	int x = A[r].value, i = p - 1;
	for (int j = p; j < r; j++) {
		if (A[j].value <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

void QuickSort(int p, int r) {
	if (p < r) {
		int q = Partition(p, r);
		QuickSort(p, q - 1);
		QuickSort(q + 1, r);
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i].mark >> A[i].value;
		S[i] = A[i];
	}
	stable_sort(S, S + n, [](const Card& l, const Card& r) { return l.value < r.value; });
	QuickSort(0, n - 1);
	bool st = true;
	for (int i = 0; i < n; i++) {
		if (A[i] != S[i]) {
			st = false;
			break;
		}
	}
	cout << (st ? "Stable" : "Not stable") << endl;
	for_each(A, A + n, [](const Card& c) {
		cout << c.mark << ' ' << c.value << endl;
	});
	return 0;
}


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

using namespace std;
typedef complex<double> P;

P read()
{
    double x,y;
    cin>>x>>y;
    return P(x,y);
}

P cross(P a,P b,P c,P d)
{
    P ac=c-a,ab=b-a;
    P tmp=ac*conj(ab);
    double d1=tmp.real()/abs(ab);
    double d2=abs(tmp.imag()/abs(ab));
    P cd=d-c;
    tmp=cd*conj(ab);
    d2*=tmp.real()/abs(tmp.imag());
    return a+ab*(d1+d2)/abs(ab);
}

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

    while(q--)
    {
        P a=read(),b=read(),c=read(),d=read();
        P p=cross(a,b,c,d);
        cout<<fixed<<setprecision(10)<<p.real()<<" "<<p.imag()<<endl;
    }

    return 0;
}



Measured memory_bytes: 3344
str = gets.chomp.split("").map(&:to_s)



if str[0] == "A"
  str_len = str.length
  has_c = false
  c_index = 0
  for i in 2..(str_len-2)
    if str[i] == "C"
      if has_c == true
        has_c = false
        break
      else
        has_c = true
        c_index = i
      end
    end
  end
  if str[str_len-1] == "C"
    has_c = false
  end
  if has_c
    str2 = str
    has_ac = false
    if str2[0] == str[0].tr('a','A')
      if str2[c_index] == str[c_index].tr('c','C')
        has_ac = true
      end
    end
    if has_ac
      str2.delete("A")
      str2.delete("C")
      has_upother = false
      str2.each do |char|
        if char == char.upcase
          has_upother = true
        else
        end
      end
      unless has_upother
        puts("AC")
      else
        puts("WA")
      end
    else
      puts("WA")
    end
  else
    puts("WA")
  end
else
  puts("WA")
end


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;

const int maxn = 705;
bool bipartite = true, adj[maxn][maxn], dp[maxn][maxn];
//dp(i, j) = possible to obtain sum j using first i components
int n, m, x, y, r, b, len = 1, color[maxn];
vector<int> vs[maxn];
pair<ll, ll> balance[maxn];

void dfs(int v){
	r+= int(color[v] == 0), b+= int(color[v] == 1);
	for(int e: vs[v]){
		if (color[e] == -1) color[e] = (color[v]+1)%2, dfs(e);
		else if (color[e] == color[v]) bipartite = false;
	}
}

pair<ll, ll> bin(pair<ll, ll> a){
	return {(a.first*(a.first-1ll))/2ll, (a.second*(a.second-1ll))/2ll};
}


int main(){
	memset(color, -1, sizeof(color));
	scanf("%d %d", &n, &m);
	for(int i = 0; i<m; i++){
		scanf("%d %d", &x, &y);
		--x, --y;
		adj[x][y] = adj[y][x] = 1;
	}
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<n; j++)
			if (!adj[i][j]) vs[i].push_back(j), vs[j].push_back(i);
	}
	for(int i = 0; i<n; i++) if (color[i] == -1){
		color[i] = 0;
		dfs(i);
		balance[len++] = {r, b};
		r = b = 0;
	} len--;
	if (!bipartite) {puts("-1"); return 0;}
	int ans = 1e9;
	dp[0][0] = true;
	for(int i = 1; i<=len; i++) {
		int opt1 = balance[i].first, opt2 = balance[i].second;
		for(int sum = 0; sum<=n; sum++){
			if (sum-opt1>=0) dp[i][sum] |= dp[i-1][sum-opt1];
			if (sum-opt2>=0) dp[i][sum] |= dp[i-1][sum-opt2];
		}
	}
	for(int i = 1; i<=n; i++){
		if (dp[len][i]) {
			int t = n-i;
			ans = min((i*(i-1))/2 + (t*(t-1))/2, ans);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n,twoover=0,one=0;
	cin>>n;
	vector<ll> a(100001);
	rep(i,n){
		ll temp;
		cin>>temp;
		a[temp]++;
	}

	rep(i,100001){
		if(a[i]>=2){
			if(a[i]%2){
				one++;
			}else{
				twoover++;
			}
		}else if(a[i]==1){
			one++;
		}
	}

	cout<<one+twoover-(twoover%2)<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int N, A[3][3], b[10];
bool appear[3][3];
int main() {
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) cin >> A[i][j];
    }
    cin >> N;
    for(int i = 0; i < N; i++) cin >> b[i];
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                appear[i][j] = false;
                for(int k = 0; k < N; k++) {
                    if(A[i][j] == b[k]) appear[i][j] = true;
                }
            }
        }
    string ANS = "No";
    for(int i = 0; i < 3; i++) {
        if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
    }
    for(int i = 0; i < 3; i++) {
        if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
    cout << ANS << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    
    //変数：患者数「 n 」、患者番号「 patientsNo 」、歩いた合計距離「 sumWalk 」, 歩いた距離「walk 1 と 2」と置く
    int n, patientsNo, sumWalk, walk1, walk2;
    
    while(cin >> n, n){
        
        if( n == 0 ) break;
        
        //変数：優勝者（キング）「 king 」、最大走行距離「 maxWalk 」と置く
        int king = 0, maxWalk = 0;
        
        for(int i = 0; i < n; i++){
            
            //入力：患者番号「 patientsNo 」、歩いた合計距離「 sumWalk 」, 歩いた距離「walk 1 と 2」を入力する
            cin >> patientsNo >> walk1 >> walk2;
            
            //計算：ｎ人目の患者の合計距離を求める
            sumWalk = walk1 + walk2;
            
            //条件：キングを探す為に　➡　（　最大走行距離　が　 ｎ人目の患者の合計距離より大きいか小さいか比較している　）
            if(maxWalk < sumWalk) king = patientsNo, maxWalk = sumWalk;
        }
        
        //出力：優勝者（キング）「 king 」、最大走行距離「 maxWalk 」を出力
        cout << king << " " << maxWalk << endl;
        
    }
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int a = Integer.parseInt(br.readLine());
        int result = n % 500 - a;
        if(result <= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21076
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 2;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N + 1);
  for (int i = 1; i <= N; i++)
  {
    scanf("%lld", &a[i]);
  }
  ll arr[200010] = {};
  vector<int> v;
  for (int i = N; i > 0; --i)
  {
    if (arr[i] % 2 != a[i])
    {
      for (int j = 1; j * j <= i; ++j)
      {
        if (i % j == 0)
        {
          arr[j]++;
          if (j * j != i)
            arr[i / j]++;
        }
      }
      v.push_back(i);
    }
  }
  sort(v.begin(), v.end());
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); ++i)
  {
    cout << v[i] << " \n"[i == v.size() - 1];
  }

  return 0;
}


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

int main() {
    int N, p;
    int max = 0, sum = 0;
    cin >> N;
    for (int i = 0; i <= N-1; i++) {
        cin >> p;
        if (max < p) {
            max = p;
        }
        sum += p;
    }
    sum = sum - max / 2;
    cout << sum << '\n';
    return 0;
}

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

/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) (x.size())
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7


typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin);
    //freopen("test cases\\in.txt", "w", stdout);
    const int N = 1e6 + 1;
    int n; cin>>n;
    int f[N] = {}, a[n];
    for(int i = 0; i<n; i++) cin>>a[i], f[a[i]]++;
    ll cnt = 0;
    for(int i = 0; i<n; i++){
        ll num = n;
        f[a[i]]--;
        for(ll j = 1; j*j <= a[i]; j++){
            if(a[i]%j==0){
                num -= f[j];
                if(a[i]/j != j) num -= f[a[i]/j];
            }
        }
        f[a[i]]++;
        if(num == n) cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 8356
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) cout << 'x';
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
int pre[1000000];
int finds(int x)
{
    return x == pre[x] ? x : finds(pre[x]);//注意与 pre[x] = finds(pre[x]);的区别。
}
int main()
{
    int Q, N;
    while (~scanf("%d%d", &Q, &N) && Q && N) {
        pre[1] = 1;
        for (int i = 2; i <= Q; i++) {
            scanf("%d", &pre[i]);
        }
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            char c;
            int x;
            scanf(" %c%d", &c, &x);
            if (c == 'Q') ans += finds(x);
            else pre[x] = x;
        }
        printf("%lld\n", ans);
    }
    return 0;}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n;
signed main(){
    cin>>n;
    if(n%2)cout<<0<<endl;
    else{
        int now=10;
        int ans=0;
        while(now<=n){
            ans+=n/now;
            now*=5;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    for a in range(1,10):
        q,r=divmod(n,a)
        if(r==0 and 1<=q<=9):
            print("Yes")
            return
    print("No")
resolve()

Measured memory_bytes: 38384
#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() {
    int k;
    cin >> k;
    vector<ll> a;
    for (int i = 1; i <= 9; ++i) a.push_back(i);
    while(1){
        if(k <= a.size()){
            cout << a[k-1] << "\n";
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(old,a);
        for (ll x : old){
            for (int i = -1; i <= 1; ++i){
                int d = x % 10 + i;
                if(d < 0 || d > 9) continue;
                ll nx = x*10 + d;
                a.push_back(nx);
            }
        }
    }
    return 0;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define LL long long
#define ULL unsigned long long


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    int A, B;
    cin >> A >> B;

    int ans = A + B;
    if(ans >= 24)
        ans -= 24;
    
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  vector<int> H(n);
  rep(i, n) cin >> H[i];
  int cnt = 0;
  for(int h = 100; h > 0; h--) {
    bool eq = false;
    rep(i, n) {
      if(!eq && H[i] == h)
        eq = true, cnt++, H[i]--;
      else if(eq && H[i] == h)
        H[i]--;
      else if(!eq && H[i] < h)
        continue;
      else
        eq = false;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 310
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef pair<int,LL> pii;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int tot=1<<15;

int n,m,k;
int a[maxn][maxn],cnt;
int hav[maxn];
char c;

int main(){
	//freopen("test.txt","r",stdin);
	
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			scanf(" %c",&c);
			if(c=='.') a[i][j]=0;
			else a[i][j]=++cnt,hav[i]=i;
		}
	
	for(int i=1;i<=n;i++)if(hav[i]){
		for(int j=1;j<=m;j++){
			if(a[i][j]==0&&a[i][j-1]) a[i][j]=a[i][j-1];
		}
		for(int j=m;j>=1;j--){
			if(a[i][j]==0&&a[i][j+1]) a[i][j]=a[i][j+1];
		}
	}
	
	for(int i=1;i<=n;i++)
		if(hav[i]==0&&hav[i-1])
			hav[i]=hav[i-1];
			
	for(int i=n;i>=1;i--)
		if(hav[i]==0&&hav[i+1])
			hav[i]=hav[i+1];
	
	for(int p=1;p<=n;p++){
		int i=hav[p];
		for(int j=1;j<m;j++) printf("%d ",a[i][j]);
		printf("%d\n",a[i][m]);
	}	
	
	return 0;
} 

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x[100010],xx[100010],w[100010],l,r,t,n,m,c;
int main(){
    scanf("%lld%lld%lld",&n,&l,&t);
    for(int i=1;i<=n;i++)
    	scanf("%lld%lld",&x[i],&w[i]);
    for(int i=1;i<=n;i++){
        if(w[i]==2)
			w[i]=-1;
        r=x[i]+w[i]*t;
        if(r>0)
			(c+=r/l)%=n;
        else if(r<0)
			(c+=(r+1)/l-1)%=n;
        xx[i]=(r%l+l)%l;
    }
    sort(xx+1,xx+n+1);
    c=(c+n)%n;
    for(int i=c+1;i<=n;i++)
    	printf("%lld\n",xx[i]);
    for(int i=1;i<=c;i++)
    	printf("%lld\n",xx[i]);
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
using namespace std;
string s;
int a;
int main()
{
    cin>>s;
    a=s.length();
    if(s[0]==s[a-1])
	{
        if(a%2==0)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
            return 0;
    }
    else
	{
        if(a%2==0)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
            return 0;
    }
}

Measured memory_bytes: 512
#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>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    int cnt=0;
    rep(i,3){
        if(s[i]=='o')cnt++;
    }
    cout<<700+cnt*100<<endl;

    return 0;
}

Measured memory_bytes: 3612
import sys;input=sys.stdin.readline
N, = map(int, input().split())
MOD=67280421310721
S = []
for _ in range(N):
    s = input().strip()
    S.append(s)
S.sort(key=lambda x:len(x))
D = dict()
dd = set()
R = 0
for s in S:
    l = len(s)
    d = [0]*26
    for c in dd:
        d[c] += 1
    tmp=0
    for i in range(l-1, -1, -1):
        ee = ord(s[i]) - 97
        tmp = 100*tmp+(ee+1)
        tmp %= MOD
        R += d[ee]
        d[ee] = 0
        if tmp in D:
            for c in D[tmp]:
                d[c] += 1
        if i == 1:
            nn = tmp
    if l != 1:
        if nn not in D:
            D[nn] = set()
        D[nn].add(ee)
    else:
        dd.add(ee)
print(R)


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

int gcd(int x, int y){
    if(x*y==0) return x+y;
    while(x^=y^=x^=y%=x);
    return y;
}

int main(){
    int N, A[100001], L[100002], R[100002];
    cin>>N;
    for(int i=1; i<=N; i++)cin>>A[i];
    L[0]=0;
    for(int i=0; i<=N; i++)L[i+1]=gcd(L[i],A[i]);
    R[N+1]=0;
    for(int i=N; i>=0; i--)R[i]=gcd(R[i+1],A[i]);
    int max=0;
    for(int i=1; i<=N; i++){
        int c = gcd(L[i], R[i+1]);
        if(c>max) max=c;
    }
    cout<<max;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9+7;

long long int dfs(int K, vector<vector<int> >&graph, int now, int from) {
  int num_color;
  if (from == -1) num_color = K-1;
  else num_color = K-2;
  if (K<graph[now].size()) return 0;
  else {
    long long int case_num=1;
    for (auto x : graph[now]) {
      if (x == from) continue;
      case_num *= num_color;
      num_color--;
      case_num %= MOD;
    }
    for (auto x : graph[now]) {
      if (x == from) continue;
      case_num *= dfs(K, graph, x, now);
      case_num %= MOD;
    }
    return case_num % MOD;
  }
}

int main() {
  int N, K, a, b;
  cin >> N >> K;
  vector< vector<int> > adjlist(N);
  for (int i=0; i<N-1; i++) {
    cin >> a >> b;
    a--; b--;
    adjlist[a].push_back(b);
    adjlist[b].push_back(a);
  }
  long long int ans = K*dfs(K, adjlist, 0, -1);
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int n,a[22],b[22];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	vector<int>get;
	for(int i=0;i<n;i++)
	{
		get.push_back(a[i]-b[i]);
	}
	sort(get.begin(),get.end());
	reverse(get.begin(),get.end());
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(get[i]<0)
		{
			break;
		}
		ans+=get[i];
	}
	cout<<ans<<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;

int main(){

    double L,M;
    cin >> L;
    
    M = (L/3)*(L/3)*(L/3);
    cout << std::fixed << std::setprecision(8) << M << endl;
	return 0;
}



Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
 */
//「全問解く」:1一問も解かない」:0 としてBIT全探索→scoreに値を代入
//例.d=4,i=1011なら「100点、200点、400点の問題を全部解く」
//もしscoreがgに満たなかったら、iのビットを桁が大きいほうからしらべて0ならばその得点の問題を1問ずつ解く
//一問解くたびにscore>=gを確認し、真なら最小値と比較、最小値を下回れば更新しループを抜ける
//もし各回においてscore<gなら、p-1回まで行う
//このようなビットは高々1つでよい（p問解くならそのビットが1になっているのと同じである）
import java.util.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        out.print(a[n-1]+" ");
        int index=0;
        if(a[n-1]%2==0){
            index=Arrays.binarySearch(a,a[n-1]/2);
            if(index>=0){
                out.println(a[n-1]/2);
            }else {
                index=~index;
                if(index==0)out.println(a[0]);
                else if(index==n)out.println(a[n-1]);
                else {
                    if(a[n-1]/2-a[index-1]>a[index]-a[n-1]/2){
                        out.println(a[index]);
                    }else {
                        out.println(a[index-1]);
                    }
                }
            }
        }else {
            index=Arrays.binarySearch(a,a[n-1]/2);
            int index0=Arrays.binarySearch(a,a[n-1]/2+1);
            if(index>=0){
                out.println(a[n-1]/2);
            }else if(index0>=0){
                out.println(a[n-1]/2+1);
            }else {
                index=~index;
                if(a[n-1]/2-a[index-1]>a[index]-a[n-1]/2){
                    out.println(a[index]);
                }else {
                    out.println(a[index-1]);
                }
            }
        }
    }
}

Measured memory_bytes: 52408