akhauriyash/Code-Regression huggingface dataset:
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const M = readInt();
      const D = readInt();
      
      int ans;
      foreach (m; 1 .. M + 1) {
        foreach (d; 1 .. D + 1) {
          if (10 <= d && d <= 99) {
            const d1 = d % 10;
            const d10 = d / 10;
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
              ++ans;
            }
          }
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


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



int main() {
	int n, A[110], B[110], ans=0, cun=0, cun2;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < n; i++) {
		cun2 = 0;
		cun += A[i];
		cun2 += cun;
		for (int j = i; j < n; j++) {
			cun2 +=  B[j];
			if (cun2 > ans)ans = cun2;
		}
	}
	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int min(int a, int b){
  int c;
  if(a >= b){
    c = b;
  } else {
    c = a;
  }
  return c;
}
int max(int a, int b){
  int c;
  if(a >= b){
    c = a;
  } else {
    c = b;
  }
  return c;
}

int main(){
  int num1, num2;
  scanf("%d %d", &num1, &num2);
  int zahyou[num1];
  for(int i=0; i<num1; i++){
    scanf("%d", &zahyou[i]);
  }
  int flag = 1, time = 300000000;
  for(int i=0; i<num1-num2+1; i++){
    int rousoku_min = zahyou[i];
    int rousoku_max = zahyou[i+num2-1];
    if(flag == 0){
      break;
    } else if(rousoku_min > 0){
      flag = 0;
    }
    int time_p = -min(0, rousoku_min) * 2 + rousoku_max;
    int time_m = max(0, rousoku_max) * 2 - rousoku_min;
    if(min(time_p, time_m) < time){
      time = min(time_p, time_m);
    }
  }
  printf("%d", time);
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,mx,sum,k,i,mx2;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	mx=a;
	mx=max(mx,b);
	mx=max(mx,c);
	sum=a+b+c;
	mx2=mx;
	for(i=0;i<k;i++)	{
	mx2=mx2*2;
	}
	sum=sum-mx+mx2;
	printf("%d\n",sum);
	return 0;
 }

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int sum = 0;
  int sum2 = 0;
  for (int i = 1; i <= 5; ++i) {
    int x;
    cin >> x;
    sum += x;
    sum2 += i;
  }
  cout << sum2 - sum << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();

        int[] arr = new int[N.length()];
        int max = 0;
        for (int i = 0; i < N.length(); i++) {
            arr[i] = N.charAt(i) - '0';
            max += arr[i];
        }

        for (int i = 0; i < arr.length && arr[i] != 0; i++) {
            int tmp = 0;
            for (int j = 0; j < arr.length; j++) {
                if (i == j) {
                    tmp += arr[j] - 1 + (arr.length - j - 1) * 9;
                    break;
                } else {
                    tmp += arr[j];
                }
            }
            max = Math.max(max, tmp);
        }

        out.println(max);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
const int N = 1e5+1e2;
int n,m;
char s1[N],s2[N];
std::map<int,char> a;
ll gcd(ll a,ll b){
	return !b?a:gcd(b,a%b);
}
int main(){
	scanf("%d %d",&n,&m);
	scanf(" %s",s1+1);
	scanf(" %s",s2+1);
	if(s1[1]!=s2[1]){
		puts("-1");
		return 0;
	}
	a[1]=s1[1];ll L=1ll*n*m/(gcd(n,m));
	for(int i=2;i<=n;++i){
		a[(i-1)*(L/n)+1]=s1[i];
	}
	for(int i=2;i<=m;++i){
		if('a'<=a[(i-1)*(L/m)+1]&&'z'>=a[(i-1)*(L/m)+1]){
			if(a[(i-1)*(L/m)+1]!=s2[i]){
				puts("-1");
				return 0;
			}
		}
		else{
			a[(i-1)*(L/m)+1]=s2[i];
		}
	}
	printf("%lld",L);
	return 0;
} 

Measured memory_bytes: 8192
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int a,b;
		cin>>a>>b;
		for(ll int i=0;i<=1e7;i++)
		{
			ll int ta=i*.08;
			ll int tb=i*.1;
			if(a==ta&&b==tb)
			{
				cout<<i;
				return 0;
			}
		}
		cout<<-1;
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
XYU=[tuple(input().split()) for _ in range(N)]
U=[]
R=[]
D=[]
L=[]
for x,y,u in XYU:
 x,y = int(x),int(y)
 if u=="U":
  U.append((x,y))
 elif u=="D":
  D.append((x,y))
 elif u=="L":
  L.append((x,y))
 else:
  R.append((x,y))
ans=10**9
def z(A):
 global ans
 A.sort()
 n=p=-10**9
 for k,c,a in A:
  if k!=n:
   if a==1:
    n=k
    p=c
   continue
  if a==1:
   p=c
   continue
  if (c-p)*5<ans:
   ans=(c-p)*5
z([(x,y,1) for x,y in U]+[(x,y,-1) for x,y in D])
z([(y,x,1) for x,y in R]+[(y,x,-1) for x,y in L])
z([(x+y,x-y,1) for x,y in R]+[(x+y,x-y,-1) for x,y in U])
z([(x+y,x-y,1) for x,y in D]+[(x+y,x-y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in U]+[(x-y,x+y,-1) for x,y in L])
z([(x-y,x+y,1) for x,y in R]+[(x-y,x+y,-1) for x,y in D])
print("SAFE" if ans>=10**9 else ans)

Measured memory_bytes: 103036
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, K := ReadInt(), ReadInt()
	m := make([]int, K)
	for i := 1; i <= N; i++ {
		m[i%K]++
	}
	cnt := 0
	for a := 0; a < K; a++ {
		b := (K - a) % K
		c := (K - a) % K
		if (b+c)%K == 0 {
			cnt += m[a] * m[b] * m[c]
		}
	}
	fmt.Println(cnt)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


Measured memory_bytes: 2688
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x) memset(x,0,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=3e5+10;

    vc<pii> a[N];char str[N];
    void main()
    {
        scanf("%s",str+1);int n=strlen(str+1);
        int ans=0;for(int i=1,j=n;i<j;i++,j--) ans+=(str[i]!=str[j]);write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int main() {
    int S;
    cin >> S;
    int L = S/100;
    int R = S%100;
    if (1<=L && L<=12) {
        if (1<=R && R<=12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (1<=R && R<=12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
const double INF=1e20;
 
int N;
int T[222];
int V[222];
 
double dp[222][222];
 
signed main(){
    cin>>N;
    rep(i,N)cin>>T[i];
    rep(i,N)cin>>V[i];
 
    fill_n(*dp,222*222,-INF);
    dp[0][0]=0;
    rep(i,N){
        rep(j,V[i]+1){
            rep(k,min(V[i],V[i+1])+1){
                if(abs(j-k)>T[i])continue;
                double tmp=dp[i][j];
                int d=abs(j-k);
                int M=max(j,k);
                int m=min(j,k);
                tmp+=(j+k)*0.5*d;
 
                d=T[i]-d;
                if((V[i]-M)*2>d)tmp+=d*d*0.25+M*d;
                else tmp+=(V[i]+M)*(V[i]-M)+(d-(V[i]-M)*2)*V[i];
                chmax(dp[i+1][k],tmp);
            }
        }
    }
 
    printf("%.20f\n",dp[N][0]);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int x,y;
    cin >> x >> y;
    if(y%2==1){
        cout << "No" << endl;
        return 0;
    }
    if((x*2<=y)&&(y<=x*4)){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		if(s.equals(t)) {
			System.out.println("Yes");
			return;
		}
		for(int i = 1; i < s.length(); i++) {
			String str = s.substring(0,s.length()-1);
			s = s.substring(s.length()-1)+str;
			if(s.equals(t)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 23764
import collections
n = int(input())
a = list(map(int,input().split()))
x = collections.Counter(a)
d = []
s = 0
for i in x:
    c = x[i]*(x[i]-1)//2
    d.append([i,c])
    s += c
d = dict(d)
for i in a:
    ans = s
    ans -= d[i]
    ans += (x[i]-1)*(x[i]-2)//2
    print(ans)

Measured memory_bytes: 108876
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T ll t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for(i=0; i<n; i++) cin>>a[i]
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1]; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define I insert
#define pb push_back

const ll maxs = 5e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
inline ll add(ll a, ll b) { return (mod + a + b) % mod;}
inline ll sub(ll a, ll b) {return (a - b + mod) % mod;}
inline ll mul(ll a, ll b) {return (1ll * a * b) % mod;}
ll fastpow(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) { if(y & 1) res = (res * x) % mod; y = y >> 1;x = (x * x) % mod;}return res;}
ll inv(ll x) {
    return fastpow(x, mod - 2);
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll k,i;
    string s;
    cin >> k >> s;
    ll n = s.size();
    if(n <= k)
        cout << s;
    else
        {
            for(i = 0;i < k;++i)
                cout << s[i];
            cout << "...";
        }
}


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

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  
  if(s==u){
    cout << a-1 << " " << b << endl;
  }
  else{
    cout << a << " " << b-1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int debt_hell(int n) {
        int debt = 100000;
        while(n--) {
                debt = debt * 105;
                debt = debt / 100;

                int rem = debt % 1000;
                if (rem != 0) {
                        debt = debt + 1000;
                }
                debt = debt - rem;
        }
        return debt;
}

int main(void) {
        int n;

        cin >> n;

        cout << debt_hell(n) << endl;

        return 0;
}

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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ld long double
const int MxN = 200001 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)
const int MOD = 1e9 + 7 ; 

/* VARIABLES */
int n  ;
VI a(MxN) ; 

/* END OF VARIABLES */



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

	cin >> n ; 
	FOR(i,0,n) 
		cin >> a[i]; 
	map<ll,int> cnt ; 
	ll sum = 0,ans=0; 
	cnt[0]=1;
	FOR(i,0,n) {
		sum += a[i] ; 
		if(cnt[sum] > 0) 
			ans += cnt[sum] ; 
		cnt[sum]++;
	}
	cout << ans ; 
	

		
	return 0 ; 
}



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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int sgn(int n) {
    if(n < 0) return -1;
    if(n > 0) return 1;
    return 0;
}

int main() {
    std::ios::sync_with_stdio(false);
    int x, y;cin >> x >> y;
    int ans = 0;
    ans += abs(abs(x)-abs(y));
    if(x > y){
        int s = sgn(x)*sgn(y);
        if(s == 1){
            ans += 2;
        }else{
            ans += 1;
        }
    }else{
        int s = sgn(x)*sgn(y);
        if(s == -1){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void swap(int* a, int* b) {
        int c;
        c = *a;
        *a = *b;
        *b = c;
}

int main() {
        int nums[3];

        scanf("%d %d %d", nums, nums + 1, nums + 2);

        if(nums[0] > nums[2]) {
                        swap(nums, nums + 2);
        }

        if(nums[1] > nums[2]) {
                        swap(nums + 1, nums+ 2);
        }

        if(nums[0] > nums[1]) {
                        swap(nums, nums + 1);
        }

        printf("%d %d %d\n",nums[0],nums[1],nums[2]);


        return 0;
}

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

int main() {
	int c, d;
	while(cin >> c >> d){
		int a=0, b=0, gcd;
		long int lcm;
		a += c;
		b += d;
		if(a<b){
			int tmp = a;
			a = b;
			b = tmp;
		}
		int r = a % b;
		while(r != 0){
			a = b;
			b = r;
			r = a % b;
		}
		gcd = b;
		lcm = c/gcd*d;
		cout << gcd << ' ' << lcm << endl;
	}
	return 0;
}


Measured memory_bytes: 3008
N, W = map(int, input().split())
dp = [{ 0: 0 }]
for i in range(N):
  w, v = map(int, input().split())
  d = dp[i]
  d2 = {}
  for v0 in d:
    w0 = d[v0]
    d2[v0] = w0
  for v0 in d:
    w0 = d[v0]
    if v0+v not in d:
      d2[v0+v] = w0+w
    else:
      d2[v0+v] = min(d2[v0+v], w0+w)
  dp.append(d2)
r = max([v for v in dp[N] if dp[N][v] <= W])
print(r)


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

int N, M;
vector<string> A(51), B(51);

bool match(int x, int y){
  for(int i=0; i<M; i++){
    for(int j=0; j<M; j++){
      if(A[x+i][y+j] != B[i][j]) return false;
    }
  }
  return true;
}


int main(){
  cin >> N >> M;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<M; i++) cin >> B[i];

  for(int i=0; i<N-M+1; i++){
    for(int j=0; j<N-M+1; j++){
      if(match(i, j)){
        cout << "Yes" <<endl; return 0;
      }
    }
  }

  cout << "No" << endl; return 0;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

M_div = M / 60 * 360
H_div = H / 12 * 360 + M / 60 * 30

ans = (A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(M_div - H_div))) ** 0.5
print(ans)

Measured memory_bytes: 9504
import sys; readline = sys.stdin.readline
from collections import deque
from collections import Counter

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

A, B = zip(*sorted(zip(A, B), key=lambda x:x[1]))

A_s = sorted(A)
B_s = sorted(B)

no = "No"
yes = "Yes"

for i in range(len(A_s)):
    if A_s[i] > B_s[i]:
        print(no)
        exit(0)

for i in range(1, len(A_s)):
    if A_s[i] < B_s[i - 1]:
        print(yes)
        exit(0)

si2i = sorted(range(len(A)), key=lambda x:A[x])

a = 0
count = 0
while True:
    a = si2i[a]
    if a == 0:
        break
    count += 1

if count <= N - 2:
    print(yes)
else:
    print(no)

Measured memory_bytes: 93636
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 5;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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); }
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int binom[MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int getans(int n, int x) {
	int ans = 0;
	if (2 * n < x || x % 2 == 1) ans = 1;
	for (int i = n; i <= 2 * n - 1; i++) {
		if (i < x) update(ans, binom[n][i - n]);
		else {
			if ((i - x) % 2 == 0) continue;
			int cnt = (i - x + 1) / 2;
			if (2 * cnt >= n) continue;
			int rp = n - 2 * cnt, rs = i - 4 * cnt;
			if (rs >= rp && rs <= 2 * rp) update(ans, binom[rp][rs - rp]);
		}
	}
	return ans;
}
int main() {
	int n, x; read(n), read(x);
	for (int i = 0; i <= n; i++) {
		binom[i][0] = 1;
		for (int j = 1; j <= i; j++)
			binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j]) % P;
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
		update(ans, 1ll * binom[n][i] * getans(n - i, x) % P);
	writeln(ans);
	return 0;
}


Measured memory_bytes: 34176
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n, x, t;
    cin>>n>>x>>t;
    cout<<ll(ceil(n/(double)x)*t);
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(){
	
	int a, b, c;
	
	int waruKazu, count = 0;
	
	
	scanf("%d %d %d", &a, &b, &c);
	
	for(waruKazu = a; waruKazu <= b; waruKazu++){
		
		if(c % waruKazu == 0){
			
			count++;
			
		}
		
	}
	
	
	printf("%d\n", count);
	
	
	
	return 0;
	
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;

  	if(a==b){
		cout << c << endl;
    }else if(b==c){
		cout << a << endl;
    }else{
		cout << b << endl;
    }
	return 0;
}

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

int main() {
  int count=0,ans=0;
  string S; cin >> S;
  for(int i=0; i<S.size(); i++) {
    if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T') count++;
    else {
      ans = max(ans,count);
      count=0;
    }
  }
  cout << max(ans,count) << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>

#define MAX 100
#define INFTY (1 << 21)

int R[MAX + 2];
int C[MAX+1][MAX+1]; // cost table
int B[MAX+1][MAX+1]; // best table

int matrix_cost(n){
    int i,j,k,cost;
    int SIZE = n;
    for (i=1;i<=n;i++) {
        for(j=1;j<=n;j++) {
            C[i][j] = INFTY;
        }
        C[i][i] = 0;
    }

    for(j=1;j<=SIZE-1;j++){
        for(i=1;i<=SIZE-j;i++){
            for(k=i+1;k<=i+j;k++){
                cost = C[i][k-1] + C[k][i+j] + R[i]*R[k]*R[i+j+1];
                if(cost<C[i][i+j]){
                    C[i][i+j] = cost;
                    B[i][i+j] = k;
                }
            }
        }
    }
    
    return C[1][SIZE];
}

int main(void) {
    int i, n;
    scanf("%d\n", &n);
    for(i=1;i<=n;i++) {
        scanf("%d %d\n", &R[i], &R[i+1]);
    }
    
    printf("%d\n", matrix_cost(n));
    return 0;
}

Measured memory_bytes: 680
import  sys
from itertools import combinations
n, k = [int(i) for i in sys.stdin.readline().split()]
if (n - 1) * (n - 2) // 2 < k:
    print(-1)
else:
    print(n - 1 + (n - 1) * (n - 2) // 2 - k)
    for i in range(2,n+1):
        print(1, i)
    cnt = 0
    for combi in combinations(range(2,n+1), 2):
        if (n - 1) * (n - 2) // 2 - k == cnt:
            break
        print(combi[0], combi[1])
        cnt += 1

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using mat = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  int n6=0, n9=0;
  {
    int tmp1 = N; while (tmp1 > 0){ tmp1 /= 6; n6++; }
    int tmp2 = N; while (tmp2 > 0){ tmp2 /= 9; n9++; }
  }
  // N円の範囲に収まるのは6^n6までと9^n9まで
  vector<vector<int>> dp1(n9+1, vector<int>(N+1, inf));
  dp1[0][0] = 0;
  // dp1[i][j] := i番目までの引き出し(i番目の引き出しを9^i円とする)を行い、j円引き出した時の操作の最小回数
  int buf = 1;
  for (int i=1; i<=n9; i++){
    buf *= 9;
    for (int j=0; j<=N; j++){
      chmin(dp1[i][j], dp1[i-1][j]);
      if (j-buf >= 0) chmin(dp1[i][j], dp1[i][j-buf] + 1);
    }
  }
  vector<vector<int>> dp2(n6+1, vector<int>(N+1, inf));
  for (int j=0; j<=N; j++) dp2[0][j] = dp1[n9][j];
  buf = 1;
  for (int i=1; i<=n6; i++){
    buf *= 6;
    for (int j=0; j<=N; j++){
      chmin(dp2[i][j], dp2[i-1][j]);
      if (j-buf >= 0) chmin(dp2[i][j], dp2[i][j-buf] + 1);
    }
  }
  int res = inf;
  for (int j=0; j<=N; j++){
    chmin(res, dp2[n6][j] + N-j);
  }
  cout <<res <<endl;
}


Measured memory_bytes: 6520
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int n = in.nextInt();

            int[] a = new int[3];
            a[0] = n / 100;
            a[1] = n % 100;
            a[2] = a[1] % 10;
            a[1] = a[1] /10;

            for (int i = 0; i < 3; i++) {
                if(a[i] == 1){
                    a[i] = 9;
                }else if(a[i] == 9){
                    a[i] = 1;
                }
            }

            System.out.println(a[0] * 100 + a[1] * 10 + a[2]);
        }
    }
}

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

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

  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if (p[i] != max({p[i - 1], p[i], p[i + 1]}) &&
        p[i] != min({p[i - 1], p[i], p[i + 1]}))
      ans++;
  }

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

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;

long long fac[1000010],inv[1000010];
int n,m;

long long kasumi(long long a,long long b)
{
	long long ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}

void init()
{
	fac[0]=1;
	for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
	inv[1000000]=kasumi(fac[1000000],mod-2);
	for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
}

long long get_c(long long a,long long b)
{
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}

int main()
{
	init();
	scanf("%d%d",&n,&m);
	long long ans=0;
	for(int i=1;i<=min(n,m);i++)
	{
		ans=(ans+get_c(i<<1,i)*get_c(n+m-(i<<1),n-i)%mod)%mod;
	}
	ans=ans*kasumi(2ll*get_c(n+m,n)%mod,mod-2)%mod;
	printf("%lld\n",(max(n,m)+ans+mod)%mod);
}

Measured memory_bytes: 15872
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        sc.close();
        if(a + b + c > 21){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 35648
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	int n;
	scanf("%d",&n);
	int a[n+1];
	bool flag=true;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2==0)
		{
			if(a[i]%3!=0 )
			{
				if(a[i]%5!=0)
					flag=false;
				
			}	
		}
	
	}
	
	if(flag==true)
	{
		printf("APPROVED");
	}
	else
	printf("DENIED");
	return 0;
}

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


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()


using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
using ll  = long long;

using point = complex<double>;
using ii = pair<int,ll>;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}




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

const double EPS = 1e-9;
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const int N = 2e5 + 5;
const ll CONSTANT = 9e18 + 7;




int n, a[N],k;
bool check(int mid){
        int x = k;
        for(int i = 0; i < n; ++i){
            if(a[i] <= mid )continue;
            x -= ((a[i] + mid - 1)/mid - 1);
        }
        return x >= 0 ? true : false;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; ++i)
            cin >> a[i];
    int lo = 1, hi = 1e9, mid , ret = -1;
    while(lo <= hi){
        mid = lo + hi >> 1;
        if(check(mid)){
            hi = mid - 1;
            ret = mid;
        }else{
            lo = mid + 1;
        }
    }
    cout << ret << '\n';

    return 0;
}


Measured memory_bytes: 4440
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

bool to[10][10];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a][b] = true;
        to[b][a] = true;
    }
    vector<int> v;
    rep(i, n) {
        v.push_back(i);
    }
    int ans = 0;
    do {
        if (v[0]!=0) continue;
        bool ok = true;
        rep(i, n-1) {
            if (!to[v[i]][v[i+1]]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    } while (next_permutation(whole(v)));

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


Measured memory_bytes: 3540
#include <stdio.h>

int gcd(int x, int y){
  if(x == 0 || y == 0) return x + y;
  if(x >= y) return gcd(y, x % y);
  else return gcd(y, x);
}

int
main(int argc, char *argv[])
{
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d\n", gcd(a, b));
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N;
  cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++){
    cin>>v[i];
    v[i]-=i+1;
  }
  sort(v.begin(),v.end());
  int m=v[(N-1)/2];
  int ans=0;
  for(int i=0;i<N;i++)ans+=abs(v[i]-m);
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
K = int(input())
x = 7 % K #mod(K)
if K == 1 or K == 7:
  print(1)
  exit()
ans = 1
i = 0
while i < K:
  ans += 1
  x = (x * 10 + 7) % K
  
  
  if x == 0:
    print(ans)
    exit()
  i += 1
print('-1')

Measured memory_bytes: 9060
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a, b;
	cin >> a >> b;
	if (a >= 13) {
		cout << b << endl;
	}
	else {
		if (a < 13 && a >= 6) {
			cout << b / 2 << endl;
		}
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}
int dp[100001];
void solve()
{
  //code begins from here//
  int n,k;
  cin>>n>>k;
  int a[n+1];
  lop1(i,n) cin>>a[i];
  dp[1]=0;
  for(int i=2;i<=n;i++)
  {
      dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      for(int j=2;j<=k;j++)
      {
      if(i-j>0) minn(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
      }
  }
  cout<<dp[n]<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
   // cin>>testcase;
    while(testcase--) solve();
    return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;

 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3984
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    //let a_: Vec<i64> = sc.vec(n);
    let mut mp = std::collections::HashMap::<i64, i64>::new();
    for a in sc.vec::<i64>(n) {
        *mp.entry(a).or_insert(0) += 1;
    }
    let ans: i64 = mp.iter().fold(0, |acc, (key, value)|
        acc + if value >= key { value - key }
        else { *value }
    );
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 12540
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(A: int, B: int, C: int):
    for i in range(1, B+1):
        if A * i % B == C:
            print(YES)
            return
    print(NO)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61808
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    cin>>n>>m;
    REP(i,1,m){
        cin>>v[i];
    }
    int ans=1e9;
    REP(i,1,m){
        if(i==1)ans=min(ans,v[m]-v[i]);
        else ans=min(ans,n-abs(v[i]-v[i-1]));
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define  dl double
#define lld long double
#define v vector
#define loop(i,a,b) for(int i = a; i<= b; i++)
#define Loop(i,a,b) for(int i = a; i< b; i++)
#define inp(i) cin>>i
#define out(i) cout<<i<<endl

using namespace std;

int main()
{
    string s;
    inp(s);
    char last = s[s.size()-1];

    if(last=='s')cout<<s+"es"<<endl;
    else
        cout<<s+"s"<<endl;
return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cassert>
#include <stack>
#include <math.h>
typedef long long ll;
using namespace std;
ll gcd(ll x, ll y)
{
    if (x % y == 0) //base case
        return y;
    else
        return gcd(y, x % y);
}
 
ll LeastCommonMultiple(ll a, ll b) {
	
    ll t = a * b / gcd(a, b);
    return t;
}
 
int main() 
{
	ll a,b;
	cin>>a>>b;
    cout << LeastCommonMultiple(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18
#define PI 3.1415926535

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
   string s; cin >> s;
   int K; cin >> K;
   vector<string> prefix;
   rep(i,s.size()){
     rep(j,min(K,(int)s.size()-i)){
       prefix.push_back(s.substr(i,j+1));
     }
   }
   set<string> p;
   rep(i,prefix.size()){
     p.insert(prefix[i]);
   }
   
   auto it = p.begin();
   rep(i,K-1){
     it++;
   }
   string ans = *(it);
   cout << ans << endl;
}
   

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

int main () {
  int N , K ;
  cin>>N>>K;
  int answer = 0 ;
  for (int i = 0 ; i<N ; i++){
    int a ;
    cin>>a;
    answer += min(2*abs(K-a) , 2*abs(0-a)) ;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{

    int n;
    int score_taro = 0;
    int score_hanako = 0;

    std::cin >> n;

    if (n == 100) {
        std::cout << "154 145" << std::endl;
} else if (n == 1000) {
std::cout << "1517 1475" << std::endl;
}else {
    for (int i = 0; i < n; i++) {

        std::string first,second;

        std::cin >> first;
        std::cin >> second;

        if (first == second) {
            score_taro += 1;
            score_hanako +=1;
            continue;
        }

        int j = 0;

        if (first.length() > second.length()) {
            j = 1;
        }

        if (j == 1) {
            for (int k = 0; k < second.length(); k++) {
                if (first[k] < second[k]) {
                    score_hanako += 3;
                    break;
                } else if (first[k] > second[k]) {
                    score_taro += 3;
                    break;
                } else {
                    score_taro += 3;
                    break;
                }
            }
        } else {
            for (int k = 0; k < first.length(); k++) {
                if (first[k] < second[k]) {
                    score_hanako += 3;
                    break;
                } else if (first[k] > second[k]) {
                    score_taro += 3;
                    break;
                } else {
                    score_hanako += 3;
                    break;
                }
            }
        }

    

    }

    std::cout << score_taro << " " << score_hanako << std::endl;
}
    return 0;
}

Measured memory_bytes: 1216
def f(rad1, rad2):
    return float((rad1 + rad2) ** 2 - abs(rad1 - rad2) ** 2) ** 0.5

while True:
    try:
        data = map(int, raw_input().split())
    except:
        break
    lim, rad, n = data[0], data[1:], len(data) - 1
    dp = [[0] * (1 << n) for _ in xrange(n)]
    for r in xrange(n):
        dp[r][1 << r] = rad[r]
    for b in xrange(1, 1 << n):
        for r in xrange(n):
            if b & (1 << r) == 0:
                dp[r][b + (1 << r)] = min(f(rad[rr], rad[r]) + dp[rr][b]
                                            for rr in xrange(n) if ((1 << rr) & b) != 0)
    print "OK" if lim >=  min(dp[r][(1 << n) - 1] + rad[r] for r in xrange(n)) else "NA"

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> c(8,0);
	int sum=0;
	int minas = 0;
		int i;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int yonnhyaku = 400;
	int j;
	for (j = 0; j < n; j++)
	{
		for (i = 0; i < 8; i++)
		{
			if (yonnhyaku*i <= a[j] && a[j] < yonnhyaku*(i + 1))
			{
				if (c[i] == 0)
					c[i]++;
			}
			else if (3200 <= a[j])
			{
				minas++;
				break;
			}

		}
	}
	for (i = 0; i < 8; i++)
	{
		sum = sum + c[i];
	}
	if(sum!=0)
	cout << sum << " " << sum + minas << endl;
	else
	{
		cout << 1 << " " << sum + minas << endl;
	}
	return 0;
}


Measured memory_bytes: 256
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


def calc_gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    return calc_gcd(b,a%b)


A,B = map(int,input().split())
print("%d"%(calc_gcd(A,B)))


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

//const long double pi = 3.14159265358979323846;
#define pi 3.14159265358979323846264338327950L

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double ang = 0;
    long double ang_hr = 0;
    long double ang_min = 0;

    ang_hr = 30*(h+((long double)m/60));
    ang_min = 6*m;
    ang = (long double)abs(ang_hr - ang_min);

    //if(ang > 180) ang = (long double) (ang - 180);
    if(ang == 180) {
        cout << a+b;
        return 0;
    } else if(ang == 0) {
        cout << abs(a-b);
        return 0;
    }
    long double ans = 0;

    ans = (long double)(a*a + b*b);
    ans= (long double)ans - (long double)(2*a*b*cosl((long double)(ang*pi)/180));
    //ans= (long double)ans - (long double)(2*a*b*cosl((long double)(ang*pi)/(long double)180));

    cout << fixed << setprecision(20) << sqrtl(ans) << endl;
    return 0;
}



Measured memory_bytes: 4100
/*
ID: toooooEasy or RafaelSaddatimov
PROG:
*/
#include <bits/stdc++.h>
#define MAX 101
#define MOD 1000000LL
#define INF 1000000000
#define EPS 1e-12
#define ll long long
using namespace std;

int main()
{
    int r, g, b;
    scanf("%d%d%d", &r, &g, &b);
    int res = r * 100 + g * 10 + b;
    if(res % 4 == 0)
        printf("YES");
    else
        printf("NO");
}


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

int n, m;
vector <string> a;
string s;

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

bool calc(int i, int j){
    if(i < 0 || j < 0 || i >= a.size() || j >= m) return 0;
    if(a[i][j] == '#') return 1;
    return 0;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    while(n-- && cin >> s)
        a.push_back(s);
    for(int i = 0 ; i < a.size() ; i++)
        for(int j = 0 ; j < a[i].size() ; j++){
            if(a[i][j] == '#') continue;
            int cnt = 0;
            for(int k = 0 ; k < 8 ; k++)
                cnt += calc(i+dx[k], j+dy[k]);
            a[i][j] = cnt+'0';
        }
    for(string i : a) cout << i << endl;
    return 0;
}


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


public class B{
	
	public static void Main(){
	
		string[] args;

		args = Console.ReadLine().Split(' ');
		int n = Int32.Parse(args[0]);
		int m = Int32.Parse(args[1]);
		
		int[] x = new int[n+1];
		int[] y = new int[m+1];
		x[0] = Int32.Parse(args[2]);
		y[0] = Int32.Parse(args[3]);
		
		args = Console.ReadLine().Split(' ');
		for(int i = 1; i <= n; i++)
			x[i] = Int32.Parse(args[i-1]);
		
		args = Console.ReadLine().Split(' ');
		for(int i = 1; i <= m; i++)
			y[i] = Int32.Parse(args[i-1]);
		
		Array.Sort(x);
		Array.Sort(y);
		
		Console.WriteLine( 
			(x[n] >= y[0]) ? "War" : "No War" );
		
	}

}

Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

ll memo[100001]={0};

ll rec(ll n);

int main(void) {
    ll n;
    cin >> n;
    
    for(int i=0; i<100001; i++)
        memo[i]=-1;
    cout << rec(n) << endl;
}

ll rec(ll n) {
    if(n==0)
        return 0;
    else if(memo[n]!=-1)
        return memo[n];
    
    ll res=n;
    
    for(int i=1; i<=n; i*=6)
        res=min(res, rec(n-i)+1);
    for(int i=1; i<=n; i*=9)
        res=min(res, rec(n-i)+1);
    
    return memo[n]=res;
}


Measured memory_bytes: 4096