akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  i64 k;
  cin >> n >> k;
  vi32 a(n), f(n);
  cin >> a >> f;
  sort(all(a));
  sort(all(f));
  reverse(all(f));
  i64 ok = 1e18, ng = -1;
  while (ok - ng > 1) {
    i64 md = (ok + ng) / 2;
    i64 cnt = 0;
    rep(i, n) {
      if ((i64) a[i] * f[i] > md) {
        cnt += ((i64) a[i] * f[i] - md + f[i] - 1) / f[i];
      }
    }
    (cnt <= k ? ok : ng) = md;
  }
  cout << ok << endl;
}


Measured memory_bytes: 1792
n=int(input())
if n<105:
  print(0)
else:
  ans=0
  for i in range(105,n+1,2):
    cnt=0
    for j in range(1,i+1,2):
      if i % j==0:
        cnt +=1
    else:
      if cnt == 8:
        ans +=1
  print(ans)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))

cnt = [0 for _ in range(101010)]

ans = 0
for x in a:
    cnt[x] += 1
    ans += x

q = int(input())

for _ in range(q):
    b, c = map(int, input().split())
    cnt[c] += cnt[b]
    ans += (c - b) * cnt[b]
    cnt[b] = 0
    print(ans)

Measured memory_bytes: 21012
N = int(input())
List = [int(n)-1 for n in input().split(" ")]

flag = 0
count = 0

for i in range(N):
    l = List[i]
    if l!=i:
        if List[l] == i:
            count+=1
            List[i] = i
            List[l] = l
        else:
            flag=1
            break
        if count > 1:
            flag=1
            break
if flag==0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

using namespace std;

int main()
{
	int a,b;
	string store[5] = {"A","B","C","D","E"};

	while(cin >> a >> b)
	{
		if(a == 0 && b == 0)
		{
			break;
		}

		vector<pair<int,string> > v;
		v.push_back(make_pair(a+b,store[0]));
		
		REP(i,1,5)
		{
			cin >> a >> b;
			v.push_back(make_pair(a+b,store[i]));		
		}

		sort(v.begin(),v.end(),greater<pair<int,string> >());

		cout << v[0].second << " " << v[0].first << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
h1,m1,h2,m2,k = map(int,input().split())

d1 = h2-h1
if m2 >= m1:
    d2 = m2-m1
else:
    d2 = 60 + m2 -m1
    d1 -= 1
print(d1*60+d2-k)

Measured memory_bytes: 9164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			if (b - a == c - b) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 21204
import java.util.Scanner;

import java.util.List;
import java.util.ArrayList;;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		// while (true) {
		// String tmp = scan.nextLine();

		// }
		String tmp = scan.nextLine();
		int r = Integer.parseInt(tmp.split(" ")[0]);
		int c = Integer.parseInt(tmp.split(" ")[1]);
		int[][] nums = new int[r][c];

		for (int i = 0; i < r; i++) {
			String num = scan.nextLine();
			for (int j = 0; j < c; j++) {
				nums[i][j] = Integer.parseInt(num.split(" ")[j]);
			}
		}

		for (int i = 0; i < r; i++) {
			int sum = 0;
			for (int j = 0; j < c; j++) {
				sum += nums[i][j];
				System.out.print(nums[i][j] + " ");
			}
			System.out.println(sum);
		}
		int sumsum = 0;
		for (int i = 0; i < c; i++) {
			int sum = 0;
			for (int j = 0; j < r; j++) {
				sum += nums[j][i];
			}
			sumsum += sum;
			System.out.print(sum + " ");
		}
		System.out.println(sumsum);
	}
}



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

int main () {
  int N;
  cin >> N;
  int K;
  cin >> K;
  int cnt=0;
  vector<int> x(N);
  for (int i=0; i<N; i++) {
    cin >> x[i];
    if (x[i] < abs(K - x[i])) {
      cnt += x[i]*2;
    }
    else {
      cnt += abs(K - x[i])*2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define boost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
using namespace std;
void sol(){
  	int h,n;
  	cin >>h >> n;
  	int a[n];
  	int sum=0;
  	for(int i=0;i<n;i++){
  		cin >>a[i];
  		sum+= abs(a[i]);
  	}
  	if (sum>=h){
  		cout << "Yes";
  	}
  	else{
  		cout << "No";
  	}
 	}


int main()
{
	boost;
	sol();
}

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

using namespace std;

// AtCoderを信じる！

using int64 = long long;
const int INF = 1 << 30;

int main() {
  int N, A[200000];

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int64 ret = 0;
  int candidate_right = N;
  for(int i = N - 1; i >= 0; i--) {
    int new_right = i - A[i];
    if(candidate_right > new_right) {
      ret += i - new_right;
      candidate_right = new_right;
    } else if(candidate_right == new_right) {
      continue;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  if(candidate_right == 0) {
    cout << ret << endl;
  } else {
    cout << -1 << endl;
    return 0;
  }
}

Measured memory_bytes: 1024
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, k, a[N], dp[N];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   dp[0] = 0;
   for (int x = 1; x <= k; x ++) {
      dp[x] = 0;
      for (int i = 1; i <= n; i ++) {
         if (x >= a[i] && !dp[x - a[i]])
            dp[x] = 1;
      }   
   }
   cout << (dp[k] ? "First" : "Second");
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 640
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    set<string> st;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    rep(i, n) {
        if(st.count(s[i])) {
            cout << "No" << endl;
            return 0;
        }
        st.insert(s[i]);
    }
    rep(i, n-1) {
        if(s[i].back() != s[i+1][0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int ans = 0;
    rep(i,n){
        int x;
        cin>>x;
        if(x>=k)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

bool ok(int x) {
  stringstream ss;
  ss << x;
  auto S = ss.str();
  rep(i, S.size() - 1) {
    if (S[i] + 1 != S[i + 1]) return false;
  }
  return true;
}

signed main() {
  int N = in();
  auto A = in(N);
  int maxi = -1;
  rep(i, N) rep(j, i + 1, N) {
    auto M = A[i] * A[j];
    if (ok(M)) chmax(maxi, M);
  }
  pr(maxi);
  return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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


  ll N ;cin >> N;
  if(N <1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
	l=list(map(int,input().split()))
	if l[0]==0 and l[1]==0:
		break
	else:
		for i in range(l[0]):
			if i%2==0:
				if l[1]%2==0:
					print('#.'*(l[1]//2))
				else:
					print('#.'*(l[1]//2)+'#')
				
			else:
				if l[1]%2==0:
					print('.#'*(l[1]//2))
				else:
					print('.#'*(l[1]//2)+'.')
		print('')


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

        long long i,p,n=0;
        string s;
        cin>>s;
        n=s.size();
        for(i=0;i<n;i++){
            p=p+(s[i]-48);
        }if(p%9==0)
        cout<<"Yes";
        else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    ll sum = 0;
    rep(i, N)
    {
        cin >> H[i];
        // sum += H[i];
    }

    sort(all(H), greater<ll>());
    // ll minus_sum = 0;
    // rep(i, K)
    rep(i, N)
    {
        if (i >= K)
        {
            sum += H[i];
        }
        // minus_sum += H[i];
    }
    // cout << sum - minus_sum;
    cout << sum;
    return 0;
}

Measured memory_bytes: 1792
MOD = 10 ** 9 + 7

def inv(x):
  return pow(x, MOD - 2, MOD)


def gen_fact(n):
  fact = [1] * (n + 1)
  for i in range(2, n + 1):
    fact[i] = fact[i - 1] * i % MOD
  return fact


def binom(n, k, fact):
  assert 0 <= k <= n
  return fact[n] * inv(fact[k]) * inv(fact[n - k]) % MOD


def count(n, k, fact):
  n -= 3 * k
  return binom(n + k - 1, k - 1, fact)


if __name__ == '__main__':
  s = int(input())
  fact = gen_fact(s)
  res = 0
  for k in range(1, s // 3 + 1):
    res += count(s, k, fact)
  print(res % MOD)

Measured memory_bytes: 9160
import static java.lang.Math.*;
import static  java.util.Arrays.*;
import java.io.*;
import java.util.*;

class Scanner {
    BufferedReader br;
    StringTokenizer st;
    Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        eat("");
    }
    void eat(String s) {
        st = new StringTokenizer(s);
    }
    String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            throw new IOError(e);
        }
    }
    boolean hasNext() {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null) return false;
            eat(s);
        }
        return true;
    }
    String next() {
        hasNext();
        return st.nextToken();
    }
    int nextInt() {
        return Integer.parseInt(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
}

class Pair implements Comparable<Pair> {
    int val, cnt;
    Pair(int v, int c) {
        this.val = v; this.cnt = c;
    }
    public int compareTo(Pair o) {
        return o.cnt - this.cnt;
    }
}

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] map = new int[200001];
        ArrayList<Pair> array = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            map[tmp]++;
        }
        for (int i = 1; i <= n; i++) {
            if (map[i] != 0) {
                array.add(new Pair(i, map[i]));
            }
        }
        Collections.sort(array);
        int sz = array.size(), cnt = 0;
        while (sz > k) {
            sz--;
            cnt += array.get(sz).cnt;
        }
        System.out.println(cnt);
    }

    static public void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 46036
k, n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
d = Array.new(n)
for i in 0..(n-2)
  d[i] = a[i+1] - a[i]
end
d[n-1] = k-a[n-1] + a[0]

max = 0
d.each{|dn| max = [max,dn].max}
puts k - max

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

using namespace std;

struct Clue {
    int x, y, h;
    Clue() {}
    friend istream& operator>>(istream& in, Clue& c) {
        return in >> c.x >> c.y >> c.h;
    }
    int get_dist(int x0, int y0) {
        return abs(x-x0) + abs(y-y0);
    }
    bool consistent(int x0, int y0, int h0) {
        return max(h0 - get_dist(x0, y0), 0) == h;
    }
    bool operator<(const Clue& o) const {
        return h > o.h;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<Clue> clues(n);
    for (auto& clue : clues) {
        cin >> clue;
    }
    sort(clues.begin(), clues.end());
    assert (clues[0].h > 0);
    for (int x0 = 0; x0 <= 100; ++x0) {
        for (int y0 = 0; y0 <= 100; ++y0) {
            int h0 = clues[0].get_dist(x0, y0) + clues[0].h;
            bool consistent = true;
            for (auto& clue : clues) {
                if (!clue.consistent(x0, y0, h0)) {
                    consistent = false;
                    break;
                }
            }
            if (consistent) {
                cout << x0 << " " << y0 << " " << h0 << endl;
                return 0;
            }
        }
    }
    assert (false);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll m = 1000000007;

ll fn(ll n, ll a, ll mod = m) {
    ll res = 1, x = a%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    return ans;
}

ll mul(ll a, ll b, ll mod = m) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    return r;
}

ll power(ll x, ll n, ll mod = m) {
    ll res = 1;
    x %= mod;
    while (n)  
    {  
        if (n & 1)  res = (res*x)%mod;  
        n = n/2; 
        x = (x*x)%mod;  
    }  
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(long long x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> primes) 
{ 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

vector<bool> sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
    return prime;
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    ll n, sum = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        if(i%5 != 0 && i%3 != 0) {
            sum+=i;
        }
    }
    cout << sum << "\n";
    return 0;
} 

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    const int maxNumber = min(A, B);
    const int minNumber = max(0, min(N, (A + B) - N));

    cout << maxNumber << " " << minNumber << endl;

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    cout << (N/3) << endl;
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001;
using namespace std;
typedef long long ll;

int n;
double x;
string u;

int main(){
  std::cin >> n;
  double res = 0;
  rep(i,1,n+1){
    std::cin >> x >> u;
    if(u == "JPY")res += x;
    else res += x*380000.0;
  }
  std::cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten5],pp[ten52],mm[ten52];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,pre,money=1000;
    cin>>n;
    if(n>=30)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}





Measured memory_bytes: 3568
while True:
  a,b=map(int,input().split())
  z=0
  if a==0 and b==0:
    break
  else:
    for i in range (1,a+1):
      for o in range (i+1,a+1):
        for p in range (o+1,a+1):
          c=i+o+p
          if c==b:
            z+=1
  print(z)


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

const int N=1e3+50,mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (LL)x*y%mod;}
inline int power(int a,LL b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}
struct matrix {
	int a[2][2];
	matrix(int t=0) {memset(a,0,sizeof(a)); a[0][0]=a[1][1]=t;}
	friend inline matrix operator *(const matrix &a,const matrix &b) {
		matrix c;
		for(int i=0;i<2;i++) for(int k=0;k<2;k++) for(int j=0;j<2;j++) c.a[i][j]=add(c.a[i][j],mul(a.a[i][k],b.a[k][j]));
		return c;
	}
	friend inline matrix power(matrix a,LL b) {
		matrix rs(1);
		for(;b;b>>=1,a=a*a) if(b&1) rs=rs*a;
		return rs;
	}
};

int h,w,b1,b2,c1,c2,cnt,t;
char s[N][N]; LL k;
int main() {
	cin>>h>>w>>k; if(k<=1) {return puts("1"),0;}
	for(int i=1;i<=h;i++) cin>>(s[i]+1);
	for(int i=1;i<=h;i++) if(s[i][1]=='#' && s[i][w]=='#') ++c1;
	for(int i=1;i<=w;i++) if(s[1][i]=='#' && s[h][i]=='#') ++c2;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) if(s[i][j]=='#') ++cnt;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) if(s[i][j]=='#') b1+=(s[i][j]==s[i][j+1]), b2+=(s[i][j]==s[i+1][j]);
	if(c1&&c2) return puts("1"),0;
	else if(!c1 && !c2) return cout<<power(cnt,k-1),0;
	else {
		if(!c1) swap(c1,c2), swap(b1,b2);
		matrix A; A.a[0][0]=cnt; A.a[0][1]=0; A.a[1][0]=b1; A.a[1][1]=c1;
		A=power(A,k-1); cout<<dec(A.a[0][0],A.a[1][0]);
	}
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

const long long INF = 1LL << 60;

int MOD = 1000000007;
long long dp[100010];

long long rec(int i){
    if (dp[i]< INF){
        return dp[i];
    }
    if (i < 3){
        dp[i] = rec(i-1)+1;
        return dp[i];
    }
    dp[i] = (rec(i-1)+rec(i-2))%MOD;
    return dp[i];  
}


int main(void){
    
    int N,m,a;cin >> N >> m;
    for (int i=0;i<100010;i++) dp[i] = INF;
    dp[0] = 0;
    for (int i=0;i<m;i++){
        cin>>a;
        dp[a] = 0;
    }
    cout << rec(N) <<endl;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes";
	else
		cout << "No";


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std; 
 
int main(){
  int n;
  long long sum=0;
  cin>>n;
  for(int i=1;i<=n;i++){
   	if(i%3){
      if(i%5){
        sum+=i;
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3192
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
	static Scanner sc=new Scanner(System.in);
	static PrintWriter pr=new PrintWriter(System.out);
	static int temp=50001;
	static boolean[] judge=new boolean[temp];
	static int[] ans=new int[temp];
	public static void main(String[] args) {
		judge[0]=judge[1]=true;
		for(int i=0;i<temp;i++){
			if(judge[i]) continue;
			for(int j=i*2;j<temp;j+=i)	judge[j] = true;
		}
		for(int i=0;i<temp;i++){
			if(judge[i]) continue;
			for(int j=i;i+j<temp;j++){
				if(judge[j])continue;
				ans[i+j]++;
			}
		}
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			pr.println(ans[n]);

		}
		pr.flush();
	}
}

Measured memory_bytes: 31648
#include <iostream>
#include <algorithm>
using namespace std;
int N, a[101010];
int main(){

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	sort(a, a + N);

	if(N % 3 == 0){
		bool done = (a[0] == a[N / 3 - 1]);
		done &= (a[N / 3] == a[2 * N / 3 - 1]);
		done &= (a[2 * N / 3] == a[N - 1]);
		done &= ((a[0] == (a[N / 3] ^ a[2 * N / 3])) || 
				 (a[N / 3] == (a[0] ^ a[2 * N / 3])) || 
				 (a[2 * N / 3] == (a[0] ^ a[N / 3])));
		cout << (done ? "Yes" : "No") << '\n';
	}
	else{
		cout << ((a[0] == a[N - 1] && a[0] == 0) ? "Yes" : "No") << '\n';
	}
}

Measured memory_bytes: 640
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        int A,B,C,X;
        int Ans=0;

        cin >> A >> B >> C >> X;

        for(int i=0; (i<=A)&&(500*i)<=X; i++){
                for(int j=0; (j<=B)&&(500*i+100*j<=X); j++){
                        if(((X-500*i-100*j)%50==0)&&((X-500*i-100*j)/50<=C))Ans++;
                }
        }

cout << Ans << endl;
        return 0;
}


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

using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN/2;

const double PI = 3.14159265358979311;
int32_t main() {
	FAST_IO;
	
	int r;
	cin >> r;
	
	cout << fixed << setprecision(9) << PI*2*r << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  string a,b,c;
  char s1,s2,s3;
  cin >> a >> b >> c;
  
  transform(a.begin(),a.end(),a.begin(),::toupper);
  transform(b.begin(),b.end(),b.begin(),::toupper);
  transform(c.begin(),c.end(),c.begin(),::toupper);
  
  s1=a.at(0);
  s2=b.at(0);
  s3=c.at(0);
    
  cout << s1 << s2 << s3;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll k, t;
  cin >> k >> t;

  priority_queue<ll> pq;

  rep(i, t){
    ll a;
    cin >> a;
    pq.push(a);
  }

  while(pq.size() > 1){
    ll a, b;
    a = pq.top(); pq.pop();
    b = pq.top(); pq.pop();
    a--, b--;
    if(a > 0) pq.push(a);
    if(b > 0) pq.push(b);
  }

  ll ans = 0;
  if(pq.size() == 1){
    ans = pq.top() - 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3536
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) 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 MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)

r, d, x = MI()
num = x
for i in range(10):
    num = r*num - d
    print(num)

    


Measured memory_bytes: 67052
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();
        final String s = sc.next();

        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            ch += N;
            if (ch > 'Z') {
                ch = (char) ('A' + (ch - 'Z') - 1);
            }
            System.out.print(ch);
        }
        System.out.println();
    }
}


Measured memory_bytes: 25684
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#define INF (2000000000)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;


int head[20];
int to[400];
int next[400];
int cost[400];

int d[20];

int n, m;

void Search(int now)
{
	fill(d, d + 20, INF);
	d[now] = 0;
	
	while (true){
		bool update = false;
		
		for (int i = 0; i < n; i++){
			for (int e = head[i]; e != -1; e = next[e]){
				if (d[i] != INF && d[to[e]] > d[i] + cost[e]){
					d[to[e]] = d[i] + cost[e];
					update = true;
				}
			}
		}
		
		if (!update){
			break;
		}
	}
}

int main()
{
	scanf("%d %d", &n, &m);
	
	memset(head, -1, sizeof(head));
	for (int i = 0; i < m; i++){
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		a--; b--;
		
		next[i * 2] = head[a];
		head[a] = i * 2;
		to[i * 2] = b;
		cost[i * 2] = c;
		
		next[i * 2 + 1] = head[b];
		head[b] = i * 2 + 1;
		to[i * 2 + 1] = a;
		cost[i * 2 + 1] = d;
	}
	
	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	x1--; x2--;
	
	
	int go, back;
	Search(x1);
	go = d[x2];
	Search(x2);
	back = d[x1];
	
	printf("%d\n", y1 - y2 - go - back);
	
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
const double eps = 1e-6;
ll n, k, a[N];
ll calc(double mid){
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        double t = 1.0*a[i]/mid;
        ll tt = t;
        ans += tt;
    }
    return ans;
}
int main(void){
    IOS;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    double l = 0.1, r = 1000000000.0;
    while (r-l > eps){
        double mid = (r+l)/2;
        //debug(mid);
        if (calc(mid) <= k){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << (int)ceil(l) << endl;
    return 0;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define fi(i,a,b) for(ll i = a; i < b; i++)
#define fd(i,a,b) for(ll i = a; i >= b; i--)
#define cfi(container,it) for(auto it = container.begin(); it != container.end(); it++)
#define cfd(container,it) for(auto it = container.rbegin(); it != container.rend(); it++)
#define vi vector<int>
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back

using namespace std;
using ll = long long;
const int MOD = (int) 1e9 + 7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x,k,d;
	cin>>x>>k>>d;	
	x = abs(x);

	ll cur = x/d;
	x = x - min(k, cur)*d;
	k -= min(k, cur);

	if(k % 2 == 0) {
		cout<<x<<'\n';
	} else {
		cout<<min(abs(x - d), abs(x + d))<<'\n';
	}

	return 0;
}

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

int main()
{
    string S;
    cin >> S;
    vector<char> ACGT = {'A', 'C', 'G', 'T'};

    int counts = 0;
    int max_counts = 0;
    int flag = 0;

    for (char x : S)
    {
        if (x == 'A' || x == 'C' || x == 'G' || x == 'T')
        {
            counts++;
        }
        else
        {
            max_counts = max(counts, max_counts);
            counts = 0;
        }
    }
    cout << max(counts, max_counts) << endl;

#if 0
    for (int i = 0; i < S.size(); i++)
    {
        for (char a : ACGT)
        {
            if (a == S.at(i))
            {
                flag = 1;
            }
        }
        if (flag == 1)
        {
            counts++;
        }
        else
        {
            if (counts > max_counts)
            {
                max_counts = counts;
            }
            counts = 0;
        }
        flag = 0;
    }

    if (counts > max_counts)
    {
        max_counts = counts;
    }

    cout << max_counts << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")
ll dp[110][510],cop[110][510];
ll n,X,L[100];
int main(){
	cin>>n>>X;
	rep(i,n)cin>>L[i];
	sort(L,L+n,greater<ll>());
	ll N=n/2+1;
	rep(P,X+1)rep(S,N+1)dp[S][P]=0;
	dp[0][0]=1;
	rep(i,n){
		rep(P,X+1)rep(S,N+1)cop[S][P]=dp[S][P],dp[S][P]=0;
		rep(P,X+1)rep(S,N+1){
			for(int x=1;x<=L[i]&&P+x<=X;x++){
				if(S>=1)mad(dp[S-1][P+x],cop[S][P]*S*(S-1)*(L[i]-x+1));
				mad(dp[S][P+x],cop[S][P]*S*2);
			}
			mad(dp[S][P],cop[S][P]*(S+P-(L[i]*S)));
			if(P+L[i]<=X)mad(dp[S+1][P+L[i]],cop[S][P]);
		}
	}
	cout<<dp[1][X]<<endl;
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a >= b){
    a = b;
  }
  if(c >= d){
    c = d;
  }
  cout<<a+c<<'\n';
  return 0;
}


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

bool dfs(vector<int> c, vector<int> d, int N, int M){
    vector<vector<int>> x(N + 1, vector<int>(0));
    vector<bool> y(N + 1, true);
    for (int i = 0; i < M - 1; i++){
        x.at(c.at(i)).push_back(d.at(i));
        x.at(d.at(i)).push_back(c.at(i));
    }
    stack<int> s;
    s.push(c.at(0));
    while (!s.empty()){
        int t = s.top();
        s.pop();
        for (int i = 0; i < x.at(t).size(); i++){
            if (y.at(x.at(t).at(i))){
                s.push(x.at(t).at(i));
                y.at(x.at(t).at(i)) = false;
            }
            
        }
    }
    for (int i = 1; i <= N; i++){
        if (y.at(i)) return false;
    }
    return true;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), c(M - 1), d(M - 1);
    for (int i = 0; i < M; i++){
        cin >> a.at(i) >> b.at(i);
    }
    int count = 0;
    for (int i = 0; i < M; i++){
        int k = 0;
        for (int j = 0; j < M - 1; j++){
            if (j == i) k++;
            c.at(j) = a.at(k);
            d.at(j) = b.at(k);
            k++;
        }
        
        if (!dfs(c, d, N, M)) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(float, input().split()))
mid = sum(A)/2
tmp = 0
for i in range(N):
    tmp+=A[i]
    if tmp>mid:
        if tmp-mid>mid-(tmp-A[i]):
            print(int(sum(A[i:])-sum(A[:i])))
        else:
            print(int(tmp-sum(A[i+1:])))
        break

Measured memory_bytes: 88912
<?php
/*
    Problem URL : https://beta.atcoder.jp/contests/abc064/tasks/abc064_c

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

$sz = 10;
$m = array_pad(array(), $sz, 0);
$mmin = $mmax = $uniq = 0;

fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));

foreach ($a as $v) {
    if ($v >= 3200) {
        $c = 9;
    } else {
        $c = (int) floor($v / 400);
    }
    $m[$c]++;
}

ksort($m);

for ($i = 0; $i < $sz; $i++) {
    if ($i == 9) {
        if ($m[$i] > 0) {
            if ($mmin == 0) {
                $mmin = 1;
            }
            $mmax += $m[$i];
        }
    } else {
        if ($m[$i] > 0) {
            $mmin += 1;
            $mmax += 1;
        }
    }
}

printf("%d %d\n", $mmin, $mmax);



Measured memory_bytes: 4604
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

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

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

use std::collections::VecDeque;
fn main(){
    input!{
        base: [usize; 3],
    }
    let mut count = 0;
    let mut a = base.clone();
    if a[0] % 2 == a[1] % 2 && a[0] % 2 != a[2] % 2{
        a[0] += 1;
        a[1] += 1;
        count += 1;
    }
    else if a[0] % 2 == a[2] % 2 && a[1] % 2 != a[2] % 2{
        a[0] += 1;
        a[2] += 1;
        count += 1;
    }
    else if a[2] % 2 == a[1] % 2 && a[0] % 2 != a[2] % 2{
        a[2] += 1;
        a[1] += 1;
        count += 1;
    }
    a.sort();
    while a[0] < a[2] {
        a[0] += 2;
        count += 1;
    }
    while a[1] < a[2] {
        a[1] += 2;
        count += 1;
    }
    println!("{}", count);
}


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

// ???????¨? ??? ???????????????
main(){
	int n,m ;
	string Jkk[] = {"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan",
					"Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"} ;
	while( cin >> m >> n , m ){
		int c[10000] = {} , mx = 1 ;
		c[0] = m%10 ; c[1] = m/10 ;
		if( c[1] ) mx++ ;
		
		for( int i=1 ; i<n ; i++ ){
			int tmp[10000] = {} ;
			for( int j=0 ; j<m ; j++ ){
				int k ;
				for( k=0 ; k<mx ; k++ ){
					tmp[k] += c[k] ;
					tmp[k+1] += tmp[k]/10 ;
					tmp[k] %= 10 ;
				}
				if( tmp[k] ) mx++ ;
			}
			swap(tmp,c) ;
		}
		
		int st = (mx-1)/4 ;
		if( st >= 17 ) st = 17 ;
		int flg = 0 ;
		for( int i=mx-1 ; i>=0 ; i-- ){
			if( i%4 == 3 ) flg = 0 ;
			if( c[i] != 0 ) flg = 1 ;
			if( flg != 0 ) cout << c[i] ;
			if( i%4 == 0 && flg ) cout << Jkk[st] ;
			if( i%4 == 0 && i/4 - 1 <= 16 ) st-- ;
		}
		cout << endl ;
	}
}

Measured memory_bytes: 1292
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll __int64

int dp[1002][1002];
int n,m;
int dist[1002];
int cost[1001];
const int INF=2000000000;
int main(){

cin>>n>>m;
rep(i,n)cin>>dist[i];
rep(i,m)cin>>cost[i];

for(int i=0;i<=m;i++)for(int j=0;j<=n;j++)dp[i][j]=INF;

dp[0][0]=0;

for(int i=0;i<m;i++){//日程
	for(int j=0;j<n;j++){//距離
		if(dp[i][j]!=INF){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			dp[i+1][j+1]=min(dp[i][j+1],dp[i][j]+cost[i]*dist[j]);
		}
	}
}

/*for(int i=0;i<=m;i++){
	for(int j=0;j<=n;j++){if(dp[i][j]==INF)cout<<"F ";else cout<<dp[i][j]<<" ";}
	cout<<endl;
}*/
int ans=INF;
for(int i=n+1;i<=m;i++)ans=min(ans,dp[i][n]);
cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 6992
#include <stdio.h>
#include <string.h>

int abs(int a){
	if(a>=0)return a;
	else return -a;
}

int main(void){
	int n;
	int a[100002];
	int i;
	int sum=0;
	int ans;

	scanf("%d", &n);

	a[0] = 0;
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	a[n+1] = 0;

	for(i=1;i<=n+1;i++){
		sum += abs(a[i-1] - a[i]);
	}

	for(i=1;i<=n;i++){
		ans = sum - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]);
		printf("%d\n",ans);
	}

	return 0;
}



Measured memory_bytes: 1536
#template
def inputlist(): return [int(k) for k in input().split()]
import sys
sys.setrecursionlimit(10**8)
#template
N = int(input())
li = [0]*(N-1)
dic = {}
graph = [[]*(N+1) for _ in range(N+1)]
for i in range(N-1):
    a,b = inputlist()
    if a >= b:
        a,b = b,a
    graph[a].append(b)
    graph[b].append(a)
    k = tuple([a,b])
    dic[k] = i
ans = 0
indexa = -1
seen = [False]*(N+1)
for i in range(1,N+1):
    k = len(graph[i])
    if k > ans:
        indexa = i
    ans = max(ans,k)
def dfs(i,v):
    for v1 in graph[v]:
        if seen[v1]:
            continue
        seen[v1] = True
        i +=1
        i %= ans
        aa = min(v,v1)
        bb = max(v,v1)
        ka = tuple([aa,bb])
        li[dic[ka]] = i
        dfs(i,v1)
dfs(-1,indexa)
print(ans)
for i in range(N-1):
    print(li[i]+1)


Measured memory_bytes: 78244