akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
{ cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int n, l;
    R n >> l;
    vs v(n);
    rep(i, n) R v[i];
    SORT(v);
    rep(j, n) cout << v[j];
}

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

int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  vector<int64_t> X(N);
  for(int64_t i=0; i<N; i++){
    cin >> X.at(i);
  }
  int64_t Ans=0;
  for(int64_t i=0; i<N-1; i++){
    if((X.at(i+1)-X.at(i))*A<B){
      Ans+=(X.at(i+1)-X.at(i))*A;
    }
    else{
      Ans+=B;
    }
  }
  cout << Ans << endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<vector<int>> v(Q,vector<int>(4));
  for(int i = 0; i < Q; i++) cin>>v[i][0]>>v[i][1]>>v[i][2]>>v[i][3];
  queue<vector<int>> q;
  for(int i = 1; i <= M; i++){
    vector<int> p = {i};
    q.push(p);
  }
  while((int)q.front().size()!=N){
    vector<int> p = q.front();
    q.pop();
    int s = *(p.end()-1);
    for(int i = s;i<=M;i++){
      vector<int> t = p;
      t.push_back(i);
      q.push(t);
    }
  }
  int ans = 0;
  while(!q.empty()){
    vector<int> A = q.front();
    q.pop();
    int cnt = 0;
    for(auto x:v){
      if(A[x[1]-1]-A[x[0]-1]==x[2]) cnt+=x[3];
    }
    chmax(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9796
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
#define N 200
int main() {
    char s[N] = "", x[N] = "", ss[N] = "";
    int flg = 0;
    char n[2][5] = { { "No" },{ "Yes" } };
    fgets(s, sizeof(s), stdin);
    fgets(x, sizeof(x), stdin);
    s[strlen(s) - 1] = '\0';
    x[strlen(x) - 1] = '\0';
    strcat(ss, s);
    strcat(s, ss);
    if (strstr(s, x) != NULL) flg = 1;
    printf("%s\n", n[flg]);
    return 0;
}
 

Measured memory_bytes: 524
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# 


S = input()
ans = 0
for i in range(len(S)//2):
    if S[i] != S[-(i+1)]:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    ll h;
    cin >> h;

    ll ret = 0;
    ll count = 1;
    while (h > 0) {
        ret += count;
        h /= 2, count *= 2;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

map< string, set<string> > memo;

set<string> foo(string t, map< string, vector<string> >& v) {
	if (memo.count(t)) return memo[t];
	set<string> res;
	for (int i = 0; i < v[t].size(); i++) {
		string s = v[t][i];
		if (v.count(s)) {
			set<string> st = foo(s, v);
			for (set<string>::iterator it = st.begin(); it != st.end(); it++)
				res.insert(*it);
		}
		else res.insert(s);
	}
	return memo[t] = res;
}

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		string t;
		map< string, vector<string> > v;
		for (int k = 0; k < n; k++) {
			string s; cin >> s;
			int i = 0;
			for (; s[i] != ':'; i++);
			string g = s.substr(0, i);
			if (k == 0) t = g;
			i++;
			for (;;) {
				int _i = i;
				for (; s[i] != ',' && s[i] != '.'; i++);
				string m = s.substr(_i, i - _i);
				v[g].push_back(m);
				if (s[i] == '.') break;
				i++;
			}
		}
		memo.clear();
		cout << foo(t, v).size() << endl;
	}
}

Measured memory_bytes: 1584
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        Css: [[i64; 3]; 3],
    }

    let a0 = 0;
    for a1 in -100..=100 {
        for a2 in -100..=100 {
            let As = vec![a0, a1, a2];
            let Bs = vec![Css[0][0] - As[0], Css[0][1] - As[0], Css[0][2] - As[0]];

            let mut is_ok = true;
            for i in 0..3 {
                for j in 0..3 {
                    if Css[i][j] != As[i] + Bs[j] {
                        is_ok = false;
                    }
                }
            }

            if is_ok {
                println!("Yes");
                return;
            }
        }
    }

    println!("No");
}


Measured memory_bytes: 2172
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,m,ans=0; cin>>n>>m;
    vector<ll> a(n,0),s(m,0);
    priority_queue<pair<ll,ll>> que;
    rep(i,n){
        cin>>a[i]; a[i]--;
    }
    rep(i,n-1){
        ll from=a[i],to=a[i+1];
        if(from>to) to+=m;
        ans+=to-from;
        if(to-from>1){
            que.push(mk(-(from+2),-1));
            que.push(mk(-(to+1),to-from-1));
        }
    }
    ll cur=0,cnt=0,idx=0,q;
    while(!(que.empty())){
        while(!(que.empty()) && que.top().first==-idx){
            tie(ignore,q)=que.top();
            que.pop();
            if(q==-1) cnt++;
            else{
                cur-=q; cnt--;
            }
        }
        cur+=cnt;
        s[(2*m-idx)%m]+=cur;
        idx++;
    }
    ll res=ans;
    rep(i,m) res=min(res,ans-s[i]);
    cout<<res<<endl;
}

Measured memory_bytes: 8924
import sys
N, Q = map(int, sys.stdin.readline().rstrip().split(" "))

S = sys.stdin.readline().rstrip()

cs = [0] * (N+1)

for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        cs[i + 1] = cs[i] + 1
    else:
        cs[i + 1] = cs[i]

for _ in range(Q):
    l, r = map(int, sys.stdin.readline().rstrip().split())
    print(cs[r] - cs[l])



Measured memory_bytes: 6356
#include <cstdio>

int n;
bool num[31];

int main(){
    for(int i = 0; i < 28; i++){
        scanf("%d", &n);
        num[n] = true;
    }
    for(int i = 1; i <= 30; i++){
        if(!num[i]) printf("%d\n", i);
    }
}

Measured memory_bytes: 1024
n,m,*a=map(int,open(0).read().split())
c,d=[0,2,5,5,4,5,6,3,7,6],[0]*n*9
for i in range(n):
 for j in a:
  if d[i]or i<1:d[i+c[j]]=max(d[i+c[j]],d[i]*10+j)
print(d[n])

Measured memory_bytes: 15348
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    vec a(N); readv(a);

    mat dp(N + 1, vec(N + 1));
    REP(i, N + 1) dp[i][N - i] = 0;

    IREP(t, N){
        if(t % 2 == 0){
            REP(i, t + 1){
                int j = t - i;
                dp[i][j] = max(a[i] + dp[i + 1][j], a[N - 1 - j] + dp[i][j + 1]);
            }
        }else{
            REP(i, t + 1){
                int j = t - i;
                dp[i][j] = min(-a[i] + dp[i + 1][j], -a[N - 1 - j] + dp[i][j + 1]);
            }
        }
    }

    cout << dp[0][0];
    
    return 0;
}

Measured memory_bytes: 72832
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k, pid, qid, ct;
	cin >> n;
	vector<int> p(n), q(n), a(n);
	for (i = 0; i < n; i++) cin >> p[i];
	for (i = 0; i < n; i++) cin >> q[i];
	for (i = 0; i < n; i++) a[i] = i + 1;
	ct = 1;
	do {
		if (a == p) pid = ct;
		if (a == q) qid = ct;
		ct++;
	} while (next_permutation(a.begin(), a.end()));

	cout << abs(pid - qid) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
	    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n;
    cin>>n;
    ll a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    ll dp[n][3],x;
    for(int i=0;i<3;i++)
    {
        dp[0][i]=a[0][i];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {   
            x=-1;
            for(int k=0;k<3;k++)
            {
                if(j!=k)
                {
                    x=max(x,dp[i-1][k]);   
                }
            }
            dp[i][j]=x+a[i][j];
        }
    }
    ll ans=max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    cout<<ans<<endl;
}

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

const int N = 1e5 + 8;
int op[N];
int a[4];
int main()
{
	cin.sync_with_stdio(0);
	int x; cin >> x;
	int tot = 0;
	while (x)
	{
		a[3 - tot] = x % 10;
		x /= 10;
		tot++;
	}
	for (int i = 0; i < 8; ++i)
	{
		int tmp = a[0];
		for (int j = 1; j <= 3; ++j)
			if (i & (1 << j - 1))
			{
				tmp += a[j];
			}
			else tmp -= a[j];
		if (tmp == 7)
		{
			cout << a[0];
			for (int j = 1; j <= 3; ++j)
				if (i & (1 << j - 1))
				{
					cout << "+" << a[j];
				}
				else cout << "-" << a[j];
			cout << "=7" << endl;
			break;
		}
	}
}


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

int main(){
    int n;
    int i;
    int card[4][13]={{}};
    cin >> n;
    char a;
    int b;
    for(i = 0; i < n; i++) {
        cin >> a >> b;
        switch(a){
            case 'S':
                card[0][b - 1] = 1;
                break;
            case 'H':
                card[1][b - 1] = 1;
                break;
            case 'C':
                card[2][b - 1] = 1;
                break;
            case 'D':
                card[3][b - 1] = 1;
                break;
        }
    }
    for(i = 0; i < 52; i++) {
        switch(i / 13){
            case 0:
                if(card[0][i % 13] == 0) cout << "S " << i + 1 << endl;
                break;
            case 1:
                if(card[1][i%13] == 0) cout << "H " << i % 13 + 1 << endl;
                break;
            case 2:
                if(card[2][i % 13] == 0) cout << "C " << i % 13 + 1 << endl;
                break;
            case 3:
                if(card[3][i%13] == 0) cout << "D " << i % 13 + 1 << endl;
                break;
        }
    }
}



Measured memory_bytes: 3116
use std::io;
use std::io::Read;

fn main() {
    let mut stdin = io::stdin();
    let mut lines = String::new();
    let _ = stdin.read_to_string(&mut lines);
    let vec = lines.lines().collect::<Vec<&str>>();
    let vec2 = vec[0].split(' ').collect::<Vec<&str>>();
    let n :u32 = vec2[0].trim().parse().unwrap();
    let k :u32 = vec2[1].trim().parse().unwrap();
    let vec3 = vec[1].split(' ').collect::<Vec<&str>>();
    let d :Vec<u32> = vec3.iter().map(|x| x.trim().parse().unwrap()).collect();

    let mut t :u32 = n;
    'outer:loop {
        let v = expand_to_decimal(t);
        for i in &d {
            if v.contains(i) {
                t = t + 1;
                continue 'outer;
            }
        }
        println!("{}",t);
        break;
    }

}

fn expand_to_decimal(x:u32)->Vec<u32>{
    if x==0 {
        vec![0]
    } else {
        if 1<=x && x<=9 {
            let mut v :Vec<u32> = Vec::new();
            v.push(x);
            v
        } else {
            let mut v = expand_to_decimal(x/10);
            v.push(x%10);
            v
        }
    }   
}


Measured memory_bytes: 380
#include <stdio.h> 

int main(void)
{
	int a, b, c, d, e, f;
	int x;

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

	b=b*5;
	c=c*10;
	d=d*50;
	e=e*100;
	f=f*500;

	x=a+b+c+d+e+f;

	

	if (x>=1000)
	{
		printf("1\n");
	}
	else
		printf("0\n");


	return 0;


}

Measured memory_bytes: 584
n = int(input())
hs = list(map(int, input().split()))

dp = [float("inf")]*n
dp[0] = 0
for i in range(n):
    if i + 1 < n:
        dp[i+1] = min(dp[i+1], dp[i] + abs(hs[i]-hs[i+1]))
    if i + 2 < n:
        dp[i+2] = min(dp[i+2], dp[i] + abs(hs[i] - hs[i+2]))
print(dp[-1])

Measured memory_bytes: 13980
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var H1 = one[0];
	var M1 = one[1];
	var maeTime = H1 * 60 + M1;
	var H2 = one[2];
	var M2 = one[3];
	var atoTime = H2 * 60 + M2;
	var K = one[4];
	var diff = atoTime - maeTime - K;
	myout(diff);
}


Measured memory_bytes: 30116
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def ume(x):
    x = str(x)
    if len(x) < 6:
        return '0'*(6-len(x)) + x
    return x

def main():
    N, M = mi()
    '''
    l = dp2(0, 3, M)
    cnt = [0]*(N+1)
    ans = dp2(0, 2, M)
    for i in range(M):
        p, y = mi()
        l[i][0], l[i][1], l[i][2] = p-1, y, i
        cnt[p] += 1
    for i in range(N):
        cnt[i+1] += cnt[i]

    l.sort(key=lambda x: x[0])
    for i in range(N):
        ichibu = l[cnt[i]:cnt[i+1]]
        ichibu.sort(key=lambda x: x[1])
        for j in range(cnt[i+1]-cnt[i]):
            ans[ichibu[j][2]][0] = ichibu[j][0]+1
            ans[ichibu[j][2]][1] = j+1
    
    for x, y in ans:
        print(ume(x)+ume(y))
    '''

    l = li2(M)
    pos = [[] for _ in range(N+1)]
    ans = dp2(0, 2, M)

    for a, b in l:
        pos[a].append(b)
    for a in pos:
        a.sort()
    for i, a in enumerate(l):
        ind = bisect.bisect_left(pos[a[0]], a[1])
        l[i][1] = ind+1
        print(ume(l[i][0])+ume(l[i][1]))





if __name__ == "__main__":
    main()

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


int main(){
int n,k;
cin>>n>>k;

vector<int>l(n);
for(int i = 0;i < n;i++){
  cin >> l[i];
}

sort(l.begin(),l.end());
reverse(l.begin(),l.end());

int ans = 0;
for(int i = 0;i < k;i++){
  ans += l[i];
}



cout << ans <<endl;
}


Measured memory_bytes: 256
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import Data.List (group)

main :: IO ()
main = do
  let
    f :: Int -> Int -> Int
    f k m = (2 * k) `min` (m - 1)
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ds <- map ('R' ==) . T.unpack . head . T.words <$> T.getContents :: IO [Bool]
  let
    (m, s) = ((,) <$> length <*> sum . map (pred . length)) . group $ ds :: (Int, Int)
  print $ s + f k m

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 10860
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int n,m,i,j,k,a,b,c,cc[500000];
char s[300000];
queue<char>q;
int main(){
	scanf("%s",s);
	for (int i=0;i<strlen(s);i++){
		cc[++k]=s[i]-'0';
		while (k>=2 &&((cc[k]==0 && cc[k-1]==1)||(cc[k]==1 && cc[k-1]==0))) k-=2;
	}
	printf("%d\n",strlen(s)-k);
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		




int main() {
	
	int n;
	cin >> n;
	VI a(n);
	REP(i, n)cin >> a[i];

	sort(ALL(a));
	reverse(ALL(a));

	if (n % 2 == 0) {
		ll ans = 0;
		REP(i, n / 2 - 1)ans += a[i] * 2;
		FOR(i, n / 2 + 1, n)ans -= a[i] * 2;
		ans += a[n / 2 - 1] - a[n / 2];
		cout << ans << endl;
		return 0;
	}

	ll ans1 = 0;
	REP(i, n / 2 - 1)ans1 += a[i] * 2;
	FOR(i, n / 2 + 1, n)ans1 -= a[i] * 2;
	ans1 += a[n / 2 - 1] + a[n / 2];

	ll ans2 = 0;
	REP(i, n / 2)ans2 += a[i] * 2;
	FOR(i, n / 2 + 2, n)ans2 -= a[i] * 2;
	ans2 -= a[n / 2 + 1] + a[n / 2];

	cout << max(ans1, ans2) << endl;

	return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1<<21)

int A[N][N], n;

void dijkstra();

int main(){
  int i,j,s;
  int u,v,c,k;
  scanf("%d", &n);
  for(i=0;i<n;i++){
     for(j = 0;j<n ;j++){
	A[i][j] = INFTY;
      }
    }
    for(i=0;i<n;i++){
      scanf("%d%d", &u, &k);
      for(j = 0 ;j<k;j++){
	scanf("%d%d", &v,&c);
	A[u][v] = c;
      }
    }
    dijkstra();
    return 0;
  }

void dijkstra(){
  int i,u,v, minv;
  int sum=0;
  int d[N],flg[N];

  for(i= 0;i<n;i++){
    d[i] = INFTY;
    flg[i] = 0;
  }
  d[0]  = 0;
  flg[0] = 1;
  while(1){
    minv= INFTY;
    u = -1;
    for(i = 0;i<n; i++){
      if(minv >d[i] && flg[i] != 2){
	u = i;
	minv = d[i];
      }
    }
    if (u == -1) break;
    flg[u] = 2;
    for(v=0; v<n;v++){
      if(flg[v] != 2 && A[u][v] != INFTY ){
	if(d[v] > d[u] + A[u][v] ){
	  d[v] = d[u] +A[u][v];
	  flg[v] = 1;
	}
      }
    }
  }
  for(i = 0 ;i<n; i++ ){
    d[i] == INFTY ? -1: d[i];
    printf("%d %d\n",i,d[i]);
  }
}
	



Measured memory_bytes: 2060
X, N = map(int, input().split())
P = list(map(int, input().split()))
nP = list(map(lambda x: abs(x - X), P))
nP.sort()

if N == 0:
    print(X)
elif nP[0] != 0:
    print(X)
else:
    cnt = 1
    while True:
        if nP.count(cnt) != 2:
            if not X - cnt in P:
                print(X - cnt)
            else:
                print(X + cnt)
            break
        cnt += 1


Measured memory_bytes: 9192
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int x,y;
int gao(int x,int y) {
	if (x<=y) return y-x;
	else return 2+x-y;
}
int main() {
	scanf("%d%d",&x,&y);
	printf("%d\n",min(min(gao(x,y),gao(-x,y)+1),min(gao(-x,-y)+2,gao(x,-y)+1)));
}


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

const int mn = 1e7+5;

using ll = long long;

struct X
{
    int a,b,c;
};

vector<X> ans;
set<ll> s;
ll hh;

ll work()
{
    while (s.count(hh)==1) hh++;
    return hh;
}

int main()
{
    ll n,k,i,j,kk;
    scanf("%lld%lld",&n,&k);
    if (n<k*2-1)
    {
        printf("-1\n");
        return 0;
    }
    j=1;
    s.clear();
    hh=k+2*n;
    for (i=2*n-k+2;i<=n*2;i++)
    {
        X p;
        p.a=i+(k-1);
        p.b=j+(k-1);
        p.c=p.a+p.b;
        s.insert(p.c);
        ans.push_back(p);
        j++;
    }
    for (i=j;i<=(n*2-k+1+j)/2;i++)
    {
        X p;
        p.a=i+(k-1);
        p.b=i+(n*2-k+2-j)/2+(k-1);
        p.c=work();
        hh++;
        ans.push_back(p);
    }
    for (i=0;i<ans.size();i++)
        printf("%lld %lld %lld\n",ans[i].a,ans[i].b,ans[i].c);
    return 0;
}


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

int ans[10][10];
int g[10][10];
int y,x,n,b[15],k[15],py[15],px[15];
bool flag,res;

void rec(int a){
  if(a==n){
    if(flag)res = false;
    else{
      for(int i=0;i<y;i++)
	for(int j=0;j<x;j++)ans[i][j] = g[i][j];
      flag = true;
    }
  }else{
    int ty = py[b[a]-1], tx = px[b[a]-1];
    for(int h=1;h<=k[a];h++){
      int w = k[a]/h;
      if(h*w==k[a]){
	for(int sy=0;sy<h;sy++)
	  for(int sx=0;sx<w;sx++){
	    bool f = true;
	    for(int i=0;i<h;i++)
	      for(int j=0;j<w;j++){
		if(ty-sy+i<0 || tx-sx+j<0 || y<=ty-sy+i || x<=tx-sx+j){
		  f = false;
		  break;
		}
		if(g[ty-sy+i][tx-sx+j] && g[ty-sy+i][tx-sx+j]!=b[a]){
		  f = false;
		  break;
		}
		if(!f)break;
	      }
	    if(f){
	      for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)g[ty-sy+i][tx-sx+j] = b[a];
	      rec(a+1);
	      if(!res)return;
	      for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)g[ty-sy+i][tx-sx+j] = 0;
	      g[py[b[a]-1]][px[b[a]-1]] = b[a];
	    }
	  }
      }
    }
  }
}
		

int main(){
  while(cin >> x >> y >> n && (x||y||n)){
    for(int i=0;i<n;i++)cin >> b[i] >> k[i];
    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++){
	cin >> g[i][j];
	if(g[i][j]){
	  py[g[i][j]-1] = i;
	  px[g[i][j]-1] = j;
	}
      }

    flag = false;
    res = true;
    rec(0);
    if(flag && res){
      for(int i=0;i<y;i++){
	for(int j=0;j<x-1;j++)cout << ans[i][j] << " ";
	cout << ans[i][x-1] << endl;
      }
    }else cout << "NA\n";
  }
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n - 1) {
    int k;
    cin >> k;
    a[k - 1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 4052
#include<stdio.h>

int c[2];

int main()
{
    int n,x,i;
    scanf("%d", &n);
    for(i=1;i<=n;i++){
        scanf("%d", &x);
        c[x%2]++;
    }
    x=0;
    c[0]+=(c[1]/2);
    if(c[0]%2+c[1]%2==2){
        printf("NO");
    }
    else printf("YES");
    return 0;
}


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


int main() {
    string s;
    cin >> s;
    string out;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'B') { if (out.size() > 0)out.pop_back(); }
        else out.push_back(s.at(i));
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <queue>

using namespace std;

int main() {
	priority_queue<int> PQ;
	string com;
	int k;
	cin >> com;
	while (com != "end") {
		if (com == "insert") {
			cin >> k;
			PQ.push(k);
		}
		if (com == "extract") {
			cout << PQ.top() << endl;
			PQ.pop();
		}
		cin >> com;
	}
	return 0;
}

Measured memory_bytes: 6244
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int N, M, Q;
vector<int> a;
vector<int> b;
vector<int> c;
vector<int> d;

int dfs(vector<int> &A) {
  if (int(A.size()) == N) {
    int score = 0;
    for (int i = 0; i < Q; ++i) {
      if (A[b[i]] - A[a[i]] == c[i]) {
	score += d[i];
      }
    }
    return score;
  } else {
    int mx = 0;
    int i_min;
    if (int(A.size()) == 0) {
      i_min = 1;
    } else {
      i_min = A.back();
    }
    for (int i = i_min; i <= M; ++i) {
      A.push_back(i);
      mx = max(mx, dfs(A));
      A.pop_back();
    }
    return mx;
  }
}

int main() {
  cin >> N >> M >> Q;
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    --a[i];
    --b[i];
  }
  vector<int> A;
  int mx = dfs(A);
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 3172
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));
		StringBuilder sb = new StringBuilder();

		int cnt = 1;

		for(;;) {
			String num = br.readLine();
			if (num.equals("0")) {
				break;
			}
			sb.append("Case ").append(cnt++).append(": ").append(num).append("\n");
		}
		System.out.print(sb);
	}

}

Measured memory_bytes: 29672
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

ll add(ll &a, ll b){
    a += b;
    if(a >= MOD) a -= MOD;
    return 0;
}

ll dp[100005][4];

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

    dp[0][0] = 1;

    rep(i, s.size()){
        rep(j, 4){
            if(s[i] == '?') add(dp[i+1][j], 3 * dp[i][j] % MOD);
            else add(dp[i+1][j], dp[i][j]);
        }

        if(s[i] == '?' || s[i] == 'A') add(dp[i+1][1], dp[i][0]);
        if(s[i] == '?' || s[i] == 'B') add(dp[i+1][2], dp[i][1]);
        if(s[i] == '?' || s[i] == 'C') add(dp[i+1][3], dp[i][2]);
    }

    cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))


int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=n-k;
	if(k==1)ans=0;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
W, H, N = map(int, input().split())
x_min, x_max, y_min, y_max = 0, W, 0, H 
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > x_min:
        x_min = x
    elif a == 2 and x < x_max:
        x_max = x
    elif a == 3 and y > y_min:
        y_min = y
    elif a == 4 and y < y_max:
        y_max = y
if x_max > x_min and y_max > y_min:
    S = (x_max - x_min) * (y_max - y_min)
else:
    S = 0
print(S)

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

evens = v[::2]
odds = v[1::2]


def means(arr):
    d = dict()
    for e in arr:
        if d.get(e) is None:
            d[e] = 1
        else:
            d[e] += 1
    m = sorted(d.items(), key=lambda e: e[1], reverse=True)
    m1, m1_cnt = m[0]
    m2, m2_cnt = m[1] if len(m) > 1 else (None, None)
    return (m1, m1_cnt), (m2, m2_cnt)


(e_m1, e_m1_cnt), (e_m2, e_m2_cnt) = means(evens)
(o_m1, o_m1_cnt), (o_m2, o_m2_cnt) = means(odds)

if e_m1 != o_m1:
    print(n - e_m1_cnt - o_m1_cnt)
else:
    if o_m2 is None and e_m2 is None:
        print(n // 2)
    else:
        candidate1 = n - e_m1_cnt - o_m2_cnt if o_m2_cnt is not None else float('inf')
        candidate2 = n - e_m2_cnt - o_m1_cnt if e_m2_cnt is not None else float('inf')
        print(min(candidate1, candidate2))

Measured memory_bytes: 17008
f,*L=open(0).readlines()
n,m=map(int,f.split())
t=[(int(a.split()[0]),list(map(int,b.split()))) for a,b in zip(*[iter(L)]*2)]
K=[]
for a,C in t:
  r=0
  for c in C:
    r|=2**(c-1)
  K.append((a,r))
INF=float('inf')
dp=[INF]*(2**n)
dp[0]=0
for g in range(2**n):
  for a,c in K:
    if dp[g|c]>dp[g]+a:
      dp[g|c]=dp[g]+a
print(-1 if dp[-1]==INF else dp[-1])


Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int n, m;
const int maxn = 1e5 + 10;
int a[maxn], b[maxn], c[maxn], fa[maxn];
ll sumb[maxn], dp[maxn];
vector<int> ver, G[maxn], E[maxn];
bool cmp(const int & i, const int & j) { return c[i] < c[j] || (c[i] == c[j] && i < j);}
int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]);}
void dfs(int x)
{
	sumb[x] = b[x];
	for(auto v : E[x])
	{
		dfs(v);
		sumb[x] += sumb[v];
	}
	dp[x] = sumb[x] + c[x];
	for(auto v : E[x])
		dp[x] = min(dp[x], sumb[x] - sumb[v] + max((ll)c[x], dp[v]));
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d%d", &a[i], &b[i]);
		c[i] = max(a[i] - b[i], 0);
		ver.push_back(i); 
		fa[i] = i;
	}
	for(int i = 1; i <= m; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v);
		G[v].pb(u);
	}
	sort(ver.begin(), ver.end(), cmp);
	for(auto u : ver)
		for(auto v : G[u])
		{
			int fv = getfa(v);
			if(c[fv] > c[u] || (c[fv] == c[u] && fv >= u))
				continue;
			fa[fv] = u;
			E[u].push_back(fv);
		}
	int rt = ver.back();
	dfs(rt);
	printf("%lld\n", dp[rt]);
	return 0;
}
	
	 

Measured memory_bytes: 17912
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K <= A+B) {
        cout << min(A, K) << endl;
    } else {
        cout << A - (K - (A + B)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3672
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        var NH = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N  = NH[0];
        var H  = NH[1];
        
        var A = new List<long>();
        var B = new List<long>();
        for(int i = 0; i < N ;i++){
          var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          A.Add(AB[0]);
          B.Add(AB[1]);
        }
        B = B.OrderBy(a => -a).ToList();
        //攻撃回数を記録するカウンター
        var count = 0L;
      
        //通常攻撃をする刀を指定する
        var normal = A.Max();
      
        foreach(long item in B){
          //通常攻撃より強ければ投げつける
          if(item > normal){
            H -= item;
            count++;
            if(H <= 0){
              break;
            }
          }
        }
        
        if(H > 0){
         count +=  (long)Math.Ceiling((double)H/(double)normal);
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 24888
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>

int		main(void)
{
	int		x, y;

	scanf("%d",&x);
	scanf("%d",&y);
	printf("%d ",x*y);
	printf("%d\n",2*x+2*y);

	return 0;
}

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

int main() {
  int r;
  cin >> r;
  
  if(r<1200){
    cout << "ABC" << endl;
  }else if(r<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#include<stack>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    ll n; cin >> n;
    string s;
    stack<char> ans;
    char alp[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q','r','s','t','u','v','w','x','y','z'};

    ll q = n;
    ll count = 0;
    while(q>0){
        int r;
        q -=1;
        r = q%26;
        q = q/26;
        if(count==0)ans.push(alp[r]);
        else{
        ans.push(alp[r-1]);
        }
    }
    ll num = ans.size();
    rep(i, num){
        cout<<ans.top();
        ans.pop();
    }
    cout << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
//pとqの最大公約数
int gcd(int p,int q){
    if(p%q==0)
    return q;
    return gcd(q,p%q);
}
int main(){
    int k;
    string s;
    cin>>k>>s;
    int a=s.size();
    if(a<=k)
    cout<<s<<endl;
    else{
        while(a>k){
            s.pop_back();
            a=s.size();
        }
        cout<<s<<"..."<<endl;
    }
}

Measured memory_bytes: 3636
import java.util.Scanner

fun main(args: Array<String>){
  val scn = Scanner(System.`in`) //Scannerのインスタンスを作成
  
  val s: String = scn.nextLine()  //入力を行で取得
  if (s[0] == s[1] && s[1] == s[2]) println("No")
  else println("Yes")
}

Measured memory_bytes: 31272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  char a;
  cin>>a;
  if(a<=90){cout<<"A"<<endl;}
  else{cout<<"a"<<endl;}
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define MAX_V 100005

struct num{int kosu[9]; int sum;};
int dp[11234][10];
bool cmp(int a, int b, int add){
	if(dp[a][0] + 1 != dp[b][0]){
		return dp[a][0] + 1 > dp[b][0];
	}
	REPS(i,9){
		if(i == add){
			if(dp[a][i] + 1 != dp[b][i]){
				return dp[a][i] + 1 > dp[b][i];
			}
			continue;
		}
		if(dp[a][i] != dp[b][i]){
			return dp[a][i] > dp[b][i];
		}
	}
	return true;
}

int main(void){
	int hon[10] = {-999999,2,5,5,4,5,6,3,7,6};
	ll n,m;
	int a;
	vector<int> A;
	cin>>n>>m;
	rep(i,m){
		cin>>a;
		A.push_back(a);
	}
	//dp[][0] : sum
	
	rep(i,n+15){
		rep(j,10){
			dp[i][j] = -INF;
		}
	}
	rep(i,10){
		dp[0][i] = 0;
	}
	rep(i,n){
		rep(j,A.size()){
			if(cmp(i,i+hon[A[j]],A[j])){
				rep(k,10){
					if(k == 0){
						dp[i+hon[A[j]]][k] = dp[i][k] + 1;
					}else if(k == A[j]){
						dp[i+hon[A[j]]][k] = dp[i][k] + 1;
					}else{
						dp[i+hon[A[j]]][k] = dp[i][k];
					}
				}
			}
		}
	}
	REPS(i,9){
		rep(j,dp[n][i]){
			cout<<i;
		}
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int ans[n+1]={};
    int a[m*2];
    for(int i=0;i<m*2;i++){
      cin>>a[i];  
    }
    for(int i=0;i<m*2;i++){
          ans[a[i]]++;
    }
    for(int i=1;i<=n;i++){
      cout<<ans[i]<<endl;  
    }
}

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

int main() {
    int n, taropoint, hanakopoint;
    string taro, hanako;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> taro >> hanako;
        if (taro < hanako) {
            hanakopoint += 3;
        } else if (taro > hanako) {
            taropoint += 3;
        } else if (taro == hanako) {
            hanakopoint++;
            taropoint++;
        }
    }
    cout << taropoint << " " << hanakopoint << endl;
}


Measured memory_bytes: 3144
import java.util.*;
     public class Main{
     public static void main(String args[]){
                
       Scanner sc = new Scanner(System.in);
            
       int a = sc.nextInt();
       int b = sc.nextInt();
       String x = sc.nextLine();
       String c = sc.nextLine();
                
       if(b == 1){
         System.out.println(c.substring(0,1).toLowerCase() + c.substring(1));
       }else if(b < a){
         System.out.println(c.substring(0,b-1) + c.substring(b-1,b).toLowerCase() + c.substring(b));
       }else{
         System.out.println(c.substring(0,b-1) + c.substring(b-1).toLowerCase());
       }
     }
    }

Measured memory_bytes: 19796
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll H;
  cin >> H;
  int N = 0;
  ll sum = 0;
  while(H>0)
  {
    H /= 2;
    N ++;
  }
  ll ex = 1;
  rep(i,N)
  {
    if(i!=0)
    {
      ex *= 2;
    }
    sum += ex;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
    int n, m, s, g1, g2;
    while (cin >> n >> m >> s >> g1 >> g2) {
	if (n == 0) break;

	s--; g1--; g2--;

	int dist[100][100];
	rep(i, n) rep(j, n) dist[i][j] = INT_MAX;
	rep(i, n) dist[i][i] = 0;

	rep(i, m) {
	    int a, b, c;
	    cin >> a >> b >> c;
	    a--; b--;

	    dist[a][b] = c;
	}

	rep(k, n) rep(i, n) rep(j, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	int ans[100];
	rep(i, n) ans[i] = dist[i][g1] + dist[i][g2];
	rep(i, n) {
	    rep(j, n) {
		rep(k, n) {
		    ans[j] = min(ans[j], ans[k] + dist[j][k]);
		}
	    }
	}

	cout << ans[s] << endl;
    }

    return 0;
}

Measured memory_bytes: 3104