akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;

const int N = 1e5 + 10;
int n;
int a[N], b[N], c[N], dp[N][3];

int main() {

	scanf("%d", &n);
	for(int i = 1; i <= n; i++) 
		scanf("%d%d%d", a + i, b + i, c + i);
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	for(int i = 2; i <= n; i++) {
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_N 100000

int dp[MAX_N];

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

Measured memory_bytes: 1024
from collections import Counter

def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = 0
    amax = max(a)

    for i in a:
        if (amax/2) + 1 < i:
            break
        if table[i-1] is False:
            continue
        for j in range(i*2, amax+1, i):
            table[j-1] = False

    c = Counter(a)
    for i in set(a):
        if table[i-1]:
            if c[i] == 1:
                res += 1
    print(res)

if __name__ == '__main__':
    main()



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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 7777

int n, k;
char s[MAXN];
int pos[MAXN];
vector <int> g[2];
string d[MAXN], t;
int dp[MAXN];

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 0; i < n + n; ++i) {
		pos[i] = sz(g[s[i] - 'a']);
		g[s[i] - 'a'].pb(i);
	}

	for (int i = 0, j; i < n + n; i = j, ++k) {
		int ka = 0, kb = 0;
		s[i] == 'a' ? ++ka : ++kb;
		j = i + 1;
		while(j < n + n && ka != kb) {
			s[j] == 'a' ? ++ka : ++kb;
			++j;
		}

		int first = pos[i], last = pos[j - 1];
		int hasba = 0;
		for (int z = first; z <= last; ++z) {
			if (g[0][z] > g[1][z])
				hasba = 1;
		}

		if (!hasba) {
			d[k] = "";
			int ri = -1;
			for (int z = first; z <= last; ++z) {
				if (g[0][z] <= ri) continue;
				ri = g[1][z];
				d[k] += "ab";
			}
		} else {
			d[k] = "";
			for (int z = first; z <= last; ++z) {
				t = "";
				for (int y = i; y < j; ++y) {
					if (pos[y] < z) continue;
					t += s[y];
				}
				if (lexicographical_compare(all(d[k]), all(t))) {
					d[k] = t;
				}
			}			
		}
	}

	string ans = "";
	for (int i = k - 1; i >= 0; --i) {
		t = d[i] + ans;
		if (lexicographical_compare(all(ans), all(t))) {
			ans = t;
		}
		t = d[i];
		if (lexicographical_compare(all(ans), all(t))) {
			ans = t;
		}
	}

	puts(ans.c_str());

	return 0;
}


Measured memory_bytes: 512
// abc.098  C - Attention

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

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

    //累積和の入った配列をW,Eの2パターン作る
    int sumW[ n + 1 ] = {},
                    sumE[ n + 1 ] = {}; //累積和なので、はじめの１つは0にする

    // W,Eのカウント変数
    int cnt_w = 0, cnt_e = 0;

    for( int i = 0; i < n; i++ ) {
        if( s.at( i ) == 'W' ) {
            cnt_w++;
        } else if( s.at( i ) == 'E' ) {
            cnt_e++;
        }
        //累積和2パターンを代入
        sumW[ i + 1 ] = cnt_w;
        sumE[ i + 1 ] = cnt_e;
    }

    //カウント用
    int cnt;
    //初期値を大きな値に設定
    int ans = n + 100;

    //並んでいる人を順に計算
    for( int i = 0; i < n; i++ ) {
        cnt = 0;

        // 1番西にあるとき
        if( i == 0 ) {
            // iより右側をチェック
            cnt = sumE[ n ] - sumE[ i + 1 ];
        }

        //一番東にあるとき
        else if( i == n - 1 ) {
            // iより左側をチェック
            cnt = sumW[ i ] - sumW[ 0 ];
        }
        //間にあるとき
        else {
            // iより左側をチェック
            cnt += sumW[ i ] - sumW[ 0 ];
            // iより右側をチェック
            cnt += sumE[ n ] - sumE[ i + 1 ];
        }
        ans = min( ans, cnt );
    }

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


Measured memory_bytes: 3076
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func ScanInt() int {
	scanner.Scan()
	txt := scanner.Text()
	n, _ := strconv.Atoi(txt)
	return n
}

func main() {
	a, b, c := ScanInt(), ScanInt(), ScanInt()
	if b/a > c {
		fmt.Println(c)
	} else {
		fmt.Println(b / a)
	}
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
#define input(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,p,q,ans=0;
vl v,v2,dp(1000);
string s1,s2;
ll solve(){
    return (n-1)/(2*d+1)+1;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>d;
    cout<<solve()<<endl;

}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define SIN(x) string x; cin>>x;
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 500005
int main() {
	ios::sync_with_stdio(0);
	INN(h, w);
	bool p[100][100] = {false};
	string s[h];
	F(h) {
		cin>>s[i];
		FF(w) p[i+1][j+1] = s[i][j]=='#';
	}
	FI(h) {
		FFI(w) {
			if(p[i][j]) {cout<<'#'; continue;}
			int cnt = 0;
			if(p[i-1][j-1]) cnt++;
			if(p[i-1][j]) cnt++;
			if(p[i-1][j+1]) cnt++;
			if(p[i][j-1]) cnt++;
			if(p[i][j+1]) cnt++;
			if(p[i+1][j-1]) cnt++;
			if(p[i+1][j]) cnt++;
			if(p[i+1][j+1]) cnt++;
			cout<<cnt;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,c; cin >> a >> b >> c;
    ll k; cin >> k;
    ll ans = 0;
    if(k <= a)ans = k;
    else if(k <= a + b)ans = a;
    else{
        ans = a;
        k -= a + b;
        ans -= k;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3664
#include<stdio.h>

int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    printf("%d %d %.8lf\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2036
import math

n, k = map(int, input().split())
nums = [k]
while True:
    a = math.ceil(nums[-1] / 2)
    nums.append(a)
    if a == 1:
        break

max_e = len(nums) - 1
m = n
res = 0
for i, a in enumerate(nums):
    if m >= a:
        res += (m - a + 1) * 2**(max_e - i)
        m = a - 1
print(res / (n * 2**max_e))

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

#define int long long
#define REP(i,n) for(int i=0;i<n;i++)
#define AREP(i,a,n) for(int i=a;i<n;i++)
void SO(vector<int> &v){
  vector<int> w(8);
  REP(i,4)w[i]=w[i+4]=v[i];
  REP(j,4)
    if(w[j]*1e9+w[j+1]*1e6+w[j+2]*1e3+w[j+3]<v[0]*1e9+v[1]*1e6+v[2]*1e3+v[3])
      REP(a,4)v[a]=w[j+a];
}
int cou(vector<vector<int>> &c,vector<int> &need,int idx,int n,int ex){
  if((idx<n-1&&c[idx+1]>need)||c[n-1]<need)return 0;
  int l=idx,r=n;
  while(r-l>1){
    int mid=(r+l)>>1;
    (c[mid]<need?l:r)=mid;
  }
  int miman=l;
  r=n;
  while(r-l>1){
    int mid=(r+l)>>1;
    (c[mid]<=need?l:r)=mid;
  }
  return l-miman-(c[ex]==need);
}
int F(vector<int> &v){
  if(v[0]==v[1]&&v[1]==v[2]&&v[2]==v[3])return 4;
  if(v[0]==v[2]&&v[1]==v[3])return 2;
  return 1;
}

signed main(){
  int n;cin>>n;
  vector<vector<int>> c(n);
  REP(i,n){
    REP(j,4){
      int a;cin>>a;
      c[i].push_back(a);
    }
    SO(c[i]);
  }
  sort(c.begin(),c.end());
  int ans=0;
  REP(i,n)
    AREP(j,i+1,n)
      REP(k,4){
        vector<vector<int>> need(4);
        REP(l,4){
          need[l].push_back(c[j][(4-l+1+k)%4]);
          need[l].push_back(c[j][(4-l+k)%4]);
          need[l].push_back(c[i][(l+1)%4]);
          need[l].push_back(c[i][l]);
          SO(need[l]);
        }
        sort(need.begin(),need.end());
        int A=cou(c,need[0],i,n,j);
        int B=(need[0]==need[1]?A-1:cou(c,need[1],i,n,j));
        int C=(need[1]==need[2]?B-1:cou(c,need[2],i,n,j));
        int D=(need[2]==need[3]?C-1:cou(c,need[3],i,n,j));
        if(min({A,B,C,D})<=0)continue;
        ans+=A*B*C*D*F(need[0])*F(need[1])*F(need[2])*F(need[3]);
      }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int N; cin >> N;
    ld v[55];
    rep(i, N) {
        cin >> v[i];
    }
    sort(v, v + N);
    ld ans = v[0];
    rep1(i, N - 1) {
        ans = (ans + v[i]) / (ld)2;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int d,w,map[11][11];
int main(){
    while(cin>>d>>w){
        if(!d&&!w) break;
        memset(map,0,sizeof map);
        for(int i=1;i<=d;i++)
            for(int j=1;j<=w;j++) cin>>map[i][j];
        int ans=0;
        for(int i=1;i<=d-2;i++)
            for(int j=1;j<=w-2;j++)
                for(int x=3;x+i-1<=d;x++)
                    for(int y=3;y+j-1<=w;y++){
                        int minn=100,maxn=-1;
                        for(int z=0;z<x;z++){
                            if(minn>map[i+z][j]) minn=map[i+z][j];
                            if(minn>map[i+z][j+y-1]) minn=map[i+z][j+y-1];
                        }
                        for(int z=0;z<y;z++){
                            if(minn>map[i][j+z]) minn=map[i][j+z];
                            if(minn>map[i+x-1][j+z]) minn=map[i+x-1][j+z];
                        }
                        for(int u=i+1;u<=i+x-2;u++)
                            for(int v=j+1;v<=j+y-2;v++) maxn=max(maxn,map[u][v]);
                        if(maxn>=minn) continue;
                        int ans0=0;
                        if(maxn<=minn){
                            for(int u=i+1;u<=i+x-2;u++)
                                for(int v=j+1;v<=j+y-2;v++) ans0+=minn-map[u][v];
                        }
                        ans=max(ans,ans0);
                    }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int a,b,ans;
signed main(){
	cin>>a>>b;
	int x=1;
	while(1){
		if(b<=x){
			cout<<ans<<endl;
			return 0;
		}
		x+=a-1;
		ans++;
		
	}
		
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  for (int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int h=1;
  for (int i=0; i<N-1; i++) {
    if (d.at(i) < d.at(i+1)) {
      h++;
    }
  }
  cout << h << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int a = scanner.nextInt();
		
		if (h % a == 0) {
			System.out.println(h / a);
		} else {
			System.out.println(h / a + 1);
		}
	}
}	

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

using namespace std;

int main(){
  map <int, int> G;
  for (int i = 1; i <= 12; i++){
    if (i == 2) G[i] = 1;
    else if(i == 4 || i == 6 || i == 9 || i == 11) G[i] = 2;
  }

  int A, B; cin >> A >> B;
  if (G[A] == G[B]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  
  return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] min = new int[N+1];
		for(int i=1;i<=N;i++) min[i] = -1;
		
		List<int> E = new List<int>();
		E.Add(1);
		E.Add(9);
		while(E[E.Count - 1] * 9 <= N) E.Add(E[E.Count - 1] * 9);
		E.Add(6);
		while(E[E.Count - 1] * 6 <= N) E.Add(E[E.Count - 1] * 6);
		
		var q = new Queue<int>();
		q.Enqueue(0);
		min[0] = 0;
		while(q.Count > 0){
			var now = q.Dequeue();
			foreach(var nxt in E){
				if(now + nxt <= N && min[now + nxt] == -1){
					min[now + nxt] = min[now] + 1;
					q.Enqueue(now + nxt);
				}
			}
		}
		Console.WriteLine(min[N]);
	}
	long N;
	public Sol(){
		N = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,p,y,f,s,j,x;
    cin>>n>>m;
    set<int> pre[n];
    pair<int,int> pa[m];
    map<pair<int,int>,int> mp;
    for(i=0;i<m;i++)
    {
        cin>>p>>y;
        pre[p-1].insert(y);
        pa[i]=make_pair(p,y);
    }

    set <int, int > :: iterator it;
    for(j=0;j<n;j++)
    {
        for(it=pre[j].begin(),i=1;it!=pre[j].end();it++,i++)
        {
            x=(*it);
            mp[{j+1,x}]=i;
        }
    }
    for(i=0;i<m;i++)
        printf("%.6d%.6d\n",pa[i].first,mp[pa[i]]);

    return 0;
}


Measured memory_bytes: 20112
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)

ll c[100010];
ll ans,c2;
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		c[t]++;
	}
	rep(i,0,100010){
		while(c[i]>2){
			ans++;
			c[i]-=2;
		}
		if(c[i]==2)c2++;
	}
	ans+=(c2+1)/2;
	printf("%d\n",n-2*ans);
	return 0;
}

Measured memory_bytes: 1024
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:(input())

"""========main code==============="""

a,b,c=ml()
x=min(b-1,c)
print((a*x)//b-a*(x//b))		

Measured memory_bytes: 65032
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
inline void solve(void){
  int K,A,B;
  in(K,A,B);
  up(i,A,B){
    if(i%K==0){
      out("OK");
      return;
    }
  }
  out("NG");
}
int main(void){
  BEGIN;
  solve();
  END;
}


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

using namespace std;

const int MaxN = 2e3 + 23;

vector <pair<char, int> > v;

void print(vector <pair<char, int> > v)
{
    cout << '\n';
    for(auto x : v)
        cout << x.first << ' ' << x.second << '\n';

}

int sum[2][MaxN][MaxN];
int dp[MaxN][MaxN];

int get(char q, int x, int l, int r)
{
    if(l > r)
        return 0;
    return sum[q - '0'][x][r] - sum[q - '0'][x][l - 1];
}



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

    int n;

    cin >> n;

    v.resize(n + n);

    int ans = 0;

    for(int i = 0; i < n + n; ++i)
    {
        cin >> v[i].first >> v[i].second;

        if(v[i].first == 'W')
            v[i].first = '0';
        else
            v[i].first = '1';

        for(int j = 0; j < i; ++j)
        {
            if(v[i].first != v[j].first)
                ++sum[v[i].first - '0'][v[i].second][v[j].second];
            else
            if(v[i].second < v[j].second)
                ++ans;
        }
        for(int j = 1; j <= n; ++j)
            sum[v[i].first - '0'][v[i].second][j] += sum[v[i].first - '0'][v[i].second][j - 1];
    }

    dp[0][0] = ans;

    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= n; ++j)
            if(i + j)
            {
                dp[i][j] = 1e9;
                if(i)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + get('0', i, j + 1, n));
                if(j)
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + get('1', j, i + 1, n));
            }

    cout << dp[n][n] << '\n';

    return 0;
}
/**
1212
WBBW
*/


Measured memory_bytes: 48128
/*
[abc165] A - We Love Golf
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int K;
int A, B;

ll solve() { return B / K * K >= A; }

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

    cout << (solve() ? "OK" : "NG") << endl;

    return 0;
}


Measured memory_bytes: 3632
s=input()
n=len(s)
c=0
for i in range(2**(n-1)):
    a=[[int(s[0])]]
    for j in range(n-1):
        if (i>>j)&1:
            a.append([int(s[j+1])])
        else:
            a[-1].append(int(s[j+1]))
    for i, val in enumerate(a):
        for x in range(len(val)):
            c+=(10**x)*val[-(x+1)]
print(c)

Measured memory_bytes: 3064
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
minMP = 999999
for i in range(1 << len(l)):
    a = []
    b = []
    for j in range(len(l)):
        if ((i >> j) & 1) == 1:
            a.append(l[j])
        else:
            b.append(l[j])
    if not(a) or not(b):
        continue
    for w in range(1 << len(b)):
        c = []
        d = []
        for v in range(len(b)):
            if ((w >> v) & 1) == 1:
                c.append(b[v])
            else:
                d.append(b[v])
        if not(c) or not(d):
            continue
        for p in range(1 << len(d)):
            e = []
            f = []
            for q in range(len(d)):
                if ((p >> q) & 1) == 1:
                    e.append(d[q])
                else:
                    f.append(d[q])
            if not(e):
                continue
            MP = (len(a) + len(c) + len(e) - 3) * 10
            MP += abs(A - sum(a)) + abs(B - sum(c)) + abs(C - sum(e))
            minMP = min(minMP, MP)
print(minMP)

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;
  rep(i, s.size()) {
    switch (s[i]) {
      case '1': s[i] = '9'; break;
      case '9': s[i] = '1'; break;
      default: break;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
# bfsで探索終了条件をすでにそのノードに値があった場合として，ノードに距離を追加＋このノードを終了条件を見ながら追加とする
# こういうときのindexの扱い方とかこんがらがりやすい

N,M=map(int,input().split())
C=[[] for _ in range(N)]
for _ in range(M):
    ai,bi=map(int,input().split())
    C[ai-1].append(bi)
    C[bi-1].append(ai)

D=[-1 for _ in range(N)]

from collections import deque
que = deque([1])
while que:
    new = que.popleft()-1
    for c in C[new]:
        if D[c-1]==-1:
            que.append(c)
            D[c-1] = new+1

if -1 in D[1:N]:
    print('No')
    exit()
print('Yes')
for i in range(1,N):
    print(D[i])


Measured memory_bytes: 37484
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Programminng
{
    class Program
    {
        static void Main(string[] args)
        {
            var values = new int[10];
            for (int i = 0; i < 10; i++)
            {
                values[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(values);
            for (int i = 9; i > 6; i--)
            {
                Console.WriteLine(values[i]);
            }

        }
    }
}

Measured memory_bytes: 5720
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Array
import Control.Monad

main = do
  li <- BS.getLine
  let [n,q] = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  abs <- forM [2..n] get2
  pxs <- forM [1..q] get2
  let ans = compute n q abs pxs
  putStrLn $ unwords $ map show ans

get2 _ = do
  li <- BS.getLine
  let [a,b] = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  return (a,b)

compute :: Int -> Int -> [(Int,Int)] -> [(Int,Int)] -> [Int]
compute n _ abs pxs = ans
  where
    xa = accumArray (+) 0 (1,n) pxs
    ta = accumArray (flip (:)) [] (1,n) [ p | (a,b) <- abs, p <- [(a,b),(b,a)] ]
    ans = elems $ array (1,n) $ dfs 0 0 1 []
    dfs p v cur rest = (cur, v1) : foldr (dfs cur v1) rest (delete p $ ta ! cur)
      where
        v1 = v + xa ! cur

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int n, d, a;
  cin >> n >> d >> a;
  vector<P> m(n);
  rep(i,n) {
    int x, h;
    cin >> x >> h;
    m[i] = make_pair(x,h);
  }
  sort(all(m));
  map<int, ll> damage;
  ll ans = 0;
  ll sum = 0;
  ll cnt = 0;
  rep(i,n) {
    while(cnt < i) {
      if(m[i].first - m[cnt].first > d*2) {
        auto it = damage.find(m[cnt].first);
        if(it != damage.end()) sum -= damage[m[cnt].first];
        cnt++;
      }
      else break;
    }    
    m[i].second -= sum;
    if(m[i].second > 0) {
      ll tmp = ceil(m[i].second, a);
      ans += tmp;
      sum += damage[m[i].first] = tmp * a;
    }

  }
  cout << ans << endl;
}

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

#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

const ll MX=1e18;

int main(){
 int n,i;
 ll ans=1;
 cin>>n;
 bool ng=false;
 rep(i,n){
    ll a;
    cin>>a;
    if (a==0){
        cout<<0<<endl;
        return 0;
    }
    if (ng||(MX/ans<a)){
        ng=true;
    }
    ans*=a;
 }

 if (ng){
     cout<<-1<<endl;
 }else{
     cout<<ans<<endl;
 }
 return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.util.Arrays;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 全何種類で何種類買うか取得
      	int n = sc.nextInt();
      	int k = sc.nextInt();
      	
      	// 配列の作成
      	int prices[] = new int[n];
      	for(int i=0;i<n;i++){
        	prices[i] = sc.nextInt();
        }
		//ソート
      	Arrays.sort(prices);
      	//合計を求める
      	int sum=0;
      	for(int i=0;i<k;i++){
        	sum += prices[i];
        }
		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 38704
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10**9
MOD = 10**9+7

S, K = input(), int(input())
N = len(S)
if S[0] == S[-1]:
    i = 1
    while i < N and S[i-1] == S[i]:
        i += 1
    j = -1
    while j > -N and S[j] == S[j-1]:
        j -= 1
    if N+j <= i:
        print(N*K//2)
    else:
        ans = (K-1)*((i-j)//2)+i//2+(-j)//2
        S = S[i:j]
        l, r = 0, 0
        n = len(S)
        lst = []
        while r < n:
            while r+1 < n and S[r] == S[r+1]:
                r += 1
            r += 1
            lst.append(r-l)
            l = r
        for x in lst:
            ans += K*(x//2)
        print(ans)
else:
    l, r = 0, 0
    lst = []
    while r < N:
        while r+1 < N and S[r] == S[r+1]:
            r += 1
        r += 1
        lst.append(r-l)
        l = r
    ans = 0
    for x in lst:
        ans += K*(x//2)
    print(ans)


Measured memory_bytes: 3316
N, x = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
ans = 0
for i in range(len(a) - 1):
    x -= a[i]
    if x >= 0:
        ans += 1
    else:
        break
x -= a[N - 1]
if x == 0:
    ans += 1
print(ans)

Measured memory_bytes: 9188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

void solve(int n,ll I,ll J){

    ll maxL = 1;
    ll maxH = (1LL << n);
    ll curL = 1;
    ll curH = I;
    vector<int> cmd(n,1);//0がL,1がR
//    ll cmd = (1 << n) - 1;//
    while(maxH != 1){
        maxL *= 2LL;
        maxH /= 2LL;
        if(curH > maxH){
            curH -= maxH;
        }else{
            curL = maxL - curL + 1;
            curH = maxH - curH + 1;
        }
    }
    ll range = (1LL << n);
    ll targetL = J;
    ll nowL = curL;
//    for(int i = n - 1; i >= 0; i--){
    for(int i = 0; i < n; i++){
        range >>= 1;
//        if((targetL <= range) ^ (nowL <= range)){
//            cmd[i] = 0;
//        }
        if(range == 0){
//            cout << "err" << endl;
        }
        if(targetL <= range){
            if(nowL <= range){
            }else{
                nowL -= range;
                cmd[i] = 0;
            }
        }else{
            if(nowL <= range){
                targetL -= range;
                cmd[i] = 0;
            }else{
                nowL -= range;
                targetL -= range;
            }
        }
    }
    rep(i,0,n){
//        cout << (cmd[i]) ? "R" : "L";
        if(cmd[i] == 1){
            cout << "R";
        }else{
            cout << "L";
        }
    }
    cout << endl;
    return;
}

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

    while(true){
        int n;
        ll I,J;
        cin >> n >> I >> J;
        if(n == 0) break;
        solve(n,I,J);

    }


    return 0;
}



Measured memory_bytes: 3184
#!/usr/bin/env ruby

def comb(n, x)
    if x > n*3-3 or x < 6 then
        return []
	end

    c = []
    for i in 1..n-2 do
        if i > x/3 then
            break
		end
        for j in i+1..n-1 do
            if j > (x-i)/2 then
                break
			end
            rem = x-(i+j)
            if rem > j and rem <= n then
                c += [[i, j, rem]]
			end
		end
	end

    return c

end

if __FILE__ == $0 then
	loop do
		n, x = gets.split.map(&:to_i)

		if [n, x] == [0, 0] then
			break
		end
		puts comb(n, x).size
	end
end



Measured memory_bytes: 28568
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく

#define INF 1000000000000 // 10^12:極めて大きい値,∞
const int MOD = 1000000007;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
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;
}

int main() {

    int n, time_limit;
    cin >> n >> time_limit;
    vector<vector<int>> time_pleasure(n, vector<int>(2, 0));
    REP(i, n) {
        int a, b;
        cin >> a >> b;
        time_pleasure[i][0] = a;
        time_pleasure[i][1] = b;
    }

    // 第i列を軸にしてvvをソート
    sort(ALL(time_pleasure),
         [](const vector<int> &alpha, const vector<int> &beta) {
             return alpha[0] < beta[0];
         });

    vector<vector<int>> dp(n + 3, vector<int>(time_limit + 3, 0));
    // dp[i][j]:=i番目(1idx)までの料理の中からj分以内に完食できる美味しさの最大値

    int ans = 0;

    REP(ni, n) {
        REP(ti, time_limit) {
            chmax(dp[ni + 1][ti], dp[ni][ti]);
            int new_t = ti + time_pleasure[ni][0];
            if (new_t <= time_limit) {
                chmax(dp[ni + 1][new_t], dp[ni][ti] + time_pleasure[ni][1]);
            }
        }
        int ni_last = dp[ni][time_limit - 1] + time_pleasure[ni][1];
        chmax(ans, ni_last);
    }
    cout << ans << endl;
}


Measured memory_bytes: 38944
buff = "NNNNWNNNWNNNENNNENNNWNNN"

class Dice:
        num =[ -1 for x in range(6) ]
        def roll(self, d):
                if   d == "N":
                        b = self.num[0]
                        self.num[0] = self.num[1]
                        self.num[1] = self.num[5]
                        self.num[5] = self.num[4]
                        self.num[4] = b
                elif d == "S":
                        b = self.num[0]
                        self.num[0] = self.num[4]
                        self.num[4] = self.num[5]
                        self.num[5] = self.num[1]
                        self.num[1] = b
                elif d == "W":
                        b = self.num[3]
                        self.num[3] = self.num[0]
                        self.num[0] = self.num[2]
                        self.num[2] = self.num[5]
                        self.num[5] = b
                elif d == "E":
                        b = self.num[3]
                        self.num[3] = self.num[5]
                        self.num[5] = self.num[2]
                        self.num[2] = self.num[0]
                        self.num[0] = b
        
        def __init__(self, lst):
                self.num = lst
        
        def print_num(self, m):
                #print(self.num[m])
                return self.num[m]
        
        def return_lst(self):
                return self.num

def isSameDice(D1, D2):
        for d in buff:
                D1.roll(d)
                if D1.return_lst() == D2.return_lst():
                        return True
        return False

lst = [ int(i) for i in input().split() ]
D1 = Dice(lst)

lst = [ int(i) for i in input().split() ]
D2 = Dice(lst)

if isSameDice(D1, D2):
        print("Yes")
else:
        print("No")


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

using namespace std;
typedef long long int ll;

enum Week
{
    SAT = 1,
    FRI = 2,
    THU = 3,
    WED = 4,
    TUE = 5,
    MON = 6,
    SUN = 7
};

int DaysNextSunday(string day)
{
    if(day == "SUN")
    {
        return SUN;
    }
    else if(day == "MON")
    {
        return MON;
    }
    else if(day == "TUE")
    {
        return TUE;
    }
    else if(day == "WED")
    {
        return WED;
    }
    else if(day == "THU")
    {
        return THU;
    }
    else if(day == "FRI")
    {
        return FRI;
    }
    else if(day == "SAT")
    {
        return SAT;
    }
    return 0;
}

int main()
{
    string day;
    cin >> day;
    cout << DaysNextSunday(day) << endl;
    return 0;
}


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

int main(void)
{
	int i,j,x,max=1;
	scanf("%d",&x);
	for(i=2;i<=sqrt(x);i++){
		j=2;
		while(pow(i,j)<=x){
			j++;
		}
		if(pow(i,j-1)>max)
			max=pow(i,j-1);
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
// Vicfred
// https://atcoder.jp/contests/abc167/tasks/abc167_b
// sorting, greedy
use std::io;

fn main() {
    let mut line = String::new();

    io::stdin()
        .read_line(&mut line)
        .unwrap();

    let words: Vec<i64> =
        line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let mut k = words[3];

    let mut taken = 0;
    let mut idx = 0;

    while k > 0 {
        if idx == 0 {
            taken += std::cmp::min(words[idx],k);
        }
        if idx == 2 {
            taken -= k;
        }
        k -= words[idx];
        idx += 1;
    }

    println!("{}", taken);
}



Measured memory_bytes: 2108
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int a, b;
  readf("%s %s\n", &a, &b);

  int res;
  foreach (i; a..b+1) {
    auto s1 = i.to!string;
    auto s2 = s1.dup;
    s2.reverse();
    if (s1 == s2) {
      res++;
    }
  }
  res.writeln;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define int long long int
#define db double
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mkp make_pair
#define pb push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
double pi=3.1415926535;
double eps=0.000001;
int mod=1000000007; 
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
 
 
int32_t main(){
/////////////////////////////////////////////////////////////////////
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
    std::cout.precision(10);
	int n;
	cin>>n;
	db p[n+1];
	p[0]=0;
	rep(i,1,n+1){
		cin>>p[i];
	}
	db dp[n+1][n+1];
	mem(dp,0);
	dp[0][0]=1.0;
	rep(i,1,n+1){
		rep(ii,0,i+1){
			if(ii==0){
				dp[i][ii]=dp[i-1][ii]*(1-p[i]);
			}
			else{
				dp[i][ii]=dp[i-1][ii]*(1-p[i])+dp[i-1][ii-1]*p[i];
			}
		}
	}
//	rep(i,0,n+1){
//		rep(ii,0,n+1) cout<<dp[i][ii]<<"\t";
//		cout<<endl;
//	}
	db ans=0.0;
	rep(i,(n+1)/2,n+1) ans+=dp[n][i];
	cout<<ans<<endl;
	return 0;
	}

Measured memory_bytes: 70656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *mi;
  struct node *hi;
  struct node *oya;
  int key;
};
typedef struct node * Node;
int max;

Node root,NIL;
Node treeSearch(Node u, int k){
  while( u != NIL && k != u ->key){
    if(k < u->key)u = u->hi;
    else u = u->mi;
  }
  return u;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  int H;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->hi = NIL;
  z->mi = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->hi;
    }
    else{
      x = x->mi;
    }
  }
  z->oya = y;

  if( y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->hi = z;
    }
    else{
      y->mi = z;
    }
  }
}
void inorder( Node u){
  if( u == NIL) return;
  inorder(u->hi);
  printf(" %d",u->key);
  inorder(u->mi);
}
void preorder( Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->hi);
  preorder(u->mi);
 }


int main(){
  int n, i, a;
  char A[20];
  scanf("%d", &n);
  max = 0;
   for ( i = 0; i < n; i++ ){
    scanf("%s",A);
    if ( A[0] == 'f' ){
      scanf("%d", &a);
      Node t = treeSearch(root,a);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( A[0] == 'i' ){
      scanf("%d", &a);
      insert(a);
    } else if (A[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
   }

  return 0;
}



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

int main () {
  int n,m,X,Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  if(x[x.size()-1] < y[0] && y[0] > X && x[x.size()-1] < Y) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
for x in range(n):
    s = int(raw_input())
    print 'Case ' +str(x+1) + ':'
    
    tmp = str(s**2).zfill(8)
    for i in range(10):
        tmp2 = int(tmp[2:6])
        print tmp2
        tmp = str(tmp2**2).zfill(8)
    

Measured memory_bytes: 4204
N = int(input())
if N<=10**6:
    res = 0
    for K in range(2, N + 1):
        n = N
        while n >= K:
            if n % K == 0:
                n = n // K
            else:
                n = n % K
        if n == 1:
            res += 1
    print(res)
    exit()


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def hantei(n):
    k = int(n**0.5)
    if k*(k+1) == n or (k-1)*k == n or (k+1)*(k+2) == n:
        return k
    else:
        return 0

res1 = make_divisors(N-1)
res2 = hantei(N)
if res2!=0:
    res1.append(res2)
res1.append(2)
res1.append(N)
res1.remove(1)


res3 = make_divisors(N)
res3.remove(1)
for val in res3:
    n = N
    while n >= val:
        if n % val == 0:
            n = n // val
        else:
            n = n%val
    if n == 1:
        res1.append(val)
        # print(K)
res = len(set(res1))
print(res)

Measured memory_bytes: 40172
a,b,c,d = map(int,input().split())

W,H=[c-a,d-b]

print('R'*W + 'U'*H, end='')
print('L'*W + 'D'*H, end='')
print('D' + 'R'*(W+1) + 'U'*(H+1) + 'L', end='')
print('U' + 'L'*(W+1) + 'D'*(H+1) + 'R', end='')

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-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;}

int a;

signed main(){
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    Arrays.sort(a);
    Arrays.sort(b);
    int A = a[n / 2];
    int B = b[n / 2];
    int ans = B - A + 1;
    if((n % 2) == 0) {
      int aa = (a[n / 2] + a[(n / 2) - 1]);
      int bb = (b[n / 2] + b[(n / 2) - 1]);
      ans = (bb - aa + 1);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 61668