akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

#define MAX_N   (100000)                  // 10^5
// #define MAX_N   (1000000000)              // 10^9
// #define MAX_N   (1000000000000000000)     // 10^18
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

ll N, K;
Pl A[MAX_N];

void solve() {
  sort(A, A + N);
//  for (int i = 1; i < N; i++) A[i] = Pl(A[i].FST, A[i].SND + A[i - 1].SND);
  for (int i = 1; i < N; i++) A[i].SND += A[i - 1].SND;

  int xl = -1, xr = N - 1;
  while (xr - xl > 1) {
    int xm = (xr + xl) / 2;
    if (K <= A[xm].SND) {
      xr = xm;
    } else {
      xl = xm;
    }
  }

  cout << A[xr].FST << endl;
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i].FST >> A[i].SND;

  solve();

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int a, b, k, c, d, i;
int main(){
	scanf("%d%d%d", &a, &b, &k);
	c = a+k-1;
	d = b-k+1;
	if(c>=d){c=b; d=b+1;}
	for(i=a; i<=c; i++){
		printf("%d\n", i);
	}
	for(i=d; i<=b; i++){
		printf("%d\n", i);
	}
}


Measured memory_bytes: 128
//無断転用の一切を禁ずるよ//////////////////////////
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
#define rt "\n"//改行を最速化するよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define please return
#define AC 0
/////////////////////////////////////////////////
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool; 
//////////////////////////////////////////////////
//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　（A＋B）÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
	int n;
	cin >> n;
	vint p(n);
	rep(i, n)cin >> p[i];
	cncn;
	asas;
	rep(i, n) {
		ans += p[i];
		if (cnt < p[i]) {
			cnt = p[i];
		}
	}
	ans -= (cnt / 2);
	cout << ans << rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

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

using namespace std;

string S;

set<string> rec(int idx, int bit) {
    if (idx == S.length()) return set<string>({""});

    char c = S[idx];
    int i = c - 'a';

    set<string> ret;
    if ((bit >> i) & 1) {
        auto res = rec(idx + 1, bit);
        for(auto s : res) {
            s.insert(s.begin(), c);
            ret.insert(s);
        }
    }

    if (!((bit >> (i + 1)) & 1)) {
        auto res = rec(idx + 1, bit + (1 << (i + 1)));
        for(auto s : res) {
            s.insert(s.begin(), c + 1);
            ret.insert(s);
        }
    }

    return ret;
}

bool solve() {
    cin >> S;
    if (S == "#") return false;

    auto ans = rec(0, (1 << 26) + 1);

    cout << ans.size() << endl;

    for(int i = 0; i < 5; ++i) {
        if (ans.empty()) break;
        cout << *(ans.begin()) << endl;
        ans.erase(ans.begin());
    }

    vector<string> st;
    for(int i = 0; i < 5; ++i) {
        if (ans.empty()) break;
        st.push_back(*(--ans.end()));
        ans.erase(--ans.end());
    }

    while (!st.empty()) {
        cout << st.back() << endl;
        st.pop_back();
    }
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}


Measured memory_bytes: 6328
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  xs <- getIntList
  print $ if any (> 9) xs then -1 else product xs


Measured memory_bytes: 3700
import java.io.*;
import java.util.*;
import java.lang.*;
import java.lang.Math;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    double[] point1=new double[2];
    double[] point2=new double[2];

    for(int i=0;i<2;i++){
      point1[i]=Double.parseDouble(scan.next());
    }
    for(int i=0;i<2;i++){
      point2[i]=Double.parseDouble(scan.next());
    }

    double distance=Math.sqrt(Math.pow(point1[0]-point2[0],2)+Math.pow(point1[1]-point2[1],2));

    System.out.printf("%f",distance);
  }
}


Measured memory_bytes: 26588
#include<bits/stdc++.h>
#define maxn 500005
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fu(i,l,r) for(int i=(l);i<=(r);i++)
#define fd(i,l,r) for(int i=(l);i>=(r);i--)
#define Set set<int>
using namespace std;
//#define int long long
#define P pair<int,int>
int n,m,a[maxn],b[maxn];

int32_t main()
{
    IOS;
    cin>>n;
    fu(i,1,n)
    {
        cin>>a[i];
    }
    fu(i,1,n)
    {
        cin>>b[i];
    }
    int ans=0;
    fu(i,1,n)
    {
        ans+=max(0,a[i]-b[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;




int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    string o,e; cin >> o >> e;
    
    string s;
    
    for (int i = 0; i < min(o.size(),e.size()); i++)  s = s + o[i] + e[i];
    
    if(o.size() > e.size()) s += o.back();
    
    
    cout << s << endl;
}



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

bool ok() {
  string s;
  cin >> s;
  string t(s);
  reverse(t.begin(), t.end());
  if (s != t) return false;
  int k = s.size() / 2;
  return s.substr(0, k) == s.substr(k + 1, k);
}

int main() {
  cout << (ok() ? "Yes" : "No") << endl;
}

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  int ans = x / 500 * 1000;
  ans += ((x - x / 500 * 500) / 5 * 5);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3644
X, Y, A, B, C = map(int, input().split())

P = [[] for _ in range(3)]

for p in map(int, input().split()):
    P[0].append((p,0))
for p in map(int, input().split()):
    P[1].append((p,1))
for p in map(int, input().split()):
    P[2].append((p,2))
P[0].sort(reverse=True)
P[1].sort(reverse=True)
P[2].sort()

P[0] = P[0][:X]
P[1] = P[1][:Y]

data = P[0] + P[1]
data.sort(reverse=True)
num = [A,B]
res = sum(map(lambda x: x[0], data))
while True:
    p, i = data.pop()
    q, _ = P[2].pop()
    if p >= q:
        break
    if num[i] - 1 >= 0:
        num[i] -= 1
        res += q - p
    if sum(num) == 0:
        break
    if len(P[2]) == 0:
        break

print(res)


Measured memory_bytes: 111608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n, a = 0, b = 0;
  int k[101];
  cin >> n;
  rep(i, 0, n) cin >> k[i];
  sort(k, k + n, greater<int>());
  rep(i, 0, n) {
    if(i % 2) b += k[i];
    else a += k[i];
  }
  cout << a - b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
	string s;
  cin >> s;
    //処理
    //出力
    cout << s[0] << s.length()-2 << s[s.length()-1] << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define ll long long
using namespace std;

ll i,j,k;
const ll MOD = 1000000000 + 7;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=0;
    ans=a*min(b-1,n)/b;
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}

int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll b_c_cnt=B/C,b_d_cnt=B/D,b_cd_cnt=B/((C*D)/gcd(C,D));
    ll b = B-b_c_cnt-b_d_cnt+b_cd_cnt;
    ll a_c_cnt=(A-1)/C,a_d_cnt=(A-1)/D,a_cd_cnt=(A-1)/((C*D)/gcd(C,D));
    ll a = (A-1)-a_c_cnt-a_d_cnt+a_cd_cnt;
    //cout << b << " " << a << endl;
    cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const ll MOD = 998244353;

// 3000 にしたらランタイムエラー
ll DP[3001][3001];

// A の部分集合 T、Tの部分集合 U で数える
int main() {
  int N, S;
  cin >> N >> S;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];

  DP[0][0] = 1;
  REP(i, N) REP(j, S + 1) {
    // Ai が T に選ばれない場合
    DP[i + 1][j] += DP[i][j];
    // Ai が T には選ばれているが U には選ばれていない場合
    DP[i + 1][j] += DP[i][j];
    DP[i + 1][j] %= MOD;
    // Ai が選ばれた場合
    if (A[i] + j <= S) {
      DP[i + 1][j + A[i]] += DP[i][j];
      DP[i + 1][j + A[i]] %= MOD;
    }
  }
  cout << DP[N][S] << endl;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  string al = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  
   for( int i = 0; i < S.size(); i++ ){
    
   	if( S.at(i) == 'A' ){
   		cout << al.at( N );
   	}
     if( S.at(i) == 'B' ){
   		cout << al.at( N+1 );
   	}
      if( S.at(i) == 'C' ){
   		cout << al.at( N+2 );
   	}
      if( S.at(i) == 'D' ){
   		cout << al.at( N+3 );
   	}
      if( S.at(i) == 'E' ){
   		cout << al.at( N+4 );
   	} if( S.at(i) == 'F' ){
   		cout << al.at( N+5 );
   	} if( S.at(i) == 'G' ){
   		cout << al.at( N+6 );
   	} if( S.at(i) == 'H' ){
   		cout << al.at( N+7 );
   	} if( S.at(i) == 'I' ){
   		cout << al.at( N+8 );
   	} if( S.at(i) == 'J' ){
   		cout << al.at( N+9 );
   	} if( S.at(i) == 'K' ){
   		cout << al.at( N+10 );
   	} if( S.at(i) == 'L' ){
   		cout << al.at( N+11 );
   	} if( S.at(i) == 'M' ){
   		cout << al.at( N+12 );
   	} if( S.at(i) == 'N' ){
   		cout << al.at( N+13);
   	} if( S.at(i) == 'O' ){
   		cout << al.at( N+14 );
   	} if( S.at(i) == 'P' ){
   		cout << al.at( N+15 );
   	} if( S.at(i) == 'Q' ){
   		cout << al.at( N+16 );
   	} if( S.at(i) == 'R' ){
   		cout << al.at( N+17 );
   	} if( S.at(i) == 'S' ){
   		cout << al.at( N+18 );
   	} if( S.at(i) == 'T' ){
   		cout << al.at( N+19 );
   	} if( S.at(i) == 'U' ){
   		cout << al.at( N+20 );
   	} if( S.at(i) == 'V' ){
   		cout << al.at( N+21 );
   	} if( S.at(i) == 'W' ){
   		cout << al.at( N+22 );
   	} if( S.at(i) == 'X' ){
   		cout << al.at( N+23 );
   	} if( S.at(i) == 'Y' ){
   		cout << al.at( N+24 );
   	} if( S.at(i) == 'Z' ){
   	    cout << al.at( N+25 );
      } 
   }
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return f*x;
}
#define MAXN 20
#define Mod int(1e9)
#define INF 0x3f3f3f3f
int main(){
	int n=read(),A=read(),B=read();
	printf("%d\n",min(n*A,B));
	return 0;
}

Measured memory_bytes: 256
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

s=str(input())

if s =="ABC":
	print("ARC")
else:
	print("ABC")
	






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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/11  Problem: ABC 089 C / Link: http://abc089.contest.atcoder.jp/tasks/abc089_c  ----- */


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

	LL N; 
	cin >> N;
	vector<string> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	string ss = "MARCH";
	map<char, int>M;
	FOR(i, 0, 5) {
		M[ss[i]] = i;
	}
	VL cnt(5);
	FOR(i, 0, N) {
		if (M.find(a[i].front()) != M.end()) {
			cnt[M[a[i].front()]]++;
		}
	}

	LL ans = 0LL;
	FOR(i, 0, 5)FOR(j, 0, i)FOR(k, 0, j) {
		ans += cnt[i] * cnt[j] * cnt[k];
	}
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>

using namespace std;
typedef pair<double,double> P;




int main(){
	int field[8][8];
	string field1[8];
	
	while(cin >> field1[0]){
		for(int i = 1;i < 8;i++){
			cin >> field1[i];
		}
		for(int i = 0;i < 8;i++){
			for(int j = 0;j < 8;j++){
				if(field1[i][j] == '1') field[i][j] = 1;
				else field[i][j] = 0;
			}
		}
		/*for(int i = 0;i < 8;i++){
			for(int j = 0;j < 8;j++){
				cout << field[i][j];
			}
			cout << endl;
		}
		cout << endl;*/
		int n,k,flag = 0;
		for(n = 0;n < 8;n++){
			for(k = 0;k < 8;k++){
				if(field[n][k] == 1){
					flag = 1;
					break;
				}
			}
			if(flag == 1) break;
		}	

		if(field[n][k] == field[n][k+1]){
			if(field[n][k+1] == field[n][k+2]) cout << "C" << endl;
			else if(field[n][k+1] == field[n+1][k+1]){
				if(field[n+1][k] == field[n+1][k+1]) cout << "A" << endl;
				else if(field[n+1][k+1] == field[n+1][k+2]) cout << "E" << endl;
			}
			else if(field[n][k+1] == field[n+1][k]) cout << "G" << endl;
		}
		else if(field[n][k] == field[n+1][k]){
			if(field[n+1][k] == field[n+2][k]) cout << "B" << endl;
			else if(field[n+1][k] == field[n+1][k-1]) cout << "D" << endl;
			else if(field[n+1][k] == field[n+1][k+1]) cout << "F" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1184
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash(){
    ll n, m, k;
    cin>>n>>m>>k;
    ll a[n], b[m];
    for(ll i = 0; i < n; i++){
        cin>>a[i];
    }
    for(ll i = 0; i < m; i++){
        cin>>b[i];
    }
    ll ssA[n + 1], ssB[m + 1];
    ssA[0] = ssB[0] = 0;
    for(ll i = 1; i <= n; i++){
        ssA[i] = ssA[i - 1] + a[i - 1];
    }
    for(ll i = 1; i <= m; i++){
        ssB[i] = ssB[i - 1] + b[i - 1];
    }
    ll ans = 0;
    ll ansA = (upper_bound(ssA, ssA + n + 1, k) - ssA - 1);
    ll ansB = (upper_bound(ssB, ssB + m + 1, k) - ssB - 1);
    ll kOriginal = k;
    ll temp;
    for(ll i = 0; i < n; i++){
        k -= a[i];
        if(k < 0){
            break;
        }
        temp = i + 1;
        temp += (upper_bound(ssB, ssB + m + 1, k) - ssB - 1);
        ansA = max(ansA, temp);
    }

    k = kOriginal;
    for(ll i = 0; i < m; i++){
        k -= b[i];
        if(k < 0){
            break;
        }
        temp = i + 1;
        temp += (upper_bound(ssA, ssA + n + 1, k) - ssA - 1);
        ansB = max(ansB, temp);
    }

    ans = max(ansA, ansB);
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 9864
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1e5+10;
int n;
pa a[N];

int main(){
	n=read();
	For(i,1,n){
		int x=read(),y=read();
		a[i]=mp(x-y,x+y);
	}
	sort(a+1,a+1+n,[](pa a,pa b){
		return a.se<b.se;
	});
	int r=a[1].se,ans=1;
	For(i,2,n) if (a[i].fi>=r) r=a[i].se,++ans;
	printf("%d\n",ans);
}

Measured memory_bytes: 4432
n=int(input())
U=[n-1-i for i in range(n)]
ind='0'+str(n)+'b'

for i in range(2**n):
    compare=[int(j) for j in format(i,ind)]
    disp=[U[j] for j in range(n) if compare[j]==1]
    disp.reverse()
    print(i,end=":")
    if len(disp)!=0:
        print(" "+' '.join(map(str,disp)),end="")
    print()



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

int main(){
  int n, next = 1,i;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  
  for(i = 0; i < n; i++){
    next = a.at(next-1);
    if(next==2)
      break;
  }
  if(next==2)
    cout << i+1 << endl;
  else 
    cout << -1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

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;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,r;
	cin>>n>>r;
	cout<<r+100*max(0,10-n)<<endl;;
}


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

int main() {
  int N, M, x, y;
  M = 0;
  x = 0;
  y = 0;
  cin >> N;
  vector<int> A(N);
  while(true){
  for( int i = 0; i < N; i++){
    cin >> A.at(i);
    if( (A.at(i) % 2) == 1){
      y++;
      break;
    }
    else{
      x++;
      A.at(i) /= 2;
    }
  }
    if( y >= 1){
    break;
    }
  }
  cout << x / N << endl;
  
}


Measured memory_bytes: 256
N,M = map(int, input().split())
C = list(map(int, input().split()))

C.sort()
dp = [[float("inf") for _ in range(N+1)] for _ in range(M+1)]
dp[0][0] = 0


#i番目までのコインを使えるときに、j円を作る場合の、コインの最小枚数を求める
for i in range(M):
    for j in range(N+1):
        # i番目を使えない場合
        if C[i] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j - C[i]] + 1)

print(dp[-1][-1])


Measured memory_bytes: 45008
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;

    ll s = 0;
    map<ll,ll> A;
    REP(i, N) {
        ll a;
        cin >> a;
        A[a]++;
        s += a;
    }
    int Q;
    cin >> Q;
    vector<pair<ll, ll> > query(Q);
    REP(i, Q) cin >> query[i].first >> query[i].second;

    REP(i, Q) {
        ll a = A[query[i].first];
        A[query[i].first] = 0;
        A[query[i].second] += a;
        s -= a * query[i].first;
        s += a * query[i].second;
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 10612
#include <iostream>
#include <string>
#include <map>
#include <utility>

using namespace std;
typedef pair<char, int> P;

string s;
map<char, int> mp;

bool ans = true;
P parseWin(int &p)
{
  if(s[p] == '['){
    p++;
    P res = parseWin(p);
    p++;
    P res2 = parseWin(p);
    p++;
    if(mp[res.first] == res.second){
      if(mp[res2.first] >= res2.second+1) {
        //cout << p << " " << res2.first << " " << res2.second+1 << endl;
        return make_pair(res2.first, res2.second+1);
      }
    }
    else if(mp[res2.first] == res2.second){
      if(mp[res.first] >= res.second+1){
        //cout << p << " " << res.first << " " << res.second+1 << endl;
        return make_pair(res.first, res.second+1);
      }
    }
    ans = false;
    return res;
  }
  else if(s[p] >= 'a' && s[p] <= 'z'){
    P res = make_pair(s[p], 0);
    p++;
    return res;
  }
  return make_pair('a', 0);
}

int main(void)
{
  cin >> s;
  //s += "#";
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] >= 'a' && s[i] <= 'z') cnt++;
  }
  char c; int x;
  for(int i = 0; i < cnt; i++){
    cin >> c >> x;
    mp[c] = x;
  }

  int p = 0;
  P res = parseWin(p);
  //cout << res.first << " " << res.second << endl;
  if(ans && mp[res.first] == res.second) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3228
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;


int main() {

    int W, a, b;
    cin >> W >> a >> b;


    if (
            ((a <= b + W) and (b + W) <= a + W)
            or ((a <= b) and (b <= a + W))) {
        cout << '0' << "\n";
    } else if ((b + W < a)) {
        cout << (a - (b + W)) << "\n";
    } else {
        cout << (b - (a + W)) << "\n";
    }

    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  string res = {};
	for (int i = 0; i < s.size(); i++){
		if(n <= 'Z' - s[i]) res += s[i] + n;
		else res += s[i] + n - 26;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
def adjust(array):
    # 調整
    re_array = []
    for arr in array:
        a = set(arr)
        if len(a) == 1 and ''.join(a) == '.':
            continue
        else:
            re_array.append(arr)
    return re_array

# 入力
H, W = map(int, input().split())
array = [list(input()) for _ in range(H)]

# 横
array = adjust(array)

# 縦
array = list(zip(*array))
array = adjust(array)

# 戻す
array = list(zip(*array))

# 出力
for arr in array:
    print(''.join(arr))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
int main()
{
    cin >> n;
    if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) cout << "hon";
    if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) cout << "pon";
    if(n % 10 == 3) cout << "bon";
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const int MAX_N = 10;

int main(void){
    int N;
    int L[MAX_N];
    int Lmax = 0;

  cin >> N;
  
    rep(i, N) {cin >> L[i]; Lmax = max(Lmax, L[i]);}
    
    int Lsum = - Lmax;

    rep(i, N) Lsum += L[i];

    if(Lsum > Lmax) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int main(){
  string s; cin >> s;
  itn n=s.size();
  itn suma=0;
  itn sumb=0;
  itn sumc=0;
  itn sumd=0;
  rep(i,n){
    if(s[i]=='A') suma++;
    if(s[i]=='B') sumb++;
    if(s[i]=='C') sumc++;
    if(s[i]=='?') sumd++;
  }
  itn a=0;
  itn b=0;
  itn c=0;
  itn d=0;
  mint ans=0;
  rep(i,n-1){
    if(s[i]=='A') a++;
    if(s[i]=='B') b++;
    if(s[i]=='C') c++;
    if(s[i]=='?') d++;
    if(i==0) continue;
    if(s[i]=='A') continue;
    if(s[i]=='C') continue;
    if(s[i]=='B') ans+=((mint)a*rui(3,d)+d*rui(3,d-1))*((mint)(sumc-c)*rui(3,sumd-d)+(sumd-d)*rui(3,sumd-d-1));
    else ans+=((mint)a*rui(3,d-1)+(d-1)*rui(3,d-1-1))*((mint)(sumc-c)*rui(3,sumd-d)+(sumd-d)*rui(3,sumd-d-1));
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
  int n,a,i,j,c;
  vector <int> v;
  
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a;
    v.push_back(a);
  }
  for(i=0;;i++){
    c=0;
    for(j=0;j<n;j++){
      if(v[j]%2==0){
        c++;
        v[j]=v[j]/2;
      }
    }
    if(c!=n)
      break;
  }
  cout<<i<<endl;
  return 0;
  
  
}

Measured memory_bytes: 256
// 2^15は余裕で間に合う 選んだやつを単調増加するが、それぞれの間に高いやつがないように味付けする
// たぶんKぴったりでいい気がする（超える必要はない）（答えるのはかかったコストなので）
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	ans := int(1e18)
	for bit := 0; bit < (1 << uint64(N)); bit++ {
		tmp := make([]bool, N)
		count := 0
		for i := 0; i < N; i++ {
			if (bit>>uint64(i))&1 == 1 {
				tmp[i] = true
				count++
			}
		}
		if count != K {
			continue
		}
		pre, cost := -1, 0
		B := append([]int{}, A...)
		for i, f := range tmp {
			if f {
				if pre >= B[i] {
					cost += pre - B[i] + 1
					B[i] += pre - B[i] + 1
				}
				pre = B[i]
			} else {
				pre = max(pre, B[i])
			}
		}
		ans = min(ans, cost)
	}
	if K == 1 {
		fmt.Println(0)
		return
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005;
int f[N][3],n;
char s[N];

inline int chk(int p,int l){
	if(l==1)return s[p]!=s[p+1];
	return s[p-1]!=s[p+1]||s[p]!=s[p+2];
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	memset(f,0xc0,sizeof f);
	f[1][1]=f[2][2]=1;
	rep(i,1,n)rep(a,1,2){
		rep(b,1,2)if(i+b<=n){
			if(a!=b||chk(i,a)){
				f[i+b][b]=max(f[i+b][b],f[i][a]+1);
			}
		}
		// printf("%d %d  %d\n",i,a,f[i][a]);
	}
	printf("%d\n",max(f[n][1],f[n][2]));	
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define int long long

using namespace std;

int n, m, arr[100000];
pair<int, int> change[100000];

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

    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    for (int i = 0; i < m; i++)
        cin >> change[i].second >> change[i].first;
    sort(change, change + m, greater<pair<int, int>>());

    int i = 0;
    for (int j = 0; j < m && i < n; j++)
        while (change[j].second-- && i < n && arr[i] < change[j].first)
            arr[i++] = change[j].first;

    int ans = 0;
    for (int i = 0; i < n; i++)
        ans += arr[i];
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
int n;
int main(void){
    int n;
    string s;cin>>n>>s;
    int dp[n+1][n+1];//sの
    rep(i,n+1){
        rep(j,n+1){
            dp[i][j]=0;
        }
    }
    rep(i,n){
        rep(j,n){
            int ni=i+1,nj=j+1;
            if(s[i]==s[j]){
                dp[ni][nj]=dp[i][j]+1;
            }else{
                dp[ni][nj]=0;
            }
        }
    }
    int res=0;
    rep(i,n+1){
        rep(j,n+1){
            if(i==j)continue;
            if(i-dp[i][j]<j)continue;
            res=max(res,dp[i][j]);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 98048
// Aizu Vol-10 1074: Popularity Estimation
// 2017.8.18 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { char n[12]; int p, m, d[32]; } T;
T tbl[22];
int f[33];

int cmp(T *a, T *b)
{
	int d;
	if ((d = a->p - b->p) != 0) return d;
	return strcmp(a->n, b->n);
}

int main()
{
	int n;
	int i, j;

	while (scanf("%d", &n) && n) {
		memset(f, 0, sizeof(f));
		for (i = 0; i < n; i++) {
			scanf("%s%d", tbl[i].n, &(tbl[i].m)), tbl[i].p = 0;
			for (j = 0; j < tbl[i].m; j++)
				scanf("%d", &(tbl[i].d[j])), f[tbl[i].d[j]]++;
		}
		for (i = 0; i < n; i++)
			for (j = 0; j < tbl[i].m; j++) tbl[i].p += n - f[tbl[i].d[j]] + 1;
		qsort(tbl, n, sizeof(T), cmp);
		printf("%d %s\n", tbl[0].p, tbl[0].n);
	}
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, K = 0;
int a[100010], b[100010];
vector<int> adj[100010];
map<pint, int> color;
bool visited[100010];

void dfs(int index, int c){
    if(visited[index]){
        return;
    }
    visited[index] = true;
    int d = 1;
    for(int next : adj[index]){
        if(visited[next]) continue;
        if(d == c) d++;
        color[pint(index, next)] = color[pint(next, index)] = d;
        dfs(next, d);
        d++;
    }
}

signed main(){
    cin >> N;
    REP(i, N - 1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }
    dfs(0, 0);
    for(auto p : color) K = max(K, p.second);
    PRINT(K);
    REP(i, N - 1) PRINT(color[pint(a[i], b[i])]);
    return 0;
}

Measured memory_bytes: 24508
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


LLI f(string t, int R, int S, int P){
  int n = t.size();
  vector<vector<int>> dp(n+1, vector<int>(3));

  REP(i,n){
    REP(j,3){
      REP(k,3){
        if(j == k) continue;

        if((t[i] == 'r' and k == 1)) chmax(dp[i+1][k], dp[i][j] + P);
        else if((t[i] == 's' and k == 2)) chmax(dp[i+1][k], dp[i][j] + R);
        else if((t[i] == 'p' and k == 0)) chmax(dp[i+1][k], dp[i][j] + S);
        else chmax(dp[i+1][k], dp[i][j]);
      }
    }
  }
  
  return max({dp[n][0], dp[n][1], dp[n][2]});
}


int main(){
  int n,k,R,S,P;
  string t;
  while(cin >> n >> k >> R >> S >> P >> t){


    vector<string> a(k);
    REP(i,n){
      a[i%k] += t[i];
    }

    dump(a);

    LLI ans = 0;

    for(auto &v : a){
      auto s = f(v, R, S, P);
      dump(s);
      ans += s;
    }


    cout << ans << endl;
  }

  return 0;
}


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int k = Integer.parseInt(strArr[0]);
		int x = Integer.parseInt(strArr[1]);
		String sep = "";
		for (int i = (x - (k - 1)); i <= (x + (k - 1)); i++) {
			System.out.print(sep + i);
			if ("".equals(sep))
				sep = " ";
		}
		System.out.println();
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 079_abc_d / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL H,W;

LL ans = 0LL;

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

	cin >> H>>W;
	VVI c(10, VI(10, 0));
	FOR(i, 0, 10)FOR(j, 0, 10) {
		cin >> c[i][j];
	}
	int N = 10;
	FOR(k, 0, N)FOR(i, 0, N)FOR(j, 0, N) {
		c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
	}
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			int a;
			cin >> a;
			if (a != -1) {
				ans += c[a][1];
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())
#L, L+N-1 => sum: (2L+N-1)*N // 2
A = (2 * L + N - 1)*N // 2
if L*(L+N-1) <= 0:
  print( A )
elif L+N-1 < 0:
  print( A - (L+N-1) )
else:
  print( A - L )


Measured memory_bytes: 9100
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e16;
const double EPS=1e-8;
const ll mod = 1000000007;

int64_t powm(int64_t a,int64_t b){//a^bを求める
	if(b==0){
		return 1;
	}else{
		int64_t temp = powm(a,b/2);
		temp = temp * temp;
		if(b%2==1){
			temp = temp * a;
		}
		return temp;
	}
}

int main(){
	ll n,m;
	cin>>n>>m;
	vector<vector<ll> > delay_pay;
	delay_pay.resize(110000);
	for(ll i1=0;i1<n;i1++){
		ll a,b;
		cin>>a>>b;
		delay_pay[a].push_back(b);
	}
	ll ans=0;
	priority_queue<ll> pq;
	for(ll i1=m-1;i1>=0;i1--){
		for(auto i2=delay_pay[m-i1].begin();i2!=delay_pay[m-i1].end();i2++){
			pq.push(*i2);
		}
		if(pq.empty()){
			continue;
		}
		ans += pq.top();
		pq.pop();
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 5888
#include<iostream>
using namespace std;
int main()
{
  char s;
  cin>>s;
  if(s=='A')
    cout<<'T';
  else if(s=='T')
    cout<<'A';
  else if(s=='C')
    cout<<'G';
  else if(s=='G')
    cout<<'C';
  return 0;
}

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

int main(){
	int n;
	int a;
	int sum;
	int sum2;
	long int max;
	cin >> n;
	while(n){
		cin >> sum;
		max = sum;
		for(int i=0;i<n-1;i++){
			cin >> sum2;
			sum += sum2;
			if(sum < sum2){
				sum = sum2;
			}
			if(sum > max){
				max = sum;
			}
		}
		cout << max << endl;
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K; 
	long long int P = 1e9 + 7; 
	int A[2010] = {}; 
	cin >> N >> K; 
	long long int C[2010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; C[A[i]] ++; 
	}	
	long long int T[2010] = {}; 
	for(int i = 1; i <= 2000; i++){
		T[i] = T[i-1] + C[i]; 
	}
	long long int ans = 0; 
	for(int i = 0; i < N; i++){
		long long int tmp = 0; 
		for(int j = i+1; j < N; j++){
			if(A[i] > A[j]) tmp ++; 
		}
		tmp *= (long long) K; 
		tmp %= P; 
		long long int tmp2 = T[A[i] - 1]; 
		tmp2 *= (long long) K * (K-1) / 2 % P; 
		tmp2 %= P; 
		ans += tmp; 
		ans += tmp2;
		ans %= P; 
	}
	cout << ans << endl;
}

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

int main()
{
  string s;
  cin >> s;
  bool can = true;
  if((s[2] == s[3]) and (s[4] == s[5])  and (s[0] != s[2]) and (s[0] != s[4]) and (s[1] != s[2]) and (s[0] != s[1]) and (s[1] != s[4]))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 256