akhauriyash/Code-Regression huggingface dataset:
import copy

def main():
  H, W, K = map(int, input().split())
  C = []
  for i in range(H):
    C.append(list(input()))

  def del_row(num, m):
    res = copy.deepcopy(m)
    b = format(num, "0{}b".format(H))
    # print(b)
    for i in range(H):
      if b[H-i-1]=="1":
        res[H-i-1]=["R" for i in range(W)]
    return res

  def del_col(num, m):
    res = copy.deepcopy(m)
    b = format(num, "0{}b".format(W))
    # print(b)
    for i in range(W):
      if b[W-i-1]=="1":
        for j in range(H):
          res[j][W-i-1] = "R"
    return res

  def judge(row_bin, col_bin):
    res = del_row(row_bin, C)
    res = del_col(col_bin, res)
    c = 0
    for i in range(H):
      for j in range(W):
        if res[i][j]=="#":
          c+=1
    return c==K

  c=0
  for i in range(2**H):
    for j in range(2**W):
      if judge(i, j):
        c+=1

  print(c)

if __name__ == "__main__":
    main()

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

int main()
{
    int  n;
    cin>>n;
    string s;
    cin>>s;
    int cnt1=0,cnt2=0,cnt3=0,ans=1e7;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='W')cnt1++;
        else cnt2++;
    }
    ans=min(cnt1,cnt2);
    for(int i=0;i<cnt2;i++)
    {
        if(s[i]=='R')cnt3++;
    }
    ans=min(ans,cnt2-cnt3);
    cout<<ans<<endl;
}


Measured memory_bytes: 3724
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
import std.typecons, std.regex;

void main() {
    auto s = read.to!string;
    writeln(s[0..$-8]);
}

string read() {
    static string[] ss;
    while (!ss.length) ss = readln.chomp.split;
    auto res = ss[0];
    ss.popFront;
    return res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

int main(){
    int n;
    cin>>n;
    int ans=inf;
    vector<int> pow6;
    vector<int> pow9;
    int pos6=1;
    while(pos6<=n){
        pow6.push_back(pos6);
        pos6*=6;
    }
    int pos9=1;
    while(pos9<=n){
        pow9.push_back(pos9);
        pos9*=9;
    }
    reverse(pow6.begin(),pow6.end());
    reverse(pow9.begin(),pow9.end());
    for(int i=0;i<=n;i++){
        int pos6=i;
        int pos9=n-i;
        int pos=0;
        for(auto p:pow6){
            pos+=(pos6/p);
            pos6-=((pos6/p)*p);
        }
        for(auto p:pow9){
            pos+=(pos9/p);
            pos9-=((pos9/p)*p);
        }
        ans=min(pos,ans);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
N, M = map(int, input().split())
teiki_1 = []
teiki_N = []
for _ in range(M):
    a, b = map(int, input().split())
    if a == 1 or b == 1:
        teiki_1.append(a if a != 1 else b)
    if a == N or b == N:
        teiki_N.append(a if a != N else b)
if len(set(teiki_1) & set(teiki_N)) > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 115852
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

long long N, X[100009], Y[100009], ans;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> X[i];
	for (int i = 1; i <= N; i++) cin >> Y[i];
	for (int i = 1; i <= N; i++) ans += max(0LL, X[i] - Y[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int C(int n, int m) {
    if (n < m) return 0;
    if (m < n - m) m = n - m;
    long long ans1 = 1;
    for (int i = m + 1; i <= n; i++) {
        ans1 *= i;
    }
    long long ans2 = 1;
    for (int i = 1; i <= n - m; i++) {
        ans2 *= i;
    }
    long long ans = ans1 / ans2;
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    long long ans1 = C(N, 2);
    long long ans2 = C(M, 2);
    cout << ans1 + ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s = readln.chomp;
  auto n = s.length.to!int;

  struct T {
    int l, r;
  }

  T[] a;
  int[int] last_x;
  for (int x = 0, y = 0; x < n; x++) {
    if (s[x] == '\\') {
      last_x[y--] = x;
    } else if (s[x] == '/') {
      if ((++y) in last_x) {
        a ~= T(last_x[y], x);
      }
    }
  }
  if (a.length == 0) {
    writeln(0);
    writeln(0);
    return;
  }
  reverse(a);
  int[] ans;
  int l, r;
  foreach (i; 0 .. a.length) {
    if (i == 0) {
      l = a[i].l;
      r = a[i].r;
      ans ~= (a[i].r - a[i].l);
    } else {
      if (l <= a[i].l && a[i].r <= r) {
        ans[$ - 1] += (a[i].r - a[i].l);
      } else {
        l = a[i].l;
        r = a[i].r;
        ans ~= (a[i].r - a[i].l);
      }
    }
  }
  writeln(ans.reduce!"a+b");
  write(ans.length, " ");
  writefln("%(%s %)", ans.reverse);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}



Measured memory_bytes: 3936
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Digraph {
        final int V;
        List<List<Integer>> adj;

        public Digraph(int V) {
            this.V = V;
            adj = new ArrayList<>();
            for (int i = 0; i < V; i++) {
                adj.add(new ArrayList<>());
            }
        }

        public void addEdge(int u, int v) {
            adj.get(u).add(v);
        }

    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt(), M = in.nextInt();
            Digraph G = new Digraph(N);
            for (int i = 0; i < M; i++) {
                int u = in.nextInt(), v = in.nextInt();
                G.addEdge(u - 1, v - 1);
            }

            int res = 0;
            boolean[] marked = new boolean[N];
            int[] dp = new int[N];
            Arrays.fill(dp, -1);
            for (int i = 0; i < N; i++) {
                res = Math.max(res, dfs(G, i, marked, dp));
            }

            out.println(res);
        }

        public int dfs(Digraph G, int s, boolean[] marked, int[] dp) {
            if (dp[s] != -1)
                return dp[s];

            marked[s] = true;
            int path = 0;
            for (int v : G.adj.get(s)) {
                if(!marked[v])
                    path = Math.max(path, 1 + dfs(G, v, marked, dp));
            }
            
            marked[s] = false;
            dp[s] = path;
            return path;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}




Measured memory_bytes: 73172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		int x = n % 10;
		
		StringBuilder sb = new StringBuilder();
		if(x == 3)
			sb.append("bon\n");
		else if(x == 0 || x == 1 || x == 6 || x == 8)
			sb.append("pon\n");
		else
			sb.append("hon\n");
		
		System.out.println(sb);
		
	}

}

Measured memory_bytes: 32404
#include<stdio.h>
int main(){
  int n,m,i,j;
  int s[14]={0};
  int h[14]={0};
  int c[14]={0};
  int d[14]={0};
  char arf;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d",&arf,&m);
    if(arf=='S'){
      s[m]=1;
    }
    if(arf=='H'){
      h[m]=1;
    }
    if(arf=='C'){
      c[m]=1;
    }
    if(arf=='D'){
      d[m]=1;
    }
  }
  for(i=0;i<4;i++){
    for(j=1;j<=13;j++){
      if(i==0){
	if(s[j]==0){
	  printf("S %d\n",j);
	}
      }
      if(i==1){
	if(h[j]==0){
	  printf("H %d\n",j);
	}
      }
      if(i==2){
	if(c[j]==0){
	  printf("C %d\n",j);
	}
      }
      if(i==3){
	if(d[j]==0){
	  printf("D %d\n",j);
	}
      }
    }
  }
  return(0);
}

Measured memory_bytes: 1024
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String x = Console.ReadLine();

            String[] array  = x.Split(' ');

            int height = int.Parse(array[0]);
            int side = int.Parse(array[1]);
            int syu = height * 2 + side * 2;
            int area = height * side;
            
            //???????????¨???
            Console.WriteLine(area + " " + syu);
        }
    }
}

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

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

vector<char> S(s.size());
for (int i = 0; i < s.size(); i++) {
    S[i] = s[i];
}
sort(S.begin(), S.end());

vector<char> T(t.size());
for (int i = 0; i < t.size(); i++) {
    T[i] = t[i];
}
sort(T.begin(), T.end(), greater<char>());

if (S < T) {
    cout << "Yes" << endl;
} else {
    cout << "No" << endl;
}
}




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

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ll long long
#define fr(i,n) for(i=0;i<n;i++)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==1)
        cout<<"Borys\n";
    else
        cout<<"Alice\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
max = 0
count = 0
for i in range(N):
  if A[i] == max+1:
    max = A[i]
    count += 1

if count == 0:
  result = -1
else:
  result = N - count
print(result)

Measured memory_bytes: 26268
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int N, A, c;
  cin >> N >> A;
  
  c = N % 500;
  
  if (c > A) 
  {
    cout << "No " << endl;
  }else{
    cout << "Yes " << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> v1(N),v2(N);
  for (int i=0;i<N;i++){
    cin >> v1[i];
  }
  for (int i=0;i<N;i++){
    cin >> v2[i];
  }
  int ans=0;
  for (int i=0;i<N;i++){
    int sum=0;
    for (int j=0;j<i+1;j++){
      sum+=v1[j];
    }
    for (int k=i;k<N;k++){
      sum+=v2[k];
    }
    ans=max(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

#N = int(input())
#s = [input() for i in range(N)]
#M = int(input())
#t = [input() for i in range(M)]
# print(s)
# print(t)

h, w = map(int, input().split())
if (w == 1) or(h == 1):
    print(1)
    exit()

if h*w % 2 == 0:
    print(int((h*w)/2))
if h*w % 2 != 0:
    print(int((h*w+1)/2))


Measured memory_bytes: 3832
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
void init(int n[6]){
	int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void throwdice(char c){
	int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int main()
{
    int q;
    int n[6];
    int i,j;
    for(i=0;i<6;i++){
       	scanf("%d",&n[i]);
    }
    init(n);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        int ok = 0;
        int up, front;
        scanf("%d %d",&up,&front);
        for(j=0;j<4;j++){
            throwdice('S');
            if(dice1.d[0]==up){
                ok = 1;
                break;
            }
        }
        if(!ok){
            while(1){
                throwdice('W');
                if(dice1.d[0] == up){
                    break;
                }
            }
        }
 
        for (j=0;j<4;j++){
            throwdice('R');
            if (dice1.d[1]==front){
                break;
            }
        }
        printf("%d\n",dice1.d[2]);
    }
 
    return 0;
}




Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b, k; cin >> a >> b >> k;
    if ((b-a+1)/2 + 1 <= k) {
        rep(i, b-a+1) {
            cout << a+i << endl;
        }
    }
    else {
        rep(i, k) cout << a+i << endl;
        rep(i, k) cout << b-k+1+i << endl;
    }
}

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

using namespace std;

int N;

int main()
{
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        if(V[i]-C[i]>0)sum+=V[i]-C[i];
    }
    cout << sum << endl;
    
    

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int n,m;
    cin>>n>>m;
    int match[]={-1,2,5,5,4,5,6,3,7,6};
    vs dp(n+10,"");
    vi a(m);
    rep(i,m){
        int A;
        cin>>A;
        a[i]=A;
    }
    for(int i=n;i>0;i--){
        if(i!=n&&!dp[i].size())continue;
        rep(j,m){
            int need=match[a[j]];
            if(i-need<0)continue;
            if(dp[i].size()+1 < dp[i-need].size())continue;
            if(dp[i].size()+1 == dp[i-need].size()){
                chmax(dp[i-need], dp[i] + (char)('0'+a[j]) );
            } else{
                dp[i-need]=dp[i] + (char)('0'+a[j]);
            }
        }
    }

    fin(dp[0]);
    // cout<<"========"<<endl;
    // rep(i,n)cout<<i<<" "<<dp[i]<<endl;

}
// 5,3,7,6

Measured memory_bytes: 43648
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}


int main()
{
    weewoo;
    ll n;
    string x;
    cin >> n >> x;
    string a="ABC";
    ll ans=0;
    for(int i=0;i<=n-3;i++){
        string c = x.substr(i,3);
        if(c==a)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool f = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            f = true;
            break;
        }
    }
    if (f)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a[3];

int main(){
    for(int i = 0; i < 3; i++)  cin >> a[i];
    sort(a,a+3);
    cout << a[0]*a[1]/2 << endl;
}

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

int toInt(string s){
  int res = 0;
  for(int i=0;i<s.size();i++){
    int k = 1;
    if(isdigit(s[i]))k = s[i++] - '0';

    int b = 1;
    if(s[i] == 'm')b = 1000;
    else if(s[i] == 'c')b = 100;
    else if(s[i] == 'x')b = 10;
    res += k*b;
  }
  return res;
}

string toMCXI(int a){
  string res;
  char u[] = {'m','c','x','i'};
  int b = 1000;

  for(int i=0;i<4;i++){
    int k = a/b % 10;
    if(k>1)res += (char)('0'+k);
    if(k)res += u[i];
    b /= 10;
  }
  return res;
}

int main(){
  int n;
  string s1,s2;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s1 >> s2;
    cout << toMCXI( toInt(s1) + toInt(s2) ) << endl;
  }
}

Measured memory_bytes: 1204
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b == c || a + c == b || b + c == a)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

n = gets.chomp
a = gets.chomp.split(/ /)
b = []
a.each do |i|
  i = i.to_i
  b << i if i % 2 == 0
end
#b.sort!

j = 0
b.each do |k|
  while(k % 2 == 0) do
    j += 1
    k /= 2
  end
end

puts j


Measured memory_bytes: 2428
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split();

        int fivecnt = 0;
        int sevencnt = 0;

        for(int i = 0; i < s.Length; i++)
        {
            int x = int.Parse(s[i]);
            if (x == 5) fivecnt++;
            if (x == 7) sevencnt++;
        }
        if (fivecnt == 2 && sevencnt == 1) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}


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

int main(){
    int N;
    cin >> N;
    int C[N], D[N];
    int i;
    for(i=0; i<N; i++){
        cin >> C[i] >> D[i];
    }
    for(i=0; i<N-2; i++){
        if(C[i]==D[i]){
            if(C[i+1]==D[i+1]){
                if(C[i+2]==D[i+2]){
                    break;
                }
            }
        }
    }
    if(i<N-2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    system("pause");
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    
    long n = s.size();
    
    for(long i = n - 2; i > 0; i -= 2){
        string a = s.substr(0,i/2);
        string b = s.substr(i/2,i/2);
        
        if(a==b){
            cout << i;
            break;
        }
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA = sum(A)
a = A[:]
for i, b in enumerate(B):
    if a[i] < b:
        b -= a[i]
        a[i] = 0
        a[i+1] = max(0, a[i+1] - b)
    else:
        a[i] -= b
ans = sumA - sum(a)
a = A[:]
for i in range(N - 1, -1, -1):
    b = B[i]
    if a[i+1] < b:
        b -= a[i+1]
        a[i+1] = 0
        a[i] = max(0, a[i] - b)
    else:
        a[i+1] -= b
ans = max(ans, sumA - sum(a))
print(ans)

Measured memory_bytes: 24008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  string S;
  ll half, max, cnt = 0;
  cin >> S;
  max = S.size();
  half = max / 2;
  
  for (int i = 0; i < half; i++) {
    if (S.at(i) != S.at(max - 1 - i)) cnt++;
  }
  
  cout << cnt << endl;
  
}

Measured memory_bytes: 256
n = int(input())

red = []
for i in range(n):
    red.append([int(j) for j in input().split()])
red.sort(key=lambda x : x[1], reverse=True)

blue = []
for i in range(n):
    blue.append([int(j) for j in input().split()])
blue.sort()

count = 0
for b in blue:
    for r in red:
        if r[0] < b[0] and r[1] < b[1]:
            count += 1
            red.remove(r)
            break
print(count)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int n; cin >> n;
  vector<pair<ll,ll>> xy(n);
  rep(i,n) cin >> xy[i].first >> xy[i].second;

  vector<ll> S(n);
  rep(i,n) S[i] = xy[i].first + xy[i].second;

  vector<ll> D(n);
  rep(i,n) D[i] = xy[i].first - xy[i].second;

  sort(ALL(S));
  sort(ALL(D));

  ll ans = max(S[n-1] - S[0], D[n-1] - D[0]);
  cout << ans << endl;
}


Measured memory_bytes: 9592
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,sum[200005],ans;
void merge_sort(long long l,long long r)
{
	if (l>=r) return;
	long long mid=(l+r)/2,i,j;
	merge_sort(l,mid);
	merge_sort(mid+1,r);
	i=l;
	j=mid+1;
	vector<long long> v;
	while (i<=mid&&j<=r)
	{
		if (sum[i]<=sum[j])
		{
			ans+=(r-j+1);
			v.push_back(sum[i]);
			i++;
		}
		else
		{
			v.push_back(sum[j]);
			j++;
		}
	}
	while (i<=mid)
	{
		v.push_back(sum[i]);
		i++;
	}
	while (j<=r)
	{
		v.push_back(sum[j]);
		j++;
	}
	for (i=0;i<v.size();i++) sum[l+i]=v[i];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		cin>>sum[i];
		sum[i]-=m;
		sum[i]+=sum[i-1];
	}
	merge_sort(0,n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 h,w, a,b;

int main(){
	cin >> h >> w >> a >> b;
	
	printf("%.10f ", (double)h*w / 2.0);
	
	if(h == a*2 && w == b*2){
		cout << 1 << endl;
	}
	else{
		cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
priority_queue<lint> q;
int main()
{
	int n,m,a;cin>>n>>m;
	rep(i,n){
		cin>>a;q.push(a);
	}
	rep(i,m){
		lint t=q.top();q.pop();q.push(t/2);
	}
	lint out=0;
	while(!q.empty()){
		lint t=q.top();q.pop();out+=t;
	}
	cout<<out<<endl;
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

typedef vector<int> VI;

const int N = 2010;

int n;
int A[N];
vector<int> G[N];

int gcd(int a, int b){
	return !b ? a : gcd(b, a % b);
}

bool vis[N], used[N];

void DFS_init(int o){
	vis[o] = true;
	For(i, 0, n) if(!vis[i] && ((!o && A[i] == 1) || gcd(A[i], A[o]) != 1))
		G[o].pb(i), DFS_init(i);
}

VI work(int o){
	VI ans;
	for(int v : G[o]){
		VI S = work(v), tmp;
		auto p = ans.begin(), q = S.begin();

		while(p != ans.end() && q != S.end()){
			if(*p > *q) tmp.pb(*p), ++p;
			else tmp.pb(*q), ++q;
		}

		while(p != ans.end()) tmp.pb(*p), ++p;
		while(q != S.end()) tmp.pb(*q), ++q;

		ans = tmp;
	}
	ans.insert(ans.begin(), A[o]);
	return ans;
}

int main(){
	scanf("%d", &n);

	For(i, 1, n) scanf("%d", &A[i]);
	sort(A + 1, A + n + 1);
	
	DFS_init(0);
	VI ans = work(0);

	For(i, 1, n) printf("%d%c", ans[i], i == n ? '\n' : ' ');
	return 0;
}

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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int a; cin >> a;
        string s; cin >> s;
        if (a >= 3200) cout << s;
        else cout << "red";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

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

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for (auto& l : a) {
        cin >> l;
    }
    for (auto& l : b) {
        cin >> l;
    }
    for (int row = 0; row < n; ++row) {
        for (int col = 0; col < n; ++col) {
            bool contain = true;
            for (int r = 0; r < m; ++r) {
                if (row + r >= n) {
                    contain = false;
                    break;
                }
                for (int c = 0; c < m; ++c) {
                    if (col + c >= n) {
                        contain = false;
                        break;
                    }
                    if (a[row + r][col + c] != b[r][c]) {
                        contain = false;
                        break;
                    }
                }
                if (!contain) {
                    break;
                }

            }
            if (contain) {
                cout << "Yes" << "\n";
                return;
            }
        }
    }
    cout << "No" << "\n";


}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
<?php

$sum = 0;
$N = 0;
$i = 0;
while (true) {
    fscanf(STDIN, '%d,%d', $v, $n);
    if (feof(STDIN)) {
        break;
    }
    $i++;
    $sum += $v * $n;
    $N += $n;
}

echo $sum . PHP_EOL;
echo round($N / $i) . PHP_EOL;

Measured memory_bytes: 6596
#include<bits/stdc++.h>
using namespace std;
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int k;  cin>>k;
string s;   cin>>s;
if (s.size()<=k)
{
    cout<<s<<endl;
    return 0;
}
else {
    for(int i=0;i<k;i++)
    {
      cout<<s[i];
    }

   cout<<"..."<<endl;
}

return 0;}


Measured memory_bytes: 3616
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 40010
ll n, a, b, c;

ll inv[N], fact[N], ifact[N], be[N];
 
ll comb(ll a, ll b){
	return fact[a+b]*ifact[a]%mod*ifact[b]%mod;
}
 
ll comb_nk(ll n, ll k){
	if(n<0) return 1;
	return comb(n-k, k);
}
 
ll pow_mod(ll a, ll r, ll m){
	ll x = 1;
	while(r){
		if(r&1) (x*=a)%=m;
		(a*=a)%=m;
		r>>=1;
	}
	return x;
}
 
void init_fact(ll n = N){
    inv[1] = 1;
    for(int i = 2; i < n; i++) inv[i] = inv[mod%i] * (mod - mod/i) % mod;
	fact[0] = ifact[0] = 1;
	for(int i = 1; i < n; i++){
		fact[i] = (fact[i-1]*i)%mod;
		ifact[i]=(ifact[i-1]*inv[i])%mod;
	}
}

int main(){
	init_fact();
	cin>>n>>a>>b>>c;
	if(b%2){
		cout<<0<<endl;
		return 0;
	}
	b /= 2;
	ll res = 0;
	rep(y, a+1){
		ll z = a-y;
		for(ll x = 0; x <= (c-y)/3; x++){
			ll w = c-y-3*x;
			if(w<0) continue;
			if(b==0 && w>0) continue;
			(res+=fact[x+y+z+b]*ifact[x]%mod*ifact[y]%mod*ifact[z]%mod*ifact[b]%mod*comb_nk(w+b-1, w))%=mod;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    int min_a = 10000000;
    int min_b = 10000000;
    for (int i = 0; i < A; i++) {
        cin >> a[i];
        min_a = min(a[i], min_a);
    }
    for (int i = 0; i < B; i++) {
        cin >> b[i];
        min_b = min(b[i], min_b);
    }
    int ans = 10000000;
    for (int i = 0; i < M; i++) {
        int x, y; cin >> x >> y;
        x--, y--;
        int c; cin >> c;
        ans = min(ans, a[x] + b[y] - c);
    }
    ans = min(ans, min_a + min_b);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 100000000000000

int main (){
    int n ;
    cin >> n ;
    ll k ;
    cin >> k ;
    vector<ll> a (n) ;
    rep(i, n){
        cin >> a[i] ;
    }
    ll lb = 0, ub = INF ;
    while(ub - lb > 1){
        ll mid = (ub + lb) /2 ;
        ll num = 0 ;
        rep(i, n){
            num += (a[i] - 1) / mid ;
        }
        if(num <= k){
            ub = mid ;
        }
        else{
            lb = mid ;
        }
    }
    cout << ub << endl;
}

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

def x_spot(idx):
    if idx == -1 or idx == N:
        return 0
    else:
        return A[idx]
    
dist_of_all = sum([abs(x_spot(i) - x_spot(i-1)) for i in range(N+1)])

for i in range(N):
    dist = dist_of_all - abs(x_spot(i) - x_spot(i-1)) - abs(x_spot(i) - x_spot(i+1)) + abs(x_spot(i+1) - x_spot(i-1))
    print(dist)

Measured memory_bytes: 14048
#include<stdio.h>
const int MAX_V=1000000;
int main() {
	int i,k,n,mini=0,big=0,prime[MAX_V+1];
	for(i=2;i<=MAX_V;i++) {
		prime[i]=1;
	}
	for(i = 2; i*i <= MAX_V; i++) { 
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	while(1) {
		scanf("%d", &n);
		if(n==0) break;
		for(i=3;i<=n-2;i+=2) {
			if(prime[i]==1 && prime[i+2]==1) {
				if(i+2>big) {
					mini=i; big=i+2;
				}
			}
		}
		printf("%d %d\n",mini,big);
	}
	return 0; 
}

Measured memory_bytes: 5624
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
  int N;
  cin >> N;
  double p[3010];
  for(int i=1; i<=N; i++) cin >> p[i];
  double dp[3010][3010];
  for(int i=0; i<=N; i++){
    for(int j=0; j<=N; j++){
      dp[i][j]=0;
    }
  }
  dp[0][0]=1;
  for(int i=1; i<=N; i++){
    dp[i][0]=dp[i-1][0]*(1-p[i]);
  }
  for(int i=0; i<N; i++){
    for(int j=1; j<=i+1; j++){
      dp[i+1][j]=dp[i][j-1]*p[i+1]+dp[i][j]*(1-p[i+1]);
    }
  }
  double ans=0;
  for(int i=N; i>N/2; i--) ans+=dp[N][i];
  cout << setprecision(12) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 71040
a=[0]*5
x,y=map(int,input().split())
a[x]+=1
a[y]+=1
x1,y1=map(int,input().split())
a[x1]+=1
a[y1]+=1
x2,y2=map(int,input().split())
a[x2]+=1
a[y2]+=1
b=[]
for i in range(1,5):
  b.append(a[i])
b.sort()
if(b[0]==1 and b[1]==1 and b[2]==2 and b[3]==2):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define REPP(i,a,b) for(int i=(a), b##_len=(b); i<b##_len; ++i)
#define REPM(i,a,b) for(int i=(a), b##_len=(b); i>b##_len; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define unordered_map UMAP
typedef long long ll;
typedef long double ld;
ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}
bool isPrime(int n){if(n<2){return false;}for(int i=2;i<sqrt(n)+1;i++){if(n%i==0) return false;}return true;}

int main(){
  string s,t; cin >> s>> t;
  int s_size = s.size();
  int t_size = t.size();
  int idx=-1;
  REPR(i,s_size-t_size){
    string temp = s.substr(i,t_size);
    bool restorable = true;
    REP(j,t_size){
      char c = temp[j];
      if(c==t[j] || c=='?'){continue;}
      else{restorable =false; break;}
    }
    if(restorable){
      idx = i;
      break;
    }
  }
  if(idx>=0){
    REP(i,t_size){
        s[idx+i] = t[i];
    }
    REP(i,s_size){
      char c = s[i];
      if(c=='?'){s[i]='a';}
    }
  }else{
    s = "UNRESTORABLE";
  }
  cout << s << "\n";
}

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

int main() {
  int x, kyu;
  cin >> x;
  x /= 100;
  if(x < 6) kyu = 8;
  else if(x < 8) kyu = 7;
  else if(x < 10) kyu = 6;
  else if(x < 12) kyu = 5;
  else if(x < 14) kyu = 4;
  else if(x < 16) kyu = 3;
  else if(x < 18) kyu = 2;
  else kyu = 1;
  cout << kyu;
}

Measured memory_bytes: 3592
package main

import "fmt"

func main() {
	var H, N int
	fmt.Scan(&H, &N)
	A := make([]int, N)
	for i := range A {
		fmt.Scan(&A[i])
	}
	sum := 0
	for i := range A {
		sum += A[i]
	}
	if H <= sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n,m;
	cin>>n>>m;
	vi a(n);
	cin>>a;
	sort(all(a));
	ll l=1,r=1e12;
	ll ans=0;
	while(l<=r){
		ll mid=(l+r)/2;
		ll tot=0;
		for(int i=n-1;i>=0;i--){
			int z=lower_bound(all(a),mid-a[i])-a.begin();
			tot+=n-z;
		}
		if(tot>=m){
			l=mid+1;
			ans=max(ans,mid);
		}
		else{
			r=mid-1;
		}
	}
	vector<ll>pref(n);
	pref[0]=a[0];
	for(int i=1;i<n;i++){
		pref[i]=pref[i-1]+a[i];
	}
	ll totsum=pref[n-1];
	ll ansall=0,tot=0;
	for(int i=0;i<n;i++){
		int z=lower_bound(all(a),ans-a[i])-a.begin();
		ansall+=(n-z)*a[i];
		ansall+=totsum;
		if(z>0){
			ansall-=pref[z-1];
		}
		tot+=n-z;
	}
	if(tot>m){
		ansall-=(tot-m)*ans;
	}
	cout<<ansall;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

long long N;

long long lr(long long x, long long y, long long xx, long long yy){
    return x*yy-y*xx;
}

struct data{
    long long x, y;
}arr[20000004];
struct dat{
    long long x, y, num;

    bool operator<(const dat&r)const{
        return lr(x, y, r.x, r.y)>0 || (lr(x, y, r.x, r.y) == 0 && x*x+y*y<r.x*r.x+r.y+r.y);
    }
}startFar[20000004];
long long stk[20000004];
long long top;

int main(){
    long long M; scanf("%lld", &M);
    N = 1; arr[1].x = 0, arr[1].y = 0;
    while(M--){
        long long a, b; scanf("%lld %lld", &a, &b);
        if(!a && !b) continue;
        for(long long i=0;i<N;i++) arr[i + N].x = arr[i].x + a, arr[i + N].y = arr[i].y + b;
        N *= 2;
        if(N > 2){
            long long minNum = 0;
            for(long long i=1;i<N;i++){
                if(arr[i].y<arr[minNum].y||(arr[i].y==arr[minNum].y&&arr[i].x<arr[minNum].x)) minNum = i;
            }
            swap(arr[minNum], arr[0]);
            for(long long i=1;i<N;i++){
                startFar[i].num = i;
                startFar[i].x = arr[i].x-arr[0].x;
                startFar[i].y = arr[i].y-arr[0].y;
            }
            sort(startFar+1, startFar+N);
            stk[0] = 0;
            top = 1;
            for(long long i=1;i<N;i++){
                if(startFar[i].x == startFar[i - 1].x && startFar[i].y == startFar[i - 1].y){
                    continue;
                }
                long long cando = 1;
                while(top > 1){
                    long long gap = lr(arr[stk[top-1]].x-arr[stk[top-2]].x, arr[stk[top-1]].y-arr[stk[top-2]].y, arr[startFar[i].num].x-arr[stk[top-2]].x, arr[startFar[i].num].y-arr[stk[top-2]].y);
                    if(gap < 0){
                                    --top;
                                   }
                    else if(gap == 0 && (arr[stk[top-1]].x-arr[stk[top-2]].x)*(arr[stk[top-1]].x-arr[stk[top-2]].x)+
                                   (arr[stk[top-1]].y-arr[stk[top-2]].y)*(arr[stk[top-1]].y-arr[stk[top-2]].y)<
                                   (arr[startFar[i].num].x-arr[stk[top-2]].x)*(arr[startFar[i].num].x-arr[stk[top-2]].x)+
                                   (arr[startFar[i].num].y-arr[stk[top-2]].y)*(arr[startFar[i].num].y-arr[stk[top-2]].y)){
                                    --top;
                                   }
                    else{
                        if(!gap) cando = 0;
                        break;
                    }
                }
                if(cando) stk[top++] = startFar[i].num;
            }
            sort(stk, stk + top);
            for(long long i=0;i<top;++i){
                arr[i] = arr[stk[i]];
            }
            N = top;
        }
    }
    double ans = 0;
    for(long long i=0;i<N;++i){
        ans = max(ans, sqrt(arr[i].x*arr[i].x+arr[i].y*arr[i].y));
    }
    printf("%.12lf", ans);
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //整数Rは前回までのレーティング,整数Gは今回到達したいレーティング
  int R,G;
  
  //R,Gを入力
  cin >> R >> G;
  
  //今回取るべきパフォーマンス
  cout << 2*G - R << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll a[N];
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll m = 1e9; ll M = -1e9;
  ll p, q;
  for (ll i = 0; i < N; i++) {
    if (m > a[i]) p = i;
    if (M < a[i]) q = i;
    m = min(a[i],m); M = max(a[i],M);
  }
  if (m >= 0) {
    cout << N-1 << endl;
    for (ll i = 0; i < N-1; i++) {
      cout << i+1 << " " << i+2 << endl;
    }
  } else if (M <= 0) {
    cout << N-1 << endl;
    for (ll i = 0; i < N-1; i++) {
      cout << N-i << " " << N-i-1 << endl;
    }
  }
  else if (abs(m) <= abs(M)) {
    cout << 2*N-1 << endl;
    for (ll i = 0; i < N; i++) {
      cout << q+1 << " " << i+1 << endl;
    }
    for (ll i = 0; i < N-1; i++) {
      cout << i+1 << " " << i+2 << endl;
    }
  } else {
    cout << 2*N-1 << endl;
    for (ll i = 0; i < N; i++) {
      cout << p+1 << " " << i+1 << endl;
    }
    for (ll i = 0; i < N-1; i++) {
      cout << N-i << " " << N-i-1 << endl;
    }
  }
}

Measured memory_bytes: 384
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,a,b; cin>>n>>a>>b;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll res=0;
    rep(i,n-1){
        if((x[i+1]-x[i])*a<b) res+=(x[i+1]-x[i])*a;
        else res+=b;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1024