akhauriyash/Code-Regression huggingface dataset:
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    for (char& ch : S)
    {
        ch += N;
        if (ch > 'Z')
        {
            ch = ch - 'Z' + 'A' - 1;
        }
    }
    cout << S;
    return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string S,T;
    cin >> S;
    cin >> T;
    if(T.length() - S.length() == 1){
        if(T.erase(T.length() - 1) == S){
            cout << "Yes";
            return 0;
        }
    }
    
    cout << "No";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> s(N);
    deque<int> q;
    int sum = 0;
    for(int i = 0; i < N; ++i){
        cin >> s[i];
        sum += s[i];
        if(s[i]%10 != 0) q.push_back(s[i]);
    }
    sort(q.begin(), q.end());
    while(sum%10 == 0 && sum != 0){
        if(q.size() == 0){
            cout << 0 << endl;
            return 0;
        }
        sum -= q.front();
        q.pop_front();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#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 pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  rep(i,n-1){
    if(c*i-(n-1-i)*d<=abs(a-b)&&abs(a-b)<=d*i-(n-1-i)*c){
      COUT("YES");
      return 0;
    }
  }
  COUT("NO");
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {
	int INF = 1 << 24;
	class MCF{
		ArrayList<ArrayList<Edge>> G;
		
		class Edge {
			int to, cap, cost;
			int rev;

			public Edge(int to, int cap, int cost, int rev) {
				this.to = to;this.cap = cap;this.cost = cost; this.rev = rev;
			}
		}
		MCF(int v){
			G = new ArrayList<ArrayList<Edge>>();
			for(int i = 0; i < v; i++){
				G.add(new ArrayList<Edge>());
			}
		}
		
		private void addEdge(int from, int to, int cap, int cost){
			G.get(from).add(new Edge(to, cap, cost, G.get(to).size()));
			G.get(to).add(new Edge(from, 0, -cost, G.get(from).size() - 1));
		}

		private int minCostFlow(int s, int t, int f) {
			int V = G.size();
			int [] dist = new int[V], prevv = new int[V], preve = new int[V];
			int res = 0;
			while(f > 0){
				Arrays.fill(dist, INF);
				dist[s] = 0;
				boolean update = true;
				while(update) {
					update = false;
					for(int v = 0; v < V; v++){
						if(dist[v] == INF) continue;
						for(int i = 0 ; i < G.get(v).size(); i++){
							Edge  e = G.get(v).get(i);
							if(e.cap > 0 && dist[e.to]> dist[v] + e.cost ){
								dist[e.to] = dist[v] + e.cost;
								prevv[e.to] = v;
								preve[e.to] = i; 
								update = true;
							}
						}
					}
				}
				if(dist[t] == INF) return -1;
				
				int d = f;
				for(int v = t; v != s; v = prevv[v]){
					d = Math.min(d, G.get(prevv[v]).get(preve[v]).cap);
				}
				f -= d;
				res += d * dist[t];
				for(int v = t; v!= s; v = prevv[v]){
					Edge e =G.get(prevv[v]).get(preve[v]);
					e.cap -= d;
					G.get(v).get(e.rev).cap += d;
				}
			}
			return res;
		}
	}

	
	private void doit(){
		Scanner sc =new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [] start = new int[n];
			int [] end = new int[n];
			int [] cost = new int[n];
			for(int i = 0; i < n; i++){
				start[i] = sc.nextInt() - 1;
				end[i] = sc.nextInt();
				cost[i] = sc.nextInt();
			}
			
			int v = 366;
			MCF mcf = new MCF(v);
			for(int i = 0 ; i < n; i++){
				mcf.addEdge(start[i], end[i], 1, -cost[i]);
			}
			
			for(int i = 0; i < v-1; i++){
				mcf.addEdge(i, i + 1, 2, 0);
			}
			
			int res = mcf.minCostFlow(0,v-1, 2);
			System.out.println(-res);
		}
	}

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

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int32>> a(3, vector<int32>(3));
  REP(i,3)REP(j,3)cin >> a[i][j];
  int32 n;
  cin >> n;
  vector<vector<bool>> isCalled(3, vector<bool>(3,false));
  REP(k,n){
    int32 b;
    cin >> b;
    REP(i,3)REP(j,3){
      if(a[i][j] == b){
        isCalled[i][j] = true;
      }
    }
  }
  // REP(i,3)REP(j,3){
  //   cout << isCalled[i][j] << endl;
  // }
  REP(i,3){
    bool flg = true;
    REP(j,3){
      if(!isCalled[i][j])flg = false;
    }
    if(flg){
      cout << "Yes\n";
      return 0;
    }
  }
  REP(j,3){
    bool flg = true;
    REP(i,3){
      if(!isCalled[i][j])flg = false;
    }
    if(flg){
      cout << "Yes\n";
      return 0;
    }
  }
  if(isCalled[0][0] && isCalled[1][1] && isCalled[2][2]){
    cout << "Yes\n";
    return 0;
  }
  if(isCalled[0][2] && isCalled[1][1] && isCalled[2][0]){
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
package main

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

const WIDTH = 1002
const HEIGHT = 1002

var sc = bufio.NewScanner(os.Stdin)

func readLineToInt() []int {
    sc.Scan()
    line := strings.Split(sc.Text(), " ")
    var intLine []int
    for _, str := range line {
        n, _ := strconv.Atoi(str)
        intLine = append(intLine, n)
    }
    return intLine
}

func main() {
    var n int
    var x1, y1, x2, y2 int
    var mem [HEIGHT][WIDTH]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        intLine := readLineToInt()
        x1, y1, x2, y2 = intLine[0], intLine[1], intLine[2], intLine[3]
        mem[y1][x1] += 1
        mem[y1][x2] -= 1
        mem[y2][x1] -= 1
        mem[y2][x2] += 1
    }
    ans := mem[0][0]
    for x := 0; x < WIDTH - 1; x++ {
        mem[0][x + 1] += mem[0][x]
        if ans < mem[0][x + 1] {
            ans = mem[0][x + 1]
        }
    }
    for y := 1; y < HEIGHT - 1; y++ {
        for x := 0; x < WIDTH - 1; x++ {
            mem[y][x + 1] += mem[y][x]
            mem[y][x] += mem[y - 1][x]
            if ans < mem[y][x]  {
                ans = mem[y][x]
            }
        }
    }
    fmt.Println(ans)
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
	long long int n, d, ans = 0;
	cin >> n >> d;
	vector<long long int> x(n);
	vector<long long int> y(n);
	rep(i, n) cin >> x[i] >> y[i];
	rep(i, n)
	{
		ans += (x[i] * x[i] + y[i] * y[i]) <= d * d;
	}
	cout << ans;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
const int x_axis = 1;
const int y_axis = -1;
using ll = long long;
using namespace std;

bool dpx[8100][16100];
bool dpy[8100][16100];

int x[8100];
int y[8100];

int main(){
	dpx[0][0] = true;
	dpy[0][0] = true;
	int xr = 0, yr = 0;
	int dir = x_axis;
	string order; cin >> order;
	order += 'T';
	int n = order.l_ength();
	int offset = 0;
	if( order[0] == 'F' ){
		for( int i = 0; i < n; ++i ){
			if( order[i] == 'T' ){
				offset = i;
				break;
			}
		}
	}
	for( int i = offset; i < n; ++i ){
		char mode = order[i];
		if( mode == 'T' ){
			if( dir == x_axis ) ++xr;
			else ++yr;
			dir *= -1;
		} else{
			if( dir == x_axis ) ++x[xr];
			else ++y[yr];
		}
	}
	/*
	cout << "offset: " << offset << endl;
	cout << "x:" << endl;
	for( int i = 0; i <= xr; ++i ) cout << x[i] << ' ';
	cout << endl;
	cout << "y:" << endl;
	for( int i = 0; i <= yr; ++i ) cout << y[i] << ' ';
	cout << endl;
	*/
	for( int i = 0; i < xr; ++i ){
		for( int j = 0; j <= 8010; ++j ){
			if( j-x[i] >= 0 && dpx[i][j-x[i]] ) dpx[i+1][j] = true;
			if( -1*(j-x[i]) >= 0 && dpx[i][-1*(j-x[i])] ) dpx[i+1][j] = true;
			if( j+x[i] >= 0 && dpx[i][j+x[i]] ) dpx[i+1][j] = true;
		}
	}
	for( int i = 0; i < yr; ++i ){
		for( int j = 0; j <= 8010; ++j ){
			if( j-y[i] >= 0 && dpy[i][j-y[i]] ) dpy[i+1][j] = true;
			if( -1*(j-y[i]) >= 0 && dpy[i][-1*(j-y[i])] ) dpy[i+1][j] = true;
			if( j+y[i] >= 0 && dpy[i][j+y[i]] ) dpy[i+1][j] = true;
		}
	}
	/*cout << "dpx:" << endl;	
	for( int i = 0; i <= xr; ++i ){
		for( int j = 0; j <= 10; ++j ){
			cout << dpx[i][j] << ' '; 
		} cout << endl;
	}
	cout << "dpy:" << endl;	
	for( int i = 0; i <= yr; ++i ){
		for( int j = 0; j <= 10; ++j ){
			cout << dpy[i][j] << ' '; 
		} cout << endl;
	}*/
	int px, py; cin >> px >> py;
	bool fx, fy;
	fx = ( px-offset < 0 ) ? dpx[xr][-(px-offset)] : dpx[xr][px-offset];
	fy = dpy[yr][abs(py)];
	if( fx && fy ) cout << "Yes";
	else cout << "No";
	cout << endl;
}

Measured memory_bytes: 125696
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))


int main(void) {
	string s;
	cin>>s;
	int minv=INF,n=753;
	int size=s.size();
	int cnt;
	if(size==3) cnt=0;
	else if(size==4) cnt=1;
	else cnt=size-2;
	
	rep(i,cnt+1){
		string nu=s.substr(i,3);
		int num=stoi(nu);
		chmin(minv,abs(num-n));
	}
	cout<<minv<<endl;
	
}





Measured memory_bytes: 256
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/11.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll a,b;
    cin>>a>>b;
    if(a==b){
        cout<<a<<endl;
        return 0;
    }
    if(a%2==0){
        if(b%2==0){
            int c=b-a;
            if(c%4==0)
                cout<<b<<endl;
            else{
                b^=1;
                cout<<b<<endl;
            }
        }
        else{
            int c=b-a+1;
            if(c%4==0)
                cout<<0<<endl;
            else
                cout<<1<<endl;
        }
    }
    else{
        if(b%2==0){
            int c=b-a-1;
            if(c%4==0){
                a^=b;
                cout<<a<<endl;
            }
                   else{
                       a^=1;
                       a^=b;
                       cout<<a<<endl;
                   }
               }
               else{
                   int c=b-a;
                   if(c%4==0)
                       cout<<a<<endl;
                   else{
                       a^=1;
                       cout<<a<<endl;
                   }
                       
               }
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 256
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    long[] fact = new long[N + 1];
    fact[0] = 1;
    for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i % M;
    long[] factinv = new long[N + 1];
    factinv[0] = 1;
    for (int i = 1; i <= N; i++) factinv[i] = factinv[i - 1] * inverse(i, M) % M;

    for (int i = 1; i <= K; i++) {
      if (i > N - K + 1) {
        System.out.println(0);
        continue;
      }
      long d = choose(fact, factinv, N - K + 1, i, M);
      d *= choose(fact, factinv, K - 1, i - 1, M);
      d %= M;
      System.out.println(d);
    }
  }

  private static long inverse(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }

  private static long choose(long[] fact, long[] factinv, int n, int k, long M) {
    if (n < k) return 0;
    return fact[n] * factinv[n - k] % M * factinv[k] % M;
  }
}


Measured memory_bytes: 23252
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();  
        double pi =Math.PI;
        sc.close();        
        double CArea = r*r*pi;
        double Clength =2*r*pi;
        System.out.printf("%f %f",CArea, Clength);

    }
}


Measured memory_bytes: 28424
import numpy as np
from random import randint

D=int(input())
c=[int(i) for i in input().split()]
s=[]
for d in range(D):
    s.append([int(i) for i in input().split()])


v = [0]*D
last = [[0 for i in range(26)] for d in range(D)]
t=[0]*D

v_pre=0
for d in range(D):

    if d>=1:
        last[d] = last[d-1][:]
    
    # 初期化
    idx_best=0
    last[d][idx_best] = d+1
    v=v_pre + s[d][idx_best] - sum([c[j]*(d+1 - last[d][j]) for j in range(26)])

    for i in range(1, 26):
        v_tmp = v - s[d][idx_best] + c[idx_best]*(d+1 - last[d][idx_best]) + s[d][i] - c[i]*(d+1 - last[d][i])
        if v < v_tmp:
            v = v_tmp
            last[d][i] = d+1
            
            if d>=1:
                last[d][idx_best]=last[d-1][idx_best]
            else:
                last[d][idx_best]=0
            
            idx_best=i
    
    v_pre = v
    t[d]=idx_best + 1           # 1 <= t[d] <= 26 のため

for d in range(D):
    print(t[d])

v = [0]*D
for d in range(D):
    v[d] = s[d][t[d] - 1] - sum([c[i] for i in range(26)]) + c[t[d] - 1]

v_sum=0
for d in range(D):
    v_sum+=v[d]

Measured memory_bytes: 27108
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    char[] t = sc.next().toCharArray();
    Arrays.sort(s);
    Arrays.sort(t);
    reverse(t);
    String ss = new String(s);
    String tt = new String(t);
    if(ss.compareTo(tt) < 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
  
  public static char[] reverse(char[] array){
    for(int i = 0; i < array.length/2; i++){
      char tmp = array[i];
      array[i] = array[array.length - 1 - i];
      array[array.length - 1 - i] = tmp;
    }
    return array;
  }
}

Measured memory_bytes: 22868
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define YES_ cout<<"Yes"<<endl;
#define NO_ cout<<"No"<<endl;


//
int main(){
  int N;
  cin>>N;
  int A[2][100];
    REP(i,N){
      cin>>A[0][i];
    }
    REP(i,N){
      cin>>A[1][i];
    }
    int maxnum=0;
    REP(down,N){
        //debug(down);
        int num=0;
        REP(i,down+1){
            
         //debug(i);
            
            
          num+=A[0][i];  
        }
        num+=A[1][down];
        FOR(i,down+1,N){
        // debug(i);
            
            num+=A[1][i];
        }
        //debug(num);
        maxnum=max(num,maxnum);
    }

    cout<<maxnum<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,ans=0;
    cin>>a>>b>>c;
    if (a==7) ans++;
    if (b==7) ans++;
    if (c==7) ans++;
    if (ans==1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Accepted 0 
using namespace std;
int n,x,y,deg[11],used[11];
vector<int> g[11];
bool dfs(int i,int dep)
{
	if (dep==4)
	{
		return 1;
	}
	used[i]=1;
	for (int j=0;j<g[i].size();j++)
	{
		if (!used[g[i][j]] && dfs(g[i][j],dep+1)) return 1;
	}
	used[i]=0;
	return 0;
}
int main()
{
	n=4;
	for (int i=1;i<4;i++) 
	{
		cin>>x>>y;deg[x]++;deg[y]++;
		g[x].push_back(y);g[y].push_back(x);  
	}
	for (int i=1;i<=4;i++)
	{
		if (deg[i]==1)
		{
			if (dfs(i,1))
			{
				printf("YES\n");
				return 0;
			}
		}
	}
	printf("NO\n");
	return Accepted;
}

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

#define FOR(i , num) for(i = 0; i < num; i++)
#define REP(i, n) for(int i = 0;i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    long long int a;
    string nb;
    int b;

    cin >> a >> nb;

    char cb[3][2];
    cb[0][0] = nb[0];
    cb[1][0] = nb[2];
    cb[2][0] = nb[3];
    cb[0][1] = '\0';
    cb[1][1] = '\0';
    cb[2][1] = '\0';

    b = atoi(cb[0]) * 100 + atoi(cb[1]) * 10 + atoi(cb[2]) ;

    long long int res = a * b;

    res = res / 100;

    cout << res << endl;

    return 0;   
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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 T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n; cin >>n;
  set<string> s;
  rep(i, n){
    string t,u; cin >>t >>u;
    if (t == "insert") s.insert(u);
    else cout <<(s.count(u) ? "yes" : "no") <<endl;
  }
}


Measured memory_bytes: 32144
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const int mod = 1000000007;

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

    int n;
    cin >> n;
    bool a[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }

    int dp[1 << n];
    fill(dp, dp + (1 << n), 0);
    dp[0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (1 << n) - 1; j++) {
            if (i != __builtin_popcount(j)) continue;

            for (int k = 0; k < n; k++) {
                if (!(j & (1 << k)) && a[i][k]) {
                    dp[j | (1 << k)] += dp[j];
                    dp[j | (1 << k)] %= mod;
                }
            }
        }
    }

    cout << dp[(1 << n) - 1] << "\n";
    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int a, b;
    cin >> a >> b;

    int s = a + b;
    if (s % 2 != 0) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << s/2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define isNum(a) (a>='0'&&a<='9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define inf 2147483647
#define N 100005
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int a[N];
int main () {
    int n, k;
    read(n);
    read(k);
    for (int i=1; i<=n; ++i) {
        read(a[i]);
    }
    sort(a+1, a+n+1);
    int ans=inf;
    for (int i=1; i<=n-k+1; ++i) {
        ans=min(ans, a[i+k-1]-a[i]);
    }
    write(ans);
    EL;
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k=0;
    char ch=getchar();
    int flag=1;
    while (!isNum(ch)) {
        if (ch=='-') {
            flag=-1;
        }
        ch=getchar();
    }
    while (isNum(ch)) {
        k=(k<<1)+(k<<3)+ch-'0';
        ch=getchar();
    }
    r_e_a_d = flag*k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e<0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e<10) {
            putchar(w_r_i_t_e+'0');
        }else {
            write(w_r_i_t_e/10);
            putchar((w_r_i_t_e%10)+'0');
        }
    }
}


Measured memory_bytes: 640
class Dice
	def initialize(labels)
		@labels = labels
		@top    = labels[0]
		@front  = labels[1]
		@right  = labels[2]
		@left   = labels[3]
		@back   = labels[4]
		@bottom = labels[5]
	end
	attr_reader :top, :front, :right, :left, :back, :bottom

	def roll(op)
		case op
		when "E"
			@t      = @top
			@top    = @left
			@left   = @bottom
			@bottom = @right
			@right  = @t
		when "W"
			@t      = @top
			@top    = @right
			@right  = @bottom
			@bottom = @left
			@left   = @t
		when "N"
			@t      = @top
			@top    = @front
			@front  = @bottom
			@bottom = @back
			@back   = @t
		when "S"
			@t      = @top
			@top    = @back
			@back   = @bottom
			@bottom = @front
			@front  = @t
		when "R" # Roll around front and back
			@f      = @front
			@front  = @left
			@left   = @back
			@back   = @right
			@right  = @f 
		end
	end

	def same?(dice2)
		if dice2.top == @top && dice2.left == @left && dice2.front == @front &&
		   dice2.right == @right && dice2.back == @back && dice2.bottom == @bottom 
		   return true
		else
		   return false
		end
	end
end

def same_rolled?(dice1, dice2)
	for i in 0..3
		i.times{dice1.roll("E")}
		for j in 0..3
			j.times{dice1.roll("N")}
			for k in 0..3
				k.times{dice1.roll("W")}
				for l in 0..3
					l.times{dice1.roll("S")}
					return true if dice1.same?(dice2)
				end
			end
		end
	end
	return false
end


labels = gets.strip.split(" ").map{|i| i.to_i}
dice1 = Dice.new(labels)
labels = gets.strip.split(" ").map{|i| i.to_i}
dice2 = Dice.new(labels)

puts (same_rolled?(dice1, dice2))? "Yes" : "No"


Measured memory_bytes: 8884
#include <bits/stdc++.h>
 
using namespace std;
 
int scanint() { 
	char c = getchar_unlocked();
	int x = 0;
	for(; (c<48)||(c>57);c = getchar_unlocked());
	for(; (c>47)&&(c<58);c = getchar_unlocked())
		x = 10 * x + c - 48;
    return x;
} 
 
int main() {

    constexpr int A_MAX = 1000000;
 
    vector<int> min_factor(A_MAX);
    // q[n] = i where n = i * p^e, p = min_factor[n], p does not divide i. + 1);
    vector<int> q(A_MAX + 1, 1);
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = scanint();
    vector<int> a(A_MAX + 1);
    for (int i = 0; i < N; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        if (a[n] > 1) {
            if (a[n] == N) {
                printf("not coprime\n");
                return 0;
            }
            is_pairwise_coprime = false;
        }
        a[min_factor[n]] += a[n];
        a[q[n]] += a[n];
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15492
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n,m) for (int i=n; i<m; i++)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

bool dfs(int i, int d, long long sum, string s, int l);

long long  ssum=0;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string  s;
    cin >> s;
    int l = s.length();

    dfs(1,0,0,s,l);
    cout<<ssum<<endl;
    return 0;
}

bool dfs(int i, int d, long long sum, string s, int l){
    if (i==l){
        sum = sum+stoll(s.substr(d,i-d));
        //cout<<sum<<endl;
        ssum += sum;
        return 0;
    }
    else{
    dfs(i+1,i,sum+stoll(s.substr(d,i-d)),s,l);
    dfs(i+1,d,sum,s,l);
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <numeric>
#include <vector>
#include <cmath>
using namespace std;


int main(){
    int n; cin >> n;
    string bruh = "No";
    while(n >=0) {
        if(n%10 == 7) {
            bruh = "Yes";
            break;
        }
        if(n/10 == 0){
            break;
        }
        n/=10;
    }

    cout << bruh << endl;



}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 99940000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
string rot(string s){
	string ret="";
	ll i;
	for(i=1;s[i];i++){
		ret+=s[i];
	}
	ret+=s[0];
	return ret;
}
ll power(ll x,ll y,ll p)
{
	ll ret=1;
	while(y>0)
	{
		if(y&1)
			ret=(ret*x)%p;
		y/=2;
		x=(x*x)%p;
	}
	return ret%p;
}
void solve(){
	ll n,i,k;
	cin>>n>>k;
	vll vec(n+1);
	sfl(i,1,n+1){
		cin>>vec[i];
	}	
	if(k>=n){
		nfl(i,n){
			cout<<n<<sp;
		}
		cout<<endl;
		return;
	}
	bool f=0,f2=0;
	while(k--){
		unordered_map<ll,ll>cor;
		sfl(i,1,n+1){
			ll lf=max(0LL,i-vec[i]);
			ll rf=min(n,i+vec[i]);
			cor[lf]+=1;
			cor[rf+1]-=1;
		}
		sfl(i,1,n+2){
			cor[i]+=cor[i-1];
		}
		ll mx=0;
		sfl(i,1,n+1){
			vec[i]=cor[i];
			if(vec[i]==n)
				mx++;
		}
		if(mx==n)
			break;
	}
	sfl(i,1,n+1){
		cout<<vec[i]<<sp;
	}
	cout<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	


Measured memory_bytes: 12940
import java.util.*;

public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
	
	while(true){
	  int a = scan.nextInt();
	  String op = scan.next();
	  int b = scan.nextInt();

	  if(op.equals("?")){
	     break;
	  }else if(op.equals("+")){
	     System.out.println(a + b);
	  }else if(op.equals("-")){
	     System.out.println(a - b);
	  }else if(op.equals("*")){
	     System.out.println(a * b);
	  }else if(op.equals( "/")){
	     System.out.println(a / b);
	  }
	}
}
}

Measured memory_bytes: 18012
N = str(input())

result = N[len(N)-1]

if result == '2' or result == '4' or result == '5' or result == '7' or result == '9':
    print('hon')
elif result == '0' or result == '1' or result == '6' or result == '8':
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
bool f(int x){
  int keta =0;
  while(x){
    keta++;
    x/=10;
  }
  return keta%2==1;
}
int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=1;i<=N;i++){
    if(f(i)){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c,sum=0;
  cin>>a>>b>>c;
  for(int i=a;i<=b;i++) if(c%i==0) sum++;
  cout<<sum<<'\n';
  return(0);
}



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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (2000006)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;


signed main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];

    int ans=0;
    for(int i=1; i<n-1; i++){
        if((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 1000000000

int main(void){

  int a,b,x;

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

  if(a<1 || a>N || b<1 || b>N){
    exit(0);
  }

  if(b>a){
    x=b;
    b=a;
    a=x;
}

    while(b>0){
      x=a%b;
      a=b;
      b=x;
	}
    printf("%d\n",a);
  
  return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int A = a + b;
  int B = a + c;
  int C = b + c;
  if(A < B && A < C){
    cout << A <<endl;
  }
  else if( B < A && B < C){
    cout << B << endl;
  }
  else {
  cout << C <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	char ma[6][6];
	rep(i, h) rep(j, w) cin >> ma[i][j];
	int ans = 0;
	rep(s, 1<<h){
		rep(t, 1<<w) {
			int cnt = 0;
			rep(i, h) rep(j, w) {
				if (s>>i & 1 && t>>j & 1 && ma[i][j] == '#') cnt++; 
			}
			if (cnt == k) ans++; 
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, ans int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := range p {
		fmt.Scan(&p[i])
	}
	for i := 1; i < n-1; i++ {
		t := []int{p[i-1], p[i], p[i+1]}
		sort.Ints(t)
		if t[1] == p[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
MJD(y,m,d){
	if(m<3){
		y--;
		m+=12;
	}
	return 1461*y/4+y/400-y/100+3059*(m-2)/100+d-678912;
}
main(){
	int y1,m1,d1,y2,m2,d2;
	for(;scanf("%d%d%d%d%d%d",&y1,&m1,&d1,&y2,&m2,&d2),y1>=0;){
		printf("%d\n",MJD(y2,m2,d2)-MJD(y1,m1,d1));
	}
	exit(0);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		
		int k = 0;
		int g = 0;
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == '0') {
				if (i % 2 == 0) {
					g++;
				} else {
					k++;
				}
			} else {
				if (i % 2 == 0) {
					k++;
				} else {
					g++;
				}
			}
		}
		
		System.out.println(Math.min(k, g));
	}
}


Measured memory_bytes: 28228
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int a,b,c,k;

void work(){
    scanf("%d%d%d%d",&a,&b,&c,&k);
    int ans=0;
    if(k<=a+b){
        ans=min(a,k);
    }
    else{
        ans=a-(k-a-b);
    }
    printf("%d\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}









Measured memory_bytes: 3828
#include<stdio.h>


int MCXI(char str[]){
  int number;
  int m=0,c=0,x=0,i=0;
  int j;
  for(j=0;str[j]!='\0';j++){
    if(str[j]=='m'){
      if(j==0)m=1;
      else m=str[j-1]-'0';
    }
    if(str[j]=='c'){
      if(j==0)c=1;
      else if(str[j-1]=='m')c=1;
      else c=str[j-1]-'0';
    }
    if(str[j]=='x'){
      if(j==0)x=1;
      else if(str[j-1]=='m'||str[j-1]=='c')x=1;
      else x=str[j-1]-'0';
    }
    if(str[j]=='i'){
      if(j==0)i=1;
      else if(str[j-1]=='m'||str[j-1]=='c'||str[j-1]=='x')i=1;
      else i=str[j-1]-'0';
    }
  }
  number=m*1000+c*100+x*10+i;
  return number;
}


int mcxi(int num){
  int m,c,x,i;
  m=num/1000;
  c=(num%1000)/100;
  x=(num%100)/10;
  i=num%10;

  if(m==1)printf("m");
  else if(m!=0)printf("%dm",m);

  if(c==1)printf("c");
  else if(c!=0)printf("%dc",c);

  if(x==1)printf("x");
  else if(x!=0)printf("%dx",x);

  if(i==1)printf("i");
  else if(i!=0)printf("%di",i);

  printf("\n");

  return 0;
}

int main(void)
{
  int n;
  int j;
 
  scanf("%d",&n);
  char str_1[n][9];
  char str_2[n][9];
  int num[n];

  for(j=0;j<n;j++){
    scanf("%s%s",str_1[j],str_2[j]);
    num[j]=MCXI(str_1[j])+MCXI(str_2[j]);
  }

  for(j=0;j<n;j++){
    mcxi(num[j]);
  }

  return 0;
}

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

using namespace std;


const long int MAX_N = 1e+18;


long int N, K, res;

long int solve()
{
    if(N <= K) return min(N, K - N);
    else{
        res = N % K;
        return min(K - res, res);
    }
}

int main()
{
    cin >> N >> K;
    
    cout << solve() << endl;


    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
num=[0]
for i in range(n-1):
    if s[i+1]=="C" and s[i]=="A":
        num.append(num[-1]+1)
    else:
        num.append(num[-1])
for i in range(q):
    l,r=map(int,input().split())
    print(num[r-1]-num[l-1])


Measured memory_bytes: 11500
#!/usr/bin/perl
#B - Ruined Square

use strict;
use warnings;

my ($ret) = 0;

# データ取得
my ($x1,$y1,$x2,$y2);
{
    my ($data) = <STDIN>;
    chomp($data);
    ($x1,$y1,$x2,$y2) = split(/ / , $data);
}

# けいさん
my ($x3) = $x2 + ($y1 - $y2);
my ($y3) = $y2 - ($x1 - $x2);
my ($x4) = $x1 + ($y1 - $y2);
my ($y4) = $y1 - ($x1 - $x2);

# 出力
print("$x3 $y3 $x4 $y4\n");

exit(0);


Measured memory_bytes: 640
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main()
{
    int heights[11] = {};
    for (int i = 0; i < 10; ++i)
        cin >> heights[i];

    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (heights[i] > heights[j]) {
                heights[10] = heights[i];
                heights[i] = heights[j];
                heights[j] = heights[10];
            }
        }
    }

    for (int i = 0; i < 3; ++i)
        cout << heights[i] << endl;
}




Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll k;
int a[2005];
int sum[2005];

int main(void){
	scanf("%d%lld",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		sum[a[i]]++;
		for(int j=0;j<i;j++){
			if(a[j]>a[i])ans++;
		}
	}
	ans*=k;
	ans%=MOD;
	for(int i=2000;i>=1;i--){
		sum[i]+=sum[i+1];
		sum[i]%=MOD;
	}
	ll su=(k*(k-1)/2LL)%MOD;
	for(int i=0;i<n;i++){
		ans+=sum[a[i]+1]*su%MOD;
		ans%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += min(abs(a[i] - k), a[i]);
  }
  cout << 2 * ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var MIN int = 0

var sc = bufio.NewScanner(os.Stdin)

type Node struct {
    key, pri    int
    left, rigth *Node
}

func next() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i

}

func nextString() string {
    sc.Scan()
    return sc.Text()

}

func rightRotate(t *Node) *Node {
    s := t.left
    t.left = s.rigth
    s.rigth = t
    return s
}

func leftRotate(t *Node) *Node {
    s := t.rigth
    t.rigth = s.left
    s.left = t
    return s
}

func insert(t *Node, key int, pri int) *Node {
    if t == nil {
        return &Node{key: key, pri: pri}
    }
    if key == t.key {
        return t
    }
    if key < t.key {

        t.left = insert(t.left, key, pri)
        if t.pri < t.left.pri {
            t = rightRotate(t)
        }
    } else {
        t.rigth = insert(t.rigth, key, pri)
        if t.pri < t.rigth.pri {
            t = leftRotate(t)
        }

    }
    return t
}

func find(t *Node, key int) bool {
    if t == nil {
        return false
    }

    if t.key == key {
        return true
    }

    if t.key > key {
        return find(t.left, key)

    } else if t.key < key {
        return find(t.rigth, key)

    }
    panic("error")
}

func erase(t *Node, key int) *Node {
    if t == nil {
        return nil
    }
    if key == t.key {
        if t.left == nil && t.rigth == nil {
            return nil

        } else if t.left == nil {
            t = leftRotate(t)
        } else if t.rigth == nil {
            t = rightRotate(t)

        } else {
            if t.left.pri > t.rigth.pri {
                t = rightRotate(t)

            } else {

                t = leftRotate(t)

            }

        }
        return erase(t, key)

    }
    if key < t.key {
        t.left = erase(t.left, key)

    } else {
        t.rigth = erase(t.rigth, key)

    }
    return t
}

func printInOrder(t *Node) {
    if t == nil {
        return
    }

    printInOrder(t.left)
    fmt.Printf(" %d", t.key)
    printInOrder(t.rigth)

}

func printPreOrder(t *Node) {
    if t == nil {
        return
    }

    fmt.Printf(" %d", t.key)
    printPreOrder(t.left)
    printPreOrder(t.rigth)

}

func main() {
    sc.Split(bufio.ScanWords)

    var head *Node

    m := next()
    for i := 0; i < m; i++ {

        switch nextString() {

        case "insert":
            k, p := next(), next()
            head = insert(head, k, p)

        case "print":
            printInOrder(head)
            fmt.Println()
            printPreOrder(head)
            fmt.Println()
        case "find":
            k := next()
            if find(head, k) {
                fmt.Println("yes")
            } else {
                fmt.Println("no")
            }
        case "delete":
            k := next()
            head = erase(head, k)

        }

    }
}


Measured memory_bytes: 12184
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
cost = 0

AB_sort = sorted(AB, key=lambda x: x[0])
#print(AB_sort)

i = 0
while M != 0:
  if AB_sort[i][1] <= M:
    cost += AB_sort[i][0] * AB_sort[i][1]
    M -= AB_sort[i][1]
  else:
    cost += AB_sort[i][0] * M
    M = 0
  i += 1

print(cost)


Measured memory_bytes: 65496