akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	


// 12341234


bool sortbysecond(const pair<long long,int> &a,const pair<long long,int> &b){

	return (a.se < b.se);

}


int main(){

	
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	int n,val;

	long long W,w;


	cin >> n >> W; 


	vector<pair<long long,long long>> v(n);

	vector<long long> dp(100010); 

	f(t,0,n){
		cin >> w >> val;

		v[t] = {w,val};


	}

	f(i,0,n){

		fr(j,100005,1){
			long long x = v[i].fi; 
			int y = v[i].se;
			if(dp[j]!=0){
				if(dp[j+y]==0){
					dp[j+y] = dp[j]+x; 
				}else{
					dp[j+y] = min(dp[j+y],dp[j]+x);
				}
			}
			if(j==y){
				if(dp[j]==0){
					dp[j] = x;
				}else{
					dp[j] = min(dp[j],x);
				}
			}
		}

	}

	

	int ans = 0;

	f(i,1,SZ(dp)){
		if(dp[i] <=W && dp[i]!=0) {
			ans = max(ans,i);
		}

	}

	cout <<ans << endl;


}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll x=in(),y=in();
    ll m[]={300000,200000,100000};
    cout<<(x<=3?m[x-1]:0)+(y<=3?m[y-1]:0)+(x==1&&y==1?400000:0)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

ll dp[205][100005];
// i番目まで見て、あまりがjである時の場合の数

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

    int s[n];
    for (int i = 0; i < n; i++) cin >> s[i];

    sort(s, s+n, greater<int>());

    dp[0][x] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= x; j++) {
            (dp[i+1][j] += dp[i][j] * (n - i - 1)) %= MOD;
            (dp[i+1][j%s[i]] += dp[i][j]) %= MOD;
        }
    }

    ll ans = 0LL;
    for (int j = 1; j < s[n-1]; j++) {
        (ans += dp[n][j] * j) %= MOD;
    }

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

Measured memory_bytes: 157184
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const ll INF = 1001001001001;
int main(){
    int n,m;
    ll l;
    cin >> n >> m >> l;
    ll d[n][n];
    ll dist[n][n];
    rep(i,n){
        rep(j,n){
            d[i][j]=INF;
            dist[i][j]=INF;
        }
    }
    rep(i,m){
        int a,b; ll c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(d[i][j]<=l) dist[i][j]=dist[j][i]=1;
        }
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    int q; cin >> q;
    rep(i,q){
        int s,t; cin >> s >> t;
        s--; t--;
        if(dist[s][t]==INF) cout << -1 << "\n";
        else cout << dist[s][t]-1 << "\n";
    }
}


Measured memory_bytes: 1920
import heapq


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    Circle

    left with [A, B] and A < B

    _ _ A B _

    _ _ B A _

    """
    N = read_int()
    A = read_ints()
    A.sort()
    A_max = A.pop()
    ranges = [(-A_max, -A_max)]
    score = 0
    while A:
        a = A.pop()
        left, right = heapq.heappop(ranges)
        score += -left
        heapq.heappush(ranges, (-a, left))
        heapq.heappush(ranges, (-a, right))
    return score


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 108560
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -float('inf')
for i in range(1, 1 << 10):
    bit = i
    profit = 0
    for j in range(N):
        cnt = sum(F[j][k] & (bit >> k) for k in range(10))
        profit += P[j][cnt]
    ans = max(ans, profit)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll pass(ll m)
{
    ll t=1,b[100000];
    memset(b,0,sizeof(b));
    b[m] = -1;
    while(1)
    {
        if(m%2==0)
        {
            m /= 2;
        }
        else
        {
            m = m*3+1;
        }
        //cout<<" m "<<m<<endl;
        if(b[m]==-1)
        {
            t++;
            cout<<t<<endl;
            break;
        }
        else
        {
            b[m] = -1;
            t++;
        }
    }
}
int main()
{
    int m;
    cin>>m;
    pass(m);
}


Measured memory_bytes: 1024
#include <stdio.h>

int drawCount(int x,int y);

int main() {
  int X,Y,count=0;
  scanf("%d %d",&X,&Y);
  if(Y%4==0 || Y%2==0) {
    count = drawCount(X,Y);
  }
  if(X==count) {
    printf("Yes");
  }else {
    printf("No");
  }
  return 0;
}

int drawCount(int x,int y) {
  int count = 0;
  int cnt4 = 0;
  while(y!=0) {
    if(y>=4) {
      y=y-4;
      count++;
      cnt4++;
    }else if(y==2) {
      y=y-2;
      count++;
    }
  }
  if(count!=x) {
    for(int i=0;i<cnt4;i++) {
      count++;
      if(count==x) {
        break;
      }
    }
  }
  return count;
}
  

Measured memory_bytes: 1720
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
using namespace std;

int N,K;

void func(){

	int baseTable[N],baseValue = 0;
	for(int i = 0; i < N; i++){
		scanf("%d",&baseTable[i]);
	}

	int tmp = 1,pre;
	for(int p = 0; p < K; p++){
		tmp *= baseTable[p];
	}
	baseValue = tmp;
	pre = tmp;

	for(int i = 1; i <= N-K; i++){
		tmp = (pre/baseTable[i-1])*baseTable[i+K-1];
		baseValue = max(baseValue,tmp);
		pre = tmp;
	}

	int nextValue = 0,tmpValue;
	//???????????§??§??????????????§????????????????????£???????????§?????????????????¨?????????????????¨??¢?´¢
	for(int a = 0; a < N-1; a++){
		for(int b = a+1; b < N; b++){
			swap(baseTable[a],baseTable[b]);

			tmp = 1;
			for(int p = 0; p < K; p++){
				tmp *= baseTable[p];
			}
			tmpValue = tmp;
			pre = tmp;

			for(int i = 1; i <= N-K; i++){
				tmp = (pre/baseTable[i-1])*baseTable[i+K-1];
				tmpValue = max(tmpValue,tmp);
				pre = tmp;
			}

			nextValue = max(nextValue,tmpValue);
			swap(baseTable[a],baseTable[b]); //????????????
		}
	}

	if(nextValue < baseValue){
		printf("NO GAME\n");
	}else{
		printf("%d\n",nextValue - baseValue);
	}
}


int main(){

	while(true){
		scanf("%d %d",&N,&K);
		if(N == 0 && K == 0)break;

		func();
	}

    return 0;
}

Measured memory_bytes: 3200
S = input()

size = len(S)

# 偶数を 0 として書き換える

swaps = 0

for i, s in enumerate(S):
    # 余りが = 偶数ならば 0 に書き換え
    if (i % 2 == 0 and s == '1') or (i % 2 == 1 and s == '0'):
        swaps += 1

print(min(swaps, size - swaps))


Measured memory_bytes: 3188
//Created by Aminul on 8/29/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int d = in.nextInt(), t = in.nextInt(), s = in.nextInt();
        pw.println(t * s >= d ? "Yes" : "No");

        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

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

int main()
{
	int n;
	scanf("%d", &n);
	int a[200000];
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a, a+n, greater<int>());
	long long sum = a[0];
	int j = 0;
	for(int i = 1; i < n - 1; i++) {
		if(i & 1) j++;
		sum += a[j];
	}
	if(n == 1) sum = 0;
	printf("%lld\n", sum);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

  template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

string Decode(string s, int n){
  string res = s;
  rep(i,s.size()){
    if(s[i] != '.' && s[i] != ' '){
      if(s[i] + n > 'z'){
        res[i] = 'a' + (s[i] + n - 'z')-1;
      }
      else{
        res[i] = s[i] + n;
      }
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int code;
  vector<string> vs;
  while(1){
    code = 0;
    getline(cin,s);
    if(cin.eof()) break;
    rep(i,27){
      if(Decode(s,i).find("this") != string::npos ||Decode(s,i).find("that") != string::npos||Decode(s,i).find("the") != string::npos){
        code = i;
        break;
      }
    }
    cout << Decode(s,code) << endl;
  }
  return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int main(){
  string s, ans="Good";
    cin >> s;
    for(int i=0; i<s.size()-1; i++)
      if(s[i]==s[i+1]) ans = "Bad";
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
hash = {}
N.times do |i|
    a,b = gets.split.map(&:to_i)
    if hash[a]
        hash[a] += b
    else
        hash[a] = b
    end 
end

array = hash.sort

sum_drink = 0
sum_price = 0
array.each_with_index do |d,i|
    if M >= (sum_drink + d[1])
        sum_price += d[0] * d[1]
        sum_drink += d[1]
    else
        sum_price += d[0] * (M - sum_drink)
        sum_drink = M
    end
end

puts sum_price

Measured memory_bytes: 14840
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int ans=0;
    string str;
    cin>>n;
    cin>>str;
    for(int i=0;i<n;++i){
        string str2;
        cin>>str2;
        bool flg=false;
        for(int j=0;j<str2.size();++j){
            for(int k=1;k<=str2.size()/2;++k){
                int num=1;
                int t=k;
                for(int l=0;l<str.size();++l){
                    if(str[0]==str2[j]){
                        if(t+j<=str2.size()){
                            if(str[num]==str2[j+t]){
                                num++;
                                t+=k;
                            }
                            if(num==str.size()&&!flg){
                                ans++;
                                flg=true;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1208
from bisect import bisect_left

N = int(input())
e5 = 10 ** 5

v = [[] for _ in range(2 * e5)]
visited = [True] * (2 * e5)

for _ in range(N) :
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    v[x].append(y + e5)
    v[y + e5].append(x)
    visited[x] = visited[y + e5] = False

ret = 0
for i in range(e5) :
    if not visited[i] :
        queue = [i]
        visited[i] = True
        nx, ny = 1, 0
        
        while queue :
            q = queue.pop()
            for j in v[q] :
                if not visited[j] :
                    visited[j] = True
                    queue.append(j)
                    
                    if j < e5 :
                        nx += 1
                    else :
                        ny += 1
                    
        ret += nx * ny
                    
print(ret - N)

Measured memory_bytes: 65612
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	one := n % 10
	if one == 9 || one == 7 || one == 5 || one == 4 || one == 2 {
		fmt.Println("hon")
		return
	}
	if one == 8 || one == 6 || one == 1 || one == 0 {
		fmt.Println("pon")
		return
	}
	if one == 3 {
		fmt.Println("bon")
		return
	}
}


Measured memory_bytes: 1816
N = int(input())
P = map(int, input().split())

Kcost = [min(row, N - 1 - row, clm, N - 1 - clm) for row in range(N) for clm in range(N)]

Sitting = [1] * (N * N)
Kcount = 0


def Kcheck(qsn, cdsn):
    if Kcost[cdsn] > Kcost[qsn] + Sitting[qsn]:
        Kcost[cdsn] = Kcost[qsn] + Sitting[qsn]
        queue.append(cdsn)


for sn in P:
    csn = sn - 1
    Kcount += Kcost[csn]
    Sitting[csn] = 0
    queue = [csn]

    while queue:
        qsn = queue.pop()
        div, mod = divmod(qsn, N)
        if mod: Kcheck(qsn, qsn - 1)
        if mod != N - 1: Kcheck(qsn, qsn + 1)
        if div: Kcheck(qsn, qsn - N)
        if div != N - 1: Kcheck(qsn, qsn + N)

print(Kcount)


Measured memory_bytes: 137560
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//int frq[123];
int main(){
	Lancer();
	string a, b;
	cin >> a >> b;
	bool ch = false;
	for (int i = 0; i < b.length(); i++){
		char c = a[a.length() - 1];
		a.erase(a.length() - 1, 1);
		a = c + a;
		if (a == b){
			ch = true;
			break;
		}
	}
	if (ch) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


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

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

  if (A < B) swap(A, B);
  if (B < C) swap(B, C);
  if (A < B) swap(A, B);

  int x = A - B, y = A - C;
  
  int ans = x / 2 + y / 2;
  if (x % 2 == 1 && y % 2 == 1) ans++;
  else if (x % 2 != y % 2) ans += 2;

  cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define JD



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

    #ifndef JD
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif

    int n;
    cin>>n;
    int g = ceil((double)n/1000);
    cout<<(g*1000-n);



    return 0;
}


Measured memory_bytes: 3644
import sys
rl = sys.stdin.readline


def solve():
    N, A, B = map(int, rl().split())
    h = [int(rl()) for _ in range(N)]
    ad_d = A - B
    
    def calc(t):
        cnt = 0
        for i in range(N):
            d = h[i] - B * t
            if 0 < d:
                cnt += d // ad_d if d % ad_d == 0 else d // ad_d + 1
        return cnt <= t
    
    ok, ng = 10 ** 9, 0
    while 1 < ok - ng:
        mid = (ok + ng) // 2
        if calc(mid):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 7072
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

long long factorial(long long n, long long mod) {
    long long ret = 1;
    for (long long i = 1; i <= n; i++) {
        ret = (ret * i) % mod;
    }
    return ret;
}

long long inv_mod(long long n, long long mod) {
    long long a = n % mod, b = mod - 2, ret = 1;
    while (b > 0) {
        if (b & 1) ret = (ret * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ret;
}

long long nPr(long long n, long long r, long long mod) {
    long long ret = 1;
    for (long long i = n; i >= n - r + 1; i--) {
        ret = ret * (i % mod) % mod;
    }
    return ret;
}

long long nCr(long long n, long long r, long long mod) {
    return nPr(n,r,mod) * inv_mod(factorial(r,mod),mod) % mod;
}

long long nHr(long long n, long long r, long long mod) {
    return nCr(n+r-1,r,mod);
}

int main ()
{
    ll X,Y;
    cin >> X >> Y;

    if ((2 * Y - X) < 0) {
        cout << 0 << endl;
        return 0;
    }

    if ((2 * Y - X) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll y = (2 * Y - X) / 3;
    ll x = Y - 2 * y;

    if (!(y >= 0 && x >= 0)) {
        cout << 0 << endl;
        return 0;
    }

    cerr << "x = " << x << ", y = " << y << endl;
    cout << nCr(x + y, x, 1000000007LL) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>    
#include <vector>       
#include <set>
#include <utility>  
#include <cstring>
#include <stdio.h>
#include <limits.h>
#include <queue>
#include <algorithm> 
#define MAX_DOUBLE  40000000000.0 
#include <math.h> 
#include <unistd.h>

using namespace std;

int max(int a, int b){
	if(a > b) return a;
	return b;
}


long long res[1010][1010];


int main(){
	
	int n,m;
	cin>>n>>m;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			char a;
			cin>>a;
			if(a == '#'){
				res[i][j] = -1;
			} else{
				res[i][j] = 0;
			}
		}
	}
	
	res[n-1][m-1] = 1;
	
	long long mod = (1e9 + 7);
	
	for(int i = n-1; i >= 0; i--){
		for(int j = m-1; j >= 0; j--){
			if(res[i][j] >= 0){
				if(res[i+1][j] > 0) res[i][j] += res[i+1][j];
				res[i][j] = res[i][j] % (mod);
				if(res[i][j+1] > 0) res[i][j] += res[i][j+1];
				res[i][j] = res[i][j] % (mod);
			}					
		}
	}
	
	cout<<res[0][0]<<endl;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,a;
    cin >> n>>a;
    cout << ((n%500<=a)?"Yes":"No") << endl;
    return 0;
}


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

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

    queue<long long> A;
    for (long long i = 0; i < 9; i++) {
        A.push(i + 1);
    }

    long long ans;
    for (int i = 0; i < K; i++) {
        ans = A.front();
        if (ans % 10 != 0) {
            A.push(10 * ans + ans % 10 - 1);
        }
        A.push(10 * ans + ans % 10);
        if (ans % 10 != 9) {
            A.push(10 * ans + ans % 10 + 1);
        }
        A.pop();
    }

    cout << ans << endl;
}

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

using namespace std;

bool win(int a[3][3]){
    if(a[0][0]==1 && a[0][1]==1 && a[0][2]==1){return true;}
    if(a[1][0]==1 && a[1][1]==1 && a[1][2]==1){return true;}
    if(a[2][0]==1 && a[2][1]==1 && a[2][2]==1){return true;}

    if(a[0][0]==1 && a[1][0]==1 && a[2][0]==1){return true;}
    if(a[0][1]==1 && a[1][1]==1 && a[2][1]==1){return true;}
    if(a[0][2]==1 && a[1][2]==1 && a[2][2]==1){return true;}


     if(a[0][0]==1 && a[1][1]==1 && a[2][2]==1){return true;}
    if(a[2][0]==1 && a[1][1]==1 && a[2][0]==1){return true;}
    return false;
}   

int main(){
   int a[3][3];
   int i,j,k;
   for(i=0;i<3;i++){
        for(j=0;j<3;j++){cin>>a[i][j];}}
    int n,cnt;
    int b[3][3]={};
    cin>>n;
    for(i=0;i<n;i++){
        cin>>cnt;
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(a[j][k]==cnt){b[j][k]=1;}
            }
        }
    }
    if(win(b)){cout<<"Yes";}
    else{cout<<"No";}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
ll dp[200000];
const ll INF = 1LL<<60;
int main() {
  int n,k;
  cin >> n;
  k = 2;
  vi h(n);
  rep(i,n)cin >> h[i];
  fill(dp,dp+200000,INF);
  dp[0] = 0;
  rep(i,n){
    srep(j,1,k+1){
      if(i-j<0)continue;
      mins(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

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

int main(){
	int n,k,l;
	cin >> n >> k;
	vector<int> x(n);
	for(int i = 0;i < n;i++){
		cin >> l;
		x[i] = l;
	}

	int ans = 0;
	for (int i = 0;i < n;i++){
		ans += 2*min(x[i], k-x[i]);
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2
D_MAX = int(5e10 + 1)


def generate_adj_matrix(v_info):
    for each in v_info:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        # assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_matrix[v_index][pair[0]] = pair[1]

    return init_adj_matrix


def dijkstra_path():
    # path search init
    path_list[init_vertex_index] = 0
    path_heap = []
    # heapq: rank by tuple[0], here ranked by d[u]
    hp.heappush(path_heap, (0, init_vertex_index))
    while len(path_heap) >= 1:
        current_vertex_index = hp.heappop(path_heap)[1]

        color[current_vertex_index] = BLACK

        current_vertex_index_info = adj_table[current_vertex_index]
        for adj_vertex_index in current_vertex_index_info.keys():
            current_adj_weight = current_vertex_index_info.get(adj_vertex_index)
            if color[adj_vertex_index] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = path_list[current_vertex_index] + current_adj_weight
                if alt_path < path_list[adj_vertex_index]:
                    # update path_list
                    path_list[adj_vertex_index] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj_vertex_index))
                    parent_list[adj_vertex_index] = current_vertex_index
                    color[adj_vertex_index] = GRAY

    return path_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_table = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    parent_list, path_list = [-1] * vertices_num, [D_MAX] * vertices_num
    color = [WHITE] * vertices_num
    init_adj_matrix = tuple(dict() for _ in range(vertices_num))
    init_vertex_index = 0

    adj_table = generate_adj_matrix(init_vertices_table)
    ans = dijkstra_path()
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 62916
// Date: 2020-02-27

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkMax(T &x, T y) { x = max(x, y); }
template <typename T> void chkMin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, a[N], vis[21];
int main() {
    scanf("%d", &n);
    rep(i, 1, n) scanf("%d", &a[i]);
    LL ans = 0;
    int r = 1;
    rep(i, 0, 19) if(a[1] >> i & 1) vis[i] = 1;
    for(int l = 1; l <= n; ++l) {
        while(1) {
            if(r == n) break;
            int f = 1;
            rep(j, 0, 19) if((a[r+1] >> j & 1) && vis[j]) f = 0;
            if(!f) break;
            else {
                ++r;
                rep(j, 0, 19) if(a[r] >> j & 1) vis[j] = 1;
            }
        }
        ans += r-l+1;
        rep(j, 0, 19) if(a[l] >> j & 1) vis[j] = 0;
    }
    printf("%lld\n", ans);
    

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i=0; i<N; i++){
        cin >> A[i];
    }
    set<int> numbers;
    for (int i=0; i<N; i++){
        numbers.insert(A[i]);
    }
    cout << numbers.size() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

vi adj[111111];
int sub[111111];
int par[111111];
int h[111111];

void dfs(int u, int p)
{
	sub[u]=1;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		if(v==p) continue;
		par[v]=u;
		h[v]=h[u]+1;
		dfs(v,u);
		sub[u]+=sub[v];
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i = 0; i < n - 1; i++)
	{
		int u,v; cin>>u>>v;
		u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	par[0]=-1;
	dfs(0,-1);
	int cur=n-1;
	for(int i=0;i<(h[n-1]-1)/2;i++)
	{
		cur=par[cur];
	}
	if(n-sub[cur]>=n/2+1) cout<<"Fennec\n";
	else cout<<"Snuke\n";
}


Measured memory_bytes: 14976
#include<cstdlib>
#include<vector>

class RootedTree{
private:
    static const int NIL = -1;
    struct Node{
        // left: child, right: sibling
        int parent, left, right, depth;
        Node(){parent = left = right = depth = NIL;}
    };
    std::vector<Node> T;
    int root;
public:
    RootedTree(int N):T(N){root = NIL;}
    void addNode(int p, int c){
        static int sib;
        if(T[p].left == NIL) T[p].left = c;
        else T[sib].right = c;
        T[c].parent = p;
        sib = c;
    }
    void makeTree(){
        setRoot();
        setDepth(root, 0);
    }
    int getDepth(int v){
        return T[v].depth;
    }
    int getParent(int v){
        return T[v].parent;
    }
    std::vector<int> getChildren(int v){
        std::vector<int> c;
        for(int i=T[v].left;i!=NIL;i=T[i].right) c.push_back(i);
        return c;
    }
    int getType(int v){
        if(T[v].parent == NIL) return NIL;
        if(T[v].left == NIL) return 1;
        else return 0;
    }
private:
    void setRoot(){
        for(size_t i=0;i<T.size();++i)
            if(T[i].parent == NIL) root = i;
    }
    void setDepth(int v, int d){
        T[v].depth = d;
        if(T[v].right != NIL) setDepth(T[v].right, d);
        if(T[v].left != NIL) setDepth(T[v].left, d+1);
    }
};
#include<iostream>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    RootedTree T(n);
    for(int i=0;i<n;++i){
        int id, k;
        cin>>id>>k;
        for(int j=0;j<k;++j){
            int c;
            cin>>c;
            T.addNode(id, c);
        }
    }
    T.makeTree();
    for(int i=0;i<n;++i){
        cout<<"node "<<i<<": parent = "<<T.getParent(i)<<", depth = "<<T.getDepth(i)<<", "<<(T.getType(i)?~T.getType(i)?"leaf":"root":"internal node")<<", [";
        vector<int> c = T.getChildren(i);
        for(size_t j=0;j<c.size();++j)
            if(!j) cout<<c[j];
            else cout<<", "<<c[j];
        cout<<"]"<<endl;
    }
}

Measured memory_bytes: 6568
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
bool* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
const int max_size = ( 1e6 + 5 );
int mp_prime[ max_size ] = {};
int vec[ max_size ] = {};
int main( void ){
	int N;
	scanf("%d", &N);
	rep( i, 0, N ){
		scanf("%d", vec+i);
		int temp_input = vec[ i ];
		for(int j = 2; j * j <= temp_input; j++){
			if (temp_input % j == 0){
				int cnt = 0;
				while(temp_input % j == 0){
					temp_input /= j;
					cnt++;
				}
				if (cnt > mp_prime[ j ])
					mp_prime[ j ] = cnt;
			}
		}
		if (temp_input > 1 && mp_prime[ temp_input ] == 0){
			mp_prime[ temp_input ] = 1;
		}
	}
	int lcm = 1;
	rep( i, 2, max_size ){
		if (mp_prime[ i ] > 0){
			int a = i, b = mp_prime[ i ];
			int pow = 1;
			for(; b; b >>= 1, a = ( ll )a * a % k_mod) if(b & 1) pow = ( ll )pow * a % k_mod;
			lcm = (ll)lcm * pow % k_mod;
		}
	}
	int sum = 0;
	rep( i, 0, N ){
		int a = vec[ i ], b = k_mod - 2;
		int pow = 1;
		for(; b; b >>= 1, a = ( ll )a * a % k_mod) if(b & 1) pow = ( ll )pow * a % k_mod;
		sum = ( sum + lcm * ( ll )pow ) % k_mod;
	}
	printf("%d\n", sum);
}
bool* eratosthenes( int N ){
	bool* prime_array = new bool[ N + 1 ];
	int lim = sqrt( N ) + 1;
	prime_array[ 0 ] = false;
	prime_array[ 1 ] = false;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = true;
	}
	rep( i, 2, lim ){
		if (!prime_array[ i ])
			continue;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = false;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

using namespace std;

typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;++i)

typedef pair<ll,ll> pll;
#define MP make_pair<ll>

int main(){
  ll n,r,l;
  cin >> n >> r >> l;
  ll nowtime = 0;
  ll times[n]; REP(i,n)times[i]=0;
  ll score[n]; REP(i,n)score[i]=0;
  set<pll> ranking; REP(i,n)ranking.insert(MP(score[i],i));
  set<pll>::iterator iter;
  REP(i,r){
    ll d,t,x;
    cin >> d >> t >> x;
    times[ranking.rbegin()->second] += (t-nowtime);
    nowtime = t;
    d = n-d;

    pll nw = MP(score[d],d);
    iter = ranking.find(nw);
    ranking.erase(iter);
    score[d] += x;
    nw = MP(score[d],d);
    ranking.insert(nw);
  }
  times[ranking.rbegin()->second] += (l-nowtime);
  ll id = 0;
  ll mx = times[0];
  REP(i,n){
    if(times[i]>mx){
      mx = times[i];
      id = i;
    }
  }
  cout << (n-id) << endl;
  return 0;
}

Measured memory_bytes: 9004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        int s=n*800;
        if(n>=15)s-=(n/15)*200;
        cout<<s<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
int n,k,mx;
str s;
vector<int> seq,pre;
int main(){
    cin>>n>>k;
    cin>>s;
    int f=1;
    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1]){
            seq.push_back(f);
            f=1;
        }
        else{
            f++;
        }
    }
    seq.push_back(f);
    pre.push_back(seq[0]);
    for(int i=1;i<seq.size();i++){
        pre.push_back(seq[i]+pre.back());
    }

    //for(int i=0;i<seq.size();i++)cout<<seq[i]<<" ";cout<<endl;
    bool hand;
    if(s[0]=='1')hand=true;
    else{hand=false;}
    mx = 0;
    for(int i=0;i<seq.size();i++){
        int sum = 0;
        int l,r;
        if(hand){
            l = i;
            int sz = seq.size();sz--;
            r = min(i + 2*k, sz);

            sum = pre[r];
            if(l>0)sum-=pre[l-1];
        }
        else{
            l = i;
            int sz = seq.size();sz--;
            r = min(i + 2*k - 1,sz);

            sum = pre[r];
            if(l>0)sum-=pre[l-1];
        }
        mx = max(sum,mx);
        hand = not hand;
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 1528
#include <iostream>
#include<map>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;

	map<string, int> w;
	w["SUN"] = 7;
	w["MON"] = 6;
	w["TUE"] = 5;
	w["WED"] = 4;
	w["THU"] = 3;
	w["FRI"] = 2;
	w["SAT"] = 1;

	cout << w[s] << endl;


	return 0;
}


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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;
const int MAX = 100001;
bool is_lun(ll x){
	ll p = x%10;
	while(x){
		ll c = x%10;
		if(abs(c-p) > 1) return false;
		p = c;
		x /= 10;
	}
	return true;
}
vector<ll> L;
queue<ll> q;

void bfs(){
	while(L.size() < MAX){
		ll tp = q.front();
		q.pop();
		L.push_back(tp);
		ll m = tp%10;
		if(m==0){
			q.push(tp*10);
			q.push(tp*10 + 1);
		}else if(m==9){
			q.push(tp*10 + 8);
			q.push(tp*10 + 9);
		}else{
			q.push(tp*10 + m-1);
			q.push(tp*10 + m);
			q.push(tp*10 + m + 1);
		}
	}
}

void solve(){
	for(int i = 1; i < 10; i++){
		q.push(i);
	}
	bfs();
	sort(L.begin(), L.end());
	int k;
	cin >> k;
	k--;
	cout << L[k] << "\n";
}

int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 2676
fun main(arr:Array<String>) {
    val (a,b) = readLine()!!.split(" ").map { it.toInt() }
    val tmp1 = a/b
    var tmp2 = 0
    if(b % 2 == 0) {
        tmp2 = tmp1
        if(a%b >= b/2) {
            tmp2++
        }
    }
    val ans = Math.pow(tmp1.toDouble(), 3.0) + Math.pow(tmp2.toDouble(), 3.0)
    println(ans.toLong())
}


Measured memory_bytes: 36188
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a, b;   //a String a
        while (sc.hasNext()){
            a = sc.nextInt();
            b = sc.nextInt();
            System.out.println(a+b);
        }
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  string s; cin >> s;
  if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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



int main()
{
	int A,B,C,count = 0;

	cin >> A >> B >> C;



	for(int i=100;i!=0;i--)
	{
		if (A % i == 0 && B % i == 0)
		{
			count++;
		}

		if (count == C)
		{
			cout << i;
			return 0;
		}
			
	}


}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
from itertools import combinations

n = int(input())
l = sorted(map(int, input().split()))
ans = 0

for (i1, a), (i2, b) in combinations(enumerate(l[:-1]), 2):
    i3s = i2 + 1
    i3e = bisect_left(l, a + b, i3s)
    ans += i3e - i3s

print(ans)

Measured memory_bytes: 3316
import bisect
n = int(input())
l_li = list(map(int,input().split()))
l_li.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l_li,l_li[i]+l_li[j])
        num = ind-1 - j
        ans += num
print(ans)


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

#ifdef _DEBUG
#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#else
#define DUMP(x)
#endif

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(r) (r).begin(), (r).end()
using ll = int64_t;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

ll str2ll(string s) {
    ll r = 0;
    rep(i, s.length()) {
        r += (s[i] - '0') * pow(10, s.length() - i - 1);
    }
    return r;
}

void Main() {
    string s; ll result = 0;
    cin >> s;
    rep(bit, 1 << (s.length()-1)) {
        int prev = 0;
        rep(i, (s.length()-1)) {
            if (bit & (1 << i)) {
                result += str2ll(s.substr(prev, i-prev+1));
                prev = i+1;
            }
        }
        result += str2ll(s.substr(prev, s.length()-prev));
    }
    cout << result << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

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

    int N;
    cin >> N;

    int ans = 0;

    for(int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int a,b;
    int ans[101]={0};
    int x=1;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b;
        if(a==b)
            ans[x]++;
        if(a!=b)
            x++;
    }
    sort(ans,ans+x+1);
    if(ans[x]>=3)
        cout<<"Yes"<<endl;
    if(ans[x]<3)
        cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


ll ans;

void rec(const string s, int d, ll sum) {
  if (d == (int)s.size()) {
    ans += sum;
    return;
  }

  ll cur = 0;
  for (int i = d; i < (int)s.size(); i++) {
    cur = cur * 10 + (s[i] - '0');
    rec(s, i+1, sum + cur);
  }
}

int main2() {
  string s; cin >> s;
  ans = 0;
  rec(s, 0, 0);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
n = int(input())
monster = list(map(int,input().split()))

def euclid(num1,num2):
  if num1<num2: num1,num2 = num2,num1
  if num2 != 0: return euclid(num2,num1%num2)
  else: return num1
  
def euclid_list(l):
  ans = euclid(l[0],l[1])
  for i in range(2,n):
    ans = euclid(ans,l[i])
  return ans

ret = euclid_list(monster)
print(ret)

Measured memory_bytes: 14252
X = int(input())
uresisa = 0

while(1):
    if(X >= 500):
        X = X - 500
        uresisa = uresisa + 1000
        continue
    elif(X >= 5):
        X = X - 5
        uresisa = uresisa + 5
        continue
    else:
        break

print(uresisa)
    

Measured memory_bytes: 2940
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
-----------------------
local L, R, d = read.nnn()
local c = 0
for i=L,R do
    if i % d == 0 then
        c = c + 1
    end
end
print(c)

Measured memory_bytes: 2792