akhauriyash/Code-Regression huggingface dataset:
/*
3
[8, 12, 40];

6
[382253568, 723152896, 37802240, 379425024, 404894720, 471526144]
*/
fn main() {
    let n = read();
    let mut vec = read_line();

    let mut cnt = std::u32::MAX;
    for i in 0..n as usize {
        let mut t_cnt = 0;
        while (vec[i] % 2 == 0 && vec[i] != 0) {
            vec[i] /= 2;
            t_cnt += 1;
        }
        cnt = std::cmp::min(t_cnt, cnt);
    }

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

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_line() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    return v
}

Measured memory_bytes: 4352
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn main() {
    let (l, r) = parse_pair::<usize, usize>();

    let mut i_mods = (l..r).take(2019).map(|n| n % 2019).collect::<Vec<usize>>();
    i_mods.sort();
    i_mods.dedup();

    let mut j_mods = (l + 1..r + 1).take(2019).map(|n| n % 2019).collect::<Vec<usize>>();
    j_mods.sort();
    j_mods.dedup();

    let mut min_mod = 2018;

    for i in i_mods {
        for &j in &j_mods {
            let m = (i * j) % 2019;
            if m < min_mod { min_mod = m; }
        }
    }

    println(min_mod);
}


Measured memory_bytes: 4352
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#define vi vector<int>
#define lli long long int
#define fo(i,n) for(int i=1;i<=n;i++)
#define foo(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define vii vector<lli>

#define ok ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#define vp vector<pair<lli,lli>>
#include <map>           
lli mod=1000000007;         


int main(){
  lli n,x,t;
  cin>>n>>x>>t;
  if(n%x == 0){
  	cout<<(n/x * t);
  }
  else cout<<((n/x + 1)*t);
//  cout<<(n%x==0)?(n/x * t):(n/x + 1)*t;
}

/*int main(){
	string s;
	cin>>s;
	lli sum=0;
	for(char c:s){
		sum+=(c-'0');
	}
	if(sum%9) cout<<"No";
	else cout<<"Yes";
}

/*int main(){
	lli n,mxx,s=0;
	cin>>n;
	vi v(n),mx(n);
	foo(i,n) cin>>v[i];
	mxx=v[0];
//	cout<<mxx;

    foo(i,n){
    	if(v[i]>mxx)
    	mxx=v[i];
    	s+=abs(mxx-v[i]);
	}

for(int i=1;i<=n-1;i++)
	{
		if(v[i]>mxx)
		mx[i]=v[i],mxx=v[i];
		else mx[i]=mxx;
	}
	foo(i,n){
		s+=abs(v[i]-mx[i]);
	}
	
//	foo(i,n) cout<<mx[i]<<" ";
	cout<<s;
}*/







Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vl p(n);
  rep(i, n) {
    cin >> p[i];
  }

  ll mini = 1LL << 60;
  ll ans = 0;
  rep(i, n) {
    if (mini >= p[i]) {
      ans++;
    }
    cmin(mini, p[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
A,B,C,X,Y = map(int,input().split())

ave = (A+B)//2
#個別で買う or 組み合わせて不足分を買う or 組み合わせて余る　

ans1 = A*X + B * Y

ans2 = min(X,Y)*C*2
if X > Y:
    ans2 += (X-Y) * A
elif Y > X:
    ans2 += (Y-X) * B

ans3 = max(X,Y)*C*2

print(min(ans1,ans2,ans3))

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        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 mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};




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

    mint k = 1;

    for(int i = 0 ; i < n; i ++) {
        k *= (i + 1);
    }

    cout << k.x << endl;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int a[200000];


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

	cin >> n;
	rep(i, n)cin >> a[i];


	long long s = accumulate(a, a + n, 0LL);
	int mi = *min_element(a, a + n);
	int ma = *max_element(a, a + n);

	if (s % 2) {
		if (mi % 2 == 0 || mi % 2 == 1 && (mi != ma || n % 2 == 1)) {
			cout << "First" << endl;
		}
		else {
			cout << "Second" << endl;
		}
	}
	else {
		if (mi % 2 == 1 && n % 2 == 0) {
			cout << "First" << endl;
		}
		else {
			cout << "Second" << endl;
		}
	}



	return 0;
}


Measured memory_bytes: 3948
package main

import "fmt"

func main() {
	var n, x int
	for {
		fmt.Scan(&n, &x)

		if n == 0 && x == 0 {
			return
		}

		count := 0
		for i := 1; i <= n; i++ {
			for j := i + 1; j <= n; j++ {
				if j == i {
					continue
				}
				for k := j + 1; k <= n; k++ {
					if k == i || k == j {
						continue
					}

					if i+j+k == x {
						count++
					}
				}
			}
		}

		fmt.Println(count)
	}
}



Measured memory_bytes: 1124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1619&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */

ll n,m;

string b[505];

// n <= m
bool ok[501];

// n >= m
int bit[501];
int dp[2][1<<22];

int solve(){
    int res = 0;
    for(int i = 0; i < n;i++) cin >> b[i];
    if(n <= m){
        for(int i = 0; i < (1<<n);i++){
            if(res >= __builtin_popcount(i)) continue;
            fill(ok,ok+501,false);
            for(int j = 0; j < n;j++){
                if(!((i>>j)&1)) continue;
                for(int k = 0; k < m;k++){
                    if(b[j][k] == '1') ok[k] = !ok[k];
                }
            }
            if(accumulate(ok,ok+m,0)) continue;
            res = max(res,__builtin_popcount(i));
        }
    }else{
        fill(bit,bit+n,0);
        for(int i = 0; i < n;i++){
            for(int j = 0; j < m;j++){
                if(b[i][j] == '1'){
                    bit[i] |= (1<<j);
                }
            }
        }
        for(int i = 0; i < 2;i++) for(int j = 0; j < (1<<m);j++) dp[i][j] = -1;
        dp[0][0] = 0;
        int cur = 0, next = 1;
        for(int i = 0; i < n;i++){
            for(int j = 0; j < (1<<m);j++){
                if(dp[cur][j] == -1) continue;
                dp[next][j] = max(dp[next][j],dp[cur][j]);
                dp[next][j^bit[i]] = max(dp[next][j^bit[i]],dp[cur][j]+1);
                
                dp[cur][j] = -1;
            }
            swap(cur,next);
        }
        res = dp[cur][0];
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> n >> m,n){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 19588
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N, M, a,b;
    cin >> N >>M;
    dsu uf(N);
    rep(i,M){
        cin >> a >> b;
        --a; --b;
        uf.merge(a,b);
    }
    set<int> cnt;
    rep(i,N){
        cnt.insert(uf.leader(i));
    }
    cout <<  cnt.size() - 1 << endl;
    return 0;
}


Measured memory_bytes: 7728
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    if h == eh and w == ew:
        dst[h][w] = d
        break
    if 0 <= h < H and 0 <= w < W and dst[h][w] < 0 and S[h][w] != '#':
        dst[h][w] = d
        for i in range(4): dq.appendleft((h + dhw[i][0], w + dhw[i][1], d))
        for i in range(4, 24): dq.append((h + dhw[i][0], w + dhw[i][1], d+1))

print(dst[eh][ew])


Measured memory_bytes: 264444
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


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

#define PII pair<int,int>
#define PP pair< int,PII >


using namespace std;

int c[16][16];

int main(){
	
	int n;
	while(scanf("%d", &n),n){
		int x = n/2;
		int y = n/2+1;
		rep(i,16)rep(j,16)c[i][j] = -1;
		
		reps(i,1,n*n+1){
			
			if(n <= x || x < 0 || n <= y){
				if(n <= x)x = 0;
				else if(x < 0)  x = n-1;
				else if(n <= y) y = 0;
				i--;
				continue;
			}
			
			if(c[y][x] != -1){
				x--;y++;
				i--;
				continue;
			}
			
			c[y][x] = i;
			x++;y++;
		}
		
		rep(i,n){
			rep(j,n){
				printf("%4d", c[i][j]);
			}puts("");
		}
	}
	
	return 0;
	
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

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

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    int sn[n+1]={};
    f(i,0,k)
    {
        int d;cin>>d;
        f(i,0,d)
        {
            int a;cin>>a;
            sn[a]++;
        }
    }
    int ans=0;
    f(i,1,n+1) if(!sn[i]) ans++;
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> f(10001);
    int nt;
    for(int x = 1; x < 100; ++x) {
        for(int y = 1; y < 100; ++y) {
            for(int z = 1; z < 100; ++z) {
                nt = x * x + y * y + z * z + x * y + y * z + z * x;
                if(nt <= 10000) f[nt]++;
            }
        }
    }

    for(int i = 1; i <= n; ++i) {        
        printf("%d\n", f[i]);
    }

    return 0;
}

Measured memory_bytes: 3780
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    cout1(24+(24-N))
}

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

int main(){
    int n,m,A[100][100],b[1000];
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            int x;
            cin >> x ;
            A[i][j] = x;
        }
    }
    for (int i = 0; i < m; i++)
    {
        int y;
        cin >> y;
        b[i] = y;
    }
    for (int i = 0; i < n; i++)
    {
        int z = 0;
        for (int j = 0; j < m; j++)
        {
            z = z + (A[i][j] * b[j]);
        }
        cout << z << endl;
    }
return 0;
}
    


Measured memory_bytes: 3112
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'



void solve()
{
 
}


int main() 
{ IOS
 
 int n;
  cin>>n;
  long long int a[n] , dp[n+1][n+1],c[n+1][n+1];

  for (int i = 0; i < n; ++i)
  	{cin>>a[i];
  		c[i+1][i+1]=a[i];
  		dp[i+1][i+1]=0;
  	}
  
 

   for (int i = 1; i < n ; ++i)
   {
   	  for(int j=1;i+j<=n;j++)
   	  {  dp[j][i+j]=1e17;
         for(int k = j+1; k <= (i+j) ; ++k)
         {  c[j][i+j]=c[j][k-1]+c[k][i+j];
         	dp[j][i+j]=min(dp[j][i+j],dp[j][k-1]+dp[k][i+j]+c[j][i+j]);

         }

   	  }
   }

   cout<<dp[1][n];


  return  0;

}

Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = list( map( int ,input().split()))
    dpOne = [0]*(N+1)
    for i in range(3):
        a, b = A[i], B[i]
        for j in range(N-a+1):
            if dpOne[j+a] < dpOne[j]+b:
                dpOne[j+a] = dpOne[j]+b
    donguri = N
    for i in range(N+1):
        if donguri < N-i+dpOne[i]:
            donguri = N - i +dpOne[i]
    K = donguri
    dpTwo = [0]*(K+1)
    for i in range(3):
        a, b  = A[i], B[i]
        for j in range(K-b+1):
            if dpTwo[j+b] < dpTwo[j]+a:
                dpTwo[j+b] = dpTwo[j]+a
    ans = K
    for i in range(K+1):
        if ans < K - i + dpTwo[i]:
            ans = K-i+dpTwo[i]
    print( ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 228508
#include<bits/stdc++.h>
#define int long long
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
const int N = 2e6 + 233;
int a[N], b[N], cnt = 0, x, n, k;
vector<pair<int, int> > ans;

inline void solve() {
  ans.clear();
  memcpy(a, b, sizeof(int) * (n + 233));
  for(int i = 1; i <= n; i ++) a[i] = -a[i];
  reverse(a + 1, a + n + 1);
  cnt = 0;
  // for(int i = 1; i <= n; i ++)
  //   cout << a[i] << " ";
  // puts("");
  int mx = *max_element(a + 1, a + n + 1);
  int pos; for(int i = 1; i <= n; i ++) if(mx == a[i]) pos = i;
  int cnt = 0;
  for(int i = 2; i <= n; i ++) {
    while(a[i] < a[i - 1]) {
      a[i] += mx, cnt ++;
    }
    for(int k = 1; k <= cnt; k ++) ans.push_back(make_pair(pos, i));
    cnt = 0;
    if(a[i] > mx) mx = a[i], pos = i;
  }
  if((int)ans.size() <= 2 * n) {
    cout << (int)ans.size() << "\n";
    for(auto &u:ans) cout << n - u.first + 1 << " " << n - u.second + 1 << "\n";
  }
}

main() {
  read(n); for(int i = 1; i <= n; i ++) read(a[i]);
  memcpy(b, a, sizeof(int) * (n + 233));
  int mx = *max_element(a + 1, a + n + 1);
  int pos; for(int i = 1; i <= n; i ++) if(mx == a[i]) pos = i;
  int cnt = 0;
  for(int i = 2; i <= n; i ++) {
    while(a[i] < a[i - 1]) {
      a[i] += mx, cnt ++;
      if((int)ans.size() + cnt > 2 * n) {
	solve();
	return 0;
      }
    }
    for(int k = 1; k <= cnt; k ++) ans.push_back(make_pair(pos, i));
    cnt = 0;
    if(a[i] > mx) mx = a[i], pos = i;
  }
  if((int)ans.size() <= 2 * n) {
    cout << (int)ans.size() << "\n";
    for(auto &u:ans) cout << u.first << " " << u.second << "\n";
  }
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

map<string,int> price;
map<string,vector<string> > mix;

int res(string s){
	if(!mix.count(s))return price[s];
	int ans=0;
	for(int i=0;i<mix[s].size();i++){
		ans+=res(mix[s][i]);
	}
	if(price[s]>ans)price[s]=ans;
	return price[s];
}

int main(){
	int n,b,c;
	string a,d;
	while(cin>>n,n){
		price.clear();mix.clear();
		for(int i=0;i<n;i++){
			cin>>a>>b;
			price[a]=b;
		}
		cin>>c;
		for(int i=0;i<c;i++){
			cin>>a>>b;
			for(int i=0;i<b;i++){
				cin>>d;
				mix[a].push_back(d);
			}
		}
		cin>>d;
		cout<<res(d)<<endl;
	}
}

Measured memory_bytes: 1232
a,b,c,x,y = map(int,input().split())
if a >= c * 2 and b >= c * 2:
  ans = max(x , y) * 2 * c
elif a >= c * 2:
  ans = x * 2 * c + max(0,y - x) * b
elif b >= c * 2:
  ans = y * 2 * c + max(0,x - y) * a
elif a + b > 2 * c:
  if x >= y:
    ans = y * 2 * c + min((x - y) * a, (x - y) * 2 * c)
  else:
    ans = x * 2 * c + min((y - x) * b, (y - x) * 2 * c)
elif a + b <= 2 * c:
  ans = x * a + y * b

print(ans)

Measured memory_bytes: 3064
/*  UntilDeathDoesUsApart
    DO   NOT   GIVE   UP!
*/

#include <bits/stdc++.h>

using namespace std;

#define inc(a)           a.begin(), a.end()
#define dec(a)           a.rbegin(), a.rend()
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define to(i, a, n)      for(int i=a; i<n; i++)
#define fr(i, a, n)      for(int i=a; i>=n; i--)
#define read(arr, l, r)  for(int i=l; i<r; cin >> arr[i++])
#define prnt(arr, l, r)  for(int i=l; i<r; cout << arr[i++] << " \n"[i==r])

typedef long long ll;
typedef long double ld;

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

    double a, b, c, d, y, x; cin >> a >> b >> c >> d;
    y = ceil(a/d), x = ceil(c/b);

    cout<<(x <= y ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3736
n=int(input())
a=[0]*n
for i in range(n):
    a[i] = int(input())
import numpy as np
b=np.array(a).argsort()
imax1=b[-1]
amax=a[imax1]
for j in range(n):
    if j==imax1: print(a[b[-2]])
    else:print(amax)

Measured memory_bytes: 23304
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <map>
#include <bitset>
#include <string.h>
#include <cmath>
#include <queue>
#include <algorithm>
#define N 10005
#define P pair<int,int>
#define ll long long
#define mk(a, b) make_pair(a, b)
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
int inf = 0x3f3f3f3f;
int  n, m;
struct ac{
	int e, l, c;
	bool operator < (const ac &x) const{
		return x.l < l;
	}
};
vector<ac> g[N];
bool vis[N];
int dis[N], mon[N];
void Dijkstra() {
	mem(dis, inf);
	mem(mon, inf);
	mem(vis, false);
	dis[1] = 0;
	mon[1] = 0;
	priority_queue<ac, vector<ac> >que;
	que.push((ac){1, 0, 0});
	while (!que.empty()) {
		ac first = que.top();
		que.pop();
		int e = first.e;
		int l = first.l;
		int c = first.c;
		// if (vis[e])	continue;
		if (dis[e] < l || vis[e])	continue;
		vis[e] = true;
		for (int j = 0; j < g[e].size(); ++j) {
			ac t = g[e][j];
			if (vis[t.e])	continue;
			if (l + t.l < dis[t.e]) {
				dis[t.e] = l + t.l;
				mon[t.e] = t.c;
				que.push((ac){t.e, dis[t.e], mon[t.e]});
			}else if (l + t.l == dis[t.e]) {
				mon[t.e] = min(mon[t.e], t.c);
			}
		}
	}

}
int main(){
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
// #endif
	ios::sync_with_stdio(false);
	while (cin >> n >> m, n + m) {
		for (int i = 0; i < m; ++i) {
			int s, e, l, c;
			cin >> s >> e >> l >> c;
			g[s].push_back((ac){e, l, c});
			g[e].push_back((ac){s, l, c});
		}

		Dijkstra();
		int ans = 0;
		for (int i = 1; i <= n; ++i) {
			ans += mon[i];
			// cout << mon[i] << " ";
		}
		cout << ans << endl;
		for (int i = 1; i <= n; ++i) {
				g[i].clear();
		}
	}

	return 0;
}



Measured memory_bytes: 5236
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(b / a, c) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();
        
        int out = n/x;
        if(n%x > 0) out++;
        
        out = out *t;
        
        System.out.println(out);
        
    }
}


Measured memory_bytes: 35540
#include<bits/stdc++.h>
using namespace std;
int n,k,c[100];
map<int,bool> ans;
int used[20];
void dfs(int s,int d,int p){
  if(d==k){ans[s]=1;return;}
  for(int i=0;i<n;i++){
    if(used[i])continue;
    int r=10;
    if(c[i]>9)r*=10;
    used[i]=1;
    dfs(s*r+c[i],d+1,i+1);
    used[i]=0;
  }
}

int main(){
  while(cin>>n>>k,n){
    for(int i=0;i<n;i++)cin>>c[i];
    memset(used,0,sizeof(used));
    ans.clear();
    dfs(0,0,0);
    cout<<ans.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  unordered_map<lint, lint> m;
  rep (i, n) m[a[i]]++;
  lint sum = 0;
  allrep (x, m) sum += x.second * (x.second - 1) / 2;
  rep (i, n) {
    lint cnt = m[a[i]];
    lint ret = sum - cnt * (cnt - 1) / 2 + (cnt - 1) * (cnt - 2) / 2;
    cout << ret << "\n";
  }
  return 0;
}

Measured memory_bytes: 8392
//
//  main.cpp
//  181229
//

#include <iostream>

int main(int argc, const char * argv[]) {
    // insert code here...
    long long int A,B,C;
    long long int answer;
    std::cin>>A>>B>>C;
    if(A+B>=C-1){
        answer=B+C;
    }else{
        answer=A+2*B+1;
    }
    
    std::cout<<answer;
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


k, x = Is()
ans = []
for i in range(x-k+1, x+k):
    ans.append(str(i))

print(" ".join(ans))

Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int s, w;
	cin >> s >> w;
	if (s <= w)cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
int n,a[200050];
bool mark[25];
long long ans;
void undo(int x){
	int cnt=0;
	while(x){
		if(x&1) mark[cnt]=false;
		++cnt; x>>=1;
	}
	return ;
}
bool check(int x){
	int cnt=0;
	while(x){
		if((x&1)&&mark[cnt]) return false;
		++cnt; x>>=1;
	}
	return true;
}
void ins(int x){
	int cnt=0;
	while(x){
		if(x&1) mark[cnt]=true;
		++cnt; x>>=1;
	}
	return ;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int st=0,en=0;
	while(st<=n){
		if(st!=0) undo(a[st]);
		++st;
		while(en<n){
			if(check(a[en+1]))
				ins(a[++en]);
			else break;
		}
		ans+=en-st+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

ll C[102000][1001];



int main(){
  int H,W,a[510][510];
  pair<int,int> C[300000];
  cin>>H>>W;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i][j];
      a[i][j]%=2;
    }
  }

  int k,ca=0,count=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i%2==1) k=W-1-j;
      else k=j;
      if(ca==1){
        C[count++]=make_pair(i+1,k+1);
        if(a[i][k]==0){
          C[count++]=make_pair(i+1,k+1);
        }else{
          ca=0;
        }
      }else{
        if(a[i][k]==1){
          ca=1;
          C[count++]=make_pair(i+1,k+1);
        }
      }
    }
  }
  cout<<count/2<<endl;
  if(count%2==1) count--;
  for(int i=0;i<count;i++){
    if(i%2==0) cout<<C[i].first<<" "<<C[i].second;
    else cout<<" "<<C[i].first<<" "<<C[i].second<<endl;
  }
  return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=0;i<n;i+=2)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u) a--;
  else b--;
  cout << a << ' '<< b << endl;
}

Measured memory_bytes: 256
h = gets.to_i
flag = 1
count =0

def shori(h)
  if (h != 1)&& (h%2==1)
    h-=1
  end
  return h
end
def shori2(h)
  if h==1
    return 0
  else
    return 1
  end
end
h=shori(h)


while shori2(h)==1
  h=h/2
  h=shori(h)
  count+=1
end
ans=0
for i in 0..count
  ans += 2**i
end

puts ans



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

int main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == t[i]){
      ans++;
    }
  }

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

Measured memory_bytes: 256
def gcd(a, b):
    if a == 0:
        return b
    return gcd(b%a, a)

def lcm(a,b):
    return a*b//gcd(a,b)

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    l = int(1)
    for e in a:
        l = lcm(l,e)
    s = int(0)
    for e in a:
        s += l//e
    mod = int(1000000007)
    print(int(s % mod))


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

int main() {
	int N;
	int tmp, minNum=1e9, maxNum=-1e9;
	cin >> N;
	for (int i=0; i < N; i++){
	    cin >> tmp;
	    minNum = min(minNum, tmp);
	    maxNum = max(maxNum, tmp);
	}

	cout << maxNum-minNum << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int N = 0;
  for(int i = A; i <= B; ++i){
    int D1 = i % 10;
    int D2 = (i / 10) % 10;
    int D4 = (i / 1000) % 10;
    int D5 = (i / 10000) % 10;
    if(D1 == D5 && D2 == D4){
      ++N;
    }
  }
  cout << N << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
 
using namespace std;
 
#define INFTY 1000000001
 
typedef struct card{
  char mark;
  int num;
} card;
 
//merge sort is stable sort and fast
void merge(card *A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i, j;
 
  card L[n1 + 10], R[n2 + 10];
  for(i = 0;i < n1;i++) L[i] = A[left + i];
  for(i = 0;i < n2;i++) R[i] = A[mid + i];
 
  L[n1].num = INFTY;
  R[n2].num = INFTY;
 
  i = 0;
  j = 0;
 
  for(int k = left;k < right;k++){
    if(L[i].num <= R[j].num){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}
 
void mergeSort(card *A, int left, int right){
  if(left + 1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

//quick sort
int partition(card *A, int p, int r){
  int x = A[r].num;
  int i = p - 1;
    for(int j = p;j < r;j++){
      if(A[j].num <= x){
        i++;
        swap(A[i], A[j]);
      }
    }
    swap(A[i + 1], A[r]);
  return i + 1;
}
 
void quicksort(card *A, int p, int r){
  if(p < r){
    int q = partition(A, p, r);
    quicksort(A, p, q - 1);
    quicksort(A, q + 1, r);
  }
}
 
int main(){
 
  int n;
  card a[100010], b[100010];

  //input
  cin >> n;
  for(int i = 0;i < n;i++){
    char mark;
    int num;
 
    cin >> mark >> num;
    a[i].mark = mark;
    a[i].num = num;
    b[i].mark = mark;
    b[i].num = num;
  }

  //sotring
  quicksort(a, 0, n - 1);
  mergeSort(b, 0, n);

  //compare quicksort to mergesort
  bool flag = true;
  for(int i = 0;i < n;i++){
    if(a[i].mark != b[i].mark){
      flag = false;
      break;
    }
  }

  //output
  if(flag) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for(int i = 0;i < n;i++) cout << a[i].mark << ' ' << a[i].num << endl;
 
  return 0;
}



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

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

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


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        a = [LS() for _ in range(n)]
        d = {}
        e = collections.defaultdict(int)
        b = []
        for day,ts,f,i in a:
            i = int(i)
            ta = ts.split(':')
            t = int(ta[0]) * 60 + int(ta[1])
            if i == 0:
                if f == 'I':
                    for k in list(d.keys()):
                        e[k] -= t - d[k]
                    d[i] = t
                else:
                    del d[i]
                    for k in list(d.keys()):
                        e[k] += t - d[k]
            else:
                if f == 'I':
                    d[i] = t
                else:
                    if 0 in d:
                        e[i] += t - d[i]
                    del d[i]
        if len(e) == 0:
            rr.append(0)
        else:
            rr.append(max(e.values()))

    return '\n'.join(map(str,rr))


print(main())




Measured memory_bytes: 9684
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
const int NIL2 = -1337;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

const int MAX_V = 1007;
const int MAX_E = 2014;

struct Edge
{
	int from, to, active;
};

Edge edges[MAX_E];
vector<int> g[MAX_V];

int n, m;

int q[MAX_V], head = 0;
int prv[MAX_V], dist[MAX_V];

vector<int> find_cycle(int id)
{
	vector<int> cycle;
	edges[id].active = 0;

	for(int i = 0; i < n; ++i)
	{
		prv[i] = NIL;
		dist[i] = INT_INF;
	}

	head = 0;
	int src = edges[id].to;
	int dst = edges[id].from;
	q[head++] = src;
	dist[src] = 0;
	prv[src] = NIL2;

	for(int j = 0; j < head; ++j)
	{
		int v = q[j];

		for(auto& id2: g[v])
		{
			if(edges[id2].active == 0)
				continue;

			int u = edges[id2].to;

			if(dist[u] > dist[v] + 1)
			{
				dist[u] = dist[v] + 1;
				prv[u] = v;

				q[head++] = u;
			}
		}
	}

	edges[id].active = 1;

	if(prv[dst] != NIL)
	{
		for(int v = dst; v >= 0; v = prv[v])
			cycle.push_back(v);
	}

	return cycle;
}

void solve()
{
	cin >> n >> m;

	for(int i = 0; i < m; ++i)
	{
		int v, u;
		cin >> v >> u;
		--v, --u;

		edges[i] = {v, u, 1};
		g[v].push_back(i);
	}

	vector<int> shortest_cycle;

	for(int id = 0; id < m; ++id)
	{
		auto cand = find_cycle(id);

		if(cand.empty())
			continue;

		if(shortest_cycle.empty())
			shortest_cycle = cand;
		else if(len(cand) < len(shortest_cycle))
			shortest_cycle = cand;
	}

	if(shortest_cycle.empty())
	{
		cout << NIL << endl;
	}
	else
	{
		cout << len(shortest_cycle) << endl;

		for(auto& v: shortest_cycle)
			cout << v + 1 << endl;
	}
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e4) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0] + a[1] << endl;

    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
//#include<unordered_map>
//#include<unordered_set>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long Int;
typedef pair<Int, Int> P;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 100005;
//////////////////////////////

string s;
int k;
int dp[330][330][330];

void solve()
{
	cin >> s;
	cin >> k;
	int n = s.size();
	REP(i, n) REP(l, n) REP(x, k + 1) {
		int r = l + i;
		if (l > r || n <= r) continue;
		
		if (l == r) { dp[l][r][x] = 1; continue; }
		if (r - l + 1 <= 2 * x) { dp[l][r][x] = r - l + 1; continue; }
		if (s[l] == s[r]) dp[l][r][x] = dp[l + 1][r - 1][x] + 2;
		else if(x > 0) dp[l][r][x] = max(dp[l + 1][r - 1][x - 1] + 2, max(dp[l + 1][r][x], dp[l][r - 1][x]));
		else dp[l][r][x] = max(dp[l + 1][r][x], dp[l][r - 1][x]);
	}
	cout << dp[0][n - 1][k] << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13);
	solve();
	return 0;
}



Measured memory_bytes: 62932
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

int dp[501][501];
bool dfs(string &s,int from,int to){
  if(dp[from][to]>=0)return dp[from][to];
  if(s=="")return true;
  else if(s.size()<=2)return false;
  else if(s[0]!='m'||s[s.size()-1]!='w')return false;
  for(int i=1;i<s.size()-1;i++){
    if(s[i]!='e')continue;
    string X=s.substr(1,i-1);
    string Y=s.substr(i+1);Y=Y.substr(0,Y.size()-1);
    if((X==""||dfs(X,from+1,from+i-1))
       &&(Y==""||dfs(Y,from+i+1,from+s.size()-2)))
      return dp[from][to]=true;
  }
  return dp[from][to]=false;
}

int main(){

  string S;
  cin>>S;
  memset(dp,-1,sizeof(dp));
  if(dfs(S,0,S.size()-1))cout<<"Cat"<<endl;
  else cout<<"Rabbit"<<endl;

  return 0;
}

Measured memory_bytes: 1908
#include <stdio.h>

int main(void)
{
    int i, score, minv, count;
    int data[200000];

    scanf("%d", &count);

    for (i = 0; i < count; i++) {
        scanf("%d", &data[i]);
    }

    score = data[1] - data[0];
    minv = data[0];

    for (i = 1; i < count; i++) {
        if (score < data[i] - minv) {
            score = data[i] - minv;
        }

        if (minv > data[i]){
            minv = data[i];
        }
    }

    printf("%d\n", score);

    return 0;
}



Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  float x;
  string s;
  float total = 0;
  for (int i=0;i<n;i++){
    cin >> x >> s;
    if (s == "JPY") total += x;
    else total += x*380000.0;
  }
  
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt(sc)
	}
	//fmt.Println("n", n, "h", h)
	ok := true
	for j := n - 1; j > 0; j-- { // 右から順に見ていく
		//fmt.Printf("h[%d] %d\n", j, h[j])
		if h[j-1] > h[j] { // 左側のマスの方が大きい
			// fmt.Printf("d01\n")
			if h[j-1] == h[j]+1 { // 左側のマスがちょうど1だけ大きい
				//fmt.Printf("d02\n")
				h[j-1]--
			} else {
				//fmt.Println("d03 break")
				ok = false
				break
			}
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3072
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
int a[10],k;
int main(){
	scanf("%d%d%d",&a[1],&a[2],&a[5]);
	k=a[5]*3;
	a[3]=k-a[1]-a[2];
	a[7]=k-a[5]-a[3];
	a[4]=k-a[1]-a[7];
	a[6]=k-a[4]-a[5];
	a[8]=k-a[2]-a[5];
	a[9]=k-a[1]-a[5];
	printf("%d %d %d\n%d %d %d\n%d %d %d\n",a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]);
}

Measured memory_bytes: 256
class Dice
	def initialize(n=Array.new(6,0))
		@num = n
		@LRRoll = [:u, :b, :d, :f]
		@FBRoll = [:u, :l, :d, :r]
		@UDRoll = [:r, :b, :l, :f]
		reset
	end

	def reset
		@position = { u: @num[0],
									d: @num[5],
									r: @num[2],
									l: @num[3],
									f: @num[4],
									b: @num[1]
		}
	end

	def move(v)
		case v
		when "N"
			Roll(@LRRoll)
		when "S"
			Roll(@LRRoll, -1)
		when "E"
			Roll(@FBRoll)
		when "W"
			Roll(@FBRoll, -1)
		end
	end

	def move_roll(n)
		n.times { Roll(@UDRoll) }
	end

	def Roll(roll, v=1)
		v = -1 if v != 1
		t = @position[roll[0]]
		@position[roll[  0]] = @position[roll[1*v]]
		@position[roll[1*v]] = @position[roll[2*v]]
		@position[roll[2*v]] = @position[roll[3*v]]
		@position[roll[3*v]] = t
	end

	def v_up
		@position[:u]
	end

	def v_down
		@position[:d]
	end

	def v_foward
		@position[:f]
	end

	def v_back
		@position[:b]
	end

	def v_right
		@position[:r]
	end

	def v_left
		@position[:l]
	end

end

n1 = gets.chomp.split(" ").map &:to_i
d1 = Dice.new(n1)
n2 = gets.chomp.split(" ").map &:to_i
d2 = Dice.new(n2)

same = false
n = 0

3.times {
	break if d1.v_up == d2.v_up and d1.v_down == d2.v_down
	d2.move("E")

	break if d1.v_up == d2.v_up and d1.v_down == d2.v_down
	d2.move("N")
}

same = true if d1.v_up == d2.v_up and d1.v_down == d2.v_down

if same
	case d1.v_back
	when d2.v_left
		d2.move_roll(1)
	when d2.v_foward
		d2.move_roll(2)
	when d2.v_right
		d2.move_roll(3)
	end
end

if same
	same = false if not  (d1.v_foward == d2.v_foward and
												d1.v_right  == d2.v_right  and
										 		d1.v_left   == d2.v_left)
end

if same
	print("Yes\n")
else
	print("No\n")
end

Measured memory_bytes: 8752
dp = [float("inf") for _ in range(100000 + 1)]
dp[0] = 0

N = int(input())

for i in range(len(dp)):
    if i == N:
        print(dp[i])
        break

    dp[i + 1] = min(dp[i + 1], dp[i] + 1)

    k = 6
    while i + k <= N:
        dp[i + k] = min(dp[i + k], dp[i] + 1)
        k *= 6

    k = 9
    while i + k <= N:
        dp[i + k] = min(dp[i + k], dp[i] + 1)
        k *= 9


Measured memory_bytes: 6296
#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++)
typedef long long ll;

int main(){
	ll a,b,v,w,t;
	cin >> a >> v >> b >> w >> t;
	if(v <= w){
		cout << "NO" << endl;
		return 0;
	}
	ll d = abs(a-b);
	if(d <= t*(v-w)){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
    return 0;
}

Measured memory_bytes: 3624
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  int s, w;
  cin >> s >> w;
  if(s > w) {
    cout << "safe" << endl;
  }else{
    cout << "unsafe" << endl;
  }
}


Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
    int K, X;
    scanf("%d %d", &K, &X);
    int lower = X - K + 1;
    int upper = X + K - 1;
    if(lower < -1000000){
        lower = -1000000;
    }
    if(upper > 1000000){
        upper = 1000000;
    }
    for(int i=lower; i<=upper; i++){
        printf("%d ", i);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int len = s.length();
      
      int start = 0;
      for(int i=0; i<len; i++){
        if("A".equals(s.substring(i,i+1))){
            start = i;
            break;
        }
      }  
      int end = 0;
      for(int j=len-1; j>0; j--){
        if("Z".equals(s.substring(j,j+1))){
            end = j;
            break;
        }
      }  

      System.out.println(end-start+1);
    }  
} 

Measured memory_bytes: 33576