akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N;
	long long mn = 1e9 + 7; 
	long long sum = 0; 
	for(int i = 0; i < N; i++){
		long long a, b; 
		cin >> a >> b; 
		sum += a; 
		if(a > b) mn = min(mn, b); 
	}
	if(mn == 1e9 + 7){
		cout << 0 << endl; return 0; 
	}
	cout << sum - mn << endl; 
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

struct Point{double x,y;};

void koch(int n,Point a,Point b){
  if(n==0) return;
  Point s,t,u;
  s.x=(2*a.x+b.x)/3;
  s.y=(2*a.y+b.y)/3;
  t.x=(a.x+2*b.x)/3;
  t.y=(a.y+2*b.y)/3;
  u.x=(t.x+s.x-sqrt(3)*t.y+sqrt(3)*s.y)/2;
  u.y=(sqrt(3)*t.x-sqrt(3)*s.x+t.y+s.y)/2;
  
  koch(n-1,a,s);
  cout<< fixed << setprecision(10) <<s.x<<" "<<s.y<<endl;
  koch(n-1,s,u);
  cout<< fixed << setprecision(10) <<u.x<<" "<<u.y<<endl;
  koch(n-1,u,t);
  cout<< fixed << setprecision(10) <<t.x<<" "<<t.y<<endl;
  koch(n-1,t,b);
}

int main(){
  int n;
  cin>>n;
  
  Point p1={0.0,0.0},p2={100.0,0.0};
  cout<< fixed << setprecision(10) <<p1.x<<" "<<p1.y<<endl;
  koch(n,p1,p2);
  cout<< fixed << setprecision(10) <<p2.x<<" "<<p2.y<<endl;
    
  return 0;
}



Measured memory_bytes: 3280
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut h = vec![];
    for i in 0..n {
        h.push(read::<i64>());
    }
    let mut ans = std::i64::MAX;
    h.sort();
    let mut sum = vec![];
    sum.push(0);
    for i in 0..n {
        let last = sum[sum.len() - 1];
        sum.push(h[i] + last);
    }
    debug!(sum);
    for i in 0..n - k + 1 {
        let temp = h[i + k - 1] - h[i];
        ans = min(ans, temp);
    }
    println!("{:?}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long int
#define pb push_back
#define ull unsigned long long int

#define IO ios::sync_with_stdio(false);
typedef vector<int> vi;
#define H return 0;
#define C continue;
#define B break;
#define sec second

int n,k,q;
    int main()
{   IO
   cin.tie(0);
   cin>>n>>k>>q;
   vi v;
   v.pb(fabs(n-k));
   v.pb(fabs(k-q));
   v.pb(fabs(n-q));
   sort(v.begin(),v.end());
   cout<<v[0]+v[1];
}


Measured memory_bytes: 256
#include<cstdio> 
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;

int n,k,f[300005];

int main()
{
	scanf("%d%d",&k,&n);
	
	if (n==1) 
	{
		printf("%d",(k+1)>>1);
		return 0;
	}
	
	if (k&1) 
	{
		int x=n-1,y=1,t;
		f[n]=1;
		for (int i=n-1;i>=1;i--) 
		{
			x--,y=y*k+1;
			f[i]=y;
			if (y>x) 
			{
				for (int j=1;j<=i;j++) printf("%d ",k/2+1);
				t=(x+y+1)/2-x;
				for (int j=i+1;j<=n;j++) 
				{
					if (t==1) break;t--;
					for (int l=1;l<=k;l++) 
					if (t<=f[j]) {printf("%d ",l);break;}
					else t-=f[j];
				}
				break;
			}
		}
		
	}
	else 
	{
		printf("%d ",k/2);
		for (int i=1;i<=n-1;i++) printf("%d ",k);
	}
	return 0;
}

Measured memory_bytes: 2176
def readinput():
    n=int(input())
    s=[]
    for _ in range(n):
        s.append(input())
    return n,s

def main(n,s):
    ac=0
    wa=0
    tle=0
    re=0
    for ret in s:
        if ret=='AC':
            ac+=1
        elif ret=='WA':
            wa+=1
        elif ret=='TLE':
            tle+=1
        elif ret=='RE':
            re+=1
    print('AC x {}'.format(ac))
    print('WA x {}'.format(wa))
    print('TLE x {}'.format(tle))
    print('RE x {}'.format(re))

if __name__=='__main__':
    n,s=readinput()
    main(n,s)


Measured memory_bytes: 16328
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
aa.sort(reverse=True)

f = s = 0
for i in range(N):
	if i%2 == 0:
		f += aa[i]
	else:
		s += aa[i]

print(f-s)


Measured memory_bytes: 4204
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<string.h>
#include<map>
#include<cmath>
#include<stack>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
inline ll floor(const ll&a,const ll&b){return a/b;};
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const ll INF=4223372036854775807,max_n=100005,mod=1000000007;
inline ll ceil(const ll&a,const ll&b){if(a%b==0)return a/b;return a/b+1;};
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
double Rad_to_deg = 45.0 / atan(1.0);
int main()
{
	double a,b,x;
	cin>>a>>b>>x;
	double h=x/a/a;
	double ans1=atan(2*(b-h)/a);
	double ans0=atan(b/a);
	if(ans1<=ans0)
	{
		printf("%.10f",ans1*Rad_to_deg);
	}
	else
	{
		//cout<<atan(b/(2.0*a))<<endl;
		printf("%.10f",atan(b*b/(2.0*h*a))*Rad_to_deg);
	}
}

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

int main() {
    int N;
    cin >>N;
    bool judge = false;
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(i*j ==N){
                judge = true;
                break;
            }
        }
    }
    if(judge) cout << "Yes" <<endl;
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		System.out.println(getSmaller(a,b) + getSmaller(c,d));
	}

	private static int getSmaller(int a, int b) {
		if (a < b) {
			return a;
		} else {
			return b;
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 16;
int n;
ll a[N][N], DP[bit(N)];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n)FOR(j, 0, n) cin >> a[i][j];
  FOR(i, 1, bit(n)){
    FOR(j, 0, n-1)if(i&bit(j))FOR(k, j+1, n)if(i&bit(k)) DP[i] += a[j][k];
    for(int j=i; j; j=(j-1)&i) maxs(DP[i], DP[j]+DP[i^j]);
  }
  cout << DP[bit(n)-1] << endl;
}

Measured memory_bytes: 896
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a1: usize,
        a2: usize,
        a3: usize,
    }

    let n = a1 + a2 + a3;
    if 22 <= n {
       println!("{}","bust");
    }else{
        println!("{}","win");
    }
}

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

int main(){
    //入力
    int N,M;
    cin >> N >> M;

    vector<string> A(N);
    vector<string> B(M);

    //Aの入力
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }

    //Bの入力
    for(int i=0;i<M;i++){
        cin >> B.at(i);
    }

    for(int i=0;i<N-M+1;i++){
        for(int j=0;j<N-M+1;j++){
            bool ans=true;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A.at(i+k).at(j+l)!=B.at(k).at(l)){
                        ans=false;
                        break;
                    }
                }
                if(ans==false){
                    break;
                }
            }
            if(ans==true){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,c,i,shakkin;
	shakkin = 100000;
	scanf("%d",&a);
	for(i = 0;i < a;i++)
	{
		c = (shakkin*105/100) % 1000;
		if(c == 0)
		{
			shakkin = shakkin*105/100;
		}else{
			shakkin = ((int)(shakkin*105/100/1000) + 1)*1000;
		     }
	}

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

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> cnt(n+1);

	ll total=0;
	rep(i,0,n) {
		cin>>a[i];
		total+=cnt[a[i]];
		cnt[a[i]]++;
	}

	rep(i,0,n) {
		if (cnt[a[i]]<=1) {
			cout<<total<<'\n';
			continue;
		}

		cout<<total-cnt[a[i]]+1<<'\n';
	}
}


Measured memory_bytes: 4224
import sys

N = int(input())
s = []
for i in range(N):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
else:
    for i in sorted(s):
        if i % 10 != 0:
            print(sum(s) - i)
            sys.exit()
    print(0)


Measured memory_bytes: 2940
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	int ans=0;
	for(int a=1;a<N;a++){
		for(int b=1;a*b<N;b++){
			ans++;
		}
	}
	prin(ans);
	return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e16;

struct Vertex
{
    vector<pll> n;
    int count = 0;
};

ll S[1005];
Vertex V[1005];
//! 各頂点に戻ってくるコストが正のループが存在するか
bool L[1005] = {false};

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        V[a].n.push_back(pll(b, c));
        V[b].count++;
    }
    REP(i, N)
    {
        S[i] = -INF;
    }
    queue<pll> q;
    q.push(pll(0, 0));
    S[0] = 0;
    while (!q.empty())
    {
        pll t = q.front();
        q.pop();
        REP(i, V[t.first].n.size())
        {
            pll node = V[t.first].n[i];
            ll c = t.second + node.second;
            V[node.first].count--;
            if (S[node.first] >= c)
                continue;
            if (L[node.first])
                continue;
            S[node.first] = c;
            if (V[node.first].count < 0)
                L[node.first] = true;
            q.push(pll(node.first, c));
        }
    }

    if (L[N - 1])
        cout << "inf" << endl;
    else
        cout << S[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
int main() {
	int n, x; cin>>n>>x;
    vector<int> D(n+1);
    D[0] = 0;
  
   rep(i,n){
     int x;cin >> x;
     D[i+1] = D[i] + x;
   }
  int ans = 0;
  for(int i=0;i<=n;++i){
    if (D[i]<=x){
      ans++;
    }
  }
    cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  int max = -1, max_i = -1;
  REP(i, N) {
    cin >> p[i];
    if (p[i] > max) {
      max = p[i];
      max_i = i;
    }
  }

  p[max_i] /= 2;

  int res = 0;
  REP(i, N) {
    res += p[i];
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    lli x, y;
    cin >> x >> y;
    lli sum;
    lli a = x;
  	while(a<=y){
    	a *= 2;
    }
    lli k = log2(a / x);
    //x*2^k = a
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 256
//2分探索, 座標圧縮的な何か, imos法
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
double x[100000], r[100000];

bool check(double y) {
	int i;
	vector<double> vec;
	static int imos[200001];
	
	rep(i, n) {
		if (y >= r[i]) return false;
		double width = sqrt(r[i] * r[i] - y * y);
		vec.push_back(x[i] - width);
		vec.push_back(x[i] + width);
	}
	sort(vec.begin(), vec.end());
	
	rep(i, 2 * n) imos[i] = 0;
	
	rep(i, n) {
		double width = sqrt(r[i] * r[i] - y * y);
		int l = lower_bound(vec.begin(), vec.end(), x[i] - width) - vec.begin();
		int r = lower_bound(vec.begin(), vec.end(), x[i] + width) - vec.begin();
		//区間l,l+1,…,r-1に1を足す
		imos[l]++;
		imos[r]--;
	}
	
	rep(i, 2 * n) if (i > 0) imos[i] += imos[i - 1];
	rep(i, 2 * n) if (imos[i] == n) return true;
	return false;
}

int main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> x[i] >> r[i];
	
	double st = 0, ed = 1000000, mid;	//ooooxxx, [st, ed)
	for (i = 0; i < 50; i++) {
		mid = (st + ed) / 2;
		if (check(mid)) st = mid;
		else ed = mid;
	}
	printf("%.14f\n", st);
	return 0;
}


Measured memory_bytes: 8976
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w := intScanner(), intScanner()
	x, y := intScanner(), intScanner()
	fmt.Println(h*w - w*x - h*y + x*y)
}


Measured memory_bytes: 1772
#include<iostream>
#include<iomanip>
#define _USE_MATH_DEFINES
#include<cmath>
int main()
{
	double r;
	std::cin >> r;
	std::cout << std::fixed << std::setprecision(10);
	std::cout << M_PI*r*r << ' ' << 2 * M_PI*r << std::endl;
	return 0;
}


Measured memory_bytes: 3264
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<ll, ll> P;
typedef pair<ll, P> E;
struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<int> cmp;
	int size;
	UnionFind(int n) :size(n) {
		par.resize(size);
		rank.resize(size);
		cmp.resize(size);
		for (int i = 0; i < size; i++) {
			par[i] = i;
			rank[i] = 0;
			cmp[i] = 1;
		}
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
			cmp[y] += cmp[x];
		}
		else {
			par[y] = x;
			cmp[x] += cmp[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		x = find(x);
		y = find(y);
		return x == y;
	}
};
int main() {
	int N;
	cin >> N;
	vector<P> vx, vy;
	for (int i = 0; i < N; i++) {
		ll x, y;
		cin >> x >> y;
		vx.emplace_back(x, i);
		vy.emplace_back(y, i);
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	priority_queue<E, vector<E>, greater<E>> Q;
	for (int i = 1; i < N; i++) {
		Q.push(E(vx[i].first - vx[i - 1].first, P(vx[i].second, vx[i - 1].second)));
		Q.push(E(vy[i].first - vy[i - 1].first, P(vy[i].second, vy[i - 1].second)));
	}
	UnionFind U(N);
	ll ans = 0;
	while (!Q.empty()) {
		E e = Q.top(); Q.pop();
		if (!U.same(e.second.first, e.second.second)) {
			ans += e.first;
			U.unite(e.second.first, e.second.second);
		}
	}
	cout << ans << endl;
 }

Measured memory_bytes: 13024
#include<bits/stdc++.h>
using namespace std;
long long n,x,y,z,d,ma;
int main(){
    scanf("%d%d%d%d%d",&x,&y,&z,&d,&n);ma=min(min(4*x,2*y),z);
    cout<<min(ma*n,(n/2*d+n%2*ma))<<endl;
    return 0;
}

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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;
int d[1000];


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

    cin >> n;
    for(int i=0; i<n; ++i) cin >> d[i];

    ll cnt=0;
    for(int i=0;i<n;i++) for(int j=i+1; j<n; j++) {
        cnt+=(long long)d[i]*d[j];
    }

    cout << cnt << endl;
    


    return 0;

}



Measured memory_bytes: 256
import fileinput

iterator = fileinput.input()

n, a, b = map(int, iterator.next().split())

def compute(n, a, b):
    # edge cases
    if n == 0:
        return 0
    if n == 1:
        if a == b:
            return 1
        else:
            return 0
    if a > b:
        return 0

    return (b - a) * (n - 2) + 1

print compute(n, a, b)


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1)
        a = 14;
    if (b == 1)
        b = 14;
    if (a > b)
        cout << "Alice" << endl;
    else if (a < b)
        cout << "Bob" << endl;
    else
        cout << "Draw" << endl;
//    main();
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
z = 0
b = [1]
c = [0]*n
for i in range(n*3):
  j = [a[b[i]-1]]
  b.extend(j)
  c[a[b[i]-1]-1] = c[a[b[i]-1]-1]+1
  if c[a[b[i]-1]-1] == 2:
    z = z + 1
if k <= n:
  y = b[k]
else:
  l = (k-n)%z
  y = b[n+l]
print(y)

Measured memory_bytes: 32300
from math import ceil
N,H=map(int, input().split())

A=[0]*N
B=[0]*N
for i in range(N):
    a,b=map(int, input().split())
    A[i]=a
    B[i]=b

A=sorted(A)
B=sorted(B, reverse=True)
amax=max(A)

ans=0

for i in range(N):
    b=B[i]
    if b>amax:
        H-=b
        ans+=1
        if H<=0:
            break
    else:
        break
if H>0:
    ans+=ceil(H/amax)
print(ans)


Measured memory_bytes: 79000
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	long long H;
	long long count = 0;

	long long PowOfTwo = 1;

	cin >> H;
	
	for(int i=0; ;i++){
		
		if(PowOfTwo > H){
			break;
		}
		count += PowOfTwo;
		PowOfTwo *=2;
	}

	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)

ary1_hash = Hash.new(0)
0.step(n - 1, 2) do |i|
  ary1_hash[ary[i]] += 1
end
ary1 = ary1_hash.sort_by(&:last).reverse

ary2_hash = Hash.new(0)
1.step(n - 1, 2) do |i|
  ary2_hash[ary[i]] += 1
end
ary2 = ary2_hash.sort_by(&:last).reverse

ans = if ary1[0][0] != ary2[0][0]
  ary1[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i +
    ary2[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i
else
  ary1_sec = ary1[1][1] rescue 0
  ary2_sec = ary2[1][1] rescue 0
  if ary1_sec >= ary2_sec
    ary1[0..-1].inject(0){|sum, attr| sum + attr.last} - ary1_sec +
      ary2[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i
  else
    ary1[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i +
      ary2[0..-1].inject(0){|sum, attr| sum + attr.last} - ary2_sec
  end
end
puts ans

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

int main() {

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

    return 0;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#ifndef LOCAL
#pragma GCC optimize(3)
#endif
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
int n;
int len[maxn];
bool inq[maxn];
int spfa() {
    queue<int> q;
    memset(len, 0x3f3f, sizeof(len));
    memset(inq, 0, sizeof(inq));
    inq[1] = 1, len[1] = 1;
    q.push(1);
    while (!q.empty()) {
        int now = q.front(); q.pop();
        inq[now] = 0;
        int new1 = (now+1) % n;
        if (len[new1] > len[now] + 1) {
            len[new1] = len[now] + 1;
            if (!inq[new1]) inq[new1] = 1, q.push(new1);
        }
        new1 = (now*10) % n;
        if (len[new1] > len[now]) {
            len[new1] = len[now];
            if (!inq[new1]) inq[new1] = 1, q.push(new1);
        }
    }
    return len[0];
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    scanf("%d", &n);
    printf("%d\n", spfa());
    return 0;
}

Measured memory_bytes: 896
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const n = parseInt(spi[0]);
    const map = new Map([["AC", 0], ["WA", 0], ["TLE", 0], ["RE", 0],]);
    
    for (let i = 1; i < n + 1; i++) {
        map.set(spi[i], map.get(spi[i])+1);
    }

    for (let entry of map.entries()) {
        console.log(entry[0] + " x " + entry[1]);
    }
};

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


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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	long long ans=0LL,cnt=0LL;
	for (int i = 2; i < s.size(); ++i)
	{
		if (s.at(i-2)=='A')
		{
			++cnt;
		}
		else
		{
			cnt=0LL;
		}
		if (s.at(i-1)=='B'&&s.at(i)=='C')
		{
			ans+=cnt;
			--cnt;
			s.at(i)='A';
			++i;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  long int r, D, x2000;
  long int tmp;
  cin >> r >> D >> x2000;

  tmp = r * x2000 - D;
  cout << tmp << endl;
  for(int i = 1; i < 10; i++){
    tmp = r * tmp - D;
    cout << tmp << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
c=[0]*(n-1)
s=[0]*(n-1)
f=[0]*(n-1)
for i in range(n-1):
    c[i],s[i],f[i]=map(int,input().split())
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<s[j]:
            t=s[j]
        elif t%f[j]==0:
            pass
        else:
            t=t+f[j]-t%f[j]
        t+=c[j]
    print(t)
    


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000007;
const static int inf = INT_MAX;
const static llong INF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
    
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            int n = int.Parse(Console.ReadLine()) - 1;

            var stops = new int[n][];

            for (int i = 0; i < n; i++) {
                // 整数配列の入力
                stops[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            }

            for(int i = 0; i < n; i++) {
                var start = stops[i][1];
                var elapsed = start + stops[i][0];
                for(int j = i + 1; j < n; j++) {
                    if (elapsed < stops[j][1]) {
                        elapsed = stops[j][0] + stops[j][1];
                    } else {
                        if ((elapsed - stops[j][1]) % stops[j][2] != 0) {
                            var turn = elapsed / stops[j][2];
                            turn++;
                            elapsed = (turn * stops[j][2]) + stops[j][0];
                        } else {
                            elapsed += stops[j][0];
                        }
                    }
                }
                Console.WriteLine(elapsed);
            }

            Console.WriteLine(0);

            Console.Out.Flush();
        }
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());

    vector<int> p, m;

    p.push_back(a.at(n - 1));
    m.push_back(a.at(0));

    for (int i = 1; i < n - 1; i++)
    {
        if (a.at(i) < 0) m.push_back(a.at(i));
        else p.push_back(a.at(i));
    }
    
    int sum = 0;
    for (int i = 0; i < (int)p.size(); i++)
    {
        sum += p.at(i);
    }
    for (int i = 0; i < (int)m.size(); i++)
    {
        sum += m.at(i) * -1;
    }
    
    cout << sum << endl;

    int res = m.at(0);
    for (int i = 1; i < (int)p.size(); i++)
    {
        printf("%d %d\n", res, p.at(i));
        res -= p.at(i);
    }

    printf("%d %d\n", p.at(0), res);
    
    p.at(0) -= res;

    for (int i = 1; i < (int)m.size(); i++)
    {
        printf("%d %d\n", p.at(0), m.at(i));
        p.at(0) -= m.at(i);
    }
    
}

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

int setCount(int n) {
    int aRange = 9;
    int bRange = 9;
    int cRange = 9;
    int dRange = 9;
    int sum;
    int count = 0;
    
    for(int a = 0; a <= aRange; a++) {
        for(int b = 0; b <= bRange; b++) {
            for(int c = 0; c <= cRange; c++) {
                for(int d = 0; d <= dRange; d++) {
                    sum = a + b + c + d;
                    if(sum == n){
                        count++;
                    }
                }
            }
        }
    }
    return count;
}

int main(void) {
    int count = 0;
    int n;
    
    while(cin >> n) {
        count = setCount(n);
        cout << count << endl;
        count = 0;
    }
    
    return 0;
}

Measured memory_bytes: 1160
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {

    let ln = read_t_in_line::<i32>();
    let (a, b) = (ln[0], ln[1]);
    let mut ans = 0;
    for i in a..(b+1) {
        let s = i.to_string().into_bytes();
        let mut ok = true;
        for j in 0..s.len() {
            if s[j] != s[s.len() - 1 - j] {
                ok = false;
                break;
            }
        }
        if ok {
            ans += 1;
        }
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n,k,a[100000],i;

    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++) scanf("%d",a+i);

    printf("%d",((n-1)+(k-1)-1)/(k-1));

    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.util.Map.Entry;
 
 

class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   public static void main(String[] args) {
   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       boolean[] visited2 = new boolean[N*N];
       int[] cntc = new int[N*N];
       int[] first = new int[N];
       int[] weight;
  	   List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
       for(long i=0;i<N*N;i++)list.add(new ArrayList<Integer>());
       for(int i=0;i<N;i++) {
           int pre=0;
       	for(int j=0;j<N-1;j++){
       		int a=sc.nextInt();
       		int tmp=Math.min(a-1, i)*N+Math.max(a-1, i);
       		if(pre!=0) {
               	list.get(pre).add(tmp);      	
               	visited2[tmp]=true;
               	cntc[tmp]++;
       		} else {
           		first[i]=tmp;
       		}
       		pre=tmp;
       	}
       }
       Arrays.sort(first);
		int max=0;

		LinkedList<Integer> queue = new LinkedList<Integer>();
	    int[] tcnt= new int[N*N];
	    weight=new int[N*N];
		int p=-1;
		for(int i=0;i<first.length;i++) {
			if(p!=first[i]&&visited2[first[i]]==false) {
		       	queue.add(first[i]);
		       	queue.add(1);				
			}
			p=first[i];
       }
		
		int cnt=0;
		boolean[] visited = new boolean[N*N];
   	while(!queue.isEmpty()) {
   		int n = queue.poll();
   		int w = queue.poll();
   		if(w!=1)cnt++;
   		tcnt[n]++;
		if(tcnt[n]<cntc[n])continue;
   		if(visited[n]) {
   			System.out.println(-1);
   			return;
   		}
		weight[n]=w;
		max=Math.max(max, w);
   		for(int i:list.get(n)) {
   			queue.add(i);
   			queue.add(w+1);
   		}
   		visited[n]=true;
   	}
   	
   	if(cnt!=N*(N-2))max=-1;
    System.out.println(max);  	
              		
   }

}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(std::string C){
    cout<<(char)(C.at(0)+1)<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    std::string C;
    std::cin >> C;
    func(C);
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = list(ns().strip())
t = ns().strip()


def ok(s, t):
    if len(s) < len(t):
        return False
    for i in range(len(s) - len(t) + 1):
        o = 1
        for j in range(len(t)):
            if s[i + j] != '?' and s[i + j] != t[j]:
                o = 0
        if o == 1:
            return True
    return False


if not ok(s, t):
    print("UNRESTORABLE")
    sys.exit(0)

for i in range(len(s)):
    if s[i] == '?':
        for j in range(97,97+26):
            s[i] = chr(j)
            if ok(s, t):
                break

print("".join(s))

Measured memory_bytes: 3064
using System;
namespace ITP1_6_C
{
    class Program
    {
        static void Main(string[] args)
        {
		    int n = int.Parse(Console.ReadLine());
		    int [,,] v = new int[4,3,10];
            for(int i = 0; i < n; i++)
            {
			    string[] s = Console.ReadLine().Split(' ');
                v[int.Parse(s[0]) - 1, int.Parse(s[1]) - 1, int.Parse(s[2]) - 1] += int.Parse(s[3]);
		    }
		    for(int i = 0; i < 4; i++)
		    {
			    for(int j = 0; j < 3; j++)
			    {
				    for(int k = 0; k < 10; k++)
				    {
					    Console.Write(" {0}", v[i, j, k]);
				    }
			    	Console.WriteLine();
			    }
			    if(i != 3)
			    {
			        Console.WriteLine("####################");
			    }
		    }
	    }
    }
}


Measured memory_bytes: 15904
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int n;
  cin>>n;

  int max_wk=0,output=1;
  for(int i=2;i<=n;i+=2){
    int wk=i;
    int cnt=0;
    do{
      if(wk%2==0){
        wk/=2;
        cnt++;
      }
    }while(wk%2==0);
    if(max_wk<cnt){
      output=i;
      max_wk=cnt;
    }
  }

  cout<<output<<endl;

  
	return 0;
}

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

int main(int argc, char* argv[]){
	int n; cin >> n;
	int a[81];
	int k = 0;
		for(int i=1;i<=9;++i){
			for(int j=1;j<=9;++j){
				a[k] = i*j;
				++k;
			}
		}
	bool ans = false;
	for(int i=0;i<=80;++i){
		if(a[i]==n) { ans = true; break; }
	}
	cout << ( ans ? "Yes" : "No" ) << endl; 
}

Measured memory_bytes: 256
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
import math
# from itertools import product, accumulate, combinations, product
#import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 998244353


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())


def run():
    A, B, C, D, E, F = mapline()
    aa = 100 * A
    bb = 100 * B
    max_con = 0
    ans = (100 * A, 0)
    for x in range(0, F // aa + 1):
        ylim = (F - aa * x) // bb
        for y in range(0, ylim + 1):
            tot = aa * x + bb * y
            if not tot:continue
            slim = E * (x * A + y * B)
            #print(tot, slim)
            for w in range(0, slim // C + 1):
                vlim = (slim - w * C) // D
                for v in range(0, vlim + 1):
                    sug = C * w + D * v
                    #print(sug)
                    if tot + sug <= F:
                        _con = sug / (tot + sug)
                        if max_con < _con:
                            max_con = _con
                            ans = (tot + sug, sug)
    print(f'{ans[0]} {ans[1]}')


if __name__ == "__main__":
    run()


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

def solve():
    N = int(input())
    d = {}
    T = []
    for i in range(N):
        s, t = input().split()
        d[s] = i
        T.append(int(t))
    X = input()
    return str(sum(T[d[X]+1:]))

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

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

    int n,m,k;
    int mem[31];
    int ans = 0;
    int tmp = 0;

    memset(mem,0,sizeof(mem));

    cin >> n >> m;
    for(int i = 0; i < n; i ++){
        cin >> k;
        for(int j = 0; j < k; j ++){
            cin >> tmp;
            mem[tmp] ++;
        }
    }

    for(int i = 1; i <= m; i ++){
        if(mem[i] ==  n) ans ++;
    }
    cout << ans;
    return 0;
}









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

using namespace std;

int main() {
    while(true) {
        int N, S;
        cin >> N >> S;
        if(!N && !S) break;

        int arr[10] = {0};
        for(int i = 0; i < N; ++i) arr[9-i] = 1;
        int cnt = 0;
        do {
            int sum = 0;
            for(int i = 0; i < 10; ++i)
                if(arr[i]) sum += i;
            if(sum == S) ++cnt;
        } while(next_permutation(arr, arr+10));

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

Measured memory_bytes: 0
#include<stdio.h>
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int a = n / 2;
    if (n % 2 == 1)
        a++;
    if (a >= k)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

using namespace std;

int main(){
    
    int N;
    cin >> N;
    int A[N];
    int B[N];
    
    pair<int, int> s[N];
    
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        s[i].first = B[i];
        s[i].second = A[i];
        
    }
    
    sort(s, s+N);
    
    int time = 0;
    bool ans = true;
    
    for (int i = 0; i < N; i++) {
        
        time += s[i].second;
        
        if (time > s[i].first) {
            ans = false;
            break;
        }
        
        
    }
    
    
    /*
    for (int i = 0; i < N; i++) {
        cout << s[i].first << " " << s[i].second << " " << endl;
    }
     */
    
    if (ans) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(void)
{
	long long int N,M,m=0,sum=0;
	scanf("%lld%lld",&N,&M);
	m=M/2;
	if(N>m){
		sum=m;
	}
	else{
		sum=N+(m-N)/2;
	}
	printf("%lld\n",sum);
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, 3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << '\n';
  
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<unordered_map>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmax(a,b) a=max(a,b);
#define N (1<<18)
#define M 19
ll n,v;
class Alpha{
 public:
 ll f[N];
 P g[N][M];
 void setg(ll a[]){
     for(int k=0;k<M;k++){
         for(int i=0;i<n;i++)g[i][k]=make_pair(i,i);
         ll bef=-1e18,pnt=0; a[n]=1e18;
         for(int i=0;i<=n;i++){
          if(abs(a[i]-bef)>(v>>k)){
           for(int j=pnt;j<i;j++)g[j][k]=make_pair(pnt,i-1);
           pnt=i;   
          }
          bef=a[i];
         }
         if((v>>k)==0)break;
     }
 }
 void main(ll a[]){
  setg(a);   
  for(int i=0;i<N;i++)f[i]=-1;
  for(int i=0;i<N;i++){
      for(int j=0;j<M-1;j++){
          if(i&(1<<j))continue;
          chmax(f[i+(1<<j)],g[f[i]+1][j+1].second);
      }
  }
  //for(int i=0;i<16;i++)cout<<f[i]<<" ";cout<<endl;
 }
};Alpha L,R;

class Solve{
  public:
  unordered_map<ll,bool> mas;
  bool main(ll l,ll r){
      if(mas.size()>30)return 0;
      if(mas.find(l)!=mas.end()){
       return mas[l];   
      }
      bool res=0;
      int cnt=0;
      for(int x=v;x;x>>=1)cnt++;
      int who=1;
      for(int i=0;i<cnt;i++)who*=2;//cout<<who<<endl;
      for(int i=0;i<who;i++){
       int ls=i,rs=who-1-i;
       if(l-1<=L.f[ls]&&n-1-R.f[rs]<=r+1)res=1;
      }
      mas[l]=res;
      return res;
  }
};Solve sv;

ll a[N];
int main(){
    cin>>n>>v;
    for(int i=0;i<n;i++)cin>>a[i];
    L.main(a);
    for(int i=0;i<n/2;i++)swap(a[i],a[n-i-1]);
    R.main(a);
    for(int i=0;i<n;i++){
     bool ans=sv.main(L.g[i][0].first,L.g[i][0].second);   
     cout<<(ans?"Possible":"Impossible")<<endl;
    }
 return 0;   
}


Measured memory_bytes: 163712
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n; cin>>n;
    for(int i=0;i<25;i++){
        if((n-4*i)%7==0){
            cout<<"Yes"<<endl;
            return 0;
        }
        if((n-4*i)<0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
    int h,w;
	char r[101][101];
	int e[101][101];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>r[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int k=j;
			while(true){
			if(r[i][k]=='c'){
				e[i][j]=j-k;
				break;
			}
			if(0>k){
				e[i][j]=-1;
				break;
			}
			k--;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<e[i][j];
			if(j<w-1)
				cout<<" ";
		}
		cout<<"\n";
	}
    return 0;
} 

Measured memory_bytes: 1208
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 51;

int n, d[N], x[N][2], g[N << 1][N << 1];

int dis(int x, int y)
{
    int d = std::abs(x - y);
    return std::min(d, 24 - d);
}

bool check(int ans)
{
    memset(g, 0, sizeof(g));
    for (int i = 0; i < n; ++ i) {
        for (int j = 0; j < n; ++ j) {
            if (i == j) {
                continue;
            }
            for (int p = 0; p < 2; ++ p) {
                for (int q = 0; q < 2; ++ q) {
                    if (dis(x[i][p], x[j][q]) < ans) {
                        g[i << 1 | p][j << 1 | q ^ 1] = true;
                    }
                }
            }
        }
    }
    int n2 = n << 1;
    for (int k = 0; k < n2; ++ k) {
        for (int i = 0; i < n2; ++ i) {
            for (int j = 0; j < n2; ++ j) {
                g[i][j] |= g[i][k] && g[k][j];
            }
        }
    }
    for (int i = 0; i < n; ++ i) {
        int i0 = i << 1;
        int i1 = i << 1 | 1;
        if (g[i0][i1] && g[i1][i0]) {
            return false;
        }
    }
    return true;
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("C.in", "r", stdin);
#endif
    d[0] = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i) {
        scanf("%d", d + i);
    }
    n ++;
    for (int i = 0; i < n; ++ i) {
        x[i][0] = d[i];
        x[i][1] = 24 - d[i];
        if (x[i][1] == 24) {
            x[i][1] = 0;
        }
    }
    int ans = 12;
    while (!check(ans)) {
        ans --;
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 256