akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    REP(i, -100, 100) {
        REP(r, -100, 100) {
            bool complete = true;
            rep(j, 3) {
                if (c[j][0] != (c[j][1] + i)) complete = false;
                if (c[j][0] != (c[j][2] + r)) complete = false;
                //if(r == 0 && i == 1 ) cout << c[j][0] << " " << c[j][1]  + i << " " <<c[j][2] + r << endl;
            }
            if(complete) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep_zero(i, n) for(int i=0; i<n; i++)
#define rep(i, n) for(int i=1; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    int a[5];
    rep_zero(i, 5) cin >> a[i];
    rep_zero(i, 5){
        if(a[i] == 0) cout << i+1 << endl;
    }
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    int ans = 11;
    int a = 0;
    int b = 0;
    int max = 0;
    for(int i = 1; i <= Math.sqrt(n); i++){
      if(n%i == 0){
        a = String.valueOf(i).length();
        b = String.valueOf(n/i).length();
        max = Math.max(a,b);
        if(max < ans){
          ans = max;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

using Edge=pair<int,int>;
using Graph=vector<vector<Edge>>;
int N;
Graph G;

void dfs(int v,int p,int pc,vector<int> &res){
    int color=1;
    if(color==pc)++color;
    for(auto e:G[v]){
        if(e.first==p)continue;
        res[e.second]=color;
        dfs(e.first,v,color,res);
        color++;
        if(color==pc)color++;
    }
}

signed main(){
    cin>>N;
    G.assign(N,vector<Edge>());
    REP(i,N-1){
        int a,b;cin>>a>>b;a--;b--;
        G[a].eb(b,i);
        G[b].eb(a,i);
    }
    int max_color=0;
    REP(i,N)max_color=max(max_color,(int)G[i].size());
    vector<int>res(N-1,-1);
  	dfs(0,-1,-1,res);
    cout<<max_color<<endl;
    for(auto v:res)cout<<v<<endl;
}

Measured memory_bytes: 9728
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <queue>
#include <vector>
using namespace std;
const int N=110000,mo=1e9+7;
int dp[N][4],n;
char ch[N];
void update(int &k1,int k2){
	k1=(k1+k2)%mo;
}
int main(){
	scanf("%s",ch+1);
	dp[0][0]=1; n=strlen(ch+1);
	for (int i=1;i<=n;i++)
		for (int j=0;j<=3;j++)
			for (int k=0;k<3;k++){
				if (ch[i]!='?'&&ch[i]!='A'+k) continue;
				update(dp[i][j],dp[i-1][j]);
				if (j==k+1) update(dp[i][j],dp[i-1][j-1]);
			}
	printf("%d\n",dp[n][3]);
}

Measured memory_bytes: 1920
n, k = map(int, input().split())
P = [*map(lambda x: int(x)-1, input().split())]
C = [*map(int, input().split())]

score = -10**18
for st in range(n):
    lap_cn = lap_sc = sum_sc = 0
    nx = st
    while True:
        lap_cn += 1
        lap_sc += C[nx]
        nx = P[nx]
        if nx == st: break
    lap_sc = max(0, lap_sc)

    for k_cn in range(1, k+1):
        sum_sc += C[nx]
        score = max(score, sum_sc + lap_sc * ((k - k_cn) // lap_cn))
        nx = P[nx]
        if nx == st: break

print(score)


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

int main(){
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for(int i = 0; i < N; i++) cin >> V.at(i);
  for(int i = 0; i < N; i++) cin >> C.at(i);
  
  vector<int> I(N);
  int MaxI = 0;
  for(int i = 0; i < N; i++) I.at(i) = V.at(i) - C.at(i);
  sort(I.begin(), I.end());
  reverse(I.begin(), I.end());
  for(int i = 0; i < N; i++){
    if(I.at(i) < 0) break;
    MaxI += I.at(i);
  }
  cout << MaxI << endl;
}

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

using namespace std;

typedef long long ll;

#define MAX 1024
#define INF LLONG_MAX/4

ll N, W;
ll memo[MAX];
vector<ll> a;

ll solve(int line, int n)
{
    if (n == N) return 0;
    ll &res = memo[n];
    if (res != -1) return res;
    res = INF;
    ll sum = 0;
    for (int i = n; i < N; i++) {
        sum += a[i];
        res = min(res, solve(line + 1, i+1) + abs(sum - W));
    }
    res = min(res, solve(line + 1, N) + max(0LL, sum - W));
    return res;
}

int main()
{
    int T = 1;
    while (cin >> N >> W, N) {
        a.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        memset(memo, -1, sizeof(memo));
        cout << "Case " << T++ << ": " << solve(0, 0) << endl;
    }    
    return 0;
}

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


int main(){
  int n;cin>>n;
  int a[n][3];
  for (int i=0;i<n;i++){
    cin>>a[i][0];cin>>a[i][1];cin>>a[i][2];}
  for (int i=1;i<n;i++){
     a[i][0]+=max(a[i-1][1],a[i-1][2]);
     a[i][1]+=max(a[i-1][0],a[i-1][2]);
     a[i][2]+=max(a[i-1][1],a[i-1][0]);
   //  cout<<a[i][0]<<" "<<a[i][1]<<" "<<a[i][2]<<endl;
}
  cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]))<<endl;
  
 return 0; 
}

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

int main(){
    int a[2];
    cin >> a[0] >> a[1];
    sort(a,a+2);
    for(int i = a[0];i <= a[1];i++){
        if(abs(a[0] - i) == abs(a[1] - i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;
long long cmb(int a, int b){
  long long s=1;
  for(int i=1;i<=b;i++){
    s=s*(a+1-i)/i;
  }
  return s;
}
int main(){
  int n, p;
  cin >> n >> p;
  vector<int> m(2,0);
  int a,i;
  for(i=0;i<n;i++){
    cin >> a;
    m[a%2]++;
  }
  long long ans=(long long)exp2(m[0]),t=0;
  for(i=p;i<=m[1];i+=2){
    t+=cmb(m[1],i);
  }
  ans*=t;
  cout << ans << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    w = I()
    a = LI()
    b = [0] * w
    c = [0] * w
    ti = 0
    for i in range(w):
        k = a[i]
        if k == 0:
            ti = -inf
        elif k < 0:
            if ti < k:
                ti = k
            elif ti < 0:
                ti += 1
        elif ti < 0:
            ti += 1
        b[i] = ti

    ti = 0
    for i in range(w-1,-1,-1):
        k = a[i]
        if k == 0:
            ti = -inf
        elif k < 0:
            if ti < k:
                ti = k
            elif ti < 0:
                ti += 1
        elif ti < 0:
            ti += 1
        c[i] = ti

    r = 0
    for i in range(w):
        if a[i] <= 0:
            continue
        r += min(abs(min(b[i], c[i])), a[i])

    return r




print(main())



Measured memory_bytes: 19800
#include <stdio.h>

int main() {
  int n;
  
  scanf("%d",&n);
  
  if(n==0 || n==1){
    printf("1\n");
    return 0;
  }
  
  int data[n+1];
  int i;
  
  data[0]=1;
  data[1]=1;
  for(i = 2;i <= n;i++) data[i]=data[i-1]+data[i-2];
  printf("%d\n",data[n]);
  return 0;
  
}



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

int main()
{
    int X, Y;
    cin >> X >> Y;
    int prize = 0;
    if (X == 1){
        prize += 300000;
    }else if(X == 2){
        prize += 200000;
    }else if(X == 3){
        prize += 100000;
    }
    if (Y == 1){
        prize += 300000;
    }else if(Y == 2){
        prize += 200000;
    }else if(Y == 3){
        prize += 100000;
    }
    if(X ==  1 && Y == 1){
        prize += 400000;
    }
    cout << prize << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<pair<int,char>> V(M);
	for(int i=0;i<M;i++)cin>>V[i].first>>V[i].second;
	
	for(int i=0;i<1000;i++){
		string t = to_string(i);
		if(t.size()!=N)continue;
		bool f = true;
		for(int j=0;j<M;j++){
			if(t[V[j].first-1]!=V[j].second){
				f=false;
				break;
			}
		}
		if(f){
			cout<<i<<endl;
			return 0;
		}
	}
	
	cout<<-1<<endl;
	
	return 0;
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let s=ts()
  let a=0
  for(let i=0;i<s.length;i++)a+=Number(s[i])
  to(Number(s)%a==0?'Yes':'No')
}
main()


Measured memory_bytes: 7372
def main():
  n = int(input())
  d = list(map(int,input().split()))
  #print(d)
  ans = 0
  for i in range(n):
    for j in range(i+1,n):
    	ans += d[i]*d[j]
  print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
#define N 87

long long int dp[N];

int main(){
    int n;
    cin >> n;
    dp[0] = 2,dp[1] = 1;
    for(int i = 2;i <= n;i++){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;
    return 0;
}

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

const unsigned M = 1000000007;

unsigned pow_mod(unsigned a, unsigned b)
{
    unsigned r = 1;
    while (b != 0) {
        if (b & 0x1)
            r = (1ull * r * a) % M;

        a = (1ull * a * a) % M;
        b >>= 1;
    }
    return r;
}

unsigned nCk(unsigned n, unsigned k)
{
    if (k > n)
        return 0;

    static std::vector<unsigned> f(1, 1);
    static std::vector<unsigned> f_i(1, 1);
    while (f.size() <= n) {
        const unsigned x = (1ull * f.back() * f.size()) % M;
        f.push_back(x);
        f_i.push_back(pow_mod(x, M - 2));
    }

    return 1ull * f[n] * f_i[k] % M * f_i[n-k] % M;
}

void solve(unsigned h, unsigned w, unsigned a, unsigned b)
{
    unsigned r = 0;
    for (unsigned i = b; i < w; ++i) {
        unsigned y1 = h - a - 1;
        unsigned x1 = i;
        unsigned y2 = a - 1;
        unsigned x2 = w - i - 1;
        unsigned p = 1ull * nCk(x1 + y1, x1) * nCk(x2 + y2, x2) % M;
        r = (r + p) % M;
    }
    std::cout << r << '\n';
}

int main()
{
    unsigned h, w;
    std::cin >> h >> w;

    unsigned a, b;
    std::cin >> a >> b;

    solve(h, w, a, b);

    return 0;
}



Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
#define LE(n,m) ((n)<(m)+EPS)
#define GE(n,m) ((n)+EPS>(m))
#define EQ(n,m) (abs((n)-(m))<EPS)
const double EPS=1e-8;
struct Circle{Point center; double r;};

vector<Point> crosspointCC(const Circle &c1,const Circle &c2){
    vector<Point> ps;
    Point ls=c2.center-c1.center;
    double dist=abs(ls);
    double crL=(norm(ls)+c1.r*c1.r-c2.r*c2.r)/(2.0*dist);
    if (EQ(dist,0)||c1.r<abs(crL)) return ps;
    Point dir=ls*Point(0.0,sqrt(c1.r*c1.r-crL*crL)/dist);
    Point mc=c1.center+crL/dist*ls;
    ps.emplace_back(mc+dir);
    if (!EQ(norm(dir),0.0)) ps.emplace_back(mc-dir);
    return ps;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int N,K; cin >> N >> K;
    vector<Point> ps;
    vector<double> cs;
    for (int i=0;i<N;++i){
        double x,y,c; cin >> x >> y >> c;
        ps.emplace_back(x,y);
        cs.emplace_back(c);
    }
    double lb=0,ub=1e9;
    while(ub-lb>1e-7){
        double mid=(ub+lb)/2.0;
        vector<Point> cand;
        vector<Circle> checks;
        for (int i=0;i<N;++i){
            Circle C={ps[i],mid/cs[i]};
            checks.emplace_back(C);
        }
        for (int i=0;i<N;++i){
            cand.emplace_back(ps[i]);
            for (int j=i+1;j<N;++j){
                vector<Point> cps=crosspointCC(checks[i],checks[j]);
                for (Point p:cps) cand.emplace_back(p);
            }
        }
        int ok=0;
        for (Point p:cand){
            int cnt=0;
            for (int i=0;i<N;++i)
                if (LE(abs(p-checks[i].center),checks[i].r))
                    ++cnt;
            if (cnt>=K) ok=1;
        }
        (ok?ub:lb)=mid;
    }
    cout << ub << '\n';
}

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

#define MOD 1000000007

int main() {
	int H, W; cin >> H >> W;
	vector<vector<char> > Grid(H + 1, vector<char>(W + 1)); 
	vector<vector<long long> > sum(H + 1, vector<long long>(W + 1 , 0));
	sum[0][1] = 1;
	for(int i = 1; i <= H; i++) for(int j = 1; j <= W; j++) cin >> Grid[i][j];
	for(int i = 1; i <= H; i++) {
	    for(int j = 1; j <= W; j++) {
	        if(Grid[i][j] != '#') sum[i][j] = (sum[i - 1][j] + sum[i][j - 1]) % MOD;
	    }
	}
    cout << sum[H][W] << endl;
	return 0;
}


Measured memory_bytes: 12164
#include <iostream>
 
using namespace std;
 
int N,A,B,C,D;
int X_SET,Y_SET,X_SUM,Y_SUM;
int main(){
cin>>N>>A>>B>>C>>D;
X_SET = N/A;
if(N%A>0)X_SET=X_SET+1;
Y_SET=N/C;
if(N%C>0)Y_SET=Y_SET+1;
X_SUM=B*X_SET;
Y_SUM=D*Y_SET;
if(X_SUM<Y_SUM)cout<<X_SUM<<endl;
else
cout<<Y_SUM<<endl;
return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>

int main() {
	long long int n, s[5000] = {},m,min=10000000,count=0,x;
	char str[3000];
	scanf("%lld", &n);
	for (int i = 0; i <= 100; i++) {
      	scanf(" %c", &str[i]);
		if (str[i] == 'Y') { printf("Four"); return 0; }
	}
	printf("Three");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//in the name of god;;
using namespace std;
////////////////////////////////////////////////////////
typedef long long ll;                                 //
typedef long double ld;                               //
////////////////////////////////////////////////////////
#define pb push_back                                  //
#define vc vector<ll>                                 //
#define vpl vector<pair<ll, ll> >                     //
#define d double                                      //
#define So(v) sort(v.begin(), v.end())                //
#define Y cout << "YES\n"                             //
#define N cout << "NO\n"                              //
#define rep(x, n) for(ll i = x; i <= n; ++i)          //
#define repp(x, n) for(ll i = n; i >= x; --i)         //
////////////////////////////////////////////////////////
const ll MAXN = 1e6;                                 ///
//////////////////////////////////////////////////////// 
 
 int main(){
    string a;
	cin >> a;
	if(a[a.size() - 1] == 's')cout << a << "es";
	else cout << a << "s";	
 }

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>

int check(int *A, int num, int min_w, int max_w, int truck_n){
    int i = 0;
    int sum = 0;
    int ans = 0;
    int t_n = truck_n;
    int left = min_w;
    int right = max_w;
    int mid;
    
    while (left <= right) {
        
        mid = (left + right)/2;
        t_n = truck_n;
        sum = 0;
        
        for (i = 0; i < num; i++) {
            
            if (sum + A[i] <= mid) {
                sum += A[i];
            }else{
                sum = A[i];
                t_n--;
            }
        }
        
        if (t_n > 0) {
            ans = mid;
            right = mid -1;
        }else{
            left = mid+1;
        }
        
    }
    return ans;
}


int main( ){
    
    int i,n,k, ans, sum;
    int max_v = 0;
    scanf("%d %d", &n, &k);
    
    int w[n];
    
    for (i=0; i<n; i++) {
        scanf("%d", &w[i]);
    }
    sum = 0;
    for (i=0; i<n; i++) {
        if (max_v < w[i]) {
            max_v = w[i];
        }
        sum += w[i];
    }
    
    ans = check(w, n, max_v, sum, k);
    
    printf("%d\n", ans);
    
    return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n,s) for (int i=a;s>0?i<n:i>n;i+=s)
#define rep(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int inf = 1e9+10, mod = 1e9+7; const long long llinf = 1e18;
// head

int main(){
  string s;
  cin >> s;
  string ans;
  rep(i,4) ans += s[i];
  ans += " ";
  rep(i,4,12) ans += s[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
d={}
for i in a:
  if i in d:d[i]+=1
  else:d[i]=1
ans=0
for i in d:ans+=d[i]*(d[i]-1)//2
for i in a:
  m=d[i]*(d[i]-1)//2
  mm=(d[i]-1)*(d[i]-2)//2
  print(ans-m+mm)

Measured memory_bytes: 25716
import unittest
import collections
import bisect


def solve(s, t):
    d = collections.defaultdict(list)
    for i, c in enumerate(s):
        d[c].append(i)
    i = 0
    n = 0
    for c in t:
        if len(d[c]) == 0:
            return - 1
        k = bisect.bisect_left(d[c], i)
        if k == len(d[c]):
            n += 1
            k = bisect.bisect_left(d[c], 0)
        i = d[c][k]+1
    return len(s)*n+i


def main():
    s = input()
    t = input()
    print(solve(s, t))


class TestAbc138_e(unittest.TestCase):
    def test_abc138_e(self):
        self.assertEqual(solve('contest', 'son'), 10)
        self.assertEqual(solve('contest', 'programming'), -1)
        self.assertEqual(solve('contest', 'sentence'), 33)
        self.assertEqual(solve('abc', 'abccccac'), 15)


if __name__ == "__main__":
    # unittest.main()
    main()


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    ll N, K;
    cin >> N >> K;
    // if(K % 2 == 1){
    //     cout << (N/K) * (N/K) * (N/K) << "\n";
    // }else{
    //     if((N/K) * K + (K/2) > N){
    //         cout << 2 * (N/K) * (N/K) * (N/K) << "\n";
    //     }else{
    //         cout << 2 * (N/K) * (N/K) * (N/K) + 3 * (N/K) * (N/K) + 3 * (N/K) + 1 << "\n";
    //     }
    // }
    if(K % 2 == 1){
        cout << ll(pow(N/K, 3)) << "\n";
    }else{
        if((N/K) * K + (K/2) > N){
            cout << 2 * ll(pow(N/K, 3)) << "\n";
        }else{
            cout << 2 * ll(pow(N/K, 3)) + 3 * ll(pow(N/K, 2)) + 3 * (N/K) + 1 << "\n";
        }
    }
    
    return 0;
}

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

int main() {
int N;
  cin>>N;
  int A[2][110];
  for(int i=0; i<2; i++){
   for(int j=0; j<N; j++){
    cin>>A[i][j]; }}
  
  int ans=0;
  for(int x=0; x<N; x++){
    int sum1=0, sum2=0;
    for(int i=0; i<=x; i++){
      sum1+=A[0][i];
    }
    for(int j=x; j<N; j++){
      sum2+=A[1][j]; 
    }
   if(sum1+sum2>ans){ans=max(ans, sum1+sum2);}
  }

  cout<<ans;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int d = sc.nextInt();
        int d1, d10,sum = 0;

        for(int i = 1; i <= m; i++) {
        	for(int j = 22; j <= d; j++) {
        		d1 = j % 10;
                d10 = j / 10;
                sum += (d1 >= 2)&&(d10 >= 2)&&(i == d1 * d10) ? 1: 0;
        		
        	}
        }
        System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define FastRead                      \
                        ios_base::sync_with_stdio(false); \
                        cin.tie(0);
#define endl "\n"
using namespace std;
int main()

{
    FastRead
    int c=0,i;
    string a,b;
    cin>>a>>b;
    for(i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            c++;
    }
    cout<<c;
    return 0;

}


Measured memory_bytes: 3840
N=gets.to_i
A, B=gets.strip.split.map{|i| i.to_i}
P=gets.strip.split.map{|i| i.to_i}
q1=0
q2=0
q3=0
P.each do |i|
    if i>B then
        q3+=1
    elsif i>A then
        q2+=1
    else
        q1+=1
    end
end
puts [q1,q2,q3].min

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

int main() {

  int N;
  cin >> N;
  
  int sum = 0;

  vector<int> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    sum += S[i];
  }

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

  if (sum % 10 == 0) {
    for (int i = 0; i < N; i++) {
      if (S[i] % 10 != 0) {
        sum = sum - S[i];
        break;
      }
    }
    if (sum % 10 == 0) {
      sum = 0;
    }
  }

  cout << sum << endl;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int A=0, B=0, C=0;
	
	cin >> A >> B >> C;
	
	if (A == 5 && B == 5 && C == 7) {
		cout << "YES" << endl;
	}
	else if (A == 5 && B == 7 && C == 5) {
		cout << "YES" << endl;
	}
	else if (A == 7 && B == 5 && C == 5) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 3568
#include<stdio.h>

int main(void) {
	int l, r;

	scanf("%2d%2d", &l, &r);

	if (l <= 12 && 1 <= l) {
		if (r <= 12 && 1 <= r) {
			printf("AMBIGUOUS\n");
		}
		else {
			printf("MMYY\n");
		}
	}
	else {
		if (r <= 12 && 1 <= r) {
			printf("YYMM\n");
		}
		else {
			printf("NA\n");
		}
	}

	return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;

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

  ll k, a, b;
  cin >> k >> a >> b;
  ll c = a / k;
  c++;
  c = c * k;
  if(a % k == 0) cout << "OK" << endl;
  else{
   if(c >= a && c <= b) cout << "OK" << endl;
   else cout << "NG" << endl;
  }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll x;
    cin >> x;

    for(ll a = -118; a < 120; a++) {
        for(ll b = -119; b < 119; b++) {
            if (pow(a,5) - pow(b,5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }


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

Measured memory_bytes: 4068
#include<bits/stdc++.h>
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
using namespace std;
using ll = long long;
const int M = 1e9+7;

int main(){
	// read;
	// write;
	int n,m;
	cin >> n >> m;
	vector<bool> forbid(n+1,false);
	for(int i=1;i<=m;++i){
		int x;
		cin >> x;
		forbid[x]=true;
	}
	vector<ll> dp(n+1);
	dp[0]=1;
	for(int i=1;i<=n;++i){
		for(int j : {i-1,i-2}){
			if(j >= 0 && !forbid[j]) dp[i]=(dp[i]%M + dp[j]%M)%M;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main{

	static long divNum = 1000000007;
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		String[] tmp = s.nextLine().split(" ");
		long m = Long.parseLong(tmp[0]);
		long n = Long.parseLong(tmp[1]);
		System.out.println(calc(m, n));
	}

	public static long calc(long m, long n) {

		if(n == 1)
			return m;
		if(n%2 == 0)
			return calc(((m*m%divNum)), n/2);
		else
			return ((calc(m*m%divNum, n/2) * m)%divNum);
	}
}

Measured memory_bytes: 26172
a, b, c = map(int, input().split())
k = int(input())

for i in range(k):
  if b <= a:
    b = b * 2
  elif c <= b:
    c = c * 2
  else:
    pass

if (a < b) & (b < c):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9172
row , column = map(int,input().split())
b = [[0]*column for i in range(row)]

for i in range(row):
    k = list(map(int,input().split()))
    b[i] = k

for i in range(column):
    a= int(input())
    for j in range(row):
        b[j][i] *= a
    
for i in range(row):
    print(sum(b[i]))
#print(sum([row-1]),end="")



Measured memory_bytes: 5964
#include <stdio.h>
#include <stdint.h>

#define MAX      200000
#define SENTINEL 2000000000

static int L[MAX / 2 + 1];
static int R[MAX / 2 + 1];

static uint64_t merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;

    int i = 0, j = 0;
    uint64_t count = 0;

    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            count += n1 - i;
        }
    }

    return count;
}

static uint64_t mergeSort(int A[], int n, int left, int right)
{

    if (left + 1 < right) {
        int mid = (left + right) / 2;
        uint64_t v1 = mergeSort(A, n, left, mid);
        uint64_t v2 = mergeSort(A, n, mid, right);
        uint64_t v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    } else {
        return 0;
    }
}

int main()
{
    int n;
    int A[MAX];

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

    printf("%llu\n", mergeSort(A, n, 0, n));
}


Measured memory_bytes: 3360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int sec = sc.nextInt() + sc.nextInt() + sc.nextInt() + sc.nextInt();
		
		System.out.println(sec / 60);
		System.out.println(sec % 60);
		
		
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
	int Max1=0,Max2=0;
	int num1=0;
	int N,A;
	cin >> N;
	int loop;
	for(loop=0;loop<N;loop++){
		cin >> A;
		if(A>Max1){
			Max2 = Max1;
			Max1 = A;
			num1 = loop;
		}else if(A>Max2){
			Max2 = A;
		}
	}
	for(loop=0;loop<N;loop++){
		if(loop==num1){
			cout << Max2 << endl;
		}else{
			cout << Max1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main(void){
  int a, b, c, d, e;
  scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
  if(a==0){
    printf("1");
  }
  else if(b==0){
    printf("2");
  }
  else if(c==0){
    printf("3");
  }
  else if(d==0){
    printf("4");
  }
  else{
    printf("5");
  }
  return 0;
}
    

Measured memory_bytes: 1620
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e10;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};


int main(){
    ll S,W; cin>>S>>W;
    if(W>=S) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3628
use std::io;


fn main() {
    let n = read_one::<String>();

    if n == "1" {
        println!("Hello World");
    } else {
        let a = read_one::<usize>();
        let b = read_one::<usize>();
        println!("{}", a + b);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
s=input()
t=input()
q=int(input())
x=[1 if s[i]=='B' else 2 for i in range(len(s))]
y=[1 if t[i]=='B' else 2 for i in range(len(t))]
for i in range(1,len(s)):
  x[i]+=x[i-1]
for i in range(1,len(t)):
  y[i]+=y[i-1]

for i in range(q):
  a,b,c,d=map(int,input().split())
  u=x[b-1]-(x[a-2] if 2<=a else 0)
  v=y[d-1]-(y[c-2] if 2<=c else 0)
  print('YES' if u%3==v%3 else 'NO')

Measured memory_bytes: 13548
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){

  int n, a[3][101];

  cin>>n;
  for(int i=1;i<=2;i++) for(int j=1;j<=n;j++) cin>>a[i][j];

  for(int i=1;i<=2;i++){
    for(int j=1;j<=n;j++){
      if(i==1&&j!=1) a[i][j]+=a[i][j-1];
      else if(i==2){
        if(j==1) a[i][j]+=a[i-1][j];
        else a[i][j]+=max(a[i][j-1], a[i-1][j]);
      }
    }
  }

  cout<<a[2][n]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

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

int min(int x, int y) {
  return x < y ? x : y;
}

int max(int x, int y) {
  return x > y ? x : y;
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  bool flag;
  for (int i = 0; i < k; i++) {
    flag = true;
    for (int j = 1; j <= n; j++) {
      c[j] = 0;
    }
    for (int j = 1; j <= n; j++) {
      c[max(1, j - a[j])] += 1;
      c[min(j + a[j] + 1, n + 1)] -= 1;
    }
    for (int j = 1; j <= n; j++) {
      a[j] = a[j - 1] + c[j];
      if (a[j] != n) {
        flag = false;
      }
    }
    if (flag) {
      break;
    }
  }
  for (int j = 1; j <= n; j++) {
    printf("%d%c", a[j], j == n ? '\n' : ' ');
  }
}


Measured memory_bytes: 3292
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

#define exp orz

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 500000;

int n, m, d;
int len[MaxN + 1];

int pos[MaxN + 1];

int exp[MaxN + 1];

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

	pos[0] = d;
	for (int i = 1; i <= n; ++i)
	{
		len[i] = getint();
		pos[i] = pos[i - 1];
		if (len[i] <= pos[i])
			pos[i] -= len[i];
		else if (len[i] - pos[i] < pos[i])
			pos[i] = len[i] - pos[i];
	}

	exp[n] = 1;
	for (int i = n - 1; i; --i)
	{
		exp[i] = exp[i + 1];
		if (exp[i] > len[i + 1] / 2)
			exp[i] += len[i + 1];
	}

	cin >> m;
	while (m--)
	{
		int x = getint();
		if (exp[x] <= pos[x - 1])
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

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

ll mod_pow(ll x, ll n){
  ll res = 1;
  while (n != 0){
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n = n >> 1;
  }
  return res;
}

ll mod_fact(ll x){
  ll res = 1;
  for (ll i = x; i > 0; i--)
    res *= i, res %= mod;
  return res;
}

ll nCr(ll n, ll r){
  ll nume = mod_fact(n);
  ll deno = mod_fact(r) * mod_fact(n - r) % mod;
  return nume * mod_pow(deno, mod - 2) % mod;
}

int main() {
  int N, M;
  cin >> N >> M;
  ll ans = 1;
  for(int i = 2; i * i <= M; i++) {
    ll cnt = 0;
    while(M % i == 0) {
      M /= i;
      cnt++;
    }
    if(cnt) ans = ans * nCr(N + cnt - 1, cnt) % mod;
  }
  if(M != 1) ans = ans * N % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def resolve():
    n, m = map(int, input().split())

    num_balls = [1] * n
    red_prov = [False] * n
    red_prov[0] = True

    for _ in range(m):
        x, y = map(lambda x: int(x) - 1, input().split())

        # リストnum_ballsを更新
        num_balls[x] -= 1
        num_balls[y] += 1

        # リストred_provを更新
        if red_prov[x]:
            red_prov[y] = True

        if num_balls[x] == 0:
            red_prov[x] = False

    print(sum(red_prov))
    
resolve()

Measured memory_bytes: 10260
#include <bits/stdc++.h>
 
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'
 
int main()
{
	IOS;
	int t=1;
//	cin>>t;
	while(t--)
	{
int a[3];
f(i,0,3)
cin>>a[i];
sort(a,a+3);
int ans=0;
ans+=abs(a[1]-a[0]);
ans+=abs(a[2]-a[1]);
cout<<ans;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, n, max = 0, min = 2000, a;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", &a);
    if(a < min) min = a;
    if(a > max) max = a;
  }
  printf("%d", max - min);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(void){

    double N,T,A,ans=0,tmp;
    
    cin >> N >> T >> A;
    
    vector<double> vec(N);
    REP(i,N) cin >> vec[i];
    
    REP(i,N){
       vec[i] = T - 0.006*vec[i];    
    }

   double min = 9999999999;

   for(int i=0;i<N;i++){
       tmp = A-vec[i];
        if(tmp < 0)  tmp *= -1;
 

        if(min > tmp){
            min = tmp;
            ans= i+1;
        }
       
   }

   cout << ans << endl;
   
}


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


int main() {
	int N; cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	double ans = (v[0]+v[1])/2;
	for (int i = 2; i < N; i++)
	{
		ans = (ans + v[i]) / 2;
	}
	cout << fixed << setprecision(20) << ans << endl;
}

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

long long int gcd (long long int a, long long int b) {
	while (a % b != 0) {
		long long int a_hold = a;
		a = b;
		b = a_hold % b;
	}
	return b;
}

long long int lcm (long long int a, long long int b) {
	long long int aa = a / gcd(a, b);
	long long int bb = b / gcd(a, b);
	long long int ans = aa * bb * gcd(a, b);
	return ans;
}

int main() {
	long long int a, b;
	cin >> a >> b;

	long long int ans = lcm(a,b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <iostream>
#include <cstdio>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2e5+5;
LL K,n;
double a[maxn],eps=1e-6;

bool can(double len)
{
    LL tot=0;
    REP(i,1,n)
    {
        LL x=a[i]/len;
        if(fabs(a[i]-len*x)>eps) x++;
        tot+=x-1;
        if(tot>K) return 0;
    }
    return 1;
}

int main()
{
    n=read(),K=read();
    REP(i,1,n) a[i]=read();
    double l=1e-5,r=1e9,mid;
    while(l<r-0.000001)
    {
        mid=(l+r)/2;
        if(can(mid)) r=mid;
        else l=mid;
    }
    LL x=r+1-eps;
    cout<<x;

    return 0;
}


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

int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
    long long i,j,k,count=0,ans=0,x,y,l,n,sum=0,m,r;
  string s;
  cin>>s;
  n=s.length();
  for(i=0;i<n;i++)
  {
      if(s[i]=='?')
      cout<<'D';
      else
      cout<<s[i];
  }
	return 0;
}

Measured memory_bytes: 3748
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL X,K,D;

LL ans = 0;

void solve(){
	if(X==0){
		if(K%2==0) ans = 0;
		else ans = D;
		return;
	}
	X = abs(X);
	if(X%D==0){
		LL need = X/D;
		if(need==K) ans = 0;
		if(need<K){
			if((K-need)%2LL==0){
				ans = 0;
			}else{
				ans = D;
			}
		}
		if(need>K){
			ans = X - D*K;
		}
		return;
	}
	LL p = abs(X%D);
	LL n = abs(X%D-D);
	if(p<=n){
		LL need = X/D;
		if(need==K) ans = p;
		if(need<K){
			if((K-need)%2LL==0){
				ans = p;
			}else{
				ans = n;
			}
		}
		if(need>K){
			ans = X - D*K;
		}
		return;
	}
	if(n<p){
		LL need = X/D+1LL;
		if(need==K) ans = n;
		if(need<K){
			if((K-need)%2LL==0){
				ans = n;
			}else{
				ans = p;
			}
		}
		if(need>K){
			ans = X - D*K;
		}
		return;
	}
}

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

    solve();

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

Measured memory_bytes: 3192
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll x, ans;

int main() {
    fast_io; cout_precision;
    cin >> x;
    ans = x / 11; ans <<= 1; x %= 11;
    if (x > 6) {
        ans += 2;
    } else if (x > 0) {
        ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		String answer = "";
		
		final int num = scan.nextInt();
		int len = scan.nextInt();
		String[] words = new String[num];
		
		for(int i = 0; i < num; i++){
			words[i] = scan.next();
		}
		
		// ソート
		for(int i = 1; i < num; i++){
			String temp = words[i];
			int j = i - 1;
			while(j >= 0 && words[j].compareTo(temp) > 0){
				words[j + 1] = words[j];
				j--;
			}
			words[j + 1] = temp;
		}
		
		// 全単語の結合
		for(int i = 0; i < num; i++){
			answer = answer.concat(words[i]);
		}
		
		System.out.println(answer);
		
	}
}

Measured memory_bytes: 23380
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	char data[999999];
	
	int i,j,num,check,count = 0;
	
	data[0] = 0;
	data[1] = 1;
	
	for(i=3;i<1000000;i++){
		check = 1;
		if(i%2==0){
			data[i-1]=0;
		}
		if(i%2==1){
			for(j=3;j*j<=i;j+=2){
				if(i%j==0){
					check = 0;
					break;
				}
			}
			if(check == 1){
				data[i-1] = 1;
			}
			else{
				data[i-1] = 0;
			}
		}
	}
	/*
	for(i=0;i<20;i++){
		if(data[i] == 1){
			printf("%d\n",i+1);
		}
	}
	*/
	
	
	while(cin>>num){
		count = 0;
		for(i=0;i<num;i++){
			if(data[i] == 1){
				count++;
			}
		}
		printf("%d\n",count);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1844
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N) ;
    N= N % 10 ;
    if (N==2||N==4||N==5||N==7||N==9)
    {
          printf("hon\n") ;
    }
    else if (N==3)
   {
         printf("bon\n") ;
   }
   else 
   {
        printf("pon\n") ;
   }
   return 0 ;
}


Measured memory_bytes: 1652
#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
//#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double

#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
int32_t main()
{
io

int n;cin>>n;
string s[n];map<string,int>mm;
mm["AC"]=mm["WA"]=mm["TLE"]=mm["RE"]=0;
for(int i=0;i<n;i++)
{
  cin>>s[i];
  mm[s[i]]++;
}
cout<<"AC x "<<mm["AC"]<<endl;
cout<<"WA x "<<mm["WA"]<<endl;
cout<<"TLE x "<<mm["TLE"]<<endl;
cout<<"RE x "<<mm["RE"]<<endl;

}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
int m, n;

int main() {
  int ans=0,r=10;
  rep(_,5){
    int x;
    cin>>x;
    ans+=(x-1)/10*10+10;
    if(x%10!=0) r=min(r,x%10);
  }
  cout<<ans-10+r<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, M, a, b;
	vector<int> from1;
	map<int, bool> toN;
	bool ans = false;

	cin >> N >> M;
	rep(i, M) {
		cin >> a >> b;
		if (a == 1) from1.push_back(b);
		if (b == N) toN[a] = true;
	}

	rep(i, (int)from1.size()) {
		if (toN.count(from1[i]) >= 1) ans = true;
	}

	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;

	return 0;
}


Measured memory_bytes: 5368
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<limits.h>

using namespace std;

int gcd(int a, int b) {
	if (b > a) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

int main(void) {
	int A, B, C;
	cin >> A >> B >> C;
	if (C % gcd(A, B) == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import  math

num = int(input())
val = [int(x) for x in input().split()]

two = 0
four = 0
for i in val:
    if i % 4 != 0 and i % 2 == 0:
        two += 1
    elif i % 2 == 0:
        four += 1

print("Yes" if math.floor((len(val) - abs(two-1 if two > 0 else 0))/2) <= four else "No")

Measured memory_bytes: 14252
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define PI 3.141592653589793
#define MOD 1000000007
//#define MOD 998244353
#define ALL(obj) (obj).begin(),(obj).end()
const ll INF = 1LL << 60;
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() { 
    ll n;
    cin >> n;
    ll x=1,y=1,z=1;
    for (ll i=0;i<n;i++){
        x*=9;
        y*=10;
        z*=8;
        x%=MOD;
        y%=MOD;
        z%=MOD;
    }
    ll ans=y-(x*2-z);
    ans%=MOD;
    if (ans<0)ans+=MOD;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3648
N = int(input())
L = list(map(int,input().split()))

import collections as coll
cnt = coll.Counter(L)
ans = 0
for x in cnt.items():
    if x[0] > x[1]:
        ans += x[1]
    elif x[0] < x[1]:
        ans += x[1] - x[0]
print(ans)

Measured memory_bytes: 68136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while (!(line = br.readLine().trim()).equals("0") && !line.isEmpty()) {

			int goal = Integer.parseInt(line);
			int times = Integer.parseInt(br.readLine().trim());
			int sum = 0;
			for (int i = 0; i < times; i++) {
				line = br.readLine().trim();
				int s = Integer.parseInt(line.substring(0, line.indexOf(' ')));
				int f = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
				sum += f - s;
			}
			System.out.println(sum >= goal ? "OK" : goal - sum);
		}
	}
}

Measured memory_bytes: 17056