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

const int MAXN = 1000005, mod = 1e9+7;

int n, fac[MAXN], ifac[MAXN], inv[MAXN];

inline int choose(int n, int m)
{ return n < m ? 0 : (long long)fac[n]*ifac[m]%mod*ifac[n-m]%mod; }

int main()
{
	scanf("%d", &n);
	inv[1] = 1, ifac[0] = fac[0] = 1;
	for (register int i = 2; i <= n; i++) inv[i] = (mod-(long long)mod/i*inv[mod%i]%mod)%mod;
	for (register int i = 1; i <= n; i++) fac[i] = (long long)fac[i-1]*i%mod, ifac[i] = (long long)ifac[i-1]*inv[i]%mod;
	int ans = 0, pre = 0, cur;
	for (register int k = 1; k < n; k++) {
		cur = (((long long)choose(k-1, n-k-1)*fac[k]%mod*fac[n-1-k]-pre)%mod+mod)%mod;
		(pre += cur) %= mod;
		(ans += (long long)cur*k%mod) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11904
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ABCD = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int left = ABCD[0]+ABCD[1];
            int right = ABCD[2]+ABCD[3];
            if(left>right){
                Console.WriteLine("Left");
            }else if(left < right){
                Console.WriteLine("Right");
            }else{
                Console.WriteLine("Balanced");
            }
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int mn = min(x, y);
    x -= mn, y -= mn;
    cout << mn * min(a + b, 2 * c) +
         min(x * a + y * b, 2 * max(x, y) * c) << "\n";
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> mp;
  rep(i,n){
    ll a; cin>>a;
    mp[a]++;
  }
  ll m; cin>>m;
  bool ok=true;
  rep(i,m){
    ll a; cin>>a;
    mp[a]--;
    if(mp[a]<0) ok=false;
  }
  if(ok) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 14848
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long
#define pii pair<intt,intt>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;

/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

#define double long double

const double EPS = 1e-9;

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    intt n;
    cin >> n;
    for (intt x = 1; x <= 3500; x++) {
        for (intt y = 1; y <= 3500; y++) {
            double z = 1.0 * n * x * y / (4.0 * x * y - 1.0 * n * y - 1.0 * n * x);
            if (z < 0) {
                continue;
            }
            if (ceil (1.0 * z) - floor (1.0 * z) < EPS) {
                cout << fixed << setprecision(0);
                cout << x << " " << y << " " << ceil (z) << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <math.h>
#include <iostream>
 
using namespace std;
 
int main()
{
  string a;
  cin >> a;
  if (a == "000")
    cout << "0";
  else if (a == "001")
    cout << "1";
  else if (a == "010")
    cout << "1";
  else if (a == "100")
    cout << "1";
  else if (a == "101")
    cout << "2";
  else if (a == "110")
    cout << "2";
  else if (a == "011")
    cout << "2";
  else if (a == "111")
    cout << "3";
}

Measured memory_bytes: 3592
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

cal = []
for i in range(0,n):
    cal.append(v[i]-c[i])
cal.sort(reverse=True)
ans = 0
for j in range(0,n):
    if cal[j] < 0:
        break
    ans += cal[j]
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int N,K,sum=0;
    cin >> N >> K;
    vector<int> l(N);
    for(int i=0;i<N;i++)cin >> l.at(i);
    sort(l.begin(),l.end());
    for(int i=N-1;i>=N-K;i--)sum += l.at(i);
    cout << sum << endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/******************************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/******************************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
 //   file();
    

    int n;
    cin>>n;
    vector<double> v;
    forn(i,n){
        double x;
        cin>>x;
        v.pb(x);
    }
    sort(all(v));
    double ans = v[0];
    fore(i,1,n-1){
        ans+=v[i];
        ans/=2;
    }
    cout<<fixed<<setprecision(10)<<ans;
    

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 21
#define INF 9999999

int g[MAX][MAX],v[MAX],n,mn,minm;
bool visit[MAX];

int dijkstra(int start,int goal){
    for(int i = 0 ; i < MAX; i++){
        v[i] = INF;
        visit[i] = false;
    }
    
    v[start] = 0;
    while(true){
        minm = INF;
        for(int i = 1 ; i <= n ; i++){
            if(v[i] < minm && !visit[i]){
                minm = v[i];
                mn = i;
            }
        }
        
        if(minm == INF) break;
        visit[mn] = true;
        
        for(int j = 1 ; j <= n ; j++){
            int tmp = g[mn][j]+v[mn];
            if(tmp < v[j]) v[j] = tmp;
        }
    }

    return v[goal];
}

int main(){
    int m,a,b,c,d,x1,x2,y1,y2;
    char ch;
    
    for(int i = 1 ; i < MAX; i++)
        for(int j = 1 ; j < MAX ; j++)
            g[i][j] = INF;

    cin >> n >> m;
    while(m--){
        cin >> a >> ch >> b >> ch >> c >> ch >> d;
        g[a][b] = c;
        g[b][a] = d;
    }
    
    cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;
    cout << y1 - y2 - dijkstra(x1,x2) - dijkstra(x2,x1) << endl;

    return 0;
}

Measured memory_bytes: 1160
x,y=map(int,input().split())
n=(2*x-y)/3
m=(2*y-x)/3
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if n>=0 and m>=0 and n%1==0 and m%1==0:
  n=int(n)
  m=int(m)
  print(cmb(n+m,n)%(10**9+7))
else:
  print(0)

Measured memory_bytes: 46024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string dir = "UDLR";
    int moveX = tx - sx;
    int moveY = ty - sy;
    for (int i = 0; i < moveX; i++) {
        cout << 'R';
    }
    for (int i = 0; i< moveY; i++) {
        cout << 'U';
    }
    for (int i = 0; i < moveX; i++) {
        cout << 'L';
    }
    for (int i = 0; i< moveY; i++) {
        cout << 'D';
    }

    cout << 'D';
    for (int i = 0; i < moveX + 1; i++) {
        cout << 'R';
    }
    for (int i = 0; i< moveY + 1; i++) {
        cout << 'U';
    }
    cout << 'L';
    cout << 'U';
    for (int i = 0; i < moveX + 1; i++) {
        cout << 'L';
    }
    for (int i = 0; i< moveY + 1; i++) {
        cout << 'D';
    }
    cout << 'R';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;

int ans[100000];
vector<int>rinsetu[100000];
int mincost[100000];
int E[100000], F[100000], G[100000];
int K[100000];//その地点から探索した最大の距離の地点
signed main() {
	memset(ans, -1, sizeof(ans));
	memset(K, -1, sizeof(K));
	int a, b;
	scanf("%d%d", &a, &b);
	for (int c = 0; c < b; c++) {
		int d, e; scanf("%d%d", &d, &e); d--; e--;
		rinsetu[d].push_back(e);
		rinsetu[e].push_back(d);
	}
	int c; scanf("%d", &c);
	for (int d = 0; d < c; d++) {
		int e, f, g; scanf("%d%d%d", &e, &f, &g);
		e--;
		E[c - d - 1] = e;
		F[c - d - 1] = f;
		G[c - d - 1] = g;
	}
	for (int d = 0; d < c; d++) {
		int e = E[d], f = F[d], g = G[d];
		memset(mincost, -1, sizeof(mincost));
		mincost[e] = 0;
		queue<int>Q;
		Q.push(e);
		while (Q.size()) {
			int i = Q.front(); Q.pop();
			if (mincost[i] > f)break;
			if (K[i] < f - mincost[i]) {
				K[i] = f - mincost[i];
			}
			else continue;
			if (ans[i] == -1)ans[i] = g;
			for (int j : rinsetu[i]) {
				if (mincost[j] == -1) {
					mincost[j] = mincost[i] + 1;
					Q.push(j);
				}
			}
		}
	}
	for (int i = 0; i < a; i++) {
		if (ans[i] == -1)puts("0");
		else  printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 10872
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0) 
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int inf = ~0u >> 1;
int main() {
    IO;
    int k;
    cin >> k;
    ll ans = 0;
    for (int a = 1; a <= k; ++a)
        for (int b = 1; b <= k; ++b)
            for (int c = 1; c <= k; ++c)
                ans += __gcd(__gcd(a, b), c);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3516
<?php
list($a, $b) = ints();
if(($a - $b) % 2 == 0){
  echo ($a+$b)/2;
}else{
  echo "IMPOSSIBLE";
}
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
/*
  Name:
  Author: Homo_sapiens
  Date:   2020/6/13 20:10:21
  Source:
  Description:
  
*/

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#define IL inline
using namespace std;


int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	double a,v,b,w,t;
	scanf("%lf%lf%lf%lf%lf",&a,&v,&b,&w,&t);
	double m=abs(a-b);
	if(t*(v-w)>=m) printf("YES\n");
	else printf("NO\n");
    return 0;
}


Measured memory_bytes: 3784
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	iA := strings.Index(s, "A")
	iC := strings.Index(s, "C")

	ns := strings.Replace(s, "A", "a", 1)
	ns = strings.Replace(ns, "C", "c", 1)

	if iA == 0 && iC > 1 && iC < len(s)-1 && ns == strings.ToLower(s) {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

string n;
int k;

// メモ化再帰
ll dp[110][2][4];

// digit桁目，現状がNと等しい数か，0以外を使用できる残り回数
ll rec(int digit, bool smaller, int k)
{
    if (k == 0)
        return 1;

    // 桁がnの長さよりも大きければ再帰を終了する
    if (digit >= n.size())
        return 0;

    // 参照型でretを宣言
    ll &ret = dp[digit][(int)smaller][k];

    if (ret > 0)
        return ret;

    ret = 0;

    if (smaller)
    {
        ret += rec(digit + 1, true, k);           // 次の桁が0の時
        ret += rec(digit + 1, true, k - 1) * 9LL; // 次の桁が0以外の時
    }
    else
    {
        if (n[digit] == '0') // 次の桁が0しかあり得ない時
        {
            ret += rec(digit + 1, false, k);
        }
        else
        {
            ret += rec(digit + 1, true, k);                        // 0を使う時
            ret += rec(digit + 1, true, k - 1) * (n[digit] - '1'); // n[digit]より小さい数を使う時
            ret += rec(digit + 1, false, k - 1);                   // n[digit]と等しい数を使う時
        }
    }
    return ret;
}

int main()
{
    cin >> n >> k;
    cout << rec(0, false, k) << endl;
    return 0;
}


Measured memory_bytes: 3648
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




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


int main() {
	int k, a, b;
	cin >> k >> a >> b;
	for(int i = a; i < b+1; i++){
		if(i%k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int>> dp(H+1,vector<int>(W+1,0));

  REP(i,H){
    REP(j,W){
      cin >> dp[i+1][j+1];
    }
  }
  int max_square = 0;
  REP(i,H){
    REP(j,W){
      if(dp[i+1][j+1] == 1)
	dp[i+1][j+1] = 0;
      else {
	dp[i+1][j+1] = 1 + min(dp[i][j+1],min(dp[i+1][j],dp[i][j]));
      	max_square = max(dp[i+1][j+1],max_square);
      }
    }
  }
  /*    REP(i,H+1){
    REP(j,W+1){
      cout << dp[i][j];
    }
    cout << endl;
  }*/
  if(max_square==0)cout << 0 << endl;
  else cout << int(pow(max_square,2)) <<endl;
  return 0;
}

Measured memory_bytes: 10364
#include<bits/stdc++.h>
#define rep(i,n) for(long long int i=0;i<n;i++)
#define lli long long int
#define ll long long 
#define dd double
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

const double pi=3.14159265358;

using namespace std;

int main()
{
	fast
	lli a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	
	    
	
}

//

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N=210;
int n,a[N],ans=0;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n*2;i++)scanf("%d",&a[i]);
    sort(a+1,a+2*n+1);
    for(int i=1;i<=n*2;i+=2)ans+=a[i];
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
while 1:
    w,d=map(int,input().split())
    if w==0:
        break
    W=list(map(int,input().split()))
    D=list(map(int,input().split()))
    ans=0
    table=[0 for i in range(21)]
    for n in W:
        ans+=n
        table[n]+=1
    for n in D:
        if table[n]>0:
            table[n]-=1
        else:
            ans+=n
    print(ans)        


Measured memory_bytes: 5600
N, M = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

CB = []
for _ in range(M):
    B, C = map(int, input().split(" "))
    CB.append((C, B))
    
CB.sort(reverse=True)
cand = []
for cb in CB:
    cand += [cb[0] for _ in range(cb[1])]
    if len(cand) >= N: break
A += cand
A.sort(reverse=True)
print(sum(A[:N]))

Measured memory_bytes: 24000
int main(void)
{
	int a,b,c,min;

	scanf("%d %d %d",&a,&b,&c);


	if(a>b){
		min=b;
		b=a;
		a=min;
	}
	if(b>c){
		min=c;
		c=b;
		b=min;
	}
	if(a>b){
		min=b;
		b=a;
		a=min;
	}
	printf("%d %d %d\n",a,b,c);

	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	int len = s.l_ength();
	int scnt = 0;
	int tcnt = 0;
	int ans = 0;
	for( char c : s ){
		if( c == 'S' ){
			++scnt;
		}
		if( scnt > 0 && c == 'T' ){
			--scnt;
			++ans;
		}
	}
	cout << len-2*ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()

ans = 0
for n in range(len(s)//2-1,-1,-1):
    if s[:n] == s[n:2*n]:
        ans = n
        break
        
print(2*ans)

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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

pair<int,int> f(int x){
    int a=x%10;
    int b=0;
    while(x){
        b=x;
        x/=10;
    }
    return pair<int,int>(a,b);
}

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

    int n;
    cin >> n;
    
    map<pair<int,int>,int> mp;
    for(int i=1;i<=n;i++){
        pair<int,int> c;
        c=f(i);
        mp[c]++;
    }
    int count=0;
    for(int i=1;i<=n;i++){
        pair<int,int> c;
        pair<int,int> d;
        c=f(i);
        d=make_pair(c.second,c.first);
        count+=mp[d];
    }
    cout << count;
    return 0;
}

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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

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

    vector<bool> dp(10, false);
    vector<bool> dp2(100, false);
    vector<bool> ans(1000, false);

    REPS(c, s) {
        int x = (int)(c - '0');
        REP(i, 100) {
            if (dp2[i]) ans[i * 10 + x] = true;
        }
        REP(i, 10) {
            if (dp[i]) dp2[i * 10 + x] = true;
        }
        dp[x] = true;
    }
    int t = 0;
    for (auto b : ans) if (b) t++;
    cout << t << EOL;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int W,H; cin >> W >> H ;
  vl p(W),q(H);
  rep(i,W) cin >> p[i] ;
  rep(j,H) cin >> q[j] ;
  sort(ALL(q));
  ll ans = 0;
  for(auto qq:q) ans += qq;
  vl s(H+1);
  rep(i,H) s[i+1] = s[i] + q[i];
  auto rsum = [&](int l,int r){
    // [l,r)
    if(r<=0) return 0LL;
    return s[r] - s[l];
  };
  rep(i,W){
    int idx = int(upper_bound(q.begin(),q.end(),p[i])-q.begin());
    ans += rsum(0,idx) + (H+1-idx)*p[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = int(read())

A = 10 ** 9; B = 1
D = (S + (-S) % A) // A
C = (A * D - S) // B

print(0,0,A,B,C,D)

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
int res;

void input() {
	cin>>N;
}

void solve() {
	for(int i=1; i<=N; i++) {
		int A; cin>>A;
		if(i%2 && A%2) res++;
	}
	cout<<res<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3580
N = int(input())
INF = 10**9
dp = [INF]*(N+1)
dp[0] = 0
num6 = [6**i for i in range(1, 10)]
num9 = [9**i for i in range(1, 7)]
S = sorted([1] + num6 + num9)

for i in range(1, N+1):
    tmp = INF
    for j in S:
        if j > i:
            break
        else:
            dp[i] = min(tmp, dp[i-j]+1)
            tmp = dp[i]

print(dp[N])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> ar(n);
	for(int &x: ar) cin >> x;
	vector <int> res;
	for(int i=0; i<n; i++){
		if(ar[i]-1 > res.size()){
			cout << -1;
			return 0;
		}
		res.insert(res.begin()+ar[i]-1, ar[i]);
	}
	for(int r: res) cout << r << " ";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char** argv)
{
  int a,b;
  scanf("%d %d", &a, &b);
  
  if(a<6){
    b=0;
  } else if(a<13){
    b/=2;
  }
  printf("%d\n", b);
  return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    string o, s;
    cin >> o;
    s = o;
    reverse(o.begin(), o.end());
    if (s != o) {
        cout << "No" << endl;
        return 0;
    }
    if (o.substr(0, o.size() / 2) !=
        o.substr((o.size() + 3) / 2 - 1, o.size() / 2)) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


int main()
{  int n;
    cin>>n;
    vector <long long> a(n);  int i;
 for(i=0;i<n;i++)
 {  
   cin>>a[i];  
 }
  long long sum=0ll;
  for(i=0;i<n-1;i++)
 {   
    sum+=max(0ll,a[i]-a[i+1]);
    a[i+1]=max(a[i+1],a[i]);
 }
 cout<<sum;
    return 0; 
 
}


Measured memory_bytes: 4408
#include<iostream>
using namespace std;
int main(){
    //mod2019を先にする
    long long int L,R; 
    int l,r,ans=2019,c;
    cin>>L>>R;
    if(R-L>=2019)ans=0;
    l=L%2019;
    r=R%2019;
    if (l>=r)r+=2019;
    for(int i=l;i<r;i++){
        for(int j=i+1;j<=r;j++){
            c=(i*j)%2019;
            if (ans>c)ans=c;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	int a[N + 1];
	int c[10001];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int x = 0;
	for (int i = 0; i<H*W; i++) {
		c[i] = x + 1;
		a[x]--;
		if (a[x] == 0) x++;
	}
	int cnt = 0;
	for (int i = 0; i<H*W; i++) {
		cout << c[i] << " ";
		cnt++;
		if (cnt % (2 * W) == W) { cout << endl; sort(c + cnt, c + cnt + W); reverse(c + cnt, c + cnt + W); }
		else if (cnt % (2 * W) == 0)cout << endl;
	}
}

Measured memory_bytes: 384
n,x = map(int,input().split())
xl = list(map(int,input().split()))

xl = [abs(x-i) for i in xl]

# a,bの最大公約数
def gcd(a, b):
   while b:
       a, b = b, a % b
   return a

ans = xl[0]
for x in xl:
    ans = gcd(ans, x)

print(ans)



Measured memory_bytes: 63640
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef pair<int, int> ii;

int main() {
    int N;
    cin >> N;
    map<int, int> cards;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        auto it = cards.find(a);
        if (it != cards.end()) {
            cards.erase(it);
        } else {
            cards.insert(make_pair(a,1));
        }
    }
    cout << cards.size() << endl;
}


Measured memory_bytes: 4864
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rank = [0]*(n+1)
  
  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
    
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return
    elif self.rank[x] > self.rank[y]:
        self.root[x] += self.root[y]
        self.root[y] = x
    else:
        self.root[y] += self.root[x]
        self.root[x] = y
        if self.rank[x] == self.rank[y]:
          self.rank[y] += 1
  def Is_Same_Group(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  
  def Count(self, x):
    return -self.root[self.Find_Root(x)]

n,k,l=map(int,input().split())
douro=UnionFind(n)
tetudou=UnionFind(n)
for i in range(k):
  p,q=map(int,input().split())
  douro.Unite(p-1, q-1)
for i in range(l):
  r,s=map(int,input().split())
  tetudou.Unite(r-1, s-1)

d={}
for i in range(n):
  pair=(douro.Find_Root(i), tetudou.Find_Root(i))
  if pair in d:
    d[pair] += 1
  else:
    d[pair] = 1

print(' '.join([str(d[(douro.Find_Root(i), tetudou.Find_Root(i))]) for i in range(n)]))


Measured memory_bytes: 51304
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    string s;
    cin >> n >> s;

    vector<P> range;
    int head = -1;
    for(int i = 0; i < n; i++){
        if(s[i] == '1'){
            if(head == -1){
                head = i;
            }
            continue;
        }
        if(head != -1 && i - head >= 1){
            range.emplace_back(head, i - 1);
        }
        head = -1;
    }
    if(head != -1 && n - head >= 1){
        range.emplace_back(head, n - 1);
    }

    auto c = initVec2<P>(n, 0);
    for(P p : range){
        bool l = false;
        if(p.first - 2 >= 0 && s.substr(p.first-2, 3) == "101"){
            l = true;
        }
        bool r = false;
        if(p.second + 2 < n && s.substr(p.second, 3) == "101"){
            r = true;
        }

        if(l){
            c[p.first-2].emplace_back(p.second + 1, p.second - p.first + 1);
            if(p.second - p.first + 1 >= 2){
                c[p.first-2].emplace_back(p.second, p.second - p.first);
            }
        }
        if(r){
            c[p.first].emplace_back(p.second + 3, p.second - p.first + 1);
            if(p.second - p.first + 1 >= 2){
                c[p.first+1].emplace_back(p.second + 3, p.second - p.first);
            }
        }
    }

    vector<int> dp(n + 1);
    rep(i, n){
        for(P p : c[i]){
            dp[p.first] = max(dp[p.first], dp[i] + p.second);
        }
        dp[i+1] = max(dp[i+1], dp[i]);
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 24816
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll flo[300][300];

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

  cin >> h >> w;
  rep(i, 100) {
    rep(j, 100) {
      if (i == j)
        flo[i][j] = 0;
      else
        flo[i][j] = LINF;
    }
  }
  rep(i, 10) {
    rep(j, 10) {
      cin >> b;
      flo[i][j] = b;
    }
  }
  n = 10;
  rep(i, n) {
    rep(j, n) {
      rep(k, n) { flo[j][k] = min(flo[j][i] + flo[i][k], flo[j][k]); }
    }
  }
  rep(i, h) {
    rep(j, w) {
      cin >> a;
      if (a == -1) continue;
      ans += flo[a][1];
    }
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long res[3];

  

int main() {
for (int i = 0; i < 3; i++) cin >> res[i];

if (res[0]%2==0 || res[1]%2==0 || res[2]%2==0) cout << 0 << endl;
  else {
    sort (res, res+3);
    cout << res[0]*res[1] << endl;
  }

}
  
    

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define M 1000000
#define D 10000
#define QN 10000
#define inf 0x7FFFFFFF
using namespace std;

int p[20],LOG[M+10],dp[D+10][15];
void init_rmq(int dt[],int l,int r){
	for(int i=l;i<=r;i++)
		dp[i-l][0]=dt[i];
	int k=LOG[(r-l+1)]/LOG[2];
	for(int i=1;i<=k;i++)
		for(int j=l;j<=r;j++)
			if(j+p[i-1]<=r)
				dp[j-l][i]=min(dp[j-l][i-1],dp[j-l+p[i-1]][i-1]);
			else dp[j-l][i]=dp[j-l][i-1];
}
int query_rmq(int a,int b,int delta){
	int x=a,y=b;
	if(x>y) swap(x,y);
	int k=LOG[y-x+1]/LOG[2];
	return min(dp[x-delta][k],dp[y-p[k]+1-delta][k]);
}

int data[M+10];
int l[QN+10],r[QN+10],u[QN+10],d[QN+10],ans[QN+10];
int main(){
	p[0]=1;
	for(int i=1;i<19;i++) p[i]=p[i-1]*2;
	LOG[0]=-1;
	for(int i=1;i<=M;i++) LOG[i]=(i&(i-1))?LOG[i-1]:LOG[i-1] + 1 ;
	
	int n,m,q;
	while(scanf("%d%d%d",&n,&m,&q),n||m||q){
		if(n<=m){
			for(int i=0;i<n;i++)
				for(int j=0;j<m;j++)
					scanf("%d",&data[i*m+j]);
			for(int i=1;i<=q;i++) scanf("%d%d%d%d",&u[i],&l[i],&d[i],&r[i]);
		}
		else{
			for(int i=0;i<n;i++)
				for(int j=0;j<m;j++)
					scanf("%d",&data[j*n+i]);
			swap(n,m);
			for(int i=1;i<=q;i++) scanf("%d%d%d%d",&l[i],&u[i],&r[i],&d[i]);
		}
		
		for(int i=1;i<=q;i++) ans[i]=inf;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j+=D){
				int ed=(j+D-1<m)?j+D-1:m;
				init_rmq(data+i*m,j,ed);
				for(int k=1;k<=q;k++){
					if(i<u[k]||i>d[k]||j>r[k]||ed<l[k]) continue;
					ans[k]=min(ans[k],query_rmq(max(j,l[k]),min(ed,r[k]),j));
				}
			}
		}
		
		for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 9624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b,c; cin>>a>>b>>c;
    if(a==b) cout<<c<<endl;
    if(b==c) cout<<a<<endl;
    if(c==a) cout<<b<<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 n=sc.nextInt();
		int m=sc.nextInt();
		if(m<n*2||m>n*4||m%2==1) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}





	}

}

Measured memory_bytes: 35796
def main():
    n = int(input())
    initials = ["M", "A", "R", "C", "H"]
    person_name = {}
    for initial in initials:
        person_name[initial] = 0
    for _ in range(n):
        name = input()
        if name[0] in person_name:
            person_name[name[0]] += 1
    answer = 0
    for i in range(5):
        for j in range(i + 1, 5):
            for k in range(j + 1, 5):
                answer += person_name[initials[i]] * person_name[initials[j]] * person_name[initials[k]]
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    long long n;
    cin>>s>>n;
    for (int i=0;i<100;i++){
        if (s[i]!='1'){
            cout<<s[i]<<endl;
            break;
        }
        else n--;
        if (n==0){
            cout<<1<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl;
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int n;
	cin>>n;
	vll v(n+1),a(n);
	rep(i,0,n+1)cin>>v[i];
	rep(i,0,n)cin>>a[i];
	ll ans=0;
	rep(i,0,n)
	{
		ans+=min(a[i],v[i]);
		a[i]-=min(v[i],a[i]);
		if(a[i])
		{
			ans+=min(a[i],v[i+1]);
			v[i+1]-=min(a[i],v[i+1]);	
		}		
	}
	cout<<ans;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    if(p == 2) {
        ll ret = 0;
        REP(i, n) if((s[i]-'0')%2 == 0) ret += i+1;
        cout << ret << endl;
        return 0;
    }

    if(p == 5) {
        ll ret = 0;
        REP(i, n) if((s[i]-'0')%5 == 0) ret += i+1;
        cout << ret << endl;
        return 0;
    }

    ll pw = 1, num = 0, ret = 0;
    vector<ll> cnt(p);
    cnt[0]++;
    for(ll i=n-1; i>=0; --i) {
        (num += (s[i]-'0') * pw) %= p;
        ret += cnt[num];
        cnt[num]++;
        (pw *= 10) %= p;
    }
    cout << ret << endl;

    return 0;
}

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

typedef int64_t i64;
typedef uint64_t ui64;

const int inf=1073741823;
const i64 llinf=4611686018427387903LL;

int main(void){
    int a,b,c;
    scanf("%i%i%i",&a,&b,&c);
    if(a<b && b<c) printf("Yes\n");
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;
typedef pair<int,int> pir;
const int N=100010;
bool w[N];
int a[N],b[N],p[N],q[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return o*x;
}
int main() {
    int n;
    long long s1=0,s2=0,ans=1LL<<60,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
	a[i]=gi(),b[i]=gi(),s1+=a[i],s2+=b[i];
	if(a[i]>b[i]) swap(a[i],b[i]);
	sum+=a[i],p[i]=q[i]=i;
    }
    sort(p+1,p+1+n,[](const int &x,const int &y) {return b[x]<b[y];});
    sort(q+1,q+1+n,[](const int &x,const int &y) {return a[x]>a[y];});
    for(int i=1,j=1;;i++,j++) {
	while(w[p[i]]) ++i;
	while(w[q[j]]) ++j;
	if(p[i]==q[j]) {
	    if(i==n||(j<n&&b[p[i+1]]-b[p[i]]>a[q[j]]-a[q[j+1]])) ++j;
	    else ++i;
	}
	if(i>n||j>n) break;
	sum+=b[p[i]]-a[q[j]];
	ans=min(ans,sum),w[p[i]]=w[q[j]]=1;
    }
    cout<<min(ans,min(s1,s2));
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int K, ans = -1, s = 7;
    cin >> K;
    FOR(i, 1, 20000000) {
        if (s % K == 0) {
            ans = i;
            break;
        }

        s = (s * 10) + 7;
        s %= K;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	long long n;
	string res = "";
	cin >> n;
	while (n--) {
		res += 'a' + (char)(n % 26);
		n /= 26;
	}

	for (int i = res.size() - 1; i >= 0; i--) {
		cout << res[i];
	}
	return 0;
}

Measured memory_bytes: 3624