akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_HW = 305;
char c[MAX_HW][MAX_HW];
int ans[MAX_HW][MAX_HW];
bool check[MAX_HW]; //その行にイチゴがあるか

void init()
{
	rep(i,MAX_HW)
	{
		check[i] = false;
	}
}

int main()
{
	init();
	int H,W,K;
	cin >> H >> W >> K;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> c[i][j];
			if (c[i][j] == '#')
			{
				check[i] = true;
			}
		}
	}

	int fh;

	rep(i,H)
	{
		if (check[i])
		{
			fh = i;
			break;
		}
	}

	int now = 1;

	rep(i,H)
	{
		bool flag = true; //その行で初めてのイチゴか
		rep(j,W)
		{
			if (c[i][j] == '#')
			{
				//cout << "a";
				if (flag)
				{
					//cout << "b";
					flag = false;
					rep(k,j+1)
					{
						ans[i][k] = now;
					}
				}

				ans[i][j] = now;
				j++;

				while(j < W && c[i][j] == '.')
				{
					ans[i][j] = now;
					j++;
				}
				j--;
				now++;
			}
		}
	}

	bool up = false;

	rep(i,H)
	{
		if (i == 0 && !check[i])
		{
			up = true;
			rep(j,W)
			{
				ans[i][j] = ans[fh][j];
			}
		}
		else if(!check[i])
		{
			rep(j,W)
			{
				ans[i][j] = ans[i-1][j];
			}
		}
	}

	rep(i,H)
	{
		rep(j,W)
		{
			if (j != 0)
			{
				cout << " ";
			}
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define M 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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

struct uf {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rcount;

    uf(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%M+M)%M) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= M) x -= M;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += M-a.x) >= M) x -= M;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= M;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime M
    mint inv() const {
        return pow(M-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


int main(){
	int n,k;cin>>n>>k;
	if(k==1)cout<<0<<endl;
	else if(n>=k)cout<<1<<endl;
	else if(!((k-n)%(n-1)))cout<<(k-n)/(n-1)+1<<endl;
	else cout<<(k-n)/(n-1)+2<<endl;
}


Measured memory_bytes: 256
# 嘘解法（-1 1は1になるはずが0と出力される）
# x, y = map(int,input().split())
# ans = float("inf")
# T = [y-x, 1+(-y-x), 1+(y+x), 2+(-y+x)]
# for i in T:
#     if i >= 0:  # 本当はここで(-y-x)や(y+x)や(-y+x)が0以上でないと通してはいけない
#         ans = min(ans, i)
# print(ans)

x, y = map(int,input().split())
ans = float("inf")
T = [[0, y-x], [1, -y-x], [1, y+x], [2, -y+x]]
for i in T:
    if i[1] >= 0:
        ans = min(ans, sum(i))
print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x = stdIn.nextInt();

        int[] l =  new int[n];
        for(int i = 0; i < n; i++) {
            l[i] = stdIn.nextInt();
        }

        int[] bound = new int[n + 1];
        bound[0] = 0;
        for(int i = 0; i < n; i++) {
            bound[i + 1] = bound[i] + l[i];
        }

        int count = 0;
        for(int i = 0;i < n + 1; i++) {
            if(bound[i] <= x) {
                count += 1;
            }
        }

        System.out.println(count);


        

    }
}

Measured memory_bytes: 23764
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
long long n,a[200010],ans,h,j;
int main()
{
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++){
		for (j;j<n;j++)
			if ((h|a[j])!=h+a[j])
				break;
			else{
				h=h+a[j];
				ans=ans+j-i+1;
			}
		h-=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
input = input()

arr = {}

for i in range(ord('a'), ord('z') + 1):
	arr[i] = 0;

for s in input:
	arr[ord(s)] = 1

flag = True
for i in arr:
	if arr[i] == 0:
		print(chr(i))
		flag = False
		break
	
if flag:
	print('None')



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define inv(x) qpow(x,mod-2)
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=200010;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n;
int fa[N],son[N];
int Max[N],dep[N],sz[N];
int bgn[N],nxt[N],to[N],e;
int Bgn[N],Nxt[N],To[N],E;
int w[N][3],ans;
inline void add_edge(int u,int v){nxt[++e]=bgn[u],bgn[u]=e,to[e]=v;}
inline void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
inline int qpow(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)ret=1ll*ret*a%mod;
	return ret;
}
inline void dfs_dep(int u)
{
	Max[u]=dep[u]=dep[fa[u]]+1;
	sz[dep[u]]++;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		dfs_dep(v=to[i]);
		if(chkmax(Max[u],Max[v]))son[u]=v;
	}
}
inline void dfs_ans(int u)
{
	if(son[u])dfs_ans(son[u]),Bgn[u]=Bgn[son[u]];
	int len=0;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==son[u])continue;
		dfs_ans(v);
		for(int now=1,x=Bgn[u],y=Bgn[v];y;x=Nxt[x],y=Nxt[y],now++)
		{
			if(chkmax(len,now))Add(w[x][0],w[x][2]),w[x][2]=0;
			Add(w[y][0],w[y][2]),w[y][2]=0;
			w[x][2]=1ll*w[x][2]*(w[y][0]+w[y][1])%mod;
			Add(w[x][2],1ll*w[x][1]*w[y][1]%mod);
			w[x][1]=1ll*w[x][1]*w[y][0]%mod;
			Add(w[x][1],1ll*w[x][0]*w[y][1]%mod);
			w[x][0]=1ll*w[x][0]*w[y][0]%mod;
		}
	}
	Nxt[++E]=Bgn[u];Bgn[u]=E;w[E][0]=w[E][1]=1;
}
int main()
{
	file();
	read(n);n++;
	For(i,2,n)
	{
		read(fa[i]);fa[i]++;
		add_edge(fa[i],i);
	}
	dfs_dep(1);
	dfs_ans(1);
	for(int len=1,x=Bgn[1];x;x=Nxt[x],len++)Add(ans,1ll*w[x][1]*qpow(2,n-sz[len])%mod);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 39296
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N;
int c[100010];

int dp[2][2][5002];

int main()
{
    N = in();

    rep(i, N - 1) {
        c[i+1] = in();
    }

    rep(i, 2) rep(j, 2) rep(k, N / 2 + 1) dp[i][j][k] = inf; 
    dp[0][0][0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= min(i, N / 2); ++j) {
            dp[(i + 1) & 1][0][j + 1] = min(dp[i & 1][0][j], dp[i & 1][1][j] + c[i]);
            dp[(i + 1) & 1][1][j] = min(dp[i & 1][1][j], dp[i & 1][0][j] + c[i]);
        }

        dp[(i + 1) & 1][0][0] = inf;
    }

    printf("%d\n", min(dp[N&1][0][N / 2], dp[N&1][1][N / 2]));
}

Measured memory_bytes: 3336
{-# LANGUAGE BangPatterns         #-}
{-# LANGUAGE DerivingStrategies   #-}
{-# LANGUAGE FlexibleContexts     #-}
{-# LANGUAGE RankNTypes           #-}
{-# LANGUAGE ScopedTypeVariables  #-}
{-# LANGUAGE UndecidableInstances #-}
import           Control.Monad.State.Strict
import qualified Data.ByteString.Char8      as BS
import           Data.Char
import           Data.List

main :: IO ()
main = do
  [n,m] <- readLnAsListWith unconsInt

  print $ (2^m) * (1900*m + 100*(n-m))

-- converter
unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

-- 1D Data
-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine


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

int main(){
    int n; cin >> n;
    map<string,int> s;
    int maxl = 0;

    for(int i = 0; i < n; i++){
        string tmp; cin >> tmp;
        s[tmp] += 1;
        maxl = max(maxl,s[tmp]);
    }
    for(auto i = s.begin(); i != s.end(); i++){
        if(i->second == maxl)
            cout << i->first << endl;
    }
    return 0;
}

Measured memory_bytes: 25216
def f(n):
  D={}
  A=[]
  for _ in range(n):
    a,b,c=map(int,raw_input().split(' '))
    if a in D: D[a]+=b*c
    else:
      D[a]=b*c
      A.append(a)
  B=[i for i in A if D[i]>=1e6]
  if B==[]: B=["NA"]
  return B

while 1:
  n=input()
  if n==0:break
  for e in f(n): print e

Measured memory_bytes: 4360
function main(input) {
  const args = input.split('\n');
  const row = args[0].split(' ');
  const N = row[0],
        K = row[1];
  let S = args[1].split('');
  
  S[K - 1] = S[K - 1].toLowerCase();
  console.log(S.join(''));
  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29516
#https://atcoder.jp/contests/abc147/submissions/8874645
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    ofs=6400
    h,w=map(int,input().split())
    A=[list(map(int,input().split())) for _ in range(h)]
    B=[list(map(int,input().split())) for _ in range(h)]
    dp=[[0]*w for _ in range(h)]
    x=abs(A[0][0]-B[0][0])
    dp[0][0]|=((1<<(ofs+x))|(1<<(ofs-x)))

    from itertools import product
    for i,j in product(range(h),range(w)):
        x=abs(A[i][j]-B[i][j])
        t=0
        if(i-1>=0):
            t|=dp[i-1][j]
        if(j-1>=0):
            t|=dp[i][j-1]
        dp[i][j]|=((t<<x)|(t>>x))

    for i,s in enumerate(bin(dp[-1][-1])[-ofs-1:]):
        if(s=='1'):
            print(i)
            return
                    
resolve()


Measured memory_bytes: 51292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MAXN=200100;
const int MAXK=16;
const int INF = 1e9;
const ll MOD = 1e9+7;

ll N,M,K,Q,u,v,w,a,b,c;
vpi V[MAXN];
ll A[MAXN];

int main(){
	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<SZ(a);++i){
		if(a[i]!=b[i])++ans;
	}
	cout<<ans;
}

Measured memory_bytes: 8616
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

fn rec(i: usize, j: usize, k: usize, dp: &mut [Vec<Vec<f64>>], n: usize) -> f64 {
    if i == 0 && j == 0 && k == 0 {
        return 0.0;
    }
    if dp[i][j][k] != 0.0 {
        return dp[i][j][k];
    }

    let mut result = 0.0;
    if i != 0 {
        result += rec(i - 1, j, k, dp, n) * i as f64;
    }
    if j != 0 {
        result += rec(i + 1, j - 1, k, dp, n) * j as f64;
    }
    if k != 0 {
        result += rec(i, j + 1, k - 1, dp, n) * k as f64;
    }
    result += n as f64;
    if i + j + k != 0 {
        result /= (i + j + k) as f64;
    }
    dp[i][j][k] = result;
    dp[i][j][k]
}

#[fastout]
pub fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let ones = a.iter().filter(|a| **a == 1).count();
    let twos = a.iter().filter(|a| **a == 2).count();
    let threes = a.iter().filter(|a| **a == 3).count();

    let mut dp = vec![vec![vec![0.0; 330]; 330]; 330];
    let result = rec(ones, twos, threes, &mut dp, n);
    println!("{:.10}", result);
}


Measured memory_bytes: 287224
#include<cstdio>

int main(){
    int f = 0,s = 0;

    for(int i=0;i<3;i++){
        int tmp;
        scanf("%d",&tmp);
        if(tmp == 5)f++;
        else if(tmp == 7) s++;
    }

    if(f == 2 && s == 1)printf("YES\n");
    else printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int64_t mod=1000000007;

int64_t modinv(int64_t a, int64_t m) {
    int64_t b=m,u=1,v=0;
    while(b){
      int64_t t=a/b;
      a-=t*b;swap(a,b);
      u-=t*v;swap(u,v);
    }
    u%=m;
    if(u<0)u+=m;
    return u;
}

int64_t comb2(int64_t n,int64_t r){
  if(n<=r) return 1; 
  int64_t re=1;
  for(int i=0;i<r;i++){
    re*=n-i;
    re%=mod;
    re*=modinv(i+1,mod);
    re%=mod;
  }
  
  return re;
}

int main(){
  int64_t n,ans=0,m;
  cin >> n;
  for(int i=1;i<=n/3;i++){
    m=1;
    m*=n-3*i;
    ans+=comb2(m+i-1,i-1);
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
n,m=gets.split.map(&:to_i)
l=[]
n.times do
  l << []
end
m.times do
  a,b=gets.split.map(&:to_i)
  l[a-1] << b-1
  l[b-1] << a-1
end
v=[0]*n
x=0
n.times do |i|
  if v[i]==0
    v[i]=1
    s=[i]
    c=1
    while s!=[]
      z=[]
      s.each do |ss|
        l[ss].each do |lss|
          if v[lss]==0
            v[lss]=1
            c+=1
            z << lss
          end
        end
      end
      s=z.dup
    end
    x=c if x<c
  end
end
puts x


Measured memory_bytes: 36080
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
    long X = 1;
    ArrayList<Long> array = new ArrayList<>();

    for(long i = 1; i <= (long)Math.sqrt(N);i++){
      if(N%i == 0){
        array.add(i + (N/i));
      }
    }

    long culc = array.get(0);
    for(int i = 1; i < array.size(); i++){
      if(array.get(i) < culc)
        culc = array.get(i);
    }

    System.out.println(culc-2);
	}

  public static boolean isPrime(long num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = Math.sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
  }
}

Measured memory_bytes: 24020
# ABC102C - Linear Approximation (ARC100C)
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    A = sorted(j - i for i, j in enumerate(A, start=1))
    b = A[n // 2]
    ans = sum(abs(a - b) for a in A)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25324
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	/* 後日解説みながら */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long X = scan.nextLong();
		scan.close();

		List<Long> a = new ArrayList<>();
		List<Long> p = new ArrayList<>();

		for(int i=0; i<N; i++) {
			a.add(count(i));
			p.add(countP(i));
		}
		System.out.println(f(N, X, p, a));
	}

	public static long f(int N, long X, List<Long> p, List<Long> a) {
		if(N==0) {
			if(X<=0) {
				return 0;
			} else {
				return 1;
			}
		} else if(X<=1+a.get(N-1)) {
			return f(N-1, X-1, p, a);
		} else {
			return p.get(N-1)  + 1 + f(N-1, X-2-a.get(N-1), p, a);
		}
	}

	public static void main2(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		long X = scan.nextLong();
		scan.close();

		//System.out.println(count(N));
		//System.out.println(countP(N));
		//System.out.println(fullL(countP(N)));

		long eatP=0;
		long eatAll = 0;
		int eatLevel = 0;

		if(X<=N) {
			System.out.println(0);
			return;
		}

		while(true) {
			eatLevel = fullL(X);
			eatP+= countP(eatLevel);
			eatAll+= count(eatLevel);
			if(eatLevel==0) {
				break;
			}
			if(count(eatLevel)<X-2) {
				eatP++;
				eatAll+=2;
			}
			X = X - eatAll;

		}

		System.out.println(eatP);





		//System.out.println(countPX(N,X));

	}

	private static long countPX(int N, int X) {
		return 0;
	}

	//指定された層までに完全に含まれるバーガーのレベルを返す
	public static int fullL(long sou) {
		int L=0;
		for(int i=1; i<=50; i++) {
			if(count(i)<=sou) {
				L++;
			} else {
				break;
			}
		}
		return L;
	}

	//層の数を返す
	public static long count(int N) {
		if(N==0) return 1;
		return(count(N-1)*2+3);
	}

	//Pの数を返す
	public static long countP(int N) {
		if(N==0) return 1;
		return(countP(N-1)*2+1);
	}
}


Measured memory_bytes: 22736
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    w, h, x, y = MII()
    print((w*h)/2, end=' ')
    if w/2 == x and h/2 == y: print(1)
    else: print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
 int main() {
	 int N;
	 cin >> N;
	 int D, X;
	 cin >> D >> X;
	 int ans = X;
	 for (int i = 0; i < N; i++) {
		 int A;
		 cin >> A;
		 ans += 1 + (D - 1) / A;
	 }
	 cout << ans << endl;
}

Measured memory_bytes: 256
from functools import reduce
import math

k = int(input())

s = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            s += gcd(i,j,l)

print(s)



Measured memory_bytes: 69912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    vector<int> a(N);
    cin >> a;
    int ans = 0, count = 1;
    for (int i = 0; i < N; i++) {
        if (a[i] == count) ++count;
        else {
            ++ans;
        }
    }
    if (ans == N) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,p;
    scanf("%lld %lld",&n,&p);
    ll sz[100];
    int times[100]={0};
    int len=0;
    for(ll i=2;i*i<=p;i++)
    {
        if(p%i==0)
        {
            sz[len]=i;
            while(p%i==0)
            {
                times[len]++;
                p/=i;
                
            }
            len++;
        }
    }
    if(p!=1)
    {
        sz[len++]=p;
        times[len-1]=1;
    }
    ll res=1;
    for(int i=0;i<len;i++)
    {
     //   printf("%d  %d\n",sz[i],times[i]);
        while(times[i]>=n)
        {
            res*=sz[i];
            times[i]-=n;
        }
    }
    printf("%lld",res);
    return 0;
}



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


using namespace std;

int main(){
    string s,ans = "Good";
    cin>>s;
    for(int i = 0; i < 3;i++){
        if(s[i] == s[i+1]){
            ans = "Bad";
        }
    }
    
    
    
    cout << ans <<endl;

    return 0;
}

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

#define MAX 4000
int num[MAX+1],cnt[MAX/2+1];

void s(){
    for(int i = 0 ; i <= MAX ; i++) num[i] = 0;
    for(int j = 0 ; j <= MAX/2 ; j++) cnt[j] = 0;
    
    for(int i = 0 ; i <= MAX/4 ; i++)
        for(int j = 0 ; j <= MAX/4 ; j++)
            ++cnt[i+j];
    
    for(int i = 0 ; i <= MAX/2 ; i++)
        for(int j = 0 ; j <= MAX/2 ; j++)
            num[i+j] += cnt[i] * cnt[j];
}

int main(){
    int n; s();
    
    while(cin >> n) cout << num[n] << endl;
    
    return 0;
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
const long long MOD =  998244353;
const int MAX = 300001;
long long fac[MAX];
long long finv[MAX];
long long inv[MAX];

void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  long long N;
  long long A;
  long long B;
  long long K;
  cin >> N >> A >> B >> K;
  comb_init();
  long long ans = 0;
  for(long long i = 0; i <= N; i++){
    if((K - i * A) % B == 0 && (K - i * A) / B <= N){
      ans = (ans + (comb(N, i) * comb(N, (K - i * A) / B)) % MOD) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
N = int(input())
H = list(map(int,input().split()))
maximum = 0
for i in range(N-1):
  if H[i] > H[i+1]:
    H[i] -= 1
    maximum = max(maximum,H[i])
    if maximum > H[i+1]:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 14396
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

const int maxn = 1e5;
int n, a[maxn];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += (a[i] & 1);
  }
  puts(cnt & 1 ? "NO" : "YES");
}


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

string S;

int main(){
    cin >> S;

    int64_t ans = 0;
    int64_t Acnt = 0;
    for(int i=0;i<S.size();i++){
        if( i + 1 < S.size() && S[i] == 'B' && S[i+1] == 'C' ){
            ans+=Acnt;
            i++;
        } else if( S[i] == 'A' ){
            Acnt++;
        }
        else{
            Acnt = 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<"T"<<v.at(i)<<endl;
}
int main(){
    lli mod=1000000007;
    lli n,k,ans=0;
    cin>>n>>k;
    vi ov;
    vi num(n);
    map<lli,lli> ovn;
    vi a(n);
    rep(i,n) {
        cin>>a[i];
        ov.push_back(a[i]);
    }
    rep(i,n){
        lli now=0;
        for(lli j=i+1;j<n;j++){
            if(a[i]>a[j]){
                now++;
            }
        }
        num[i]=now;
    }
    sort(all(ov));
    reverse(all(ov));
    rep(i,n){
        if(!ovn.count(ov[i])){
            lli t=0;
            while(i+t+1<n&&ov[i]==ov[i+t+1]){
                t++;
            }
            ovn[ov[i]]=n-i-t-1;
        }
    }
    rep(i,n){
        ans+=num[i]*k;
        ans%=mod;
        lli sum=((k*(k-1))/2);
        sum%=mod;
        ans+=ovn[a[i]]*sum;
        ans%=mod;
    }
    out(ans);
}

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

int main() {
  long X;
  cin >> X;
  long A, B;
  for (A=0; A<=120; A++) {
    long A5 = A*A*A*A*A;
    for (B=-80; B<A; B++) {
      if (A5-B*B*B*B*B == X) {
        cout << A << ' ' << B << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3596
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K= IL()
if K*2-1 <= N:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 22012
class DisjointSet(object):
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n
        self.num = n  # number of disjoint sets

    def union(self, x, y):
        self._link(self.find_set(x), self.find_set(y))

    def _link(self, x, y):
        if x == y:
            return
        self.num -= 1
        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def find_set(self, x):
        xp = self.parent[x]
        if xp != x:
            self.parent[x] = self.find_set(xp)
        return self.parent[x]

def read_data():
    N = int(input())
    xs = []
    ys = []
    for i in range(N):
        x, y = map(int, input().split())
        xs.append((x, i))
        ys.append((y, i))
    return N, xs, ys

def add_edges(xs):
    es = []
    prev_x, prev_i = xs[0]
    for x, i in xs[1:]:
        es.append((x - prev_x, prev_i, i))
        prev_x = x
        prev_i = i
    return es

def solve(N, xs, ys):
    xs.sort()
    ys.sort()
    es = add_edges(xs)
    es.extend(add_edges(ys))
    es.sort()
    ds = DisjointSet(N)
    cost = 0
    for d, i, j in es:
        if ds.find_set(i) == ds.find_set(j):
            continue
        ds.union(i, j)
        cost += d
    return cost

N, xs, ys = read_data()
print(solve(N, xs, ys))


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

int main(void){
	
	long int N;
	cin >> N;
	long int M = (long int)sqrt(N);
	long int i = 1;
	long int w,p;
	long int ans = N+1;
	for(i = 2; i <= M + 1; i++){
		if(N%i==0){
			w = N / i;
			p = i + w;
			if(ans > p){
				ans = p;
			}
		}
	}
	
	cout << ans-2<<endl;
	return 0;
}

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

int main(void){
	int N;
	ll K;
	cin >> N >> K;
	int A[N+1];
	rep(i,N) cin >> A[i+1];

	int vis[N+1], step[N+1];
	rep(i,N) vis[i+1] = 0;
	int k = 1;
	int i_loop = N;
	for (int i = 0; i <= N; i++) {
		vis[k]++;
		if (vis[k] == 2) {
			i_loop = i;
			break;
		}
		step[k] = i;
		k = A[k];	
	}

	if (K <= step[k]) {
		int goal = 1;
		rep(i,K){
			goal = A[goal];
		}
		cout << goal << endl;
		return 0;
	}

	int T = i_loop - step[k];
	vector<int> ltown;
	rep(i,T){
		ltown.push_back(k);
		k = A[k];
	}

	K -= step[k];
	K %= T;
	cout << ltown[K] << endl;
	
	
return 0;
}


Measured memory_bytes: 6488
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int A[1000005];

int cti(char c)
{
	return c - '0';
}

int main()
{
	string S;
	cin >> S;
	int ans = 0;
	rep(i,S.size())
	{
		ans += cti(S[i]);
		A[i] = cti(S[i]);
		//cout << A[i];
	}
	//cout << endl;
	//cout << ans << endl;
	for (int i = S.size()-1; i > 0; --i)
	{
		if (A[i] == 10)
		{
			ans -= 9;
			A[i] = 0;
			A[i-1]++;
		}
		else if (A[i] >= 6 || (A[i] == 5 && A[i-1] >= 5))
		{
			ans -= 2 * A[i] - 11;
			A[i-1]++;
		}
	}

	//cout << A[0] << endl;
	if (A[0] == 10)
	{
		ans -= 9;
		A[0] = 0;
	}
	else if (A[0] >= 6)
	{
		//cout << "a" << endl;
		ans -= 2 * A[0] - 11;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5252
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

struct UnionFind {
    vector<ll> par;  // 親
    vector<ll> siz;  // 親

    UnionFind(ll N) : par(N), siz(N, 1){ //最初は全てが根であるとして初期化
        for(ll i=0; i < N; i++) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);  // 小を大にくっつける
        par[ry] = rx;
        siz[rx] += siz[ry];
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }

    ll size(ll x) {
        return siz[root(x)];
    }

};


int main() {
    ll N, M;
    cin >> N >> M;

    vector<pair<ll, ll>> Bridges(M-1);
    for (ll i=0; i<M; i++) {
        ll a, b; 
        cin >> a >> b; 
        --a;
        --b;
        if (i==0) continue;
        pair<ll, ll> p = {a, b};
        Bridges[M-1-i] = p;
    }

    UnionFind tree(N);
    vector<ll> res(M);
    res[0] = N*(N-1)/2;
    ll i = 1;
    for (pair<ll, ll>& bridge: Bridges) {
        if (tree.same(bridge.first, bridge.second)) {
            res[i] = res[i-1];
        } else {
            ll sizx = tree.size(bridge.first);
            ll sizy = tree.size(bridge.second);
            tree.unite(bridge.first, bridge.second);
            res[i] = res[i-1] - (sizx * sizy);
        }
        ++i;
    }

    reverse(res.begin(), res.end());  

    for (ll r: res) {
        cout << r << endl;
    }

    return 0;
}

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

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

  int n;
  cin >> n;
  vector<int> v_odd(n / 2), v_even(n / 2);
  for(int i = 0; i < n; ++i) {
    if(i % 2 == 0) {
      cin >> v_odd.at(i / 2);
    }
    else {
      cin >> v_even.at(i / 2);
    }
  }

  sort(v_odd.begin(), v_odd.end());
  sort(v_even.begin(), v_even.end());

  vector<pair<int, int>> even_list, odd_list;
  int cnt = 0;
  int odd_comp = v_odd.at(0);
  for(int i = 0; i < v_odd.size(); ++i) {
    if(odd_comp == v_odd.at(i)) cnt++;
    else {
      odd_list.push_back({cnt, odd_comp});
      odd_comp = v_odd.at(i);
      cnt = 1;
    }
    if(i == v_odd.size() - 1) {
      odd_list.push_back({cnt, odd_comp});
    }
  }
  cnt = 0;
  int even_comp = v_even.at(0);
  for(int i = 0; i < v_even.size(); ++i) {
    if(even_comp == v_even.at(i)) cnt++;
    else {
      even_list.push_back({cnt, even_comp});
      even_comp = v_even.at(i);
      cnt = 1;
    }
    if(i == v_even.size() - 1) {
      even_list.push_back({cnt, even_comp});
    }
  }

  // for(int i = 0; i < odd_list.size(); ++i) {
  //   cout << odd_list.at(i).first << " : " << odd_list.at(i).second << endl;
  // }
  // for(int i = 0; i < even_list.size(); ++i) {
  //   cout << even_list.at(i).first << " : " << even_list.at(i).second << endl;
  // }

  sort(odd_list.begin(), odd_list.end());
  sort(odd_list.rbegin(), odd_list.rend());
  sort(even_list.begin(), even_list.end());
  sort(even_list.rbegin(), even_list.rend());

  if(odd_list.at(0).second != even_list.at(0).second) {
    cout << ((n / 2) - odd_list.at(0).first) + ((n / 2) - even_list.at(0).first) << endl;
  }
  else {
    if(odd_list.at(0).first < even_list.at(0).first) {
      int odd_min_second = ((n / 2) - odd_list.at(1).first) + ((n / 2) - even_list.at(0).first);
      cout << odd_min_second << endl;;
    }
    else if(odd_list.at(0).first > even_list.at(0).first) {
      int even_min_second = ((n / 2) - odd_list.at(0).first) + ((n / 2) - even_list.at(1).first);
      cout << even_min_second << endl;;
    }
    else {
      if(odd_list.at(0).first == n / 2) {
        cout << n / 2 << endl;
      }
      else {
        cout << min(((n / 2) - odd_list.at(1).first) + ((n / 2) - even_list.at(0).first), ((n / 2) - odd_list.at(0).first) + ((n / 2) - even_list.at(1).first)) << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1784
#include <stdio.h>

int main()
{
    int N,H,max = 0,n = 0;
    scanf("%d",&N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d",&H);
        if (max <= H){
            max = H;
            n++;
        }
    }
    printf("%d",n);
}

Measured memory_bytes: 128
alpha = input()

# ald = [1:a,2:b,3:c,4:d,5:e,6:f,8:g,9:h,10:i,11:j,12:k,13:l,14:m,15:n,16:o,16:p,17:q,18:r,19:s,20:t,21:u,22:v,23:w,24:x,25:y,26:z]

ald = {'a':'b','b':'c','c':'d','d':'e','e':'f','f':'g','g':'h','h':'i','i':'j','j':'k','k':'l','l':'m','m':'n','n':'o','o':'p','p':'q','q':'r','r':'s','s':'t','t':'u','u':'v','v':'w',"w":'x','x':'y','y':'z'}


if alpha in ald:
    print(ald[alpha])

Measured memory_bytes: 3064
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    S = sum(A)
    cumsum = accumulate(A)
    mini = min(cumsum,key=lambda x: abs(x-S/2))
    ans = abs(mini-S/2)*2
    print(int(ans))
if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m, x, y; cin>>n>>m>>x>>y;
    vector<int> a(n), b(m);
    int MAX=-MOD;
    for(int i=0; i<n; i++) {
        cin>>a[i];
        MAX=max(MAX, a[i]);
    }
    int MIN=MOD;
    for(int i=0; i<m; i++) {
        cin>>b[i];
        MIN=min(MIN, b[i]);
    }

    for(int i=MAX+1; i<=MIN; i++){
        if(x<i && i<=y){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e10,dp1[1000001];
int num[10];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {    
       int n,x,t;
       cin>>n>>x>>t;
       if(n%x==0)
       cout<<(n/x)*t;
       else
       {
           cout<<((n/x)+1)*t;
       }
    }
 
}
// 🍪 🍪 🍪

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

//using ll = long long int;
#define PI 3.141592653589793
//141167095653376;

int main(void) {
	
	char s[200010];
	char t[200010];
	int i = 0;
	int cnt = 0;
	scanf("%s", s);
	scanf("%s", t);

	while (s[i] != '\0')
	{
		if (s[i] != t[i])
		{
			cnt++;
		}
		i++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 2124
package main

import (
	"fmt"
)

func main() {
	var p, q, r, min int
	fmt.Scanf("%d%d%d", &p, &q, &r)

	min = p + q
	if min > q+r {
		min = q + r
	}
	if min > r+p {
		min = r + p
	}
	fmt.Printf("%d\n", min)
}


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

#define ll long long
#define mod 1000000007

int main() {

    string s,t;
    cin>>s>>t;
    ll L[s.length()+ 1][t.length()+ 1];
    for (ll i = 0; i <= s.length(); i++)
    {
        for (ll j = 0; j <= t.length(); j++)
        {
        if (i == 0 || j == 0)
            L[i][j] = 0;
        else if (s[i - 1] == t[j - 1]){
                L[i][j] = L[i - 1][j - 1] + 1;
        }
        else
            L[i][j] = max(L[i - 1][j], L[i][j - 1]);
        }
    }
    ll idx=L[s.length()][t.length()];
    string ans="";

   ll i = s.length(), j = t.length();
   while (i > 0 && j > 0)
   {
      if (s[i-1] == t[j-1])
      {
          ans+= s[i-1];
          i--; j--;
      }
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
   reverse(ans.begin(),ans.end());
   cout<<ans;

    return 0 ;
}


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

typedef long long ll;
typedef unsigned long long ull;

bool pair_sort(pair<ll, ll> &a, pair<ll, ll> &b) {
  return a.second > b.second;
}

int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  vector<pair<ll, ll>> bc(m);
  for (ll i = 0; i < m; ++i) {
    ll b, c;
    cin >> b >> c;
    bc[i] = make_pair(b, c);
  }
  sort(bc.begin(), bc.end(), pair_sort);

  ll j = 0;
  for (ll i = 0; i < n; ++i) {
    if (bc.size() <= j) break;
    bc[j].first--;
    ll c = bc[j].second;
    if (bc[j].first == 0) ++j;

    if (a[i] < c) a[i] = c;
  }

  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    ans += a[i];
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 2560
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  unordered_set<ll> uos;
  const ll AEND = min(A + K - 1, B);
  for (ll i = A; i <= AEND; i++) {
    cout << i << endl;
    uos.emplace(i);
  }
  const ll BBEGIN = max(B - K + 1, A + K);
  for (ll i = BBEGIN; i <= B; i++) {
    if (uos.count(i) == 0) {
      cout << i << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3612
import Control.Monad
import Data.List
main = getLine >>= main' . map read . words
    where
        main' [0, 0, 0] = return ()
        main' xs@(m : _) = replicateM m readLn >>= print . solve xs . sort >> main

solve :: [Int] -> [Int] -> Int
solve [m, nmin, nmax] xs = fst . fst $ foldl' ff ((m, -1), xs) [m - 1, (m - 2)..nmin]
    where
        ff (prev@(prevn, prevp), (a : b : cs)) n
            | n > nmax = (prev, b : cs)
            | p <= prevp = (prev, b : cs)
            | otherwise = ((n, p), b : cs)
            where
                p = b - a

Measured memory_bytes: 5448
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int A, B;
    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        A = int.Parse(line[0]);
        B = int.Parse(line[1]);
    }


    public void Solve()
    {
        Scan();
        if ((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0))
        {
            Console.WriteLine("Possible");
        }
        else
        {
            Console.WriteLine("Impossible");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n,k;
	cin>>n>>k;
	ll v;
	vector<ll> V;
	rep(i,n){
		cin>>v;
		V.push_back(v);
	}
	ll ans = 0;
	reps(i,n){//i個取り出す
		if(i>k) break;
		rep(j,i+1){//左からj個取り出す
			vector<ll> stack;
			int l = 0;
			int r = n-1;
			ll value  = 0;
			for(l=0; l<j; l++){
				stack.push_back(V[l]);
				value += V[l];
			}
			rep(h,i-j){
				stack.push_back(V[r]);
				value += V[r];
				r--;
			}
			
			sort(all(stack));
			rep(h,k-i){
				if(h >= stack.size()) break;
				if(stack[h] >= 0) break;
				
				value -= stack[h];
			}
			chmax(ans,value);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n,t;
	cin>>n>>t;
	long int i,a[n],x=t;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<n;i++)
	{
		if(a[i]-a[i-1]<=t)
		{
			x=x+a[i]-a[i-1];
		}
		else
		{
			x=x+t;
		}
	}
	cout<<x<<endl;
	
}

Measured memory_bytes: 5072
#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'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
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(){
    
    int h, w;
    cin >> h >> w;
    int sh, sw, gh, gw;
    cin >> sh >> sw >> gh >> gw;
    sh--; sw--; gh--; gw--;
    V<string> s(h);
    rep(i,h) cin >> s[i];

    V<V<int>> dist(h,V<int>(w,-1));
    deque<pair<P,int>> dq; // pair = (pair(y,x), cost)
    dq.emplace_front(pair(sh,sw),0);

    while(sz(dq)) {
        P v = dq.front().fi;
        int cost = dq.front().se;
        dq.pop_front();
        if(dist[v.fi][v.se] != -1) continue;
        dist[v.fi][v.se] = cost;
        rep(di,4) {
            int ny = v.fi + dy[di];
            int nx = v.se + dx[di];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(s[ny][nx] == '#' || dist[ny][nx] != -1) continue;
            dq.emplace_front(pair(ny,nx),cost);
        }
        for(int y = -2; y <= 2; y++) for(int x = -2; x <= 2; x++) {
            int ny = v.fi + y;
            int nx = v.se + x;
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(s[ny][nx] == '#' || dist[ny][nx] != -1) continue; 
            dq.emplace_back(pair(ny,nx),cost+1);          
        }
    }
    int ans = dist[gh][gw];
    cout << ans << endl;
}

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

int main(void)
{
    int a,b,c,k;
    int magic=0;

    cin >> a >> b >> c >> k;

    //a<b<cになればYes

    while(b<=a){
        b*=2;
        magic++;
    }
    while(c<=b){
        c*=2;
        magic++;
    }

    if(magic>k){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> visited(n);
  visited[0] = 1;
  int _new = 0;
  long long bar = 1;
  while (true) {
    _new = a[_new];
    if (visited[_new]) {
      break;
    }
    visited[_new] = 1;
    bar++;
  }
  int cur = _new;
  long long cnt = 0;
  vector<int> path;
  path.push_back(cur);
  while (true) {
    _new = a[_new];
    cnt++;
    if (_new == cur) break;
    path.push_back(_new);
  }
  long long foo = bar - cnt;
  if (foo > k) {
    _new = 0;
    for (int i = 0; i < k; i++) {
      _new = a[_new];
    }
    cout << _new + 1 << '\n';
    return 0; 
  }
  k -= (bar - cnt);
  k %= cnt;
  
  cout << path[k] + 1 << '\n';
  return 0;
}

Measured memory_bytes: 5792