akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define INF 100000000

int calc(int a,int b);

int main(){
  int n,k;
  cin >> n >> k;
  vint A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(),A.end());
  vint B(n-k+1);
  rep(i,n-k + 1){
    B[i] = A[i + k-1] - A[i];
  }
  //rep(i,A.size()) cout << A[i] << endl;
  //rep(i,B.size()) cout << B[i] << endl;
  sort(B.begin(),B.end());
  cout << B[0] << endl;
}  

Measured memory_bytes: 1024
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.nextLine();
        String B = sc.nextLine();
        String A_new = null;
        String B_new = null;
        String []A_array = A.split("");
        String []B_array = B.split("");
        Arrays.sort(A_array);
        Arrays.sort(B_array,Comparator.reverseOrder());
        for(int i = 0; i < A_array.length; i++){
            A_new += A_array[i];
        }
        for(int i = 0; i < B_array.length; i++){
            B_new += B_array[i];
        }
        if(A_new.compareTo(B_new) < 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23508
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        int field[50][50];
        for(int i=0; i < 50; i++) for(int j=0; j < 50; j++) field[i][j] = 0;
        field[1][1] = 1;
        int c;
        cin >> c;
        for(int i=0; i < c; i++){
            int x, y;
            cin >> x >> y;
            field[y][x] = -1;
        }
        for(int i=1; i <= m; i++){
            for(int j=1; j <= n; j++){
                if(i==1 && j==1) continue;
                if(field[i][j] == -1) continue;
                int p = field[i-1][j];
                int q = field[i][j-1];
                if(p == -1) p = 0;
                if(q == -1) q = 0;
                field[i][j] = p+q;
            }
        }
        cout << field[m][n] << endl;
    }
}

Measured memory_bytes: 1164
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) //cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll dp[10005][2][100];
ll mod = 1e9+7;
int main(){
    string s;
    cin >> s;
    int d;
    cin >> d;
    dp[0][0][0] = 1;
    rep(i,s.size()){
        rep(j,d){
            for(int k = 0; k < s[i]-'0'; k++){
                dp[i+1][1][(j+k)%d] = (dp[i+1][1][(j+k)%d] + dp[i][0][j]) % mod;
            }
            dp[i+1][0][(j+s[i]-'0')%d] = (dp[i+1][0][(j+s[i]-'0')%d] + dp[i][0][j]) % mod;
            for(int k = 0; k <= 9; k++){
                dp[i+1][1][(j+k)%d] = (dp[i+1][1][(j+k)%d] + dp[i][1][j]) % mod;
            }
        }
    }
    cout << (dp[s.size()][0][0] + dp[s.size()][1][0] -1 + mod) % mod << endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int X(int x){
  return x>=0?x:-x;
  }
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((X(b-a)<=d&&X(c-b)<=d)||X(c-a)<=d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  }

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

int n, k, dp[100005], a[100005];

int solve(int idx)
{
	  if (idx == n - 1)
	  		return 0;
	  if (dp[idx] != -1)
	      return dp[idx];
	  int ans = 1e9;
	  for (int i = 1; i + idx < n && i <= k; i++)
	       ans = min(ans, solve(i + idx) + abs(a[idx] - a[idx + i]));
	  return dp[idx] = ans;
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

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

  int n;
  cin >> n;

  for(long double i=0;i<=n;i++){
    int x = (i * 1.08);
    if(x == n){
      cout << i << endl;
      return 0;
    }
  }

  cout << ":(" << endl;

  return 0;
}

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

int main(){
    int N;
    bool color_list[8] = {0};
    int rate;
    int god = 0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> rate;
        if(rate >= 3200){
            god++;
        }else{
            color_list[rate/400] = true;
        }
    }
    int color_num = 0;
    for(int i=0; i<8; i++){
        if(color_list[i]){
            color_num++;
        }
    }
    int color_min, color_max;
    if(color_num == 0){
        color_min = 1;
    }else{
        color_min = color_num;
    }
    color_max = color_num + god;
    cout << color_min << " " << color_max;
    return EXIT_SUCCESS;
}

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

using namespace std;

int main(){
  int n; // 変数名まちがえた
  cin >> n;
  cin.ignore();

  // 戦略 各下一桁に対し、組み合わせを定義

  int m = n % 100;
  if(m == 0){ // 100円のおにぎりだけでいい
    cout << 1 << endl;
    return 0;
  }

  m = n % 101;
  if(m == 0){ // 100円のおにぎりだけでいい
    cout << 1 << endl;
    return 0;
  }

  m = n % 102;
  if(m == 0){ // 100円のおにぎりだけでいい
    cout << 1 << endl;
    return 0;
  }

  m = n % 103;
  if(m == 0){ // 100円のおにぎりだけでいい
    cout << 1 << endl;
    return 0;
  }

  m = n % 104;
  if(m == 0){ // 100円のおにぎりだけでいい
    cout << 1 << endl;
    return 0;
  }

  m = n % 105;
  if(m == 0){ // 100円のおにぎりだけでいい
    cout << 1 << endl;
    return 0;
  }

  if( n < 100){
    cout << 0 << endl;
    return 0;
  }

  // まず100円だけでやってみる

  int d[6] = {0};
  d[0] = n / 100; // 商
  m = n % 100; // 余り

  // 余りをとりあえず105円に置換
  // これが一番少ない数で済む

  d[5] = m / 5;
  m %= 5;

  // d[0] から d[5] を削除

  d[0] -= d[5];
  if(d[0] < 0){ // 負になったら負け
    cout << 0 << endl;
    return 0;
  }

  // この時点で余りなしならOK
  if(m == 0){
    cout << 1 << endl;
    return 0;
  }

  if(d[0] == 0){ // mが余ってるのにdがゼロ
    cout << 0 << endl;
    return 0;
  } else {
    cout << 1 << endl;
    return 0;
  }
  return 0;
}
  
  


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

int main() {
  int N;
  int judge = 0;
  
  cin >> N;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      judge = 1;
    }
  }
  if(judge == 0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}



Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int main() {
    int n, p, a[200000], b[200000], da[200000], db[200000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p;
        a[p - 1] = b[p - 1] = i;
    }
    for (int i = 1; i < n; i++) {
        da[i] = a[i] - a[i - 1];
        db[i] = b[i - 1] - b[i];
        int o = min(1, min(da[i], db[i])) - 1;
        da[i] -= o;
        db[i] -= o;
    }
    a[0] = 1;
    b[0] = 1000000000;
    for (int i = 1; i < n; i++) {
        a[i] = a[i - 1] + da[i];
        b[i] = b[i - 1] - db[i];
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
        cout << b[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 55

struct LOC{
	LOC(){
		x = y = z = 0;
	}

	LOC(int arg_x,int arg_y,int arg_z){
		x = arg_x;
		y = arg_y;
		z = arg_z;
	}
	int x,y,z;
};

int H,W,N;
LOC loc[SIZE];
bool used[SIZE][SIZE];

int main(){

	scanf("%d %d %d",&W,&H,&N);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			used[row][col] = false;
		}
	}

	int ans = 0;

	for(int i = 0; i < N; i++){

		scanf("%d %d %d",&loc[i].x,&loc[i].y,&loc[i].z);
		loc[i].x--;
		loc[i].y--;
		used[loc[i].y][loc[i].x] = true;

		ans += loc[i].z;
	}

	for(int i = 0; i < N-1; i++){
		for(int k = i+1; k < N; k++){

			int diff_z = abs(loc[i].z-loc[k].z);
			int diff_x = abs(loc[i].x-loc[k].x);
			int diff_y = abs(loc[i].y-loc[k].y);

			if(diff_z > diff_x+diff_y){

				printf("No\n");
				return 0;
			}
		}
	}

	for(int x = 0; x < W; x++){
		for(int y = 0; y < H; y++){
			if(used[y][x])continue;

			int maximum = -BIG_NUM;
			for(int i = 0; i < N; i++){

				int diff_x = abs(loc[i].x-x);
				int diff_y = abs(loc[i].y-y);
				maximum = max(maximum,loc[i].z-(diff_x+diff_y)); //なるべく低くする
			}

			used[y][x] = true;
			ans += maximum;
		}
	}

	printf("%d\n",ans);
}



Measured memory_bytes: 3220
# -*- coding: utf-8 -*-
"""
Bitset I - Bit Flag
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_10_C&lang=jp

"""
class Bit:
    def __init__(self):
        self.data = 0

    def process(self, op, arg):
        funcs = (self.test, self.set, self.clear, self.flip, self.all, self.any, self.none, self.count, self.val)
        funcs[int(op)](arg)

    def test(self, arg):
        print(int(bool(self.data & 1 << int(arg))))

    def set(self, arg):
        self.data |= 1 << int(arg)

    def clear(self, arg):
        self.data &= ~(1 << int(arg))

    def flip(self, arg):
        self.data ^= 1 << int(arg)

    def all(self, arg):
        print(int(bin(self.data).count('1') == 64))

    def any(self, arg):
        print(int(self.data != 0))

    def none(self, arg):
        print(int(self.data == 0))

    def count(self, arg):
        print(bin(self.data).count('1'))

    def val(self, arg):
        print(self.data)

b = Bit()
for _ in range(int(input())):
    op, arg = (input() + ' 1').split()[:2]
    b.process(op, arg)



Measured memory_bytes: 5640
a[5000],s,r,i;main(n,j){for(;scanf("%d",&n),n;i=!printf("%d\n",r)){for(r=-(1e7);i<n;)scanf("%d",a+i++);for(i=0;i<n;s=0)for(j=i++;j<n;)r=fmax(r,s+=a[j++]);}}

Measured memory_bytes: 432
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int result = 0;
        if (Math.abs(a-b) <= 1) {
            result = a + b;
        } else if (Math.abs(a-b) >= 2) {
            result = Math.max(a, b)*2 - 1;
        }
        
        System.out.println(result);
    }
}


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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
int N;
vector<pair<int, int>> G[100000];
int ans[100000];
bool used[100000];

void dfs(int v, int nouse){
    if(used[v])return;
    used[v] = true;
    int now = 1;
    rep(i, G[v].size()){
        if(now == nouse)now++;
        if(!used[G[v][i].first]){
            ans[G[v][i].second] = now;
            dfs(G[v][i].first, now);
            now++;
        }
    }
}

// solve
int main(){

    cin >> N;
    rep(i, N - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back({ b, i });
        G[b].push_back({ a, i });
    }

    int big = 0, pos = 0;
    rep(i, N)if(chmax<int>(big, G[i].size()))pos = i;
    dfs(pos, -1);

    cout << big << '\n';
    rep(i, N - 1)cout << ans[i] << '\n';
    return 0;

}


Measured memory_bytes: 8448
import sys
from collections import deque, defaultdict
import copy
import bisect
#sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import combinations, permutations

import sys
def input():
	return sys.stdin.readline().strip()


N, M = list(map(int, input().split()))

graph = [[] for _ in range(3*N)]

for i in range(M):
	u, v = list(map(int, input().split()))
	u -= 1
	v -= 1
	graph[u%(3*N)].append((v + N)%(3*N))
	graph[(u + N) % (3 * N)].append((v+2*N)%(3*N))
	graph[(u + 2*N) % (3 * N)].append(v % (3 * N))
S, T = list(map(int, input().split()))
S -= 1
T -= 1

dist = [1000000000000000000 for _ in range(3*N)]
que = deque([])
que.append(S)
dist[S] = 0
while len(que) > 0:
	node = que.popleft()
	for edge in graph[node]:
		if dist[edge] > dist[node] + 1:
			dist[edge] = dist[node] + 1
			que.append(edge)

if dist[T] < 100000000000000:
	print(dist[T]//3)
else:
	print(-1)

Measured memory_bytes: 98316
s = input()

if not (1 <= int(s[:2]) <= 12):
    if 1 <= int(s[2:]) <= 12:
        print('YYMM')
    else:
        print('NA')
else:
    if 1 <= int(s[2:]) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    ll hcount = 0, dcount = n / k;
    if (k % 2 == 0) {
        FOR(i,1,n+1) if (i % k == k/2) hcount++;
    }
    
    OUT(hcount * hcount * hcount + dcount*dcount*dcount)


    return 0;
}

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

int main() {
  int n;
  int k;
  int q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for(int i = 0; i < q; i++)
    cin >> a.at(i);
  vector<int> point(n,k-q);
  for(int i : a)
    point.at(i-1)++;
  for(int p : point){
    if(p > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

ll calc_gcd(ll x, ll y) {
    if (y == 0) {
        return x;
    }
    return calc_gcd(y, x % y);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> T(N);
    for (auto& t : T) {
        cin >> t;
    }
    ll gcd = T.front();
    ll lcm = T.front();
    rep(i, 1, N) {
        gcd = calc_gcd(lcm, T[i]);
        ll g1 = calc_gcd(gcd, lcm);
        ll g2 = gcd / g1;
        lcm = lcm / g1 * T[i] / g2;
    }
    cout << lcm << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n, a[100];
	bool tf = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				tf = false;
			}
		}
	}
	if (tf) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> a(n), ans(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        int cnt = 0;
        int x = i; x+= i+1;
        while(x<=n-1){ 
            cnt+= ans[x];
            x += i+1;
        }
        //cout<<cnt<<'+'<<a[i]<<' '<<i<<' '<<x<<endl;
        ans[i] = abs(a[i] - cnt%2);
    }
    vector <int> out;
    for(int i=0;i<n;i++){
        if(ans[i]) out.push_back(i+1);
        //cout<<ans[i]<<endl;
    }
    cout<<out.size()<<endl;
    for(int i=0;i<out.size();i++){
        cout<<out[i]<<' ';
    }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;
//const double pi = 3.14159265358979;

int main() {
    int n,m;
    cin >> n >> m;
    vi h(n);
    rep(i,n) cin >> h[i];
    vector<pii> v;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        v.pb(mp(a,b));
    }
    map<int,int> ma;
    for(auto c : v) {
        int x = h[c.fi];
        int y = h[c.se];
        //cout << x << " " << y << endl;
        if(x > y) ma[c.se]++;
        else if(x < y) ma[c.fi]++;
        else if(x == y) {
            ma[c.fi]++;
            ma[c.se]++;
        }
    }
    int counter = 0;
    for(auto c : ma) {
        if(c.se > 0) counter++;
    }
    cout << n - counter << endl;
}

Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,k;
  cin>>n>>k;
 ll arr[n+10];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  if(k>=n)
  {
    cout<<0<<endl;
  }
  else
  {
    sort(arr,arr+n);
   ll l=n-k,sum=0;
    for(int i=0;i<l;i++)
    {
      sum+=arr[i];
    }
    cout<<sum<<endl;
  }
  return 0;
}


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

int a[105] ;

long long sum = 0 , ans = 0 ;

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

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

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

	ans = ans / 2 ;
	cout << ans << endl ;




	return 0 ;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

a = inp()
s = input()

if a >= 3200:
    print(s)
else:
    print('red')


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

using namespace std;

#define rep(i, n) for(int64 i = 0; i < (int64)(n); i++)

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  int N, K;
  cin >> N >> K;
  int ret = 0;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    ret += min(K - x, x);
  }
  cout << ret * 2 << endl;
}


Measured memory_bytes: 256
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)


def nxor(x,n,k):
    if (n&k) == k:
        return x
    else:
        return 0


def main():
    n = int(input())
    a = [int(i) - 1 for i in list(input())]
    
    cumxor = 0
    amod = [i%2 for i in a]
    for i in range(n):
        cumxor ^= nxor(amod[i],n - 1,i)
    
    if cumxor == 1:
        ans = 1
    else:
        if 1 in a:
            ans = 0
        else:
            cumxor = 0
            adiv = [i//2 for i in a]
            for i in range(n):
                cumxor ^= nxor(adiv[i],n - 1,i)
            if cumxor == 0:
                ans = 0
            else:
                ans = 2
    
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 31092
// AOJ 0550: Dividing Snacks
// 2017.11.18 bal4u@uu

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

#define INF 0x33333333
#define MIN(a,b)   ((a)<=(b)?(a):(b))
int dp[2][2][5001];
int ti[10001];

int main()
{
    int n, n1, n2, i, j, k, k1, k2, ans;
	
	scanf("%d", &n), n1 = n - 1, n2 = n >> 1;
	for (i = 0; i < n1; i++) scanf("%d", ti+i);

	memset(dp, INF, sizeof(dp));
    dp[0][0][0] = dp[0][1][0] = 0;
    for (k1 = 0, k2 = 1, i = 0; i < n; i++, k1 = k2, k2 = !k2) {
		memset(dp[k2], INF, sizeof(dp[k2]));
		for (j = 0; j <= n2; j++) {
			for (k = 0; k < 2; k++) {
				if(dp[k1][k][j] == INF) continue;
				if (k == 0) dp[k2][k][j+1] = MIN(dp[k2][k][j+1], dp[k1][k][j]);
			     else        dp[k2][k][j]   = MIN(dp[k2][k][j],   dp[k1][k][j]);
				if (k == 0) dp[k2][1][j+1] = MIN(dp[k2][1][j+1], dp[k1][k][j] + ti[i]);
				else        dp[k2][0][j]   = MIN(dp[k2][0][j],   dp[k1][k][j] + ti[i]);
			}
        }
    }
    ans = dp[k1][0][n2]; if (ans > dp[k1][1][n2]) ans = dp[k1][1][n2];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1960
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;


vector<pair<llong,llong>> factoring(llong n){
    vector<pair<llong,llong>> ans;
    llong i=1;

    llong _n =n;
    while(1){
        i+=1;
        if( i > _n) break;
        pair<llong,llong> tmp;
        tmp.first=i;
        tmp.second=0;
        while(1){
            if(n%i!=0) break;
            n/=i;
            tmp.second+=1;
        }
        if(tmp.second!=0) ans.push_back(tmp);
    }
    if(n==_n) ans.push_back( make_pair(llong(n),llong(1)));
    return ans;

}


int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << 0 << endl;
        return 0;
    }
    int kosuu[105];
    REP(i,105) kosuu[i] = 0;
    FOR(i,2,n+1){
        vector< pair<llong,llong> > tmp = factoring(i);
        itrfor(itr,tmp) kosuu[(*itr).first] += (*itr).second;
    }

    int A[1050];
    REP(i,1050) A[i] = 0;
    REP(i,105){
        A[kosuu[i]] += 1;
    }
    REPR(i,1048) A[i] += A[i+1];

    llong ans = 0;
    if((A[2] -2) * A[4] * (A[4]-1) /2  >=0){
    ans += (A[4] * (A[4]-1) /2) * (A[2] -2);
    }

    ans += A[74];


    if( A[24] * (A[2] -1 ) >= 0){
        ans += A[24] * (A[2] -1 );
    }

    int x= A[14] ;
    int y = A[4] ;
    if( x * (y-1) >=0) ans += x * (y-1);

    cout << ans << endl; 
}

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

int main(void){
    long long N;
    cin >> N;
    long long ans = N-1;
    for(long long m=1;m*m<=N;m++){
        if(N%m==0) ans = min(ans, (m-1)+(N/m-1));
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long

long long a[1000010],t1[1000010],t2[1000010],ans;
int cnt,prime[1000000],n;
bool check[1000010];
unordered_map<long long,int> contain;
unordered_set<long long> visit;

void init()
{
	for(int i=2;i<=3000;++i)
	{
		if(!check[i])
		{
			prime[++cnt]=i;
		}
		for(int j=1;j<=cnt && (long long)i*prime[j]<=3000;++j)
		{
			check[i*prime[j]]=true;
			if(i%prime[j]==0)
				break;
		}
	}
}

inline bool issqr(long long a)
{
	long long sqrroot=sqrt(a);
	return sqrroot*sqrroot==a;
}

signed main()
{
	init();
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",a+i);
		t1[i]=t2[i]=1;
		for(int j=1;j<=cnt;++j)
		{
			long long tot=0;
			while(a[i]%prime[j]==0)
			{
				a[i]/=prime[j];
				++tot;
			}
			tot%=3;
			if(tot==1){t1[i]*=prime[j];t2[i]*=prime[j]*prime[j];}
			else if(tot==2){t1[i]*=prime[j]*prime[j];t2[i]*=prime[j];}
			if(a[i]==1)break;
		}
		t1[i]*=a[i];
		if(issqr(a[i]))t2[i]*=sqrt(a[i]);else t2[i]*=a[i]*a[i];
		++contain[t1[i]];
	}
	for(int i=1;i<=n;++i)
	{
		if(visit.find(t1[i])!=visit.end())continue;
		visit.insert(t1[i]);
		visit.insert(t2[i]);
		if(t1[i]^t2[i])
		{
			ans+=max(contain[t1[i]],contain[t2[i]]);
		}
		else
		{
			++ans;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 24904
#include<cstdio>
#include<cmath>

const int N = 100000;
char a[N];
char b[N];
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a == b+c || b == a+c || c == a+b)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

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

int main(){
  
  char b;
  
  cin >> b;
    switch(b){
        case 'A':
  		    cout << "T";
            break;

        case 'T':
  		    cout << "A";
            break;
        case 'C':
  		    cout << "G";
            break;
        case 'G':
  		    cout << "C";
        break;
        
    }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a=[int(i) for i in input().split()]
ans=1
flag=0
for i in range(n):
    ans = ans*a[i]
    if a[i]==0:
        flag=1
    if ans>pow(10,18):
        ans=0
if ans==0 and flag==0:
    print("-1")
elif ans==0 and flag==1:
    print("0")
else:
    print(ans)

Measured memory_bytes: 84804
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	string s,t,u;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	cin>>u;
	if(u==s) cout<<a-1<<" "<<b;
	else cout<<a<<" "<<b-1;
	return 0;
}

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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int mi,mx,n,ct1,ct2,as[200010];
int main()
{
	n=read(); as[1]=mx=mi=read();
	for(int i=2;i<=n;i++)
	{
		as[i]=read();
		mx=max(mx,as[i]);
		mi=min(mi,as[i]);
	}
	for(int i=1;i<=n;i++) 
		ct1+=mx==as[i],ct2+=mi==as[i];
	if(mi<mx-1){printf("No\n"); return 0;}
	if(mi==mx)
	{
		if(mx==n-1) printf("Yes\n");
		else if(mx<=n/2) printf("Yes\n");
		else printf("No\n");
	}
	else 
	{
		if(ct2+1<=mx&&mx<=ct2+ct1/2) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          string w = Input.ScanStr();
          Console.WriteLine(w.Length>=4 && w.Substring(0,4)=="YAKI" ? "Yes" : "No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(void)
{
  int n,i;
  cin>>n;
  vector<int>h(n);
  for(i=0;i<n;i++)
  {
    cin>>h[i];
  }
  vector<int>dp(n);
  dp[0]=0;dp[1]=abs(h[1]-h[0]);
  for(i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout<<dp[n-1];
  return 0;
}


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

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

  string str = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != str[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>

using namespace std;
int main(){


  int x[7];
  for(int i=1;i<7;i++){
    cin >> x[i];
  }

  int n=0;
  cin >> n;

  bool t[7][7];
  memset(t,0,7*7*sizeof(bool));
  t[1][2] = true;
  t[2][3] = true;
  t[3][1] = true;

  for(int i=0;i<n;i++){
    int top=0,front=0;
    cin >> top >> front;

    int top_i=0,front_i=0;

    for(int j=1;j<7;j++){
      if(top == x[j]) top_i = j;
      if(front == x[j]) front_i = j;
    }

    bool rev = false;
    if(top_i > 3){
      top_i = 7 - top_i;
      rev = !rev;
    }
    if(front_i > 3){
      front_i = 7 - front_i;
      rev = !rev;
    } 
    if( ! t[top_i][front_i]) rev = !rev;

    int result = 0;
    for(int j=1;j<4;j++){
      if(j!= top_i && j!=front_i){
        result = j;
        break;
      }
    }

    if(rev) cout << x[7-result] << endl;
    else cout << x[result] << endl;

  }

  



}





Measured memory_bytes: 3084
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {
    int N, K, tmp = 0, ans = 0;
    string S;
    vector<int> p;
    cin >> N >> K >> S;
    if(S[0] == '0')
        p.push_back(0);
    for(int i = 0; i < N; ++i) {
        tmp++;
        if(i + 1 != N && S[i] != S[i + 1]) {
            p.push_back(tmp);
            tmp = 0;
            continue;
        }
        if(i + 1 == N)
            p.push_back(tmp);
    }
    // pは1の人→0の人→1の人→…の順
    int count = 0, sum = 0, n = p.size();
    for(int i = 0; i < n; ++i) {
        while(count < K) {
            sum += p[i];
            if(i % 2 == 1)
                count++;
            i++;
            if(i >= n)
                break;
        }
        i--;
        if(i < n - 1) {
            ++i;
            sum += p[i];
        }
        ans = max(ans, sum);
        if(i < n - 1) {
            sum -= p[i - 2 * K] + p[i - 2 * K + 1];
            count--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1020
a, b, c, x = [int(input()) for _ in range(4)]
ans = 0

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

print(ans)

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        String[] tmp = br.readLine().split(" ");
        int ans = 0;
        int max = 0;
        for(int i = 0; i < n; i++) {
            int h = Integer.parseInt(tmp[i]);
            if(max <= h) {
                ans++;
                max = h;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	double a, b;
	cin >> a >> b;
	if (a > b) cout << "GREATER" << endl;
	else if (a < b) cout << "LESS" << endl;
	else cout << "EQUAL" << endl;
	

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(){
    int a, b, angle;
    double s, l, h;

    scanf("%d %d %d", &a, &b, &angle);
    h=b*sin(angle*M_PI/180.0);
    s=a*h/2;
    l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0)));
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<string,int> m;
  priority_queue<int> pq;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    if(m.count(S)){
      m.at(S)++;
      pq.push(m.at(S));
    }else{
      m[S]=1;
      pq.push(m.at(S));
    }
  }
  for(auto p:m){
    if(p.second==pq.top()){
      cout << p.first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 25972
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

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

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

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

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

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

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

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    int x[100],y[100],h[100];
    REP(i,N)cin>>x[i]>>y[i]>>h[i];
    int Cx,Cy,H;
    REP(i,101)REP(j,101){
        Cy = i;
        Cx = j;

        VI hd;
        int max_h = 1e9 + 100;
        REP(k,N){
            if(h[k] == 0){
                max_h = min(max_h, abs(x[k]-Cx) + abs(y[k]-Cy));
            }else{
                hd.PB(abs(x[k]-Cx) + abs(y[k]-Cy) + h[k]);
            }
        }

        bool all = true;
        H = hd[0];
        REP(k,hd.size()){
            if(hd[k] != H){
                all = false;
                break;
            }
        }
        if(all && H <= max_h){
            goto END;
        }
    }
END:
    printf("%d %d %d\n", Cx, Cy, H);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b, c, x;
	scanf("%d %d %d", &a, &b, &c);

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

	printf("%d %d %d\n", a, b, c);

	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	ll Ai[N];
	rep(i, N) {
		cin >> Ai[i];
	}

	ll maxValue = 0;
	ll maxIndex = 0;

	for (int i = 0; i < N; i++) {
		if (abs(maxValue) < abs(Ai[i])) {
			maxValue = Ai[i];
			maxIndex = i;
		}
	}
	vector<string> answers;

	if (maxValue > 0) {
		for (int i = 1; i < N; i += 1) {
			while (Ai[i] < Ai[i - 1]) {
				Ai[i] += maxValue;
				answers.push_back(to_string(maxIndex + 1) + " " + to_string(i + 1));
				if (Ai[i] > maxValue) {
					maxValue = Ai[i];
					maxIndex = i;
				}
			}
		}
	} else {
		for (int i = N - 2; i >= 0; i--) {
			while (Ai[i] > Ai[i + 1]) {
				Ai[i] += maxValue;
				answers.push_back(to_string(maxIndex + 1) + " " + to_string(i + 1));
				if (Ai[i] < maxValue) {
					maxValue = Ai[i];
					maxIndex = i;
				}
			}
		}
	}
	cout << answers.size() << endl;
	for (auto ans : answers) {
		cout << ans << endl;
	}
	return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

int main(void) {

    ll N;
    cin >> N;
    vector<vecll> abc(N + 1, vecll(3));

    REP(i, 1, N + 1) {
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }

    vector<vecll> dp(N + 1, vecll(3, 0));

    for (int i = 0; i < N; ++i) {
        for (int k = 0; k < 3; ++k) {
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][(k + 1) % 3] + abc[i + 1][k]);
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][(k + 2) % 3] + abc[i + 1][k]);
        }
    }

    ll ans = max(dp[N][0], max(dp[N][1], dp[N][2]));

    cout << ans << endl;

    return 0;
}


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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    ll a,b;
    cin >> a >> b;

    string aa = "",bb = "";


    REP(i,a)aa += (char)b + '0';
    REP(i,b)bb += (char)a + '0';

    vector<string> ans;
    ans.push_back(aa);
    ans.push_back(bb);
    sort(all(ans));

    cout << ans[0] << endl;
    return 0;
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    const auto a = Read(n);
    ll m;
    cin >> m;
    const auto b = Read(m);

    auto ans = vi();
    set_union(ALL(a), ALL(b), inserter(ans, ans.end()));

    DumpRow(ans);

    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Odd 1

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

  
  bool ans = true;
  rep(i,S.size()){
   if((i + 1) % 2 == Odd){
     if(!((S.at(i) == 'R') || (S.at(i) == 'U') || (S.at(i) == 'D'))) ans = false;
   }else{
     if(!((S.at(i) == 'L') || (S.at(i) == 'U') || (S.at(i) == 'D'))) ans = false;
   }
  }
    
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


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

typedef long long int ll;
typedef pair <ll, ll> pll;

const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;

int main() {
	ll a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
	return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if (x < -100 || y > 100 || W <= 0 || r > 100) {
			System.out.println("値は−100≤x,y≤100,0<W,H,r≤100で入力してください");
		} else if ((x - r) >= 0 && (W - x) >= r && (y - r) >= 0 && (H - y) >= r) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26080
K, N = map(int, input().split())

A = input().split()

maxv = abs(int(A[0]) + K - int(A[N-1]))

for i in range(N):
    try:
        if abs(int(A[i]) - int(A[i+1])) > maxv:
            maxv = abs(int(A[i]) - int(A[i+1]))
    except IndexError:
        break

print(K-maxv)

Measured memory_bytes: 18508
#include<stdio.h>
int main(void){
    int a[31],b[31]={0},i,j,c;
    for(i=0;i<28;i++){
        scanf("%d",&a[i]);
        c=a[i];
        b[c]=1;
    }
    for(j=1;j<=30;j++){
        if(b[j]!=1){
            printf("%d",j);
            printf("\n");
        }
    }

return 0;
}

Measured memory_bytes: 600
import sys
input = sys.stdin.readline

n,k=map(int,input().split())
vr,vs,vp=map(int,input().split())
t=list(input())

rr=0
ss=1
pp=2

vsum=0
for i in range(k):
#    ti=[t[ii] for ii in range(n) if ii%k==i]
#    ni=len(ti)
#    dp=[[0]*3 for i in range(ni+1)]
    dpir=0
    dpis=0
    dpip=0
    for i2 in range(i,n,k):
        if t[i2]=="r":
#            dp[i2+1][rr]=max(dp[i2][ss],dp[i2][pp])
#            dp[i2+1][ss]=max(dp[i2][pp],dp[i2][rr])
#            dp[i2+1][pp]=max(dp[i2][rr]+vp,dp[i2][ss]+vp)
            dpir2=max(dpis,dpip)
            dpis2=max(dpip,dpir)
            dpip2=max(dpir,dpis)+vp
        elif t[i2]=="s":
#            dp[i2+1][rr]=max(dp[i2][ss]+vr,dp[i2][pp]+vr)
#            dp[i2+1][ss]=max(dp[i2][pp],dp[i2][rr])
#            dp[i2+1][pp]=max(dp[i2][rr],dp[i2][ss])
            dpir2=max(dpis,dpip)+vr
            dpis2=max(dpip,dpir)
            dpip2=max(dpir,dpis)
        elif t[i2]=="p":
#            dp[i2+1][rr]=max(dp[i2][ss],dp[i2][pp])
#            dp[i2+1][ss]=max(dp[i2][pp]+vs,dp[i2][rr]+vs)
#            dp[i2+1][pp]=max(dp[i2][rr],dp[i2][ss])
            dpir2=max(dpis,dpip)
            dpis2=max(dpip,dpir)+vs
            dpip2=max(dpir,dpis)
        dpir=dpir2
        dpis=dpis2
        dpip=dpip2
#    vsum+=max(dp[ni][rr],dp[ni][ss],dp[ni][pp])
    vsum+=max(dpir,dpis,dpip)
print(vsum)
     

Measured memory_bytes: 78632
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

int main() {
    Int n;
    string s;
    cin >> n >> s;
    if (s.front() == 'W' || s.back() == 'W') {
        dump(0);
        return 0;
    }
    Int cnt = 0;
    for (Int i = 0; i < 2 * n; i++) {
        if (s[i] == 'W') cnt++;
    }
    if (cnt % 2 == 1) {
        dump(0);
        return 0;
    }
    vector<char> d(2 * n);
    d[0] = 'L';
    for (Int i = 0; i < 2 * n - 1; i++) {
        if (s[i] == s[i + 1]) {
            d[i + 1] = d[i] == 'L' ? 'R' : 'L';
        }
        else {
            d[i + 1] = d[i] == 'R' ? 'R' : 'L';
        }
    }
    Int res = 0;
    Int r = 0;
    Int add = 1;
    for (Int i = 2 * n - 1; i >= 0; i--) {
        if (d[i] == 'R') {
            r++;
        }
        else {
            add = (add * r) % mod;
            r--;
        }
    }
    if (r != 0) {
        dump(0);
        return 0;
    }
    res += add;
    res %= mod;
    for (Int i = 1; i <= n; i++) {
        res = (res * i) % mod;
    }
    dump(res % mod);
    return 0;
}

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

using namespace std;

const int maxn = 3001;

int dp[maxn][maxn];

char s[maxn], t[maxn], p[maxn][maxn];

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

    cin >> (s+1);
    int n = strlen(s+1);
    cin >> (t+1);
    int m = strlen(t+1);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++){
            if(dp[i][j-1] < dp[i-1][j]){
                dp[i][j] = dp[i-1][j];
                p[i][j] = 'U';
            }
            else dp[i][j] = dp[i][j-1], p[i][j] = 'L';

            if(s[i]==t[j] && dp[i][j] < dp[i-1][j-1] + 1){
                dp[i][j] = dp[i-1][j-1] + 1;
                p[i][j] = 'D';
            }
        }

    string ans = "";
    while(n && m){
        if(p[n][m] == 'D'){
            ans = s[n] + ans;
            n--, m--;
            continue;
        }
        if(p[n][m] == 'U') n--;
        else m--;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 44288