akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define ll long long int
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
using namespace std;

int main() {
    int a,b;

    cin >> a >> b;
    string a1 = to_string(a);
    string b1 = to_string(b);

    if(a1 > b1) {
        REP(i,a) cout << b;
    }else{
        REP(i,b) cout << a;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    long A; cin >> A;
    long B; cin >> B;
    long C; cin >> C;
    long K; cin >> K;
    if(A >= K)
        cout << K;
    else if(A+B >= K)
        cout << A;
    else
        cout << A-(K-A-B);
}

Measured memory_bytes: 3636
#include <stdio.h>

#define MaxNumbersequencelength 2000 //マクロの時は；要らない
#define Yes 1
#define No 0

unsigned int dwNumbersequencelength, dwNumberofelemnt; //DWORD型と分かるようにハンガリアン表記
unsigned int dwNumbersequence[MaxNumbersequencelength], dwSumnumber[MaxNumbersequencelength];

unsigned int exhausivesearch(unsigned int dwstart, unsigned int dwsumnumber);

unsigned int exhausivesearch(unsigned int dwstart, unsigned int dwsumnumber) {

	unsigned int dwresultofexhaustivesearch;

	if (dwsumnumber == 0) return Yes;
	if (dwstart >= dwNumbersequencelength) return No;

	dwresultofexhaustivesearch = exhausivesearch(dwstart + 1, dwsumnumber) || exhausivesearch(dwstart + 1, dwsumnumber - dwNumbersequence[dwstart]);

	return dwresultofexhaustivesearch;
}



int main(void) {





	//数列情報取得
	scanf("%d", &dwNumbersequencelength);
	for (int i = 0; i<dwNumbersequencelength; i++) {
		scanf("%d", &dwNumbersequence[i]);
	}

	//合成で作りたい数字取得
	scanf("%d", &dwNumberofelemnt);
	for ( int i = 0; i<dwNumberofelemnt; i++) {
		scanf("%d", &dwSumnumber[i]);
		if (exhausivesearch(0, dwSumnumber[i])) {
			printf("yes\n");
		}
		else printf("no\n");
	}





	return 0;
}




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


template<typename T>
auto gcd(T a, T b) -> T {
    T minv = min(a, b);
    T maxv = max(a, b);
    return (minv == 0) ? maxv : gcd(minv, (maxv % minv));
}

template<typename T>
auto lcm(T a, T b) -> T {
    return a * (b / gcd(a, b));
}


auto solve(long long N, std::vector<long long> T){
    return accumulate(T.begin(), T.end(), 1LL, [](long long a, long long b){return lcm(a, b);});
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> T(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&T[i]);
    }
    auto result = solve(N, std::move(T));
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,e=0;
  cin>>a;
  int f=INT_MAX;
  int b[a];
  int c[a];
  int d[a];
  lp(i,a){
    cin>>b[i];
  }
  lp(i,a){
    cin>>c[i];
  }
  lp(i,a-1){
    cin>>d[i];
  }
  lp(i,a){
    e+=c[b[i]-1];
    if(f==b[i]-1){
      e+=d[f-1];
    }
    f=b[i];
  }
  cout<<e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  llong N;
  cin >> N;
  llong sum = 0;
  llong M = N;
  for(int i=0; i<9; ++i){
    sum += M % 10;
    M /= 10;
  }
  if(N%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int NX = 1e5 + 5;
int N, a[NX];
ll M;

ll gcd(ll aa, ll b) {
    if(aa == 0 || b == 0)
        return max(aa, b);
    return gcd(b%aa, aa);
}

ll lcm(ll aa, ll b) {
    return 1ll * aa * b / gcd(aa, b);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    ll l = 1;
    REP(i, 0, N) {
        cin >> a[i];
        l = lcm(l, a[i]);
    }
    REP(i, 0, N) {
        if(l/a[i] % 2 == 0) {
            cout << 0 << "\n";
            return 0;
        }
    }
    l /= 2;
    cout << M/l/2 + M/l % 2 << "\n";
    return 0;
}


Measured memory_bytes: 4036
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    n -= 1
    print(n*(n+1)//2)

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

int main(){
 
  int K;
  string S;
  cin >> K;
  cin >> S;
  
  if(S.size() <= K){
    cout << S << endl;
    return 0;
  }else{
    
    for (int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
    return 0;
  }
  
  return 0;
}

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



int search(int a,int b,int c,string S,int N){
  int count=0;

  for(int i=0;i<N && S.at(i)!='0'+a;++i){
    ++count;
  }
  if(count==N){return 0;}

  ++count;
  for(int j=count;j<N && S.at(j)!='0'+b;++j){
    ++count;
  }
  if(count==N){return 0;}

  ++count;
  for(int k=count;k<N && S.at(k)!='0'+c;++k){
    ++count;
  }

  if(count==N){return 0;}
  else{return 1;}
}




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

  string S;
  cin>>S;
  
  int ans=0;
  for(int i=0;i<10;++i){
    for(int j=0;j<10;++j){
      for(int k=0;k<10;++k){
        ans=ans+search(i,j,k,S,N);
      }
    }
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 384
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define debug cout << "here!"
#define pii pair<int , int>
#define pdd pair<double , double>
#define F first
#define S second
const int maxn = 1e5 * 5 + 10 , inf = 1e9 , pi = 3.14159265;
int n , x, p[101];
void solve(){
    
}
void in(){
    cin >> x >> n;
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }
    for (int i = 0; i < 101; i ++){
        int a1 = x - i , a2 = x + i;
        bool check1 = 1 ,check2 = 1;
        for (int j = 0; j < n; j ++){
            if (p[j] == a1){
                check1 = 0;
            }
            if (p[j] == a2){
                check2 = 0;
            }
        }
        if (check1 == 1){
            cout << x - i;return ;
        }
        if (check2 == 1){
            cout << x + i; return ;
        }
    }
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    in();
    return 0;
}


Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

public class Main {

  public static class City {
    int P;
    int Y;
    int index;

    public City(int P, int Y, int index) {
      this.P = P;
      this.Y = Y;
      this.index = index;
    }
  }

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] input = br.readLine().split(" ");
    int N = Integer.parseInt(input[0]);
    int M = Integer.parseInt(input[1]);
    int[] P = new int[M];
    int[] Y = new int[M];
    long[] ID = new long[M];
    City[] city = new City[M];
    for (int i = 0; i < M; i++) {
      input = br.readLine().split(" ");
      P[i] = Integer.parseInt(input[0]);
      Y[i] = Integer.parseInt(input[1]);
      city[i] = new City(P[i], Y[i], i);
    }
    Arrays.sort(city, (a, b) -> a.P == b.P ? a.Y - b.Y : a.P - b.P);
    int before = city[0].P;
    int order = 1;
    for (int i = 0; i < M; i++) {
      int now = city[i].P;
      if (before != now) {
        before = now;
        order = 1;
      }
      ID[city[i].index] = order;
      order++;
    }
    for (int i = 0; i < M; i++) {
      System.out.println(String.format("%06d", P[i]) + String.format("%06d", ID[i]));
    }
  }
}


Measured memory_bytes: 112828
#include<iostream>

using namespace std;

int main()
{
  int h, w;

  cin >> h >> w;

  while(true)
    {
      if (h == 0 && w == 0) break;

      for (int i = 0; i < h; i++)
        {
          if (i == 0 || i == h-1)
            {
              for (int j = 0; j < w; j++)
                {
                  cout << "#";
                }
              cout << endl;
            }
          else
            {
              for (int j = 0; j < w; j++)
                {
                  if (j == 0 || j == w-1)
                    {
                      cout << "#";
                    }
                  else
                    {
                      cout << ".";
                    }
                }
              cout << endl;
            }
        }
      cout << endl;
      cin >> h >> w;
    }
  
  return 0;
}

Measured memory_bytes: 1152
n=int(input())
s=list(str(input()))
w=0
b=0
wl=[]
bl=[]
for i in range(n):
    if s[i]==".":
        w+=1
    else:
        b+=1
    wl.append(w)
    bl.append(b)
if "#" not in s or "." not in s:
    print(0)
elif s.count(".")==1 and s[0]=="#":
    print(1)
else:
    ans=[]
    for i in range(n):
        ans.append(bl[i]+wl[-1]-wl[i])
    print(min(min(ans),wl[-1],bl[-1]))


Measured memory_bytes: 22296
n = input()
nl = [0]
for i in range(len(n)):
    nl.append(int(n[i]))
y = 0
for i in range(1, len(nl)+1):
    if nl[-i] <= 4 or (nl[-i] == 5 and nl[-(i+1)] <= 4):
        y += nl[-i]
    else:
        y += (10-nl[-i])
        nl[-(i+1)] += 1
print(y)

Measured memory_bytes: 13632
N=int(input())
list1=[]
for i in range(N):
  list1.append(input())
a=list1.count("AC")
w=list1.count("WA")
t=list1.count("TLE")
r=list1.count("RE")
print(f'AC x {a}')
print(f'WA x {w}')
print(f'TLE x {t}')
print(f'RE x {r}')

Measured memory_bytes: 16040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int dp[21][21][1024];
bool used[21][21][1024];
int rev[21][21];
char ch[21][21];
int n,m;
int main(){
	while(1){
		cin>>m>>n;
		if(n==0 && m==0) return 0;
		for(int i=0;i<n;i++) scanf("%s",&ch[i]);
		rep(i,21)rep(j,21)rep(k,1024){
			used[i][j][k] = 0;
			dp[i][j][k] = INF;
			rev[i][j] = -1;
		}
		int cx,cy,nxt=0;
		rep(i,n) rep(j,m){
			if(ch[i][j] == 'o') cx=i,cy=j;
			else if(ch[i][j] == '*'){
				rev[i][j] = nxt++;
			}
		}
		dp[cx][cy][0] = 0;
		queue<P1>que; que.push(mp(cx,mp(cy,0)));
		while(!que.empty()){
			P1 p = que.front(); que.pop();
			int x = p.fi, y = p.sc.fi, mask = p.sc.sc;
			if(used[x][y][mask]) continue;
			used[x][y][mask] = 1;
			int dx[4]={0,1,0,-1};
			int dy[4]={1,0,-1,0};
			rep(k,4){
				int nx = x+dx[k];
				int ny = y+dy[k];
				if(0<=nx&&nx<n&&0<=ny&&ny<m&&ch[nx][ny]!='x'){
					int M = mask;
					if(rev[nx][ny] >= 0) M |= 1<<rev[nx][ny];
					dp[nx][ny][M] = min(dp[nx][ny][M],dp[x][y][mask]+1);
					if(!used[nx][ny][M]){
						que.push(mp(nx,mp(ny,M)));
					}
				}
			}
		}
		int ans = INF;
		rep(x,n)rep(y,m) ans = min(ans,dp[x][y][(1<<nxt)-1]);
		if(ans == INF) ans=-1;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 5520
#include <stdio.h>

int H, N;
int A[1024];
int B[1024];

int memo[12345];

int search(int left) {
	int answer = 999999999;
	int i;
	if (left <= 0) return 0;
	if (memo[left]) return ~memo[left];
	for (i = 0; i < N; i++) {
		int candidate = search(left - A[i]) + B[i];
		if (candidate < answer) answer = candidate;
	}
	return ~(memo[left] = ~answer);
}

int main(void) {
	int i;
	if (scanf("%d%d", &H, &N) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &A[i], &B[i]) != 2) return 1;
	}
	printf("%d\n", search(H));
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    int n;
    vector<int> a;
    Solver(LL n):n(n),a(n){};

    void solve(){
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        vector<int> b(a);
        sort(a.begin(),a.end());
        for(int i=0; i<n; ++i){
            if(b[i]<a[n/2]){
                cout << a[n/2] <<"\n";
            }else{
                cout << a[n/2-1] <<"\n";
            }
        }

    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Problem::Solver sol(n);
    sol.solve();
    Problem::Writer::write();
    return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define S second
#define F first
const int  MOD = 1e9 + 7;
const int  N = 3005;
ll a[N];
ll dp[N][N];

//  a d f j k  l  ;
int main(){
    ios::sync_with_stdio(0);  cin.tie(0);
    int n;
    cin>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a[i];
    }

    for(int j = 0 ; j < n ; j++){
        for(int i = j ; i >= 0 ; i--){
            if(i == j){
                dp[i][j] = a[i];
            }else{

                dp[i][j] = max(a[j] - dp[i][j-1] , a[i] - dp[i+1][j]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 70016
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

#define ll long long
#define p pair<ll,ll>
#define mp(a,b) make_pair(a,b)
using namespace std;

struct edge { int to, cost; };

vector<vector<edge>>graph;
vector<ll>dis;

void dijkstra(){
	priority_queue<p,vector<p>,greater<p>> que; que.push(mp(0,0)); //v dis
	while(!que.empty()){
		p now=que.top(); que.pop();
		int x=now.first;
		if(dis[x]<now.second) continue;
		
		for(auto e:graph[x]){
			if(dis[e.to]>dis[x]+e.cost){
				dis[e.to]=dis[x]+e.cost;
				que.push(mp(e.to,dis[e.to]));
			}
		}
	}
}

int main(){
	ll n,m,c; cin>>n>>m>>c;
	graph=vector<vector<edge>>(n); 
	vector<vector<ll>>edges(m,vector<ll>(3));
	ll sum=0;
	for(int i=0;i<m;i++) {
		ll a,b,d; cin>>a>>b>>d; a--;b--; edges[i]=vector<ll>{a,b,d};
		
		edge now; 
		now.to=b; now.cost=d; graph[a].push_back(now);
		now.to=a; now.cost=d; graph[b].push_back(now);
		sum+=d;
	}
	
	dis=vector<ll>(n); for(int i=1;i<n;i++) dis[i]=1145141919810364364;	
	dijkstra();
	
	for(int i=0;i<m;i++){
		edges[i][0]=max(dis[edges[i][0]],dis[edges[i][1]]);
		edges[i][1]=edges[i][2];
		edges[i][2]=0;
	}
	sort(edges.begin(),edges.end());
	vector<ll>e(m); vector<ll>f(m+1);
	for(int i=0;i<m;i++) {e[i]=edges[i][0]; f[i+1]=f[i]+edges[i][1];}
	
	ll ret=1145141919810364364;
	for(int i=0;i<n;i++){
		ret=min(ret,c*dis[i]+sum-f[upper_bound(e.begin(),e.end(),dis[i])-e.begin()]);
	}
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 31648
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
signed main()
{
    fast;
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n&1)
        cout<<"No";
    else
    {
        string sub1 = s.substr(0,n/2);
        string sub2 = s.substr(n/2);
        if(sub1 == sub2)
            cout<<"Yes";
        else cout<<"No";
    } 
}

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

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
int stoi(char c){
  if('0' <= c && c <= '9')
    return c - '0';
  return c - 'a' + 10;
}

int pow(int n){
  return n * n;
}

int main(void){
  string s;
  string ans[8] = {
    "black",//	00	00	00
    "blue",//	00	00	ff
    "lime",//	00	ff	00
    "aqua",//	00	ff	ff
    "red",//	ff	00	00
    "fuchsia",//	ff	00	ff
    "yellow",//	ff	ff	00
    "white"//	ff	ff	ff
  };
  int num[8];
  int cnt = 0;
  rep(i,8)num[i] = i * 255;     
  while(cin>>s){
    if(s == "0")break;
    int in[3];
    in[0] = stoi(s[1]) * 16 + stoi(s[2]);
    in[1] = stoi(s[3]) * 16 + stoi(s[4]);
    in[2] = stoi(s[5]) * 16 + stoi(s[6]);
    //rep(i,3)cout<<in[i]<<endl;
    int index = 0;
    unsigned long long diff = 100000000;
    rep(i,8){

      int box[3];
      rep(j,3){
	box[j] = (i>>(2-j))%2*255;
      }
      
     
      unsigned long long int calc = 0;
      rep(j,3)calc += pow(in[j] - box[j]);
     	
      if(calc < diff){
	diff = calc;
	index = i;
      }
    }
    cout<<ans[index]<<endl;
  }
}

Measured memory_bytes: 1188
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  ll x;
  scan(x);
  ll balance = 100;
  rep (i, 10000) {
    if (balance >= x) {
      print(i);
      return;
    }
    balance = balance * 1.01;
  }
  assert(false);
}

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


Measured memory_bytes: 3232
#include<stdio.h>
int main(void){
  int n,d,x,a[100],i,j;
  scanf("%d",&n);
  scanf("%d %d",&d,&x);
  int sum=x;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    for(j=0;j<d;j++){
      if(j*a[i]+1<=d)
    	sum++;
      else
        break;
    }
  }
  printf("%d\n",sum);
  return 0;
}

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

using namespace std;

int main(){
    int N,s=6,n=9,ans=0,cho,sum=100000;
    cin >> N;
    vector<int> bank(1),dp(N+1,1000000);
    bank[0] =  1;
    while(s<=N){
        bank.push_back(s);
        s*=6; 
    }

    while(n<=N){
        bank.push_back(n);
        n*=9; 
    }

    sort(bank.begin(),bank.end());
    dp[0] = 0;

    for(int i=0;i<=N;i++){
        for(int j=0;j<bank.size();j++){
            if(i+bank[j]<=N){
                dp[i+bank[j]] = min(dp[i+bank[j]],dp[i]+1);
            }
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    ll tmpmin=1e10, res=-1*1e11;
    rep(i,n){
        ll r; cin>>r;
        chmax(res,r-tmpmin);
        chmin(tmpmin,r);
        
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3112
import java.util.*;

public class Main {

  public static class Pair {
    int y;
    int x;
    int a;

    public Pair(int y, int x, int a) {
      this.y = y;
      this.x = x;
      this.a = a;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[][] a = new int[H][W];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        a[i][j] = sc.nextInt();
      }
    }
    Pair[] root = new Pair[H * W];
    int count = 0;
    int sy = 0;
    int sx = 0;
    boolean left = true;
    while (count < H * W) {
      if (W <= sx) {
        sx--;
        sy++;
        left = false;
      } else if (sx < 0) {
        sx++;
        sy++;
        left = true;
      }
      root[count] = new Pair(sy, sx, a[sy][sx]);
      if (left) {
        sx++;
      } else {
        sx--;
      }
      count++;
    }
    boolean[] ans = new boolean[H * W];
    int anscount = 0;
    Arrays.fill(ans, false);
    for (int i = 0; i < H * W - 1; i++) {
      if (root[i].a % 2 == 1) {
        root[i + 1].a++;
        ans[i] = true;
        anscount++;
      }
    }
    System.out.println(anscount);
    for (int i = 0; i < H * W - 1; i++) {
      if (ans[i]) {
        System.out
            .println((root[i].y + 1) + " " + (root[i].x + 1) + " " + (root[i + 1].y + 1) + " " + (root[i + 1].x + 1));
      }
    }
  }
}

Measured memory_bytes: 110696
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=1e5+10;
int n,m,q,L;
typedef pair<int,int> pii;
vector<pii>g[310];
int ans[310][310],f[310][310];
struct ppo{
    int u,v,cos;
};
void bfs(int st){
    queue<int>q;
    q.push(st);
    while(!q.empty()){
        int u=q.front();q.pop();
        for(pii x:g[u]){
            int v=f[st][u];
            int cost=ans[st][u];
            if(v<x.second) v=L-x.second,cost++;
            else v-=x.second;
            if(cost<ans[st][x.first]||(cost==ans[st][x.first]&&v>f[st][x.first])){
                ans[st][x.first]=cost;
                f[st][x.first]=v;
                q.push(x.first);
            }
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    //freopen("in","r",stdin);
    cin>>n>>m>>L;
    for(int i=1,a,b,c;i<=m;i++){
        cin>>a>>b>>c;
        if(c>L) continue;
        g[a].pb(pii(b,c));
        g[b].pb(pii(a,c));
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++) ans[i][j]=inf;
    }
    for(int i=1;i<=n;i++){
            if(i==7){
                ans[i][i]=0,f[i][i]=L,bfs(i);
            }else ans[i][i]=0,f[i][i]=L,bfs(i);
    }
    cin>>q;
    while(q--){
        int s,t;
        cin>>s>>t;
        if(ans[s][t]==inf) ans[s][t]=-1;
        cout<<ans[s][t]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;cin >> n >> k;
vector<int>a(n);
for(int i = 0;i<n;i++) cin >> a[i];
if(k>=n) {cout << a[n-1] - a[0];return 0;}
vector<int>dp(n,INT_MAX);
for(int i = 0;i<=k;i++){
    dp[i] = abs(a[i]-a[0]);
}
for(int i = k;i<n;i++){
    for(int j = i-k;j<i;j++){
        dp[i] = min(dp[j]+abs(a[i]-a[j]),dp[i]);
    }
}
cout << dp[n-1];
return 0;
}


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

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

  int H, W;
  cin >> H >> W;
  vector<string> C(H);
  for (int i = 0; i < H; ++i) {
    cin >> C.at(i);
  }

  for (int i = 1; i <= H * 2; ++i) {
    cout << C.at(((i + 1) / 2) - 1) << endl;
  }

  return 0;
}


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

int main(){

	int a[3];

	cin >> a[0];
	cin >> a[1];
	cin >> a[2];

	int five = 0;
	int seven = 0;

	for(int i = 0;i < 3;i++){
		if(a[i] == 5){
			five++;
		}else if(a[i] == 7){
			seven++;
		}
	}

	if(five == 2 && seven == 1){
		cout << "YES";
	}else{
		cout << "NO";
	}

}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	ll L=in<ll>(),R=in<ll>();
	ll dL = L/2019LL,dR = R/2019LL;
	if(dR-dL){
		cout << 0 << endl;
		return 0;
	}
	vector<ll> P(R-L+1);
	for(int i=0;i<P.size();i++){
		P[i] = i+L;
	}
	ll minv = 1LL<<50;
	for(int i=0;i<P.size();i++){
		for(int j=i+1;j<P.size();j++){
			minv = min(minv,(P[i]*P[j])%2019);
		}
	}

	cout << minv << endl;
	return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		BigInteger X = new BigInteger(scan.next());
		BigInteger Y = new BigInteger(scan.next());
		if(X.add(Y.negate()).abs().compareTo(new BigInteger("1")) <= 0) {
			System.out.println("Brown");
		} else {
			System.out.println("Alice");
		}
		scan.close();

	}

}


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

int n, A[22];

// 入力値の m から選んだ要素を引いていく再帰関数
// 計算量 O(2^n)
int solve(int i, int m) {
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i+1, m) || solve(i+1, m-A[i]);
  return res;
}

signed main() {
  

  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  int q; cin >> q;
  for(int i = 0; i < q; i++) {
    int m; cin >> m;
    cout << (solve(0, m) ? "yes" : "no") << endl;
  }
}



Measured memory_bytes: 3084
import qualified Data.Vector as V
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

moduloN :: Int
moduloN = 10 ^ 9 + 7

modN = flip mod moduloN

finv :: Int -> Int
finv i = finvs V.! i
    where
        finv' 0 = 1
        finv' n = modN $ finvs V.! (n - 1) * inv n
        finvs :: V.Vector Int
        finvs = V.generate (10 ^ 5 + 1) finv'

inv :: Int -> Int
inv i = invs V.! i
    where inv' 1 = 1
          inv' n = modN (-(invs V.! r) * q)
              where (q, r) = moduloN `divMod` n
          invs :: V.Vector Int
          invs = V.generate (10 ^ 5 + 1) inv'

fact :: Int -> Int
fact i = facts V.! i
    where fact' 0 = 1
          fact' n = modN $ n * (facts V.! (n - 1))
          facts :: V.Vector Int
          facts = V.generate (10 ^ 5 + 1) fact'

c :: Int -> Int -> Int
c n k | n < 0 || k < 0 || n < k = 0
      | otherwise = modN $ modN (fact n * finv k) * finv (n - k)


main = do
    [n, k] <- getIntList
    as' <- getIntList
    let as = sort as'
    let minX = modN . sum . zipWith (\x y -> modN (x * y)) as $ map (\i -> c (n - i) (k - 1)) [1..n]
    let maxX = modN . sum . zipWith (\x y -> modN (x * y)) as $ map (\i -> c (i - 1) (k - 1)) [1..n]
    print . modN $ maxX - minX

Measured memory_bytes: 42364
#include <iostream>
#include <queue>
#include <complex>
#include <map>

using namespace std;

typedef complex<int> P;

#define INF 1 << 16

int main() {
	int H, W;
	while (cin >> H >> W, H || W) {
		int m[20][20];
		int sx, sy, gx, gy;
		for (int y = 0; y < H; ++y) {
			string str; cin >> str;
			for (int x = 0; x < W; ++x)
				m[y][x] =
					  str[x] == '#' ? 1
					: str[x] == 'A' ? (sx = x, sy = y, 0)
					: str[x] == 'B' ? (gx = x, gy = y, 0)
					: 0
					;
		}
		string pattern; cin >> pattern;

		int step[20][20]; fill(&step[0][0], &step[0][0]+20*20, INF);
		queue<P> que; que.push( P(sx, sy) );
		queue<int> steps; steps.push( 0 );
		while ( !que.empty() ) {
			P p = que.front(); que.pop();
			int s = steps.front(); steps.pop();
			int x = p.real(), y = p.imag();

			if (x < 0 || x >= W || y < 0 || y >= H) continue;
			if (m[y][x]) continue;
			if (s >= step[y][x]) continue;

			step[y][x] = s;

			que.push( P(x+1, y) ); steps.push(s+1);
			que.push( P(x-1, y) ); steps.push(s+1);
			que.push( P(x, y+1) ); steps.push(s+1);
			que.push( P(x, y-1) ); steps.push(s+1);
		}

		map<char, P> dir;
		dir['8'] = P(0, -1);
		dir['4'] = P(-1, 0);
		dir['5'] = P(0, 0);
		dir['6'] = P(1, 0);
		dir['2'] = P(0, 1);

		int t = 0;
		P pos = P(gx, gy), ans;
		bool flag = false;
		while (++t < INF) {
			P next = dir[pattern[(t-1)%pattern.size()]];
			pos += next;

			if (pos.real() < 0 || pos.real() >= W || pos.imag() < 0 || pos.imag() >= H) pos -= next;

			if (step[pos.imag()][pos.real()] <= t) {
				ans = pos;
				flag = true;
				break;
			}
		}

		if (flag) cout << t << " " << ans.imag() << " " << ans.real() << endl;
		else cout << "impossible" << endl;
	}
}

Measured memory_bytes: 0
package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        out := 1000
        stock := 0
        for i := 0; i < n; i++ {
                // buy
                if i < n-1 && a[i] < a[i+1] {
                        stock += out / a[i]
                        out %= a[i]
                        continue
                }
                // sell
                if stock != 0 && a[i] > a[i-1] {
                        out += stock * a[i]
                        stock = 0
                        continue
                }
        }
        return out
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 1776
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int M=500010;
int f[M],a[M],n,lastzero;	//a[M]前一个0的位置 
char c[M];
int main()
{
	scanf("%d%s",&n,c+1);
//	scanf("%s",c+1);
	for(int i=1;i<=n;i++)
	{
		if(c[i]=='0')
			lastzero=i;
		a[i]=lastzero;
//		cout<<a[i]<<" ";
	}
	for(int i=1;i<=n;i++)
	{
		f[i]=f[i-1];
		if(c[i]=='1')
		{
/*			if(a[i]>1&&c[a[i]-1]=='1')
				f[i]=max(f[i],f[a[i]-2]+i-a[i]);	//以上一个101向后合并
			else if(c[i-1]=='0'&&c[i-2]=='1')
			{
				f[i]=max(f[i],f[a[i-2]]+i-2-a[i-2]);//这个1...101向左合并
				f[i]=max(f[i],f[a[i-2]+1]+i-3-a[i-2]);//与前面的1合并 
			}*/
			if (c[i-1] =='0'&&c[i-2] =='1')		//这个101就别向后了... 
			{
                f[i]=max(f[i],f[a[i-2]]+i-2-a[i-2]);
                f[i]=max(f[i],f[a[i-2]+1]+i-2-a[i-2]-1);
            }
            else if(a[i]>1&&c[a[i]-1]=='1')
				f[i]=max(f[i],f[a[i]-2]+i-a[i]);
		}
	}
	printf("%d\n",f[n]);
	return 0;
} 

Measured memory_bytes: 4608
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define SIZEOF(x) sizeof(x)/sizeof(x[0])
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


template <class T>
T max(T *a , LL n){
    T maxi = a[0];
    for(LL i = 0; i < n; ++i){
        if(a[i] > maxi)maxi = a[i];
    }
    return maxi;
}
template <class T>
T min(T *a , LL n){
    T mini = a[0];
    for(LL i = 0; i < n; ++i){
        if(a[i] < mini)mini = a[i];
    }
    return mini;
}
template <class T>
T sum(T *a , LL n){
    T s=0;
    for(LL i = 0; i < n; ++i){
       s+=a[i]; 
    }
    return s;
}

#define MAX(x) max(x,SIZEOF(x))
#define MIN(x) min(x,SIZEOF(x))
#define SUM(x) sum(x,SIZEOF(x))





int main(){
    LL a;
    cin >>a;
    cout<< 3*a*a;




    return 0;

}


Measured memory_bytes: 888
package main

import "fmt"

func main() {
	var a, b, k int64
	fmt.Scanf("%d %d %d", &a, &b, &k)

	if k > a {
		k, a = k-a, 0
	} else {
		k, a = 0, a-k
	}

	if k != 0 && k > b {
		k, b = k-b, 0
	} else {
		k, b = 0, b-k
	}

	fmt.Println(a, b)
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)
#define MAX_N (100000+19)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;

vector<int> adj[2*MAX_N];
bool visited[2*MAX_N];
vector<Int> cnt;

void dfs(int v) {
    if(visited[v])
        return;
    visited[v] = true;
    cnt[v/MAX_N]++;
    for(auto u:adj[v]) {
        dfs(u);
    }

    return;
}

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        int x,y;
        cin>>x>>y;
        y += MAX_N;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    Int ans = 0;
    for(int i = 0;i < 2*MAX_N;i++) {
        if(visited[i])
            continue;
        cnt = vector<Int>(2);
        dfs(i);
        ans += cnt[0]*cnt[1];
    }

    ans -= N;
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200;
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t) && t != '-') t = getchar();
	if (t == '-')
	{
		_read(x);
		x *= -1;
		return;
	}
	while (isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
int l, r;
int main()
{
	int now = 1000000;
	_read(l), _read(r);
	for (int i = l; i <= min(l + 2019, r); ++i)
		for (int j = i + 1; j <= min(l + 2019, r); ++j)
		{
			if (1ll * i * j % 2019 < now) now = 1ll * i * j % 2019;
		}
			
	cout << now << endl;
	return 0;
}

Measured memory_bytes: 256
/*     *******************Bismillahir Rahmanir Rahim************************
                          MD. ASFAKUL GHANI!
                          *ProMAGFAT*!
 SECRET_warning :)->FAT   CSE-25!
                          JAHANGIRNAGAR UNIVERSITY!
                          Dhaka,Bangladesh!
*/

#include <bits/stdc++.h>
#include <set>
using namespace std;

#define           fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define           Im int main()
#define           ll long long
#define           sc scanf
#define           pf printf
#define           rn0 return 0
#define           rn return
#define           f0(i,n) for(ll i=0;i<n;i++)
#define           f1(i,n) for(ll i=1;i<=n;i++)
#define           f2(i,n) for(ll i=n-1;i>=0;i--)
#define           pi 2*acos(0.0)
#define           modulo 1000003
#define           dd double
#define           PI 3.14159265358979
#define           pi 2*acos(0.0)
#define           p_b push_back
#define           ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/
/*
void debug1()
{
    cout << "***" << endl;
}

void debug11(ll n)
{
    cout << n << endl;
}
*/

Im
{
    /*#ifdef FAT
       freopen("input.txt","w",stdin);
    #endif // FAT*/

    fasterIO;
    ll n,m;
    cin>>n>>m;

    cout << __gcd(n,m) << endl;

   // main();

    rn0;
}

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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;

int main() {
  ll n, k;
  cin >>  n >> k;
  ll tmp = n % k;
  // check(tmp);
  cout << min(tmp, k-tmp) << endl;
  return 0;
}


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


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


int main(){
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    rep(i, N){
        cin >> x.at(i) >> y.at(i);
    }
    vector<int> order(N);
    rep(i, N) order[i] = i;
    double distSum = 0;
    int count = 0;
    do{
        double dist = 0;
        rep(i, N - 1){
            dist += sqrt((x.at(order[i]) - x.at(order[i + 1])) * (x.at(order[i]) - x.at(order[i + 1])) + (y.at(order[i]) - y.at(order[i + 1])) * (y.at(order[i]) - y.at(order[i + 1])));
        }
        distSum += dist;
        count ++;
    }while(next_permutation(all(order)));
    cout << fixed << setprecision(10) <<  distSum / count << endl;
}

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

class AIZU0026{
   public static int[,] Paper = new int[10,10];
   public static bool subsist(int x,int y) { return x>=0&&x<10&&y>=0&&y<10; }
   public static void Stain(int x,int y) { if (subsist(x,y)) Paper[x,y]++; }

   public static void Spot(int x,int y,int v) {
      Stain(x,y);
      int[,,] adja = {
       { { 1,0 },{ 0,1 },{ -1,0 },{ 0,-1 } },
       { { 1,1 },{ -1,1 },{ -1,-1 },{ 1,-1 } },
       { { 2,0 },{ 0,2 },{ -2,0 },{ 0,-2 } } };
      for (int j = 0; j<Math.Min(v,3); j++)
         for (int i = 0; i<4; i++)
            Stain(x+adja[j,i,0],y+adja[j,i,1]);
   }
   public static void Main(string[] args) {
      for (int i = 0; i<10; i++)
         for (int j = 0; j<10; j++)
            Paper[j,i]=0;

      string s;string[] ss;int x, y, v;
      while (true) {
         s=Console.ReadLine();
         if (string.IsNullOrEmpty(s)) break;
         ss=s.Split(',');
         x=int.Parse(ss[0]);y=int.Parse(ss[1]);v=int.Parse(ss[2]);
         Spot(x,y,v);
      }
      List<int> H = new List<int>();
      foreach (int p in Paper) H.Add(p);
      int virgin = H.Count(i=>i==0);
      int max = H.Max();
      Console.WriteLine(virgin);
      Console.WriteLine(max);
   }
}

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

struct Process{ string name; int time; };

int main(){
	int n, q, t = 0, head = 0, tail;
	Process p[100000];
	cin >> n >> q;
	tail = n;
	for(int i = 0; i < n; i++){
		cin >> p[i].name >> p[i].time;
	}
	while(head != tail){
		for(int i = q; i > 0; i--){
			t++;
			p[head].time--;
			if(p[head].time == 0){
				cout << p[head].name << ' ' << t << endl;
				break;
			}
		}
		if(p[head].time){
			p[tail] = p[head];
			tail = (tail+1)%100000;
		}
		head = (head+1)%100000;
	}
	return 0;
}


Measured memory_bytes: 7076
#include <stdio.h>
int main(void){
int a;
  scanf("%d",&a);
  if(a==25){printf("Christmas");}
  else if(a==24){printf("Christmas Eve");}
    else if(a==23){printf("Christmas Eve Eve");}
    else if(a==22){printf("Christmas Eve Eve Eve");}
  
return 0;
}

Measured memory_bytes: 128
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int m=1e9+7;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%m;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans)%m;
    return (x*(ans*ans)%m)%m;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
   // cin>>t;
    // int tmp=t;
    while(t--)
    {
      int n;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++) cin>>a[i];
      int ans=0;
      for(int i=0;i<n;i++)
      {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if((a[i]==a[j]) || (a[j]==a[k]) || (a[i]==a[k])) continue;
                int sum=a[i]+a[j]+a[k];
                int mx=max(a[i],a[j],a[k]);
                if(sum-mx>mx) ans++;
            }
        }
      }
      cout<<ans<<endl;
    }
}


Measured memory_bytes: 3656
console.log((args=>{
  const [[D],c,...s] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const his = [];
  const last = Array(26).fill(0);
  for ( let i = 0; i < D; i++ ) {
    let max = 0, task = 0;
    for ( let j = 0; j < 26; j++ ) {
      let score = s[i][j] + (i-last[j]) * c[j];
      if ( score > max ) {
        task = j;
        max = score;
      }
    }
    his.push(task+1);
    last[task] = i;
  }
  return his.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 30620
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int cnt = 0;  
      for(int i = 1; i <= n; i+=2) {
        int curCnt = 0;
        for(int j = 1; j * j <= i; j++) {
          if(i % j == 0) {
            if(i % j != j) curCnt += 2;
            else curCnt += 1;
          }
        }
        
        if(curCnt == 8) {
            cnt++;
        }
      }
      System.out.println(cnt);
  }
}

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

int main(void){
    string s; cin >> s;
    int n = s.size()-1; /* 1引いてること */

    ll ans = 0, tmp = 0;
    int l, r;
    for(int mask = 0; mask < (1 << n); mask++){
        /* 1をn左シフト -> 間の＋(2^n)全探索 */
        tmp = 0; l = 0;
        for(r = 0; r < n; r++){ /* n回 */
            if((mask >> r) & 1 == 1){
                string t = s.substr(l, r-l+1);
                ll add = stoll(t);
                tmp += add;
                l = r + 1;
            } 
        }
        string t = s.substr(l, r-l+1);
        ll add = stoll(t);
        tmp += add;
        ans += tmp;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256