akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;

namespace std{
  bool operator < (const P &a,const P &b){
    return (a.imag()==b.imag()?
            a.real()<b.real():
            a.imag()<b.imag());
  }
};

double eps=1e-8;
double PI=acos(-1);

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}

double Arg(P a,P b,P c){
  b-=a,c-=a;
  return arg(c*conj(b));
}

int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;  
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;// on
    sum+= Arg(p,a,b);
  }
  if( abs(sum) < eps )return 0;//out
  else  return 2;//in
}

typedef pair<double,P> Pair;

vec andrewScan(vec &t){
  int N=t.size(),C=0;
  vec R(N);
  for(int i=0;i<N;i++){
    while(2<=C&&ccw(R[C-2],R[C-1],t[i])==-1)C--;
    R[C++]=t[i];
  }
  vec res(C);
  for(int i=0;i<C;i++)res[i]=R[i];
  return res;
}

vec ConvexHull2(vec &t){
  sort(t.begin(),t.end());
  vec u=andrewScan(t);
  reverse(t.begin(),t.end());
  vec l=andrewScan(t);
  for(int i=1;i+1<(int)l.size();i++)u.push_back(l[i]);
  return u;
}

vec ConvexHull(vec &t){
  vector<Pair> u;
  vec R;
  int N=t.size(),K=0,C=0;
  for(int i=1;i<N;i++)if(t[i]<t[K])K=i;
  for(int i=0;i<N;i++)u.push_back(Pair(arg(t[i]-t[K]),t[i]));
  R.push_back(t[K]),C++;
  sort(u.begin(),u.end());
  for(int i=0;i<N;i++){
    P p=u[i].second;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==0)continue;
    if(2<=C&&ccw(R[C-2],R[C-1],p)==2)continue;
    while(2<=C&&ccw(R[C-2],R[C-1],p)!=1)R.pop_back(),C--;
    R.push_back(p),C++;    
  }
  return R;
}

int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  vec ans=ConvexHull2(t);
  vec ans2=ConvexHull(t);
  assert( eq(calcArea(ans),calcArea(ans2) ) );
  cout<<ans.size()<<endl;
  for(int i=0;i<(int)ans.size();i++){
    cout<<(int)ans[i].real()<<' '<<(int)ans[i].imag()<<endl;
  }
  return 0;
}

Measured memory_bytes: 10392
#include <stdio.h>
#include <math.h>

main() {
    int N,A;
    double T,H[10000];
    scanf("%d%lf%d",&N,&T,&A);
    for (int i = 0; i < N; ++i) {
        scanf("%lf",&H[i]);
        H[i]=fabs(A-(T-H[i]*0.006));
    }
    int minI=0;
    double min=H[0];
    for (int i = 0; i < N; ++i) {
        if (min>H[i]){
            min=H[i];
            minI=i;
        }
    }
    printf("%d",minI+1);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
long long int solve(int n,vector<int> v)
{
    int dp[n+1];
    int i;
    dp[n]=0;
    dp[n-1]=abs(v[n-1]-v[n-2]);
    for(int i=n-2;i>0;i--)
    {
dp[i]=min(dp[i+1]+abs(v[i-1]-v[i]),dp[i+2]+abs(v[i-1]-v[i+1]));
    }
    
    // for(int i=1;i<n+1;i++)
    // cout<<dp[i]<<endl;
return dp[1];
}
int main()
{
    int n;
    cin >>n;
    int i;
    int input;
    vector<int> v;
    f(i,0,n)
    {
cin >>input;
v.push_back(input);
    }
    long long int ans=solve(n,v);
    cout<<ans;
}

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

Measured memory_bytes: 128
S = input()
N = len(S)

bef = ''
i = 0
count = 0
while i < N:
  s = S[i]
  while s == bef:
    i += 1
    if i >= N:
      print(count)
      exit()
    else:
      s += S[i]
  
  bef = s
  i += 1
  count += 1
  
print(count)
    
  

Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstring>
#include <vector>

using namespace std;
int main()
{
    string s1 , s2 ;
    cin >> s1 >> s2 ;
    cout << s2 + s1 << endl;
    return 0;
}




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

using namespace std;

int main() {
	string str;
	getline(cin, str);
	for (int i = 0; i < str.size(); i++) {
		if ('a' <= str[i] && str[i] <= 'z') {
			str[i] -= 32;
		}
	}
	cout << str << endl;
	return 0;
}

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

bool IsMultiplicationTable(int N){
    bool Multiplication_flg=false;
    for(int i=1;i<10;i++){
        if(N%i==0 && N/i<10){
           Multiplication_flg=true;
           break;
        }
    }
    if(Multiplication_flg==true){
        return true;
    }
    else{
        return false;
    }
}

int main(){
    int N; cin >> N;
    if(IsMultiplicationTable(N)==true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

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

  vector<int> A(N);
  map<int, int> mp;
  rep(i,0,N-1) {
    cin >> A[i];
    mp[A[i]]++;
  }

  int cnt = N;
  rep(i,0,N-1) {
    int a = A[i];
    mp[a]--;

    for (int j = 1; j * j <= a; j++) {
      if (a % j == 0) {
        int d1 = j;
        int d2 = a / j;
        if (mp[d1] > 0 || mp[d2] > 0) {
          cnt--;
          break;
        }
      }
    }

    mp[a]++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 32676
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

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

int main(void){
	int a=in(),b=in(),c=in(),d=in(),l,r;
	l=a+b;
	r=c+d;
	if(l==r)puts("Balanced");
	else if(l>r)puts("Left");
	else puts("Right");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 1000006

using namespace std;

int n;
int a[N], b[N];

bool check(int);

int main(){
	scanf("%d", &n);n = n * 2 - 1;
	int l = 999999999, r = 0, ans;
	for(int i = 1; i <= n; ++i)
		scanf("%d",a + i), l = min(l, a[i]), r = max(r, a[i]);
	while(l <= r){
		int mid = l + r >> 1;
		if(check(mid)) l = mid + 1, ans = mid;
		else r = mid - 1;	
	//	cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

bool check(int x){
	int cnt1 = 0, cnt2 = 0;
	for(int i = 1; i <= n; ++i)
		if(a[i] >= x) b[i] = 1, ++cnt1;
		else b[i] = 0, ++cnt2;
	b[0] = -1;b[n + 1] = -1;
	int pos = n / 2 + 1, tmp1 = 0, tmp2 = 0;
	while(b[pos + tmp1 + 1] != b[pos + tmp1] && pos + tmp1 <= n) ++tmp1;
	while(b[pos - tmp2 - 1] != b[pos - tmp2] && pos - tmp2 >= 1) ++tmp2;
//	cout << x << endl;for(int i = 1; i <= n; ++i) cout << b[i] << ' ';cout << endl;cout << tmp1 << ' ' << tmp2 << endl;
	if(tmp1 == tmp2){
		if(pos - tmp2 == 0)
			return cnt1 > cnt2;	
		else return b[pos - tmp1];
	}
	else{
		if(tmp1 < tmp2) return b[pos + tmp1];
		else return b[pos - tmp2];
	}
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
long long int a, b, s = 1, i;
int main(){
	//ios::sync_with_stdio(0), cin.tie(0);
	//cout<< fixed<< setprecision(10) << x << endl;
	cin>>a>>b;
	while(s < b){
	    s += a - 1;
        i++;
	}
	cout<<i<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    while (cin >> n >> k, n|k){
        vector<vector<int>> v(n, vector<int>(n, INF<int>));
        for (int i = 0; i < n; ++i) {
            v[i][i] = 0;
        }
        for (int i = 0; i < k; ++i) {
            int a;
            scanf("%d", &a);
            if(a == 0){
                int p, q;
                cin >> p >> q;
                cout << (v[p-1][q-1] != INF<int> ? v[p-1][q-1] : -1) << "\n";
            }else {
                int c, d, e;
                cin >> c >> d >> e;
                if(v[c-1][d-1] > e){
                    v[c-1][d-1] = e;
                    for (int l = 0; l < n; ++l) {
                        for (int m = l; m < n; ++m) {
                            v[m][l] = v[l][m] = min(v[l][m], e + min(v[l][c-1]+v[d-1][m], v[l][d-1]+v[c-1][m]));
                        }
                    }
                }
            }
        }
    } 
    
    return 0;
}



Measured memory_bytes: 3264
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

p=n+1
ans =0

for n in range(n):
    ans += b[a[n]-1]
    if p+1 == a[n]:
        ans += c[p-1]
    p = a[n]
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if(a<b) swap(a,b);
    if(a<c) swap(a,c);
    if(b<c) swap(b,c);

    if(3*a%2==(a+b+c)%2){
        cout << (2*a - b - c)/2 << endl;
    }
    else{
        cout << (2*a + 3 - b - c)/2 << endl; 
    }

   return 0;
}


Measured memory_bytes: 256
package main

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

func solve() {
	cnt := make(map[string]int)

	n := getInt()
	for i := 0; i < n; i++ {
		s := getString()
		cnt[s]++
	}

	m := getInt()
	for i := 0; i < m; i++ {
		t := getString()
		cnt[t]--
	}

	ans := 0
	for _, c := range cnt {
		ans = max(ans, c)
	}
	fmt.Fprintln(wr, ans)
}

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

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
# import sys
from sys import stdout
# from copy import copy, deepcopy
# from functools import lru_cache
# from string import ascii_lowercase
# from math import inf
# inf = float('inf')


def main():
    ans = solve_case()
    stdout.write("{}\n".format(ans))

def solve_case():
    S = read_str()

    len_s = len(S)
    int_s = [ord(c) - ord('a') for c in S]

    # next_char_pos[from_idx][letter_idx] := the position of the next letter `letter_idx` from `from_idx`
    next_char_pos = make_list((len_s + 1, 26), len_s)
    for from_idx in reversed(range(len_s)):
        for letter_idx in range(26):
            if int_s[from_idx] == letter_idx:
                pos = from_idx
            else:
                pos = next_char_pos[from_idx+1][letter_idx]
            next_char_pos[from_idx][letter_idx] = pos

    # non_subseq_len[from_idx] := the length of the shortest "non subsequence" in S[from_idx:]
    non_subseq_len = make_list([len_s + 2], len_s + 1)
    non_subseq_len[len_s] = 1
    non_subseq_len[len_s + 1] = 0
    ans_next_pos = make_list([len_s + 1], len_s)
    ans_letter = make_list([len_s + 1], -1)
    for from_idx in reversed(range(len_s)):
        for letter_idx in range(26):
            new_len = non_subseq_len[next_char_pos[from_idx][letter_idx] + 1] + 1
            if non_subseq_len[from_idx] > new_len:
                non_subseq_len[from_idx] = new_len
                ans_letter[from_idx] = letter_idx
                ans_next_pos[from_idx] = next_char_pos[from_idx][letter_idx] + 1

    ans = ''
    idx = 0
    while idx < len(S):
        ans += chr(ord('a') + ans_letter[idx])
        idx = ans_next_pos[idx]
    return ans

#################################

def read_str(): return input()
def read_int(): return int(input())
def read_str_list(): return input().split(' ')
def read_int_list(): return list(map(int, input().split(' ')))
def read_lines(n, read_func): return [read_func() for _ in range(n)]
def list_to_str(l, sep=' '): return sep.join(map(str, l))
l2s = list_to_str
# shape: tuple of ints | list of ints
def make_list(shape, value=None):
    if len(shape) == 1:
        return [value] * shape[0]
    return [make_list(shape[1:], value) for _ in range(shape[0])]

if __name__ == '__main__':
    # sys.setrecursionlimit(1000000)
    main()


Measured memory_bytes: 112376
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int i;
	for(i=n-1;i>=0;i-=2)cout<<a[i]<<" ";
	if(i==-1)i=0;
	else if(i==-2)i=1;
	for(;i<n;i+=2)cout<<a[i]<<" ";
}
	

Measured memory_bytes: 2944
#include <iostream>
#include <stack>
#include <deque>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define mp make_pair
#define fname ""
#define fi first
#define se second
#define sz(a) (int)a.size()
#define pb push_back
#define fo(i,k,n) for(int i=k; (int)i<n; ++i)
#define rep(i,n,k) for(int i=n; (int)i>=k; --i)
#define all(v) v.begin(), v.end()
#define it ::iterator
#define forit(it,v) for(__typeof(v.begin()) it = v.begin(); it != v.end(); ++it)


const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int N = 100100;

int n, a[1111];

int main(){
    
//freopen(fname"in", "r", stdin);
//freopen(fname"out", "w", stdout);

	cin>>n;

	fo(i,0,n){
		scanf("%d", &a[i]);
	}

	sort(a, a+n);

	cout<<a[n-1] - a[0];
    
    return 0;
}









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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=1000000007; //998244353; //
const ld PI=3.1415926535898;
const ld EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}

int main(){
	int n;
	scanf("%d",&n);
	ll a[n];
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(a[i]==0){printf("0");return 0;}
	}
	ll res=1;
	ll big=1000000000000000000LL;
	for(int i=0;i<n;i++){
		ll arr=a[i];
		ll x=big/arr;
		if(res>x){printf("-1");return 0;}
		res*=arr;
		if(res<0||res>big){printf("-1");return 0;}
	}
	printf("%lld",res);
}


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

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

    for(int i = 0; i < s.length(); i++){
        char k = s[i];
        int num = k - 'A';
        num += n;
        num %= 26;
        char nk = 'A' + num;
        cout << nk;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3144
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;
struct graph {
	struct node {v n; int gid = 0;};
	vector<node> nodes;
	int gid_counter = 1;

	graph(int n) {
		nodes.resize(n);
	}
	void read(int n) {
		while (n--) {
			int s = in(), t = in();
			nodes[s].n.push_back(t);
			nodes[t].n.push_back(s);
		}
	}
	void traverse(int id, int gid) {
		node &n = nodes[id];
		if (n.gid)
			return;
		n.gid = gid ? gid : gid_counter++;
		for (int i: n.n)
			traverse(i, n.gid);
	}
	void traverse() {
		int i = 0;
		for (node &n: nodes)
			traverse(i++, n.gid);
	}
	bool find(int s, int t) {
		return nodes[s].gid == nodes[t].gid;
	}
};

int main() {
	int n = in(), m = in();
	graph g(n);
	g.read(m);
	g.traverse();
	int q = in();
	while (q--) {
		int s = in();
		out(g.find(s, in())? "yes" : "no", '\n');
	}
}



Measured memory_bytes: 10980
#include <stdio.h>
int main(){
  int a,b,c,x;
  int i,j,k,count=0;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&x);
  
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
      for(k=0;k<=c;k++){
        if(500*i+100*j+50*k==x){
          count++;
        }
      }
    }
  }
  printf("%d",count);
}


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

using namespace std;

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> c(h, vector<char> (w,' '));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin>>c[i][j];
    }
    int ans = 0;
    int black = 0;
    for(int row=0;row< 1<<h;++row){
        for(int col=0;col< 1<<w;++col){
            black = 0;
            for(int i=0;i<h;++i){
                for(int j=0;j<w;++j){
                    if(((row>>i) & 1) == 0 && ((col>>j) & 1) == 0 && c[i][j] =='#')
                        ++black;
                }
            }
            if(black == k)
                ++ans;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int N,M,X,count=0;
  cin >> N >> M >> X;

  vector<int> vec(M);
  for (int i=0;i<M;i++)
  	cin >> vec.at(i);

  for (;X<N;X++) {
  	for (int i=0;i<M;i++) {
  		if (X==vec.at(i))
  			count++;
  	}
  }
  cout << min(count,M-count) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[31];

int main() {
  int t;
  while (cin >> t) {
    a[t]++;
  }
  for (int i = 1; i < 31; i++) {
    if (a[i] == 0) {
      cout << i << '\n';
    }
  }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int digits[20] = {1};
    int d = 1;
    auto succ = [&]() {
        for (int i = 0; i < d; i++) {
            if (i == d - 1 || (digits[i] + 1 <= 9 && abs(digits[i + 1] - (digits[i] + 1)) < 2)) {
                digits[i]++;
                if (digits[i] >= 10) {
                    digits[i + 1] = 1, digits[i] = 0, d++;
                }
                for (int j = i - 1; j >= 0; j--) {
                    digits[j] = max(0, digits[j + 1] - 1);
                }
                break;
            }
        }
    };
    auto output = [&]() {
        for (int i = d - 1; i >= 0; i--) {
            assert(0 <= digits[i] && digits[i] <= 9);
            cout << digits[i];
        }
        cout << endl;
    };
    int K; cin >> K;
    for (int i = 0; i < K - 1; i++) succ();
    output();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
typedef long long ll;
ll a[N],b[N];
int n;
ll sum1,sum2;
int main(void){
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%lld",a+i);
    for(int i=1;i<=n;i++) scanf("%lld",b+i);
    for(int i=1;i<=n;i++) {
        if(a[i] > b[i]) sum1 += (a[i] - b[i]);
        if(a[i] < b[i]) sum2 += (b[i] - a[i])/2;
    }
    if(sum1 <= sum2) puts("Yes\r");
    else puts("No");
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

int n, t;

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

	ll last = 0;
	ll ans = 0;

	REP(i, n)
	{
		ll dt;
		cin >> dt;
		dt -= last;

		if (dt > t)
			ans += t;
		else
			ans += dt;

		last = last + dt;

	}
	ans += t;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	ll arr[n],i,j,k,x,y;
	for(i=0;i<n;i++)
		cin>>arr[i];
	pair<ll,ll> mat[n][n];
	for(i=0;i<n;i++)
	{
		j=0;
		k=i;
		while(j<n && k<n)
		{
			if(j==k)
			{
				mat[j][k].first=arr[j];
				mat[j][k].second=0;
			}
			else
			{
				x=arr[j]+mat[j+1][k].second;
				y=arr[k]+mat[j][k-1].second;
				if(x>y)
				{
					mat[j][k].first=x;
					mat[j][k].second=mat[j+1][k].first;
				}
				else
				{
					mat[j][k].first=y;
					mat[j][k].second=mat[j][k-1].first;
				}
			}
			j++;
			k++;
		}
	}
	/*for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			cout<<mat[i][j].first<<" "<<mat[i][j].second<<"   ";
		cout<<endl;
	}*/
	cout<<mat[0][n-1].first-mat[0][n-1].second<<endl;
	return 0;
}

Measured memory_bytes: 140928
def search(now, teleporter, limit):
    visit = [-1] * len(teleporter)
    cnt = 0
    
    while visit[now] == -1:
        if limit <= cnt:
            break
        
        visit[now] = cnt
        cnt += 1
        now = teleporter[now]
        
    
    return now, cnt, cnt - visit[now]
    

n, k = map(int, input().split())
a = [int(x) - 1 for x in input().split()]

start, initial_cnt, repeat_num = search(0, a, 10**6)

#print(start, initial_cnt, repeat_num)

if k < initial_cnt:
    start = 0
    r = k
else:
    r = (k - initial_cnt) % repeat_num

#print(r)

ans, _, _ = search(start, a, r)

print(ans + 1)

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


void solve()
{
	
ll a,ans;
for(int i=0;i<5;i++)
{
	cin>>a;
	if(a==0)ans=i+1;
}


 
 
 cout<<ans;
 
	
	

}




int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

#define MOD 1e7+7
typedef long long ll;

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

ll mylcm(ll a, ll b) { return a / mygcd(a, b) * b; }

ll mymax(ll a, ll b) { return (a > b) ? a : b; }

ll mymin(ll a, ll b) { return (a < b) ? a : b; }

ll myasc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }

ll mydsc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }

bool flag;
ll n ;

int main() {
	scanf("%lld", &n);
	printf("%lld", n / 3);

	return 0;
}


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

int main() {
  int x, y;
  bool ans = false;
  cin >> x >> y;
  for (int i = 0; i <= x; i++)
  {
    if (4*x -2*i == y)
    {
      ans = true;
      break;
    }
    
  }
  if (ans == true)
  {
    cout << "Yes" << endl;
  }else
  {
    cout << "No" << endl;
  }
  
  return 0;

}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

using namespace std;
//typedef long long unsigned int ll;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

//#define MAX_N 100000

int main(void){
  int h, w;
  int a[80][80];
  int b[80][80];
  int c[80][80];
  bool dp[80][80][12801];
  //bool dp[80][80][12801];

  cin >> h >> w;
  int z = 80 * (h + w) + 1;

  REP(i, h){
    REP(j, w){
      cin >> a[i][j];
    }
  }

  REP(i, h){
    REP(j, w){
      cin >> b[i][j];
    }
  }

  REP(i, h){
    REP(j, w){
      c[i][j] = abs(a[i][j] - b[i][j]);
    }
  }

  dp[0][0][c[0][0]] = 1;

  REP(i, h+w-1){
    REP(x, min(i+1, h)){
      int y = i - x;
      if(y >= w){
        continue;
      }
      REP(j, z){
        if(dp[x][y][j] == 1){
          if (x < h-1){
            dp[x + 1][y][j + c[x + 1][y]] = 1;
            dp[x + 1][y][abs(j - c[x + 1][y])] = 1;
          }
          if (y < w-1){
            dp[x][y + 1][j + c[x][y + 1]] = 1;
            dp[x][y + 1][abs(j - c[x][y + 1])] = 1;
          }
        }
      }
    }
  }

  REP(i, z){
    if (dp[h-1][w-1][i] == 1){
      cout << i;
      return 0;
    }
  }
}

Measured memory_bytes: 80256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d) {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")

	}
}

// mathパッケージの関数にintが使えるようにラップ
func abs(a int) int {
	return int(math.Abs(float64(a)))
}

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

int main(){
  int N;
  string s;
  cin >> N >> s;
  int ans = 1;
  for(int i = 1; i < N; i++){
    if(s[i - 1] != s[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()
string s;
vector<string> pp(10);
ll ans = 0;

void func()
{
	int b = 0;
	for (int i = 1; i < s.size(); ++i)
	{
		if (pp[i] == "+")
		{
			ans += stoll(s.substr(b, i - b));
			b = i;
		}
	}
	ans += stoll(s.substr(b, s.size() - b));
	return;
}

void dfs(int now)
{
	if (now == s.size())
	{
		func();
		return;
	}

	pp[now] = "-";
	dfs(now + 1);
	pp[now] = "+";
	dfs(now + 1);
	return;
}

int main()
{
	cin >> s;
	fill(all(pp), "");
	dfs(1);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  bool A[H][W];
  char a;
  vector<pair<int, int>> q;
  vector<pair<int, int>> nq;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> a;
      A[i][j] = (a == '#')? true : false;
      if(A[i][j])
        q.push_back(make_pair(i, j));
    }
  }
  int count = -1;
  
  
  
  while(true){
    /*
    for(auto p: q){
      cout << "(" << p.second << ", " << p.first << "), ";
    }
    cout << endl;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        cout << A[i][j] << " ";
      }
      cout << endl;
    }
    // */
    int len = q.size();
    if(len == 0)
      break;
    count++;
    
    vector<pair<int, int>> dirvec;
    dirvec.push_back(make_pair(-1, 0));
    dirvec.push_back(make_pair(1, 0));
    dirvec.push_back(make_pair(0, -1));
    dirvec.push_back(make_pair(0, 1));
    for(int qi = 0; qi < len; qi++){
      auto p = q[qi];
      for(auto dir : dirvec){
        int i = p.first + dir.first;
        int j = p.second + dir.second;
        if(0 <= i && i < H && 0 <= j && j < W){
          if(A[i][j] == false){
            nq.push_back(make_pair(i, j));
            A[i][j] = true;
          }
        }
      }
    }
    
    q.swap(nq);
    nq.clear();
  }
  if(count == -1)
    count = 0;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 13032
import numpy as np
MOD = 1000000007

def phi(i, m):
    if (i > 0) and (m[i-1] == 1):
        return i-1
    elif (i < len(m)) and (m[i] == 1):
        return i+1
    else:
        return i

def ok(m):
    for i in range(len(m) - 1):
        if (m[i] == 1) and (m[i+1] == 1):
            return False
    return True

def solve(H, W, K):
    M = []
    for bitmask in range(2**(W-1)):
        m = []
        for w in range(W-1):
            m.append(bitmask % 2)
            bitmask /= 2
        M.append(m)
    M = filter(ok, M)
    dp = np.zeros((H+1, W), dtype=np.int64)
    dp[0, K-1] = 1
    for h in range(H):
        for i in range(W):
            for m in M:
                j = phi(i, m)
                dp[h+1, i] = (dp[h+1, i] + dp[h, j]) % MOD
    return dp[H, 0]

H, W, K = map(int, raw_input().split())
print(solve(H, W, K))

Measured memory_bytes: 16132
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadLine().Split(' ').Select(int.Parse).ToList();

            WriteLine((a[0] * a[1]) % 2 == 0 ? "Even" : "Odd");
        }
    }
}



Measured memory_bytes: 11220
#include <iostream>
using namespace std;
int main(void){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=n; j++){
            int k = n - (i*r + j*g);
            if(k%b == 0 && k>=0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

n = int(input())
a_list = [int(input()) for i in range(n)]
ans = 0
idx = 0

for i in range(n):
    ans += 1
    if a_list[idx] == 2:
        break
    idx = a_list[idx]-1

if ans == n:
    ans = -1

print(ans)

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

int main() {
  int N, n1, n2, n3, n4;
  cin >> N;
  n1 = N /1000;
  n2 = (N % 1000) / 100;
  n3 = (N % 100) / 10;
  n4 = N % 10;
  if(n2 == n3){
    if(n1 == n2 || n3 == n4){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl; 
  }
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
dp=[0,abs(l[1]-l[0])]
for i in range(2,n):
    dp.append(min(dp[i-1]+abs(l[i]-l[i-1]),dp[i-2]+abs(l[i]-l[i-2])))
print(dp[-1])

Measured memory_bytes: 20640
#include<iostream>
#include<vector>
using namespace std;
int n;
vector<pair<int,int> >E;
vector<vector<int> >a;
bool used[111][111];
main()
{
	cin>>n;
	if(n%2==1)
	{
		vector<int>now;
		now.push_back(n);
		a.push_back(now);
		n--;
	}
	for(int i=1;i<=n/2;i++)
	{
		vector<int>now;
		now.push_back(i);
		now.push_back(n-i+1);
		a.push_back(now);
	}
	for(int i=0;i<a.size();i++)
	{
		for(int j=i+1;j<a.size();j++)
		{
			for(int I=0;I<a[i].size();I++)
			{
				for(int J=0;J<a[j].size();J++)
				{
					E.push_back(make_pair(a[i][I],a[j][J]));
				}
			}
		}
	}
	cout<<E.size()<<endl;
	for(int i=0;i<E.size();i++)cout<<E[i].first<<" "<<E[i].second<<endl;
}

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

using namespace std;

#define ll long long
#define ar array



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

    int a,b,c,k;
    cin >> a >> b >> c >> k;
    bool ans = 0;
        while(b <= a){
            b*=2;k--;
        }
        while(c<=b){
            c*=2;k--;
        }
        if(k >= 0) ans=1;
    if(!ans){
        cout << "No";
    }else{
        cout << "Yes";
    }
    
    return 0;
}


Measured memory_bytes: 3660
# AtCoder Beginner Contest 153
# E - Crested Ibis vs Monster
# https://atcoder.jp/contests/abc153/tasks/abc153_e
H, N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*2)

INF = 1 << 30
dp = [INF]*(H+1)
dp[0] = 0
for i, (a, b) in enumerate(A):
    for h in range(H+1):
        mh = min(H, h+a)
        dp[mh] = min(dp[mh], dp[h] + b)
print(dp[H])


Measured memory_bytes: 42220
N = gets.chomp.to_i

guides = []

N.times do |i|
  input = gets.chomp.split(' ')
  si = input[0]
  point = input[1].to_i
  guides.push( { city: si, number: i+1, point: point } )
end

guides.sort! { |a, b| b[:point] <=> a[:point] }
guides.sort! { |a, b| a[:city]  <=> b[:city] }

guides.each { |g| puts g[:number] }


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;

int n;
int a[100000];
P v[100000];

int main(){
	cin >> n;
	rep(i, n){
		cin >> a[i];
	}

	rep(i, n){
		v[i] = P(a[i], i);
	}
	sort(v, v + n);

	int ans = 0;
	rep(i, n){
		ans += i & 1 && !(v[i].second & 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, LL>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define pb push_back
#define a first
#define b second
vector<P> v;

int main(){

    // 1. 入力情報.
    int N;
    LL K;
    scanf("%d %lld", &N, &K);
    rep(i, N){
        int a;
        LL b;
        scanf("%d %lld", &a, &b);
        v.pb({a, b});
    }
    
    // 2. sort.
    sort(all(v));
    
    // 3. K番目に小さい数は？
    int ans = 0;
    for(auto &p : v){
        if(K <= 0) break;
        ans = p.a;
        K -= p.b;
    }
    
    // 4. 出力.
    printf("%d\n", ans);
    return 0;

}

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

int main() {
  double a, b, x; cin >> a >> b >> x;
  double s = x/a;
  double ans;
  double PI = acos(-1);
  if(s >= a*b/2){
    double h = (a*b-s)*2/a;
    double rad = atan2(h,a);
    ans = rad/(2*PI) * 360;
    printf("%.10f\n",ans);
    return 0;
  }
  else{
    double w = 2*s/b;
    double rad = atan2(b,w);
    ans = rad/(2*PI) * 360;
    printf("%.10f\n",ans);
    return 0;
  }
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;

int main(){
    int n,sum;
    cin>>n;
    for(int i=0;i<=n/4;i++){
        sum=4*i;
        while(1){
            if(sum==n){
                cout<<"Yes"<<endl;
                return 0;
            }else if(sum>n){
                break;
            }
            sum+=7;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	cin>>n>>m;
	cout<<(n>m?"safe":"unsafe")<<endl;
	return 0;
}

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

using namespace std;

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

    X = abs(X);
    long times = X / D;

    long ans;
    if (times >= K)
    {
        ans = X - K * D;
    }
    else
    {
        if ((K - times) % 2 == 0)
        {
            ans = X - times * D;
        }
        else
        {
            ans = abs(X - (times + 1) * D);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
const long long infinity = 1e18;
long long w[100];
long long v[100];
long long dp[100][100001];
int main()
{
    int n,W;
    cin>>n>>W;
    for (int i=0;i<n;i++)
    cin>>w[i]>>v[i];

    dp[0][0]=0;
    dp[0][w[0]]=v[0];
    for (int i=1;i<n;i++)
    {
        dp[i][0]=0;
        for (int j=1;j<=W;j++)
        {
            dp[i][j]=dp[i-1][j];
            if (j>=w[i])
            {

                dp[i][j]= max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
            }
            
            
        }
    }
    long long ans=0;
    for (int j=0;j<=W;j++)
    ans = max(ans,dp[n-1][j]);

    cout<<ans;
    return 0;

}

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

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];
		var pq = new int[h[1]].Select(_ => Read()).ToArray();
		var rs = new int[h[2]].Select(_ => Read()).ToArray();

		var uf1 = new UF(n);
		var uf2 = new UF(n);
		foreach (var x in pq) uf1.Unite(x[0], x[1]);
		foreach (var x in rs) uf2.Unite(x[0], x[1]);

		var d = new Dictionary<(int, int), List<int>>();
		for (int i = 1; i <= n; i++)
		{
			var key = (uf1.GetRoot(i), uf2.GetRoot(i));
			if (!d.ContainsKey(key)) d[key] = new List<int>();
			d[key].Add(i);
		}

		var r = new int[n + 1];
		foreach (var p in d)
			foreach (var i in p.Value)
				r[i] = p.Value.Count;
		Console.WriteLine(string.Join(" ", r.Skip(1)));
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n + 1).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	public int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
	public int[][] ToGroups() => Enumerable.Range(0, p.Length).GroupBy(GetRoot).Select(g => g.ToArray()).ToArray();
}


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

main(){
  int a,b,c;
  cin>> a>>b;
  c = a*b;
  for(int i = 1; i<4;i++){
    if (c*i%2 == 1){
      cout << "Yes"<< endl;
      break;
    }
    else{ 
      if (i == 3){
        cout<< "No"<<endl;
      }
     continue;}
  
  }
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      cout<<"#x "<<x<<"\n";
#define trace(x,y)  cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          cout<<"\n";


bool SBF(const pair <int,int>&a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair<int,int>& a, const pair<int,int>& b){return a.S<b.S;}


const int maxn = 1e9+7;
int n, k;
int a[100000];

void solve(){
	int dp[n];
	dp[0] = 0;
	for(int i= 1; i < n ;i++){
		dp[i] = INT_MAX;
		for(int j = 1; j<= k; j++){
			if(i-j>=0)dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n-1]<<"\n";
return ;
}
int main(){
	cin >> n >> k;
	for(int i = 0 ;i  < n ;i++)cin >> a[i];
	solve();
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	ll D;	cin>>D;
	int ans=0;
	rep(i,0,N){
		ll x,y;cin>>x>>y;
		if(D*D>=(x*x+y*y)){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a - 1 + (a <= b) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    money = 1000
    for i in range(N - 1):
        if cnt > 0:
            money += cnt * A[i]
            cnt = 0
        if A[i] < A[i + 1]:
            cnt, money = divmod(money, A[i])
    if cnt > 0:
        money += cnt * A[N - 1]
        cnt = 0
    print(money)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=998244353;
int INF=100100100100100;

int GCD(int a,int b){
  if(a<b)return GCD(b,a);
  if(b==0)return a;
  return gcd(b,a%b);
}
vector<int> pr(int N)
{
	vector<int> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		while(N%a==0)
		{
          N/=a;
		}
		res.push_back(a);
	}
	if(N!=1)res.push_back(N);
	return res;
}

bool is_prime(int n){
  for(int a=2;a*a<=n;a++){
    if(n%a==0)return false;
  }
  return true;
}
int a[10010];
set<int> ans;
signed main(){
  int n;cin>>n;
  int gc=0;
  rep(i,n+1){
    cin>>a[n-i];
    if(i==0)gc=abs(a[n-i]);
    else gc=GCD(gc,abs(a[n-i]));
    //cout<<gc<<endl;
  }
  rep(i,n+1)a[i]/=gc;
  vector<int> w=pr(abs(gc));
  for(int p:w)ans.insert(p);
  
  
  for(int p=2;p<=n+2;p++){
    if(!is_prime(p))continue;
    //cout<<p<<endl;
    bool flag=true;
    vector<int> b(p);
    for(int i=n;i>=0;i--){
      if(i>=p-1)b[i%(p-1)]+=a[i];
      else if((b[i]+a[i])%p!=0){
        flag=false;
        break;
      }
    }
    if(flag && a[0]%p==0)ans.insert(p);
  }
  for(auto x:ans)cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 3756
#include <stdio.h>

int main(void) {
  int X_A = 0;
  int Y_B = 0;
  int C = 0;
  int Y_D = 0;
  int P = 0;

  int costX = 0;
  int costY = 0;

  scanf("%d", &X_A);
  scanf("%d", &Y_B);
  scanf("%d", &C);
  scanf("%d", &Y_D);
  scanf("%d", &P);

  costX = X_A * P;
  costY = Y_B;  
    
  if (P > C) {
    costY += (P - C) * Y_D;
  }

  if (costX < costY) {
    printf("%d\n", costX);
  } else {
    printf("%d\n", costY);
  }
  
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d=0,n=0,x,y;
    string s,s1,s2;
    cin >> n;
    VI m(n);
    rep(i,n) cin >> m[i];
    for(int i=0;i<n-2;i++) {
        if((m[i]< m[i+1] && m[i+1]< m[i+2])  ||(m[i]> m[i+1] && m[i+1]> m[i+2]) ){
            c++;
        }
    }
   
    cout << c << endl;
    return 0;
} 

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

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

    int n;
    cin >> n;

    vector<int> d = { 1 };
    for (int i = 1; pow(6, i) <= n; ++i) {
        d.push_back((int) pow(6, i));
    }
    for (int i = 1; pow(9, i) <= n; ++i) {
        d.push_back((int) pow(9, i));
    }
    int dp[n + 1];
    for (int i = 0; i <= n; ++i) {
        dp[i] = i;
    }

    for (int e : d) {
        for (int j = e; j <= n; ++j) {
            dp[j] = min(dp[j], dp[j - e] + 1);
        }
    }

    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 640