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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}

int main()
{
	int h,w;
	cin>>h>>w;
	vector<string> V(h);
	for(int i=0;i<h;i++)
	{
		cin>>V[i];
	}
	vector<long long int> dp(h*w);
	dp[0]=1;
	for(int i=0;i<h*w;i++)
	{
		int x=i/w;
		int y=i%w;
		if(x<h-1&&V[x][y]=='.'&&V[x+1][y]=='.') dp[i+w]=(dp[i]+dp[i+w])%MOD;
		if(y<w-1&&V[x][y]=='.'&&V[x][y+1]=='.') dp[i+1]=(dp[i]+dp[i+1])%MOD;
	}
	cout<<dp[h*w-1]<<endl;
}

Measured memory_bytes: 9088
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(c-(a-b)<0)
			System.out.print(0);
		else
		    System.out.print(c-(a-b));

	}

}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int n=sc.nextInt();
        String[] a=new String[n];
        String[] b=new String[n];
        for(int i=0;i<n;i++){
            a[i]=sc.next();
            b[i]=a[i];
        }
        bubblesort(a,n);
        selectionsort(b,n);
    }
private static void bubblesort(String[] a,int n){
        for(int i=0;i<=n-1;i++){
            for(int j=n-1;j>=i+1;j--){
                if(Character.getNumericValue(a[j].charAt(1))<
                        Character.getNumericValue(a[j-1].charAt(1))){
                    String t=a[j];
                    a[j]=a[j-1];
                    a[j-1]=t;
                }
            }
        }
        for(int i=0;i<n-1;i++) System.out.print(a[i]+" ");
        System.out.println(a[n-1]);
        System.out.println("Stable");
    }
private static void selectionsort(String[] a,int n){
        boolean isStable=true;
        for(int i=0;i<=n-1;i++){
            int minj=i;
            for(int j=i;j<=n-1;j++){
                if(Character.getNumericValue(a[j].charAt(1))<
                        Character.getNumericValue(a[minj].charAt(1))) minj=j;
            }
            for(int k=i+1;k<minj;k++){
                if(Character.getNumericValue(a[i].charAt(1))==
                        Character.getNumericValue(a[k].charAt(1))){
                    isStable=false; 
                    break;
                }
            }
            String t=a[i];
            a[i]=a[minj];
            a[minj]=t;
        }
        for(int i=0;i<n-1;i++) System.out.print(a[i]+" ");
        System.out.println(a[n-1]);
        if(isStable) System.out.println("Stable");
        else System.out.println("Not stable");
    }
}

Measured memory_bytes: 26220
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int N; cin>>N;
	int ans=0,tmp=0; bool pro=false;
	for(int i=0;i<N;i++){
		int p; cin>>p;
		if(pro and p==i+1)tmp++;
		else if(pro and p!=i+1){
			ans+=(tmp+1)/2;
			tmp=0;
			pro=false;
		}
		else if(not pro and p==i+1){
			pro=true;
			tmp=1;
		}
	}
	if(pro)ans+=(tmp+1)/2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
class Bridge(val a : Int, val b : Int)
class Island(var group : Int)

fun moveGroup(s : MutableList<Int>, t : MutableList<Int>, lIsland : MutableList<Island>, group : Int){
    for(i in 0..(s.size - 1)){
        t.add(s[0])
        lIsland[s[0]].group = group
        s.removeAt(0)
    }
}

fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    var lIsland = mutableListOf<Island>()
    var lGroup : MutableList<MutableList<Int>> = mutableListOf()
    for(i in 0..(n - 1)){
        lIsland.add(Island(i))
        val iLGroup = mutableListOf(i)
        lGroup.add(iLGroup)
    }
    var lBridge = mutableListOf<Bridge>()
    for(i in 0..(m - 1)){
        val(a, b) = readLine()!!.split(" ").map(String::toInt)
        lBridge.add(Bridge(a - 1, b - 1))
    }
    var lRet = mutableListOf<Long>()
    lRet.add(n.toLong() * (n - 1).toLong() / 2L)
    for(i in (m - 1) downTo 1){
        val groupA = lIsland[lBridge[i].a].group
        val groupB = lIsland[lBridge[i].b].group
        if(groupA == groupB){
            lRet.add(lRet[(m - 1) - i])
        }else{
            lRet.add(lRet[(m - 1) - i] - (lGroup[groupA].size * lGroup[groupB].size))
            if(lGroup[groupA].size >= lGroup[groupB].size) moveGroup(lGroup[groupB], lGroup[groupA], lIsland, groupA)
            else moveGroup(lGroup[groupA], lGroup[groupB], lIsland, groupB)
        }
    }
    for(i in (m - 1) downTo 0){
        println(lRet[i])
    }
}


Measured memory_bytes: 95980
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long[10^^5] AS, BS, AS2B, BS2A;

void main()
{
    auto abq = readln.split.to!(int[]);
    auto A = abq[0];
    auto B = abq[1];
    auto Q = abq[2];

    foreach (i; 0..A) AS[i] = readln.chomp.to!long;
    foreach (i; 0..B) BS[i] = readln.chomp.to!long;

    int i;
    foreach (j, a; AS[0..A]) {
        if (i == B-1) {
            AS2B[j] = BS[i];
        } else if (abs(a - BS[i]) < abs(a - BS[i+1])) {
            AS2B[j] = BS[i];
        } else {
            AS2B[j] = BS[++i];
        }
    }
    i = 0;
    foreach (j, b; BS[0..B]) {
        if (i == A-1) {
            BS2A[j] = AS[i];
        } else if (abs(b - AS[i]) < abs(b - AS[i+1])) {
            BS2A[j] = AS[i];
        } else {
            BS2A[j] = AS[++i];
        }
    }

    foreach (_; 0..Q) {
        auto q = readln.chomp.to!long;

        int al = -1, bl = -1, ar = A, br = B;
        while (ar - al != 1) {
            auto mid = (al + ar) / 2;
            if (AS[mid] > q) {
                ar = mid;
            } else {
                al = mid;
            }
        }
        while (br - bl != 1) {
            auto mid = (bl + br) / 2;
            if (BS[mid] > q) {
                br = mid;
            } else {
                bl = mid;
            }
        }

        auto max_l = long.max / 4;

        auto ald = al == -1 ? max_l : q - AS[al];
        auto bld = bl == -1 ? max_l : q - BS[bl];
        auto ard = ar == A ? max_l : AS[ar] - q;
        auto brd = br == B ? max_l : BS[br] - q;

        writeln(min(
            max(ald, bld),
            max(ard, brd),
            ald*2 + brd,
            ard*2 + bld,
            bld*2 + ard,
            brd*2 + ald,
            ald + (al == -1 ? max_l : abs(AS2B[al] - AS[al])),
            ard + (ar == A ? max_l : abs(AS2B[ar] - AS[ar])),
            bld + (bl == -1 ? max_l : abs(BS2A[bl] - BS[bl])),
            brd + (br == B ? max_l : abs(BS2A[br] - BS[br]))
        ));
    }
}

Measured memory_bytes: 5500
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long ll;
ll x,y,ans;
int main()
{
	scanf("%lld%lld",&x,&y);
	for(ll i=x;;)
	{
		//printf("%lld\n",ans);
		if(i>y)break;
		i*=2;
		ans++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
#define int long long
map<char, int> m={
        {'I',1},
        {'V',5},
        {'X',10},
        {'L',50},
        {'C',100},
        {'D',500},
        {'M',1000},
};
signed main(){
        char buf[256];
        while( scanf("%s", buf) != EOF ){
                int ans = 0;
                for(int i=0; i<256 && buf[i]!=0;i++){
                        if(buf[i+1]==0){
                                ans+=m[buf[i]];
                        }else{
                                if(m[buf[i]]<m[buf[i+1]]) ans-=m[buf[i]];
                                else ans+=m[buf[i]];
                        }
                }
                cout << ans<< endl;
        }
        return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define ll long long
#define eps 1e-8
#define INF 0X3f3f3f3f
using namespace std;
const ll maxn = 1e6 + 5;
ll n,a,b,c;
int main()
{
    cin >> a >> b >> c;
    if(a == b && b == c)
    {
        cout << "No" << endl;
    }
    else
    {
        if(a == b || b == c || a == c)
            cout <<"Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();
typedef long long ll; typedef long double db;
const int N = 1e6 + 5, M = 1e9 + 7;

// #pragma GCC optimize ("trapv")

int dp[N], a[N], w[N];

int main() {
  int m, n;
  cin >> m >> n;
  int p = m;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> w[i];
    p = max(p, m + a[i] - 1);
  }
  // memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; i++) {
    if (dp[a[i]]) dp[a[i]] = min(dp[a[i]], w[i]);
    else dp[a[i]] = w[i];
    for (int j = a[i] + 1; j <= p; j++) {
      if (dp[j - a[i]]) {
        if (dp[j]) dp[j] = min(dp[j], dp[j - a[i]] + w[i]);
        else dp[j] = dp[j - a[i]] + w[i];
      }
      // cout << i << ' ' << j << ' ' << dp[j] << endl;
    }
  }
  ll ans = 1e15;
  for (int i = m; i <= p; i++) {
    if (dp[i]) ans = min((ll)dp[i], ans);
  }
  cout << ans << endl;
}


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

# A.sort()
# B.sort()

if sum(A) < sum(B):
    print(-1)
else:
    # 方針
    # 不足している準備度を計算
    # 余っている準備度を大きなものから順に奪っていく

    T = []
    for i in range(N):
        T.append([A[i], B[i], A[i]-B[i]])

    T.sort(key=lambda x: x[2])

    if T[0][2] >= 0:
        print(0)
    else:
        fusoku = 0
        cnt = 0

        for ti in T:
            if ti[2] < 0:
                cnt += 1
                fusoku += abs(ti[2])

        T.sort(reverse=True, key=lambda x:x[2])
        for ti in T:
            fusoku -= ti[2]
            cnt += 1
            if fusoku <= 0:
                break

        print(cnt)
        
        


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

using namespace std ;
typedef long long ll ;
int main() {
    ll n ;
    cin >> n ;
    map<string , ll> mp ;
    ll ans = 0 ;
    while(n--) {
        string s ;
        cin >> s ;
        mp[s]++ ;
        if (mp[s]==1) ans ++ ;
    }
    cout << ans << endl ;
}


Measured memory_bytes: 19216
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

long long si[51];
long long p[51];

long long solve(int k, long long x){
	if (x <= 0)return 0;
	if (k == 0)return 1;
	long long re = 0;
	if (x <= 1)return 0;
	if (x >= si[k])return p[k];
	if (x <= si[k - 1] + 1){
		return solve(k - 1, x - 1);
	}
	re = p[k - 1] + 1;
	return re += solve(k - 1, x - si[k - 1] - 2);
}


int main(){
	int n;
	long long k, ans;
	si[0] = 1;
	f(i, 50)si[i + 1] = (si[i] * 2) + 3;
	p[0] = 1;
	f(i, 50)p[i + 1] = (p[i] * 2) + 1;
	scanf("%d %lld", &n, &k);
	ans = solve(n, k);


	printf("%lld\n", ans);


	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll m; cin >> m;
    REP(i, m){
        ll a; cin >> a;
        n -= a;
    }
    cout << max(ll(-1), n) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
if(a>b){
cout << "a > b" << endl;
}
if(a<b){
cout << "a < b" << endl;
}
if(a==b){
cout << "a == b" << endl;
}
return 0;
}


Measured memory_bytes: 3096
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == (a*500 + b*100 + c*50):
                count+=1


print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


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

  string str;
  cin >> str;

  int manth = stoi(str.substr(5, 2));
  int day = stoi(str.substr(8));
  
  if (manth > 4) {
      cout << "TBD" << endl;
  } else if (manth < 4) {
      cout << "Heisei" << endl;
  } else {
      if (day <= 30) {
          cout << "Heisei" << endl;
      } else {
          cout << "TBD" << endl;
      }
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define N 200001

using namespace std;
vector<vector<ll>> a;

int main(void){
  ll n;
  cin >> n;
  
  a = vector<vector<ll>>(n, vector<ll>(0));
  for (int i = 0; i < n-1; i++){
    ll b;
    cin >> b;
    
    b--;
    a[b].emplace_back(i);
  }

  for (int i = 0; i < n; i++){
    cout << a[i].size() << endl;
  }
  

  return 0;
}


Measured memory_bytes: 13928
l = int(input())
n = []
for i in range(l):
  n.append(input())
ac = 0
wa = 0
tle = 0
re =0
for i in n:
  if i == 'AC':
    ac += 1
  elif i =='WA':
    wa += 1
  elif i == 'TLE':
    tle += 1
  else:
    re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


Measured memory_bytes: 16272
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret

# 文字の順番を扱うとき


def ord_from_a(char):
    return ord(char) - ord('a')


def chr_from_a(n: int):
    # nはaから何番あとかを示す
    return chr(n + ord('a'))


print(chr_from_a(ord_from_a(input()) + 1))


Measured memory_bytes: 3064
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 998244353, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;

ll dp[100001];
ll arr[100000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	rep(i, N){
		cin >> arr[i];
	}
	reverse(arr, arr+N);
	rep(i, N+1){
		dp[i] = MAX;
	}
	rep(i, N){
		*upper_bound(dp, dp + N, arr[i]) = arr[i];
	}
	cout << (lower_bound(dp, dp + N, MAX) - dp) << endl;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF=(1LL<<60);
const int mod=1000000007;

int main(){
    int s; cin >> s;
    set<int> se;
    se.insert(s);
    int pre=s;
    int now;
    int id=1;

    while(true){
        id++;
        if(pre%2==0) now=pre/2;
        else now=3*pre+1;

        if(se.find(now)!=se.end()){
            cout << id << endl;
            return 0;
        }

        se.insert(now);
        pre=now;

    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
const static int MAX = 10;

int n, k;
char S[MAX], r;
string s;

int main() {
    scanf("%d", &n);
    scanf("%s", S);
    s = S;
    scanf("%d", &k);
    r = s[k-1];

    for ( int i = 0; i < n; i++ ) {
        if ( s[i] != r ) {
            s[i] = '*';
        }
    }
    
    printf("%s\n", s.c_str());
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define iter(c) __typeof((c).begin())
#define each(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define URU(y) (!(y % 4) && y % 100 || !(y % 400))

using namespace std;

typedef pair<int, int> PII;
typedef long long LINT;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;

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

int main ( void )
{
	// cin.tie( 0 );
	// ios::sync_with_stdio( false );
	int n, r;
	while ( cin >> n >> r, n | r ) {
		VI cards( n );
		for ( int i = 0; i < n; ++i ) {
			cards[i] = n - i;
		}
		for ( int i = 0; i < r; ++i ) {
			VI t( cards );
			int p, c;
			cin >> p >> c;
			for ( int j = 0; j + 1 < p; ++j ) {
				t[c + j] = cards[j];
			}
			for ( int j = 0; j < c; ++j ) {
				t[j] = cards[p - 1 + j];
			}
			cards = t;
		}
		cout << cards[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
// https://atcoder.jp/contests/abc083/tasks/abc083_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b < c + d) {
        cout << "Right\n";
    } else if (a + b == c + d) {
        cout << "Balanced\n";
    } else {
        cout << "Left\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;


int main(void) {

    int L[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;

    cout << L[K-1];

    return 0;
}

Measured memory_bytes: 256
import math

N=int(input())
P= math.floor(N**0.5)

for A in range(P,0,-1):
  if N%A==0:
    B=N//A
    #print(A,B)
    break
    
def F(A,B):
  return max(len(str(A)),len(str(B)))

print(F(A,B))

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

int main(){
  int N;
  scanf("%d",&N);
  int a[15]={};
  int x[15][15]={};
  int y[15][15]={};  
  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
    for(int j=0;j<a[i];j++){
      scanf("%d %d",&x[i][j],&y[i][j]);
    }
  }
  int ans=0;
  for(int i=1;i<(1<<N);i++){
    bool flg=true;
    for(int j=0;j<N;j++){
      if(i&(1<<j)){
        for(int k=0;k<a[j];k++){
          if( ( ( i>>(x[j][k]-1) ) & 1) ^ y[j][k]){
            flg=false;
            break;
          }
        }
      }
    }
    if(flg){
      ans=max(ans,__builtin_popcount(i));
    }
  }
  printf("%d",ans);
}


Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  string s;
  int q;
  auto lis = DList!char();
  cin.scan(s, q);

  foreach (c; s) {
    lis.insertBack(c);
  }

  bool isFront = true;
  foreach (i; 0 .. q) {
    int t = cin.next!int;
    if (t == 1) {
      isFront = !isFront;
    } else {
      int f;
      char c;
      cin.scan(f, c);

      if (isFront) {
        f == 1 ? lis.insertFront(c) : lis.insertBack(c);
      } else {
        f == 1 ? lis.insertBack(c) : lis.insertFront(c);
      }
    }
  }

  string res;
  if (isFront) {
    foreach (c; lis) {
      res ~= c;
    }
  } else {
    foreach_reverse (c; lis) {
      res ~= c;
    }
  }

  writeln(res);
}


Measured memory_bytes: 23960
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vi a(m), b(m);
  vector<vi> c(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    rep(j, b[i]) {
      int cc;
      cin >> cc;
      c[i].push_back(cc);
    }
  }
  int dp[m + 1][1 << n];
  rep(i, m + 1) rep(j, 1 << n) dp[i][j] = 1e9;
  dp[0][0] = 0;
  rep(i, m) rep(j, 1 << n) {
    dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    int nj = j;
    for(int v : c[i]) nj |= (1 << (v - 1));
    dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a[i]);
  }
  int ans = dp[m][(1 << n) - 1];
  if(ans >= 1e9) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 16384
#[allow(unused_imports)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let _n = read::<usize>();
    let w = read_vec::<i32>();

    let answer = solve(&w);
    println!("{}", answer);
}

fn solve(w: &[i32]) -> i32 {
    let sum: i32 = w.into_iter().sum();
    let mut d: i32 = -1 * sum;
    for x in w {
        let d1 = d + 2 * x;
        if d1 < 0 {
            d = d1;
            continue;
        }
        if d1 == 0 {
            return 0;
        }
        return if d1 < -d {d1} else {-d}; 
    }
    return sum;
}


Measured memory_bytes: 4352
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>
#include <complex>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;

/*-----------------------------------------------------------------------------
　幾何学ライブラリ
 -------------------------------------------------------------------------------*/
/* 基本要素 */
typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

/*-----------------------------------------------------------------------------
　メイン
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	REP(i, N) {
		int sameCnt = 0;
		vector<bool> isUsed(26, false);
		for (int j = 0; j < i; j++) {
			if (isUsed[S[j] - 'a']) continue;
			if (S.find(S[j], i) != string::npos) {
				isUsed[S[j] - 'a'];
				isUsed[S[j] - 'a'] = true;
				sameCnt++;
			}
		}
		ans = max(ans, sameCnt);
	}
	cout << ans << endl;
	return 0;
}


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

struct Edge { int to; ll cost; };
vector<Edge> G[2510];
ll INF = 1e18;

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

  int V, E; cin >> V >> E;
  ll P; cin >> P;
  vector<ll> d(V, INF);

  for (int i = 0; i < E; i++) {
    int a, b; cin >> a >> b; a--; b--;
    ll c; cin >> c;
    G[a].emplace_back(Edge({b, -(c - P)}));
  }

  d[0] = 0;
  for (int t = 0; t < V * 2; t++) {
    for (int i = 0; i < V; i++) {
      if (d[i] == INF) continue;
      for (auto e: G[i]) {
        if (d[e.to] > d[i] + e.cost) {
          d[e.to] = d[i] + e.cost;
          if (t == V - 1) {
            d[e.to] = -INF;
          }
        }
      }
    }
  }

  if (d[V - 1] < -INF / 2) cout << "-1\n";
  else cout << max(-d[V - 1], 0ll) << '\n';

  return 0;
}

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

int main(){
  int n, maxv = 0, val;
  cin >> n;
  bool flag = true;
  for ( int i = 1; i <= n; i++){
    cin >> val;
    if ( maxv < val){
      maxv = val;
    } else if ( maxv - val >= 2){
      flag = false;
      break;
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	for ( int N, M; cin >> N >> M && ( N | M ); )
	{
		VI S( N ), T( S );
		REP( i, N )
		{
			cin >> S[i] >> T[i];
		}

		VI P( M );
		cin >> P;
		P.PB( 1000000001 );
		sort( ALL( P ) );

		VI evens( M ), odds( M );
		REP( i, M )
		{
			( i % 2 ? odds : evens )[i] = P[ i + 1 ] - P[i];
		}

		VI csum_even( 1, 0 ), csum_odd( 1, 0 );
		partial_sum( ALL( evens ), BI( csum_even ) );
		partial_sum( ALL( odds ), BI( csum_odd ) );

		LL res = 0;
		REP( i, N )
		{
			int s, t;
			tie( s, t ) = minmax( S[i], T[i] );

			const int p = lower_bound( ALL( P ), s ) - P.begin();
			const int q = upper_bound( ALL( P ), t ) - P.begin();

			VI &ary = p % 2 ? csum_odd : csum_even;

			int tmp = ( t - s ) - ( ary[q] - ary[p] );
			if ( ( q - p ) % 2 )
			{
				tmp += P[q] - t;
			}
			if ( ( q - p ) % 2 && S[i] > T[i] )
			{
				tmp = ( t - s ) - tmp;
			}
			res += tmp;
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 4436
# coding: utf-8
import sys
input = sys.stdin.readline

A, B, K = map(int, input().split())
diff = B - A
if diff < 2*K:
    for c in range(A, B+1):
       print(c)
else:
    for a in range(A, A+K):
        print(a)
    for b in range(B-K+1, B+1):
        print(b)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int INF=0x3f3f3f3f;
#define N int(2e5+5)

struct e{
	int to,d,c;
	e(int x,int y,int z):to(x),d(y),c(z){}
};
int n,m,s[N];
bool operator<(e e1,e e2){
	if(e1.d!=e2.d)return e1.d>e2.d;
	else return e1.c>e2.c;
}

ll dijkstra(vector<e> g[]){
	memset(s,0,sizeof(s));
	int cnt=1;
	priority_queue<e> q;
	vector<int> dist(n+1,INF);
	dist[1]=0;
	for(int i=0;i<g[1].size();i++){
		q.push(g[1][i]);
		dist[g[1][i].to]=g[1][i].d;
	}
	s[1]=1;
	ll ret=0;
	while(cnt<n){
		while(s[q.top().to])q.pop();
		e x=q.top();
		q.pop();
		ret+=x.c;
		s[x.to]=1;
		for(int i=0;i<g[x.to].size();i++){
			if(dist[g[x.to][i].to]>=x.d+g[x.to][i].d){
				dist[g[x.to][i].to]=x.d+g[x.to][i].d;
				q.push(e(g[x.to][i].to,dist[g[x.to][i].to],g[x.to][i].c));
			}
		}
		cnt++;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	while(cin>>n>>m){
		if(n==0 && m==0)break;
		vector<e> g[N];
		int u,v,d,c;
		for (int i = 0; i < m; i++){
			cin>>u>>v>>d>>c;
			g[u].push_back(e(v,d,c));
			g[v].push_back(e(u,d,c));
		}
		cout<<dijkstra(g)<<endl;
	}
	return 0;
}

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

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;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int n;
    cin >> n;

    vector<int> cnt(n+1, 0);

    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; j += i) ++cnt[j];
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i) ans += (i * ll(cnt[i]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 42280
from math import factorial# from math
N = int(input())

def pdwn(n):
    i=2
    z={}
    while i*i<=n:
        while n%i==0:
            n//=i
            z[i] = z.get(i,0) + 1
        i+=1
    if n>1:z[n] = z.get(n,0) + 1
    g = 1
    for y in z.keys():g *= z[y] + 1
    return g

print(pdwn(factorial(N))%(10**9+7))

Measured memory_bytes: 3064
S = input()

if S[0]=='A' and S[2:len(S)-1].count('C') == 1:
    flag = True
    for i in range(1,len(S)):
        if ord(S[i]) < ord('a') and i != S.index('C'):
            flag = False
            break
    if flag:
        print('AC')
    else:
        print('WA')
else:
    print('WA')


    

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    int c = 0, num = 0;
    vector<vector<int>> v(h, vector<int>(w, 0));
    repi(i, h, 0)
    {
        repi(j, w, 0)
        {
            if (c == 0)
            {
                num++;
                cin >> c;
            }
            if (i % 2)
            {
                v[i][w-j-1] = num;
            }
            else
            {
                v[i][j] = num;
            }
            c--;
        }
    }
    repi(i, h, 0)
    {
        repi(j, w, 0)
        {
            cout << v[i][j] << ((j + 1) % w ? " " : "\n");
        }
    }
    return 0;
}

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

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

	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	if (b > c) {
		t = b;
		b = c;
		c = t;
	}
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}


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

int main()
{
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> ac(n, 0);
  for (int i = 0; i < n - 1; ++i)
  {
    int tmp = 0;
    if (s[i] == 'A' and s[i + 1] == 'C')
      tmp = 1;
    ac[i+1] = ac[i] + tmp;
  }

  for (int i = 0; i < q; ++i)
  {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    int64_t ans = 0;
    ans = ac[r] - ac[l];
    cout << ans << endl;
  }
}

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

int main() {
	
	int w, h, n; cin >> w >> h >> n;
	int w_right = w;
	int w_left = 0;
	int h_upper = h;
	int h_lower = 0;
	for (int i = 0; i < n; i++) {
		int x, y, a; cin >> x >> y >> a;
		if (a == 1) w_left = max(w_left, x);
		if (a == 2) w_right = min(w_right, x);
		if (a == 3) h_lower = max(h_lower, y);
		if (a == 4) h_upper = min(h_upper, y);
	}
	cout << max(0, w_right - w_left) * max(0, h_upper - h_lower) << endl;
	return 0;
}

Measured memory_bytes: 3596
s = input()

if int(s[:4]) > 2019:
    print("TBD")
    exit()
if int(s[:4]) < 2019:
    print("Heisei")

if int(s[5]) * 10 + int(s[6]) > 4:
    print("TBD")
    exit()
if int(s[5]) * 10 + int(s[6]) < 4:
    print("Heisei")
    exit()

if int(s[8]) * 10 + int(s[9]) > 30:
    print("TBD")
else:
    print("Heisei")

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  } else if (a > b) {
    cout << "a > b" << endl;
  } else {
    cout << "a == b" << endl;
  }
}


Measured memory_bytes: 3028
using System;
using System.Linq;

class A
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long n = h[0], a = h[1], b = h[2];
		Console.WriteLine(Math.Max((n - 2) * (b - a) + 1, 0));
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

constexpr int N = 4096;
int h, w;
ll cur[N][4] = {}, und[N][4] = {}, a[N][N] = {};

// ll dp(int y, int x, int yc, int xc){
// 	ll &ret = memo[y][x][yc][xc];
// 	if(!~ret){
// 		if(y > h || x > w){
// 			ret = 0;
// 		}else{
// 			ret = max( dp(y+1, x, 0, xc), dp(y, x+1, yc, 0) );
// 			if(xc < 3) LAR(ret, a[y][x] + dp(y+1, x, 0, xc+1));
// 			if(yc < 3) LAR(ret, a[y][x] + dp(y, x+1, yc+1, 0));
// 		}
// 	}
// 	return ret;
// }

int main(){
	int k; scanf("%d%d%d", &h, &w, &k);
	REP(i, k){
		int y, x; scanf("%d%d", &y, &x);
		scanf("%lld", a[y]+x);
	}
	for(int y = h; y >= 1; y--){
		for(int x = w; x >= 1; x--){
			REP(yc, 4){
					ll &ret = cur[x][yc];
					ret = max( und[x][0], cur[x+1][yc]);
					if(yc < 3){
						LAR(ret, a[y][x] + und[x][0]);
						LAR(ret, a[y][x] + cur[x+1][yc+1]);
					}
					// DEBUG("[%d][%d][%d][%d] = %lld\t", y, x, yc, xc, ret);
					// if(ret == und[x][0][xc]) DEBUG("=>%d %d %d %d  ", y+1, x, 0, xc);
					// if(ret == cur[x+1][yc][0]) DEBUG("=>%d %d %d %d  ", y, x+1, yc, 0);
					// if(ret == a[y][x] + und[x][0][xc+1]) 
					// 	DEBUG("=>%lld + %d %d %d %d  ", a[y][x], y+1, x, 0, xc+1);
					// if(ret == a[y][x] + cur[x+1][yc+1][0])
					// 	DEBUG("=>%lld + %d %d %d %d  ", a[y][x], y, x+1, yc+1, 0);
					// DEBUG("\n");
			}
		}
		swap(cur, und);
	}
	printf("%lld\n", und[1][0]);
}


Measured memory_bytes: 75976
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int h, w;
    int ans[101][101];
    string mp[101];

    cin >> h >> w;

    for (int i = 0; i < h; i++) {
        cin >> mp[i];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (mp[i][j] == 'c') {
                ans[i][j] = 0;
            }
            else {
                ans[i][j] = 10000;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (mp[i][j] == 'c') {
                for (int k = j+1; k < (int)mp[i].size(); k++) {
                    if (ans[i][k] > k-j) {
                        ans[i][k] = k - j;
                    }
                }
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ans[i][j] != 10000) {
                cout << ans[i][j];
            }
            else cout << -1;

            if (j != w-1) cout << " ";
        }
        cout << endl;
    }
}




Measured memory_bytes: 3228
while True:
    n=int(input())
    if n==0:
        break
    t=[]
    for i in range(n):
        t.append(int(input()))
    t=sorted(t)

    retval=0
    for i in range(n):
        retval+=t[i]*(n-i-1)
    print(retval)



Measured memory_bytes: 5820
import java.util.Scanner;

class Node {

	int id, parent, left, right, sibling, degree, depth, height;
	String type;

	public Node(int id, int left, int right) {
		super();
		this.id = id;
		this.left = left;
		this.right = right;
		this.parent = -1;
	}

	@Override
	public String toString() {
		return "node " + id + ": parent = " + parent + ", sibling = " + sibling +
				", degree = " + degree + ", depth = " + depth + ", height = " + height +
				", " + type;
	}
}

public class Main {


	public static void nodeDownward(Node[] nodeList, int parent, int child, int sibling, int depth) {
		Node node = nodeList[child];
		node.parent = parent;
		node.depth = depth;
		node.sibling = sibling;
		node.depth = depth++;
		int left = node.left;
		int right = node.right;
//		System.out.println("node:" + node.id + " left:" + left + " right:" + right +
//				" parent:" + node.parent);
		if (left != -1) {
			nodeDownward(nodeList, node.id, left, right, depth);
		}
		if (right != -1) {
			nodeDownward(nodeList, node.id, right, left, depth);
		}
	}

	public static void leafToRoot(Node[] nodeList, int id, int height) {
		Node node = nodeList[id];
		node.height = Math.max(height++, node.height);
		if (node.parent == -1) {
			return;
		}
		leafToRoot(nodeList, node.parent, height);
	}


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

		int n = sc.nextInt();
		Node[] node = new Node[n];
		int[] rootNode = new int[n];

		for (int i = 0; i < n; i++) {
			int id = sc.nextInt(), left = sc.nextInt(), right = sc.nextInt();
			node[id] = new Node(id, left, right);
			node[id].type = "internal node";

			if (left != -1) {
				rootNode[left] = 1;
				node[id].degree = 1;

			}
			if (right != -1) {
				rootNode[right] = 1;
				node[id].degree = 1;
			}
			if (left == -1 && right == -1) {
				node[id].type = "leaf";
			}

			if (left != -1 && right != -1) {
				node[id].degree = 2;

			}

		}
		int root = 0;
		for (int i = 0; i < n; i++) {
			if (rootNode[i] == 0) {
				root = i;
				node[i].type = "root";
			}
		}

		nodeDownward(node, -1, root, -1, 0);

		for (int i = 0; i < node.length; i++) {
			if (node[i].type.equals("leaf")) {
				leafToRoot(node, i, 0);
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.println(node[i]);
		}
	}
}


Measured memory_bytes: 26420
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main( int argc, char** argv ){

	int A,B;

	cin >> A >> B;

	if( B%A == 0){
		cout << A+B << endl;
	}else{
		cout << B-A << endl;
	}

	return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n, m;
    cin >> n >> m;
    map<int,int> mp;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }

    for(auto &i : mp){
        if(i.second % 2 != 0){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}   

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return 1;}
    else if(*(int*)a<*(int*)b){return -1;}
    else {return 0;}
}


int main(void){
int n,m;
int ans[100];
char s[100][15],t[100][15];
scanf("%d",&n);

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



for(int i=0;i<n;i++){
    scanf("%s",s[i]);
}

scanf("%d",&m);
for(int i=0;i<m;i++){
    scanf("%s",t[i]);
}
//check

for(int i=0;i<n;i++){
    //blue check
    for(int j=0;j<n;j++){
        if(strcmp(s[i],s[j])==0){ans[i]++;}
    }
    //red check
    for(int k=0;k<m;k++){
        if(strcmp(s[i],t[k])==0){ans[i]--;}
    }

}

//ans check
int max=0;
for(int i=0;i<n;i++){
    if(max<=ans[i]){max=ans[i];}
}
printf("%d\n",max);

} 


Measured memory_bytes: 128