akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	long long n=llin(),k=llin(),i;
	long long ans=0;
	if(k==0){
		llprint(n*n);
		return 0;
	}
	for(i=k+1;i<=n;i++){
		ans+=n/i*(i-k)+max(0,n%i-k+1);
	}
	llprint(ans);
	return 0;
}

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

int main(){
    long long int x;
    cin >> x;

    long long int deposit = 100;
    int ans = 0;
    while(deposit < x){
        deposit += deposit / 100;
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
	int A, B, C, X;
	cin >> A >> B >> C >> X;

	int ans = 0;
	int max_A = min(X / 500, A);
	for (int i = 0; i <= max_A; ++i) {
		int max_B = min(X / 100, B);
		for (int j = 0; j <= max_B; ++j) {
			int rem = X - 500 * i - 100 * j;
			if (rem >= 0 && rem / 50 <= C)
				++ans;
		}
	}

	cout << ans << '\n';
	return 0;
}


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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const int MOD = 1e9+7;

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

  vector<string> board(H);
  REP(i, H) {
    cin >> board[i];
  }
  vvi dp(H+1, vi(W+1, 0));
  dp[0][0] = 1;
  REP(i, H) REP(j, W) {
    if (board[i][j] == '.') {
      dp[i+1][j] += dp[i][j];
      dp[i+1][j] %= MOD;
      dp[i][j+1] += dp[i][j];
      dp[i][j+1] %= MOD;
    }
  }
  OUT(dp[H-1][W-1]);

  return 0;
}


Measured memory_bytes: 5248
#include<iostream>

using namespace std;

int main()
{

        int x,y;

        cin >> x >> y;

        while ( x!=0 || y!=0 )
        {
                if ( x < y )
                        cout << x << " " << y << endl;
                else
                        cout << y << " " << x << endl;
        
                cin >> x >> y;
        }

return 0;
}



Measured memory_bytes: 3096
#include<iostream>
using namespace std;
#define mod 1000000007

int main() {
	int n;
	cin >> n;
	long long ans = 1;
	for (long long i = 1; i <= n; i++) {
		ans = (ans*i)%mod;
	}
	cout << ans%mod << endl;
	return 0;
}

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

int main()
{
	string S;
	int N, A, B;
	cin >> N >> A >> B;
	cin >> S;
	int a = 0, b = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'a') {
			a++;
			if (a <= A + B) cout << "Yes\n";
			else cout << "No\n";
		}
		else if (S[i] == 'b') {
			a++; b++;
			if (a <= A + B && b <= B) cout << "Yes\n";
			else {
				cout << "No\n";
				a--;
			}
		}
		else if (S[i] == 'c') {
			cout << "No\n";
		}
	}
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Integer[] input = readInput();
        int a = input[0];
        int b = input[1];
        System.out.printf("%d %d\n", area(a, b), perimeter(a, b));
    }

    public static int area(int a, int b) {
        return a * b;
    }

    public static int perimeter(int a, int b) {
        return (a + b) * 2;
    }
    

    public static Integer[] readInput() {
        List<Integer> l = new ArrayList<Integer>();

        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            l.add(sc.nextInt());
        }
        return l.toArray(new Integer[l.size()]);
    }
}

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

const int MAXN = 1e5;
vector< pair<int, int> > adj[MAXN + 1];
vector<bool> vis(MAXN + 1, false);
vector<int> color(MAXN + 1);

void dfs(int x, int v) {
        vis[x] = true;
        if(v % 2)
                color[x] = 1;
        for(int i = 0; i < adj[x].size(); i++) {
                if(!vis[adj[x][i].first])
                        dfs(adj[x][i].first, v + adj[x][i].second);
        }
}

int main(void)
{
	ios_base::sync_with_stdio(0);
	int n, u, v, x;
	cin >> n;
        for(int i = 1; i < n; i++) {
                cin >> u >> v >> x;
                adj[u].push_back({v, x});
                adj[v].push_back({u, x});
        }
        dfs(1, 0);
        for(int i = 1; i <= n; i++)
                cout << color[i] << endl;
	return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const int SIZE = 123456 * 2;
int prime[SIZE + 10];
bool bprime[SIZE + 10];
int psize = 0;

int main() {
  MEMSET(bprime, true);
  FOREQ(i, 2, SIZE) {
    if (!bprime[i]) { continue; }
    prime[psize++] = i;
    for (int j = i + i; j <= SIZE; j += i) {
      bprime[j] = false;
    }
  }
  int n;
  while (scanf("%d", &n), n) {
    int ans = 0;
    FOREQ(i, n + 1, 2 * n) {
      ans += bprime[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.Arrays;

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[] inputs = {a, b, c};
        Arrays.sort(inputs);

        int da = inputs[2] - inputs[0];
        int db = inputs[2] - inputs[1];

        if (da % 2 == 0 && db % 2 == 0) {  // even & even
            System.out.println((da / 2) + (db / 2));
        }
        else if (da % 2 == 1 && db % 2 == 1) {  // odd & odd
            System.out.println(((da - 1) / 2) + ((db - 1) / 2) + 1);
        }
        else {  // odd & even
            System.out.println((da / 2) + (db / 2) + 2);
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) push_back(make_pair(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
#define elif else if
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
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;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

VP bager;

int func(int n,int x){
  if(n==0)return(x<=0?0:1);
  elif(x<=1+bager[n-1].se)return func(n-1,x-1);
  else return bager[n-1].fi+1+func(n-1,x-2-bager[n-1].se);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,x;
  cin>>n>>x;
  
  bager.pb(m_p(1,1));
  rep(i,n)bager.pb(m_p(bager[i].fi*2+1,bager[i].se*2+3));
  
  out(func(n,x));
  

  return 0;
}



Measured memory_bytes: 256
n,m,x = map(int,input().split())
ans = 12*(10**5)+1
C = []
A = []

for _ in range(n):
    AC = list(map(int,input().split()))
    C.append(AC[0])
    A.append(AC[1:])

for i in range(2**n):
    understood = [0]*m
    cost = 0
    
    for j in range(n):
        if (i>>j)&1:
            cost += C[j]
            
            for k in range(m):
                understood[k] += A[j][k]
                
    ok = 0
        
    for j in understood:
        if j >= x:
            ok += 1
            
    if ok == m:
        ans = min(ans,cost)

if ans == 12*(10**5)+1:
    ans = -1
        
print(ans)


Measured memory_bytes: 68540
#include <bits/stdc++.h>
using namespace std;
long long  s , k ,n , x ,ans = 1, ok ;
int main()
{
   cin >> n >> k ;
   for (int i = 0; i < n ; i++){cin >> x , s += x;
        if (s <= k )ans ++;
        }
   cout <<ans ;

    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 5e5 + 100;
int n;
int a[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  return true;
}

void solve() {
  int mx = *max_element(a, a + n);
  vector<int> cnt(n);
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  for (int i = mx / 2 + 1; i <= mx; i++) {
    cnt[i] -= 2;
  }
  if (mx % 2 == 0) {
    cnt[mx / 2]--;
  }
  bool ok = true;
  for (int i = 1; i < n; i++) {
    if (cnt[i] < 0) {
      ok = false;
    }
    if (cnt[i] > 0) {
      if (i <= (mx + 1) / 2) {
        ok = false;
      }
    }
  }
  printf(ok ? "Possible\n" : "Impossible\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    string S, T;
    cin >> S >> T;
    bool check = 0;
    for(int i = 0; i < S.size(); i++) {
        check = 1;
        for(int j = 0; j < S.size(); j++) {
            if(T.at(j) != S.at((i + j)%S.size())) {
                check = 0;
                break;
            }
        }
        if(check) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3608
import sys
input = sys.stdin.readline

a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))

n = int(input())
for i in range(n):
    b = int(input())

    if b in a1:
        a1[a1.index(b)] = 0
    if b in a2:
        a2[a2.index(b)] = 0
    if b in a3:
        a3[a3.index(b)] = 0

# 結果確認
if (a1[0] == a1[1] == a1[2] == 0) or (a2[0] == a2[1] == a2[2] == 0) or (a3[0] == a3[1] == a3[2] == 0) \
    or (a1[0] == a2[0] == a3[0] == 0) or (a1[1] == a2[1] == a3[1] == 0) or (a1[2] == a2[2] == a3[2] == 0) \
    or (a1[0] == a2[1] == a3[2] == 0) or (a1[2] == a2[1] == a3[0] == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
    int n;
    vector<int> vec;

    while (cin >> n) {
        vec.push_back(n);
    }

    sort(vec.begin(), vec.end());
    for (int i = 0; i < vec.size(); i++) {
        if (i > 0)
            cout << ' ';
        cout << vec[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  double R;
  cin >> R;
  double pi = 3.14159265358979;
  cout << setprecision(20) << fixed;
  cout << 2*pi*R << endl;
}

Measured memory_bytes: 3784
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	string s;
	cin >> s;

	for (int i = 0; i < 3; ++i)
	{
		if(s[i] == s[i+1])
		{
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
}

Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,k;
	int h[100003];
	int cnt = 0;

	scanf("%d%d",&n,&k);
	for (int i = 0; i < n; ++i){
		scanf("%d",&h[i]);
		if(h[i] >= k)	++cnt;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 512
x,y,a,b,c=map(int,input().split())
p0=list(map(int,input().split()))
q0=list(map(int,input().split()))
r0=list(map(int,input().split()))
p1=sorted(p0)
q1=sorted(q0)
p2=[]
q2=[]
for i in range(x):
    p2.append(p1[-i-1])
for i in range(y):
    q2.append(q1[-i-1])
ringo0=p2+q2+r0
ringo1=sorted(ringo0,reverse=True)
s=0
for i in range(x+y):
    s=s+ringo1[i]
print(s)

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

int main(){
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  printf((abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d)) ? "Yes" : "No");
  return 0;
}


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

bool month(string s)
{
  if (s[0] > '1')
    return false;
  else if (s[0] == '1' && s[1] > '2')
    return false;
  else if (s[0] == '0' && s[1] == '0')
    return false;
  return true;
}

int main()
{
  string s;
  cin >> s;
  bool f = month(s.substr(0, 2));
  bool b = month(s.substr(2, 2));
  if (f && b)
    cout << "AMBIGUOUS" << endl;
  else if (b)
    cout << "YYMM" << endl;
  else if (f)
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl;  
  return 0;
}

Measured memory_bytes: 256
## -*- coding: utf-8 -*-

x_1, y_1, x_2, y_2 = map(int, input().split())

a = [x_2-x_1,y_2-y_1]

x_3 ,y_3 = x_2-a[1], y_2+a[0]

x_4, y_4 = x_3-a[0], y_3-a[1]

print(x_3, y_3, x_4, y_4)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          firstn
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define fr(i,l,u) 	for(i=l;i<=u;i++)
#define bk(i,l,u)	for(i=l;i>=u;i--)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll posx[]={1,-1,0,0};
ll posy[]={0,0,1,-1};

void solve()
{
    ll n,m,i,j;
    cin>>n>>m;
    char a[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        cin>>a[i][j];
    }
    ll dp[n][m];
    mset(dp,0);
    dp[0][0]=1;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(a[i][j]=='#')
            continue;
            if(i>0)
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
            if(j>0)
            dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[n-1][m-1];
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 9088
import math
from functools import reduce
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def repfunc(x,y):
    a=x-1
    for i in range(1,x):
        if y%i==0 and (pow(10,i)-1)%x==0:
            a=i
            break
    return a


k=int(input())
res=1
ans1=0
ans2=0
if k%7==0:
    k//=7
if k%2==0 or k%5==0:
    print(-1)
elif k ==1:
    print(1)
else:
    c=collections.Counter(prime_factorize(k))
    c2=list(c.keys())
    d=[0 for i in range(len(c2))]
    for i in range(len(c2)):
        if c2[i]==3:
            d[i]=pow(3,c[3])
        else:
            d[i]=repfunc(pow(c2[i],c[c2[i]]),pow(c2[i],c[c2[i]]-1)*(c2[i]-1))
    print(lcm_list(d))


Measured memory_bytes: 11084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }


int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    for(ll i = 1; i <= sqrt(n); i++){
        if (n % i != 0) continue;
        ll j = n / i;
        ans = min(ans, i+j-2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N,A,B int
	fmt.Scan(&N,&A,&B)
	ans := 0
	for i := 1; i <= N; i++ {
		tmp := 0
		note := i
		for note >= 1 {
			tmp += note % 10
			note /= 10
		}
		if A <= tmp && tmp <= B {
			ans += i
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 2e6 + 5;

bitset<N> f;

int main(){
	/*if(01){
		srand(time(0));
		ofstream cout("input.txt");
		cout<<2000<<endl;
		for(int i=0;i<2e3;++i) cout<<rand()%2000+1<<' ';
		cout.close();
	}*/
	
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, m;
	
	f[0] = 1;
	
	int S = 0;
	cin>>n;
	for(int i=1;i<=n;++i){
		int x;
		cin>>x;
		f|=(f<<x);
		S+=x;
	}
	
	
	int ans = -1;
	for(int x=0;x<=S-x;++x) if(f[x]){
		ans = S - x;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 1024
while(1):
    n = map(None, raw_input().split())    
    a = int(n[0])
    op = n[1]
    b = int(n[2])
    
    if(op == '?'):
        break
    
    if(op == '+'):
        print a + b
    elif(op == '-'):
        print a - b
    elif(op == '*'):
        print a * b
    else:
        print a / b

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;




int main(){
    int N;cin >> N;
    vector<LL> dp(N+1,LINF);
    dp[0]=0;
    for (int i = 0; i < N; i++) {
        LL t=1;
        while(i+t<=N){
            dp[i+t]=min(dp[i+t],dp[i]+1);
            t*=6;
        }
        t=1;
        while(i+t<=N){
            dp[i+t]=min(dp[i+t],dp[i]+1);
            t*=9;
        }
    }
    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector< vector<int> > jobs(m);

    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        if(a > m){
            continue;
        }
        jobs[m-a].push_back(b);
    }

    priority_queue<int> q;
    long long ans = 0;

    for(int i = m-1; i >= 0; i--){
        for(int b : jobs[i]){
            q.push(b);
        }
        if(! q.empty()){
            ans += q.top();
            q.pop();
        }
        //sort(jobs[i].begin(), jobs[i].end());
    }

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

Measured memory_bytes: 5632
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
s=[input() for i in range(n)]

g=[[]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        if s[i][j]=="1":
            g[i].append(j)

# print(g)
ans=-float('inf')
for i in range(n):
    itta=[0]*n
    d=deque([i])
    cnt=0
    while d:
        # print(d)
        cnt+=1
        for i in range(len(d)):
            tmp=d.popleft()
            if itta[tmp]==0:
                itta[tmp]=cnt
                for j in range(len(g[tmp])):
                    if itta[g[tmp][j]]==0:
                        d.append(g[tmp][j])
            elif itta[tmp]==cnt:
                continue
            else:
                cnt=-float('inf')
    ans=max(ans,cnt)
if ans==-float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 69340
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
  int A, B; cin >> A >> B;
  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define maxn 55
using namespace std;
int n,m,a[maxn][maxn],fg[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
char s[maxn];
bool check(int x,int y){
	for (int i=0;i<4;++i)
	if (a[x+fg[i][0]][y+fg[i][1]]) return 0;
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i){
		scanf("%s",s+1);
		for (int j=1;j<=m;++j) a[i][j]=s[j]=='#';
	}
	for (int i=1;i<=n;++i)
	for (int j=1;j<=m;++j) if (a[i][j]&&check(i,j)) {printf("No\n");return 0;}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

inline Int Gcd(Int a, Int b) {
    Int c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

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

    int n;
    cin >> n;
    Int ans;
    cin >> ans;
    for (int i = 0; i < n - 1; i++) {
        Int t;
        cin >> t;

        ans = Lcm(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# D - Powerful Discount Tickets

import heapq

N, M = map(int, input().split())
A = [int(a) * -1 for a in input().split()]
heapq.heapify(A)

for i in range(M):
    price = heapq.heappop(A)
    price = -1 * ((-1 * price) // 2)
    heapq.heappush(A, price)

print(sum(A) * -1)


Measured memory_bytes: 14180
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


int main(void) {
    double d;
    cin >> d;
    double ans = sqrt(2) * d;
    loop(i,1,11){
        if(d*d-i*i >= 0 && d*d-i*i < 1.0) ans = max(ans,i+1.0);
    }
    cout << shosu(15) << ans << endl;
}



Measured memory_bytes: 3276
#include <stdio.h>

int main()
{
	int n;
  	unsigned long long int lucas2, lucas1, lucas0;
  	scanf("%d", &n);
  	if (n == 0){
    	printf("2");
    } else if (n ==1){
    	printf("1");
    } else {
    	lucas1 = 1; lucas0 = 2;
      	for (int i = 2; i <= n; i++){
        	lucas2 = lucas1 + lucas0;
          	lucas0 = lucas1; 
          	lucas1 = lucas2;
        }
      	printf("%ld", lucas2);
    }
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int A[100000];
	int i,n,j,key,ans=0,light,right,mid;	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&A[i]);
	scanf("%d",&j);
	for(i=0;i<j;i++){
		scanf("%d",&key);

		light=0;	right=n;
		while(right-light>1){
			mid=(light+right)/2;

			if(key<A[mid])right=mid;
			else light=mid;
		}
		if(key==A[light])ans++;

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



Measured memory_bytes: 2192
long m=1e9+7,D[41][1<<17]={1};
X,i,j,k,T,M=1<<17;
main(s,n){
	scanf("%d%d%d%d",&n,&j,&k,&T);
	for(X=((1<<j|1)<<k|1)<<T-1;i++<n;s=s*10L%m)
		for(j=k=0;k/M?k=0,j++<9:1;~T&X?D[i][T&=M-1]+=D[i-1][k-1],D[i][T]%=m:0)
			T=k+++k<<j;
	for(;M--;s%=m)s+=m-D[n][M];
	printf("%d",s);
}

Measured memory_bytes: 41088
#include <iostream>
#include <cstdlib>

using namespace std;
#define N 10
#define C 10

int main()
{
    int d = 0;
    int c[26];
    int s[365][26];
    int t[365];
    int t_c[C][365];
    int last[26] = {0};
    int score = 0;

    cin >> d;

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

    for(int i = 0; i < d; i++)
    {
        for(int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }

    for(int i = 0; i < C; i++)
    {
        for(int j = 0; j < 365; j++)
        {
            t_c[i][j] = rand() % 26;
        }
    }

    /*
    for(int n = 0; n < N; n++)
    {
        for(int i = 0; i < d; i++)
        {
            for(int j = 0; j < 26; j++)
            {
                if(t[i] == j)
                {
                    last[j] = 0;
                    score += s[i][j];
                }
                else
                {
                    last[j]++;
                    score -= c[j] * last[j];
                }
            }

            //cout << score << endl;
        }
    }
    */

    for(int i = 0; i < d; i++)
    {
        cout << (t_c[0][i] + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 3696
H,W = map(int,input().split())

a=[]
for _ in range(H):
  w = input()
  if w != '.'*W:
    a.append(w)
  else:
    continue

b=[]
for i in range(W):
  c = ""
  for j in range(len(a)):
    c += a[j][i]
  if c != '.'*len(a):
    b.append(c)
  else:
    continue

d=[]
for i in range(len(b[0])):
  e = ""
  for j in range(len(b)):
    e += b[j][i]
  d.append(e)

print('\n'.join(d))  
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    ll h , w , hh , ww ;
    cin >> h >> w >> hh >> ww;
    ll remrow = abs(h - hh );
    if(remrow == 0 ){
        cout << 0 << el;
        ro ;
    }
    ll remcol = abs(w-ww);
    cout << remrow * remcol << el ;
}




















Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int ret = 0;
	if (2 * C >= A + B) {
		ret = A * X + B * Y;
	} else {
		int tmp = min(X, Y);
		ret = C * 2 * tmp;
		X -= tmp;
		Y -= tmp;
		if (X) {
			if (2 * C < A) ret += 2 * C * X;
			else ret += A * X;
		}
		if (Y) {
			if (2 * C < B) ret += 2 * C * Y;
			else ret += B * Y;
		}
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"
#include "stdlib.h"

int keyinNum(void)
{
	char buff[5];
  
  	fgets(buff, sizeof buff, stdin);
	return atoi(buff);
}

int main(void)
{
  int a = keyinNum();
  int b = keyinNum();
  
  switch (a+b) {
    case 5:
      puts("1");
      break;
    case 4:
      puts("2");
      break;
    case 3:
      puts("3");
      break;
  }      
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,m;
string A[60],B[60];
int fc(int x,int y)
{
    for (int i = 0;i < m;i++)
        for (int j = 0;j < m;j++)
            if (B[i][j] != A[i+x][j+y])
            return 0;
    return 1;
}
int main()
{
    cin >> n >> m;
    for (int i = 0;i < n;i++) cin >> A[i];
    for (int i = 0;i < m;i++) cin >> B[i];
    for (int i = 0;i <= n-m;i++)
        for (int j = 0;j <= n-m;j++)
        if (fc(i,j)) {printf("Yes\n");exit(0);}
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const ll mod = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, a[200100], pref[200100];
ll get(ll l, ll r) {
	return pref[r]-pref[l-1];
}
pair<ll, ll> cut(ll l, ll r) {
	ll pos = l;
	for(ll x = 1<<17; x; x>>=1) {
		if(pos+x<r&&get(l, pos+x)<=get(pos+x+1, r-1))
			pos+=x;
	}
	pair<ll, ll> ans = {get(l, pos),get(pos+1, r-1)};
	if(abs(get(l, pos)-get(pos+1, r-1))>abs(get(l, pos+1)-get(pos+2, r-1))) {
		ans = {get(l, pos+1), get(pos+2, r-1)};
	}
//	cout << l << " " << r << " : ";
//	cout << ans.first << " " << ans.second << "\n";
	return minmax(ans.first, ans.second);
}
ll eval(pair<ll, ll> a, pair<ll, ll> b) {
	return max(a.second,b.second)-min(a.first, b.first);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i], pref[i] = pref[i-1]+a[i];
	ll ans = LLONG_MAX;
	for(int i = 3; i+1 <= n; i++) {
		ans = min(ans, eval(cut(1, i), cut(i, n+1)));
	}
	cout << ans;
}


Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
bool b[110];
//std::ios::sync_with_stdio(0); std::cin.tie(0);
int main() {
	int x, n, t;
	cin >> x >> n;
	if (!n) {
		cout << x << endl;
		return 0;
	}
	int i;
	for (i = 0; i < n; ++i) {
		cin >> t;
		b[t] = 1;
	}
	for (i = 0; i < 200; ++i) {
		if (x - i <= 0) {
			cout << x - i << endl;
			break;
		}
		if (!b[x - i]) {
			cout << x - i << endl;
			break;
		}
		if (x + i > 100) {
			cout << x + i << endl;
			break;
		}
		if (!b[x + i]) {
			cout << x + i << endl;
			break;
		}
	}
	return 0;
}

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

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

using  namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> vec(n);
  forn(i, n) cin >> vec[i];
  ll lim = pow(10, 18);
  ll ans = 1;

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

  bool flag = true;

  if (vec[0] == 0) {
    flag = true;
    ans = 0;
  }
  else {
    forn(i, n) {
      if (ans <= lim / vec[i]) ans *= vec[i];
      else {
	  flag = false;
	  break;
	}
      //cout << ans << "\n";
     }
  }

  if (flag) cout << ans << "\n";
  else cout << -1 << "\n";

  return 0;
}


Measured memory_bytes: 4012
data_set_list = []

def swap(t1, t2):
    return t2, t1

while True:
    x, y = map(int, input().split())
    if x == y == 0:
        break
    if x > y:
        x, y = swap(x, y)
    data_set_list.append((x, y))

for data in data_set_list:
    print(data[0], data[1])


Measured memory_bytes: 6164
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int ckck(int n)
{
    if(n==2||n==3)
        return 1;
    else if(n%2==0||n%3==0)
        return 0;
    else
    {
        for(int j=2;j*j<=n;j++)
        {
            if(n%j==0)
                return 0;
        }
        return 1;
    }
}
const ll N=1e5+5;
ll freq[N+1]={0};
int main()
{
  int n,K;
  cin>>n>>K;
  int p[n],i;
  for(i=0;i<n;i++)
  {
      cin>>p[i];
  }
  sort(p,p+n);
  int S=0;
  for(i=0;i<K;i++)
  {
      S+=p[i];
  }
  cout<<S;
}




Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e18 + 7;

int n, k, a[200005], f[200005];

bool ok(int m) {
	int req = 0;
	for(int i=0;i<n;i++)
		if(a[i]*f[i] > m)
			req += (a[i] * f[i] - m + f[i] - 1) / f[i];

	return req <= k;
}

signed main()
{
	IO_OP;
	
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> f[i];
	sort(a, a+n);
	sort(f, f+n, greater<int>());
	int l = 0, r = INF;
	while(l <= r) {
		int m = (l + r) / 2;
		if(ok(m)) r = m - 1;
		else l = m + 1;
	}
	cout << l << endl;
}





Measured memory_bytes: 3328
n = int(input())
dlst = list(map(int, input().split()))
m = int(input())
tlst = list(map(int, input().split()))

dlst.sort()
tlst.sort()
posd = 0
post = 0

while 1:
    if dlst[posd] == tlst[post]:
        posd += 1
        post += 1
    else:
        posd += 1
    if post == m:
        print("YES")
        exit()
    elif posd == n:
        print("NO")
        exit()

Measured memory_bytes: 39260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;
template<typename T> T factorial(T n){
    if(n==1) return 1;
    else return n*factorial(n-1)%MOD;
}
template<typename T> T Pow(T x, T n, T m){
    if(n == 0) return 1;
    if(n % 2 == 0) return Pow(x * x % m, n / 2, m);
    else return x * Pow(x, n - 1, m) % m;
}
template<typename T> T combination(T n, T k, T m){
    return factorial<T>(n) * Pow<T>(factorial(k), m-2, m) % m * Pow<T>(factorial(n-k), m-2, m) % m;
}
struct edge{
    int to; // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using graph = vector<vector<edge>>;
using Graph = vector<vector<int>>;

int main(){
    int k; cin >> k;
    ll ans = 0;
    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            for(int l=1; l<=k; l++){
                ans += (ll)__gcd(__gcd(i, j), l);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<vector<pair<int, int>>> vt;
int de[100010],indegree[100010];
int visited[100010],update;
void dfs(int here, int par) {
	visited[here] = 1;
	for (int i = 0; i < vt[here].size(); i++)
	{
		int next = vt[here][i].first;
		int ncst = vt[here][i].second;
		if (next == par)continue;
		if (!visited[next]) {
			de[next] = de[here] + ncst;
			dfs(next, here);
		}
		else if (de[next] != de[here] + ncst)
			update = 1;
	}
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	vt.resize(n + 1);
	for (int i = 0; i < m; i++) {
		int q, w, e;
		scanf("%d %d %d", &q, &w, &e);
		vt[q].push_back({ w,e });
		indegree[w]++;
	}
	for (int i = 1; i <= n; i++) {
		if(!indegree[i])
			dfs(i, 0);
	}
	for (int i = 1; i <= n; i++) {
		if (!visited[i])
			dfs(i, 0);
	}
	if (update)puts("No");
	else puts("Yes");
}

Measured memory_bytes: 11520
while 1:
    x, y, s = map(int, raw_input().split())
    if x == y == s == 0:
        break
    ans = 0
    def calc(p, x, y):
        res = 0
        for i in xrange(1, p+1):
            if int(i*(100+x)/100.) == p:
                res = max(res, int(i*(100+y)/100.))
        return res
    for i in xrange(1, s/2+1):
        ans = max(ans, calc(i, x, y)+calc(s-i, x, y))
    print ans

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

using namespace std;

int A, B, C, mini;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &A, &B, &C), mini = 1e5;
for (int i=0; i<=150; i++)
    for (int j=0; j<=150; j++)
        for (int k=0; k<=150; k++)
        {
            int x = A + i + j, y = B + j + k, z = C + i + k;
            if (x % 2 != y % 2 || y % 2 != z % 2) continue;
            int curr = i + j + k;
            int t = max (max (x, y), z);
            curr += (t - x + t - y + t - z) / 2;
            if (curr < mini)
                mini = curr;
        }
printf ("%d\n", mini);
return 0;
}


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

int main(){
    string s;
    long long int n;
    cin >> s;
    cin >> n;
    for(int i=0;i<n;i++){
        if(s.at(i)!='1'){
            cout << s.at(i) << endl;
            return 0;
        }
        if(i==n-1){
            cout << 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s == "A") cout << "T" << endl;
    else if (s == "G") cout << "C" << endl;
    else if (s == "T") cout << "A" << endl;
    else cout << "G" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a),end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

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

double outputSin(double x, double y, double z){
    return acos( (x * x +  y * y - z * z) / (2 * x * y) ) ;
}

double inputXY(double x1, double y1, double x2, double y2, double x3, double y3){
    double x, y ,z;
    x = dist(x1, y1, x2, y2);
    y = dist(x2, y2, x3, y3);
    z = dist(x3, y3, x1, y1);
    return outputSin(x, y, z);
}

int main(){
    double x1, y1, x2, y2, x3, y3, x4, y4;
    char gar;
    while(cin >> x1 >> gar >> y1 >> gar >> x2 >> gar >> y2 >> gar >> x3 >> gar >> y3 >> gar >> x4 >> gar >> y4){
        double a, b, c, d;
        a = inputXY(x1, y1, x2, y2, x3, y3);
        b = inputXY(x2, y2, x3, y3, x4, y4);
        c = inputXY(x3, y3, x4, y4, x1, y1);
        d = inputXY(x4, y4, x1, y1, x2, y2);

        if(abs(a + b + c + d - 2 * M_PI) < 0.00001) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 1256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    LD ans;
    if (N % 2 == 0) {
        ans = 0.5;
    } else {
        ans = (LD)(N + 1)/(2*N);
    }

    printf("%.7Lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
//#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 2];
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int sum = 0;
		for (int i = 0; i <= n; i++) {
			sum += Math.abs(a[i] - a[i + 1]);
		}

		for (int i = 1; i <= n; i++) {
			System.out.println(sum + Math.abs(a[i- 1] - a[i + 1])
					- Math.abs(a[i] - a[i + 1]) - Math.abs(a[i] - a[i - 1]));
		}
	}
}


Measured memory_bytes: 64936
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
//ll longinf=1ll<<60;
int inf=1<<29;
ll longinf=(1ll<<60);

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

int N;
int M;
int ans;
vector<int> nxt[100000];
vector<int> bfr[100000];

bool dp[100001];


signed main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    rep0(i,n){
        cin>>a[i];
    }
    dp[0]=0;
    //先手勝ち→1後手勝ち→0
    rep1(i,k){
        dp[i]=0;
        if(i<a[0]) dp[i]=0;
        rep0(j,n){
            if(i>=a[j]&&!dp[i-a[j]]){
                dp[i]=1;
            }
        }
        //cout<<dp[i]<<" ";
    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 4992