akhauriyash/Code-Regression huggingface dataset:
import Data.Char
import Data.IORef
import Control.Monad
import Data.List

count :: (a -> Bool) -> [a] -> Int
count p = foldr (\a acc -> if p a then acc + 1 else acc) 0

-- '0' -> 0, '1' -> 1, ..., '9' -> 9
charToInt :: Char -> Int
charToInt a = ord a - ord '0'

-- 各桁の和
sumOfDigits :: Int -> Int
sumOfDigits = sum . map charToInt . show

interleave :: [a] -> [a] -> [a]
interleave (x:xs) (y:ys) = x : y : interleave xs ys

uninterleave :: [a] -> ([a], [a])
uninterleave = foldr (\x (xs, ys) -> (x:ys, xs)) ([], [])

flipOrder :: Ordering -> Ordering
flipOrder GT = LT
flipOrder LT = GT
flipOrder EQ = EQ

sortRev :: Ord a => [a] -> [a]
sortRev = sortBy (\a b -> flipOrder $ compare a b)

intList :: [Int] -> [Int]
intList = id

int :: Int -> Int
int = id

gridDistance :: Num a => (a, a) -> (a, a) -> a
gridDistance (x1, y1) (x2, y2) = abs (x2 - x1) + abs (y2 - y1)

main = do
  [sx, sy, tx, ty] <- intList . map read . words <$> getLine
  let way1 = replicate (tx - sx) 'R' ++ replicate (ty - sy) 'U'
  let way2 = replicate (tx - sx) 'L' ++ replicate (ty - sy) 'D'
  let way3 = 'D' : replicate (tx - sx + 1) 'R' ++ replicate (ty - sy + 1) 'U' ++ "L"
  let way4 = 'U' : replicate (tx - sx + 1) 'L' ++ replicate (ty - sy + 1) 'D' ++ "R"
  putStrLn $ way1 ++ way2 ++ way3 ++ way4


Measured memory_bytes: 1020
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String str = "abcdefghijklmnopqrstuvwxyz";
		System.out.println(str.substring(str.indexOf(s)+1, str.indexOf(s)+2));
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

	
	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int x = Integer.parseInt(sc.next());
			int y = Integer.parseInt(sc.next());
			if(x == 0 && y ==0){
				break;
			}
			if(x <= y){
				System.out.println(x +" " + y);
			}else{
				System.out.println(y +" " + x);
			}
		}
		
		sc.close();
	}
	

}



Measured memory_bytes: 36456
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int i = 0;
		while (i <= 10000) {
			int x = scanner.nextInt();
			i ++;
			if (x == 0) {
				break;
			} else {
				System.out.println ("Case " + i + ": " + x);
				}
		}
	}
}


Measured memory_bytes: 42524
#include <stdio.h>

#define MAP(a, b, c, d, e, f) \
	{a-1, b-1, c-1, d-1, e-1, f-1},\
	{a-1, c-1, e-1, b-1, d-1, f-1},\
	{a-1, e-1, d-1, c-1, b-1, f-1},\
	{a-1, d-1, b-1, e-1, c-1, f-1}

int dice_map[24][6] = {
	MAP(1, 2, 3, 4, 5, 6),
	MAP(2, 3, 1, 6, 4, 5),
	MAP(3, 6, 5, 2, 1, 4),
	MAP(4, 2, 1, 6, 5, 3),
	MAP(5, 1, 3, 4, 6, 2),
	MAP(6, 5, 3, 4, 2, 1)
};
#undef MAP

struct dice {
	int label[6];
	int map[24][6];
};

void
read_dice(struct dice *a)
{
	for (int i = 0; i < 6; i++)
		scanf("%d", &a->label[i]);
}

void
map_dice(struct dice *a)
{
	for (int i = 0; i < 24; i++)
		for (int j = 0; j < 6; j++) {
			int p = dice_map[i][j];
			a->map[i][j] = a->label[p];
		}
}

int
eq_dice(struct dice *a, struct dice *b)
{
	int j;

	for (int i = 0; i < 24; i++) {
		for (j = 0; j < 6; j++)
			if (b->label[j] != a->map[i][j])
				break;
		if (j == 6)
			return 1;
	}
	return 0;
}

int
main(void)
{
	int n;
	struct dice a[100] = {};

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		read_dice(&a[i]);
		map_dice(&a[i]);
	}

	for (int i = 0; i < n-1; i++)
		for (int j = i + 1; j < n; j++)
			if (eq_dice(&a[i], &a[j])) {
				printf("No\n");
				return 0;
			}

	printf("Yes\n");

	return 0;
}



Measured memory_bytes: 2140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xyz = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            Console.WriteLine($"{xyz[2]} {xyz[0]} {xyz[1]}");
        }
    }
}

Measured memory_bytes: 28236
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

ll a, b, k;
vector <ll> s;
int main() {
	cin >> a >> b >> k;
	if (b - a + 1 < k * 2) {
		FOR(i, a, b + 1)s.push_back(i);
	}
	else {
		FOR(i, a, a + min(b - a + 1, k)) s.push_back(i);
		FORR(i, b, b - min(b - a + 1, k) + 1)s.push_back(i);
	}
	sort(ALL(s));
	REP(i, s.size()) cout << s[i] << endl;
}
	


Measured memory_bytes: 256
dic={}
n=int(input())
su=0
for i in input().split():
    i=int(i)
    if i in dic.keys():
        dic[i]+=1
    else:
        dic[i]=1
    su+=i
q=int(input())
for cas in range(q):
    b,c=map(int,input().split())
    if b in dic.keys():
        su+=(c-b)*dic[b]
        if c in dic.keys():
            dic[c]+=dic[b]
        else:
            dic[c]=dic[b]
        dic[b]=0
    print(su)



Measured memory_bytes: 21708
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n,k;
	int a[100100];
	ll dp[100100];
	cin>>n>>k;
	REP(i,n)
		cin>>a[i];
	REP(i,n)
		dp[i]=1000000007;
	dp[0]=0;
	REP(i,n-1)
	{
		for(int j=1;j<=k;j++)
		{
			dp[i+j]=min(dp[i+j],abs(a[i+j]-a[i])+dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int ans;
int a, b, c;
int main() {
  scanf ("%d%d%d", &a, &b, &c);
  ans = min(a + b, c);
  if (ans != c) ans++;
  ans += b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
q = [list(map(int, input().split())) for i in range(m)]

g = [[] for i in range(n+1)]

for i in range(m):
    a, b, c = q[i]
    g[a].append((b, c))
    g[b].append((a, -c))

people = [-10**10] * (n+1)

flag = 1
for i in range(1, n+1):
    if people[i] != -10**10:
        continue
    q = [i]
    people[i] = 0
    while q:
        now = q.pop()
        for next, dist in g[now]:
            if people[next] == -10**10:
                q.append(next)
                people[next] = people[now] + dist
            else:
                if people[next] == people[now] + dist:
                    continue
                else:
                    flag = 0
                    break
        if flag == 0:
            break

if max(people[1:]) - min(people[1:]) > 10**9:
    flag = 0

if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 95052
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <thread>
#include <random>
#include <deque>
#include <queue>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
	ull w, h;
	cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << (((h * w) - 1ull) / 2ull) + 1ull << endl;
	return 0;
}


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

char map[1010][1010];
int sum[1010][1010][3] = {0};

int conv(char c) {
	
	if(c == 'J') {
		return 0;
	} else if(c == 'O') {
		 return 1;
	} else if(c == 'I') {
		return 2;
	} else {
		return -1;
	}
	
}

void calc(int a, int b, int c, int d) {

	int
		J = sum[c][d][0] - sum[a-1][d][0] - sum[c][b-1][0] + sum[a-1][b-1][0],
		O = sum[c][d][1] - sum[a-1][d][1] - sum[c][b-1][1] + sum[a-1][b-1][1],
		I = sum[c][d][2] - sum[a-1][d][2] - sum[c][b-1][2] + sum[a-1][b-1][2];
	cout << J << " " << O << " " << I << endl;

}

int main() {

	//ifstream cin("in/01.in");
	//ofstream cout("OUTPUT.txt");

	int M, N, K;
	
	cin >> M >> N >> K;
	
	for(int i = 0; i < M; i++) {
		cin >> map[i];
	}
	
	for(int i = 1; i <= M; i++) {
		for(int j = 1; j <= N; j++) {
			for(int k = 0; k < 3; k++) {
				sum[i][j][k] = sum[i-1][j][k] - sum[i-1][j-1][k] + sum[i][j-1][k] + (conv(map[i-1][j-1]) == k);
			}
		}
	}

	for(int i = 0; i < K; i++){
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		calc(a, b, c, d);
	}

	return 0;

}

Measured memory_bytes: 14084
S = list(map(int, input()))
n_len = len(S)

diff_min = 1000
for i in range(n_len-2):
    diff = abs(S[i] * 100 + S[i+1] * 10 + S[i+2] - 753)
    if diff_min > diff:
        diff_min = diff
print(diff_min)

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

using namespace std;

int main() {
    int dp[100000];
    int h[100000];
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    dp[0] = 0;
    const int upper = std::min(K, N);
    for (int i = 1; i < upper; ++i) {
        dp[i] = std::abs(h[0] - h[i]);
    }
    if (N > K) {
        for (int i = K; i < N; ++i) {
            int min_cost = 1e9;
            for (int j = 1; j <= K; ++j) {
                min_cost = std::min(min_cost, std::abs(h[i] - h[i - j]) + dp[i - j]);
            }
            dp[i] = min_cost;
        }
    }

    cout << dp[N - 1] << endl;
}


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


int main(){
  int a,b;
  cin >> a >> b;
  if(a>=13){
    cout << b << endl;
  }else if(a>=6 && a<=12){
    b=b/2;
    cout << b << endl;
  }else{
    b=0;
    cout << b << endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  vector<int>b(n);
  rep(i,n) cin >> b[i];
  vector<int>c(n-1);
  rep(i,n-1) cin >> c[i];
  rep(i,n) a[i]--;
  
  int sum = 0;
  rep(i,n){
    sum += b[a[i]];
  }
  rep(i,n-1){
    if(a[i+1]==a[i]+1) sum += c[a[i]];
    else continue;
  }
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

ll N, Q;
vvl G;
vl cnt;
vl ans;

void dfs(ll now, ll par, ll cx){
    if(ans[now] != -1) return;
    ans[now] = cnt[now] + cx;
    for(ll c : G[now]) if(c != par){
        dfs(c, now, ans[now]);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> Q;
    G = vvl(N);
    rep(i, N-1){
        ll a, b; cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    cnt = vl(N, 0);
    rep(_, Q){
        ll p, x; cin >> p >> x; p--;
        cnt[p] += x;
    }
    ans = vl(N,-1);
    dfs(0, -1, 0);
    
    rep(i, N) cout << ans[i] << " ";
    cout << endstr;
    return 0;
}


Measured memory_bytes: 25856
#include<stdio.h>
#include<string.h>
int main(void)
{
	char s[200001];
	int k,x,y,b,i; 
	scanf("%s",s);
	y=strlen(s);
	i=0;
	for(i=0;i<y;i++){
		if(s[i]=='A') {
			x=i;
			break;
		}
	}
	for(i=0;i<y;i++) {
		if(s[i]=='Z')  {
			k=i;
		}
	}
	b=k-x+1;
	printf("%d\n",b);
	return 0;
}	

Measured memory_bytes: 384
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if a[i] <= b[i]:
        all_enemy = a[i] + a[i + 1]
        if all_enemy > b[i]:
            ans += b[i]
            a[i+1] = all_enemy - b[i]
        else:
            ans += all_enemy
            a[i+1] = 0
    else:
        ans += b[i]

print(ans)

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

using namespace std;

int main(){
        int N;
        cin>>N;
        vector <int> l(N*2);
        for(int i=0;i<N*2;i++){
                cin>>l[i];
        }
        sort(l.begin(), l.end());
        int res=0;
        for(int i=0;i<N*2;i+=2){
                res+=l[i];
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}


void func() {
  LL N;
  cin >> N;
  string S;

  cin >> S;
  LL cnt = 0;
  for (LL i = 1; i < N; i++) {
    if (S[i] == S[i - 1]) {
      cnt++;
    }
  }

  cout << N - cnt;
}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 512
#D問題
NM=40
ABM=10
MM=400

N,M1,M2=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(N):
    a,b,c=map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
cmax=max(C)
CM=N*cmax+10
dp=[[[CM for broop in range(401)] for aroop in range(401)] for nroop in range(N+1)]
dp[0][0][0]=0
for i in range(N):
    for cb in range(401):
        for ca in range(401):
            if dp[i][ca][cb]==CM:
                continue
            dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
            if ca+A[i]<401 and cb+B[i]<401:
                dp[i+1][ca+A[i]][cb+B[i]]=min(dp[i+1][ca+A[i]][cb+B[i]],dp[i][ca][cb]+C[i])

ans=CM
for cb in range(400):
    for ca in range(400):
        CB=cb+1
        CA=ca+1
        if CA*M2 == CB*M1:
            ans=min(ans,dp[N][CA][CB])

if ans == CM:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 60040
import java.util.Scanner

fun main(args:Array<String>){
    val cin = Scanner(System.`in`)

    while(true){
	val h = cin.nextInt()
	val w = cin.nextInt()
	
	if(h == 0 || w == 0){
	    break
	}else{
	    for(i in 1..h){
		for(j in 1..w){
		    if(i == 1 || i == h || j == 1 || j == w){
			print("#")
		    }else{
			print(".")
		    }
		}
		print("%n".format())
	    }
	    print("%n".format())
	}
    }
}



Measured memory_bytes: 35300
#include <iostream>
using namespace std;
int main() {
	int X_Sandglass,t_time,answer;
	cin >> X_Sandglass >> t_time;
	answer = X_Sandglass - t_time;
	if (answer < 0) { cout << 0 << endl; }
	else { cout << answer << endl; }
	return 0;
}

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

using namespace std;

int main()

{

	int k,a,b,i;
	cin>>k>>a>>b;

	for(i=a;i<=b;i++)

	{

		if(i%k==0)

		break;

	}

	if(i==b+1)

	cout<<"NG"<<endl;

	else

	cout<<"OK"<<endl;

	return 0;

}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

struct edge {
    int to;
    int weight;
};

vector<edge> G[200010];
bool visit[100010];
int d[100010];

bool dfs(int v, int dist) {

    if(visit[v]) {
        if(d[v] != dist) {
            return true;
        }
        else {
            return false;
        }
    }

    visit[v] = true;
    d[v] = dist;
    rep(i, G[v].size()) {
        if(dfs(G[v][i].to, d[v] + G[v][i].weight)) {
            return true;
        }
    }

    return false;
}

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

    rep(i, m) {
        int L, R, D;
        cin >> L >> R >> D;
        L--;  R--;
        G[L].push_back({R,D});
        G[R].push_back({L,-D});
    }

    rep(i, n) {
        if(!visit[i] && dfs(i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 14464
#include<stdio.h>

int main()
{
	int a,b,c,x,y,z,o,p;
	scanf("%d %d %d\n",&a,&b,&c);
	
	x=a;y=b;z=c;
	
	if(x>y)
	{x=b;y=a;}
	if(y>z)
	{o=y;y=c;z=o;}
	if(x>y)
	{p=x;x=y;y=p;}
	
	printf("%d %d %d\n",x,y,z);
	
	return 0;
	
	
}

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

using namespace std;

int main(int argc,char* argv[]){
  int n,a,b,c;
  cin >> n;
  a = n%10;
  n /= 10;
  b = n%10;
  c = n/10;
  if(c == 1) n = 900;
  else n = 100;
  if( b == 1) n += 90;
  else n += 10;
  if( a == 1) n += 9;
  else n += 1;
  cout << n << endl;
  
  return 0;
}


Measured memory_bytes: 256
from itertools import product,chain
from functools import reduce
from operator import xor
N,M = map(int,input().split())

lights = list(sorted(map(int,input().split()[1:])) for _ in range(M))
P = list(map(int,input().split()))

cnt = 0
for c in product((False,True), repeat=N):
    if all(not reduce(xor, (c[i-1] for i in l))^p for l,p in zip(lights, P)):
        cnt += 1

print(cnt)


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <unordered_map>

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

ll N,M,ans;
const ll nmax=8;
const ll mmax=8*(8-1)/2;
ll graph[nmax+1][nmax+1];
bool visited[nmax],allvisited;

void dfs(ll c){
    allvisited=true;
//    cout<<N<<" "<<M<<endl;
    for(ll i=1;i<=N;i++){
        if(!visited[i]){
            allvisited=false;
            break;
        }
    }
    if(allvisited){
//        cout<<"aaa"<<endl;
        ans++;
        //return;
    }
    for(ll i=1;i<=N;i++){
        if(graph[c][i]==1&&(!visited[i])){
            visited[i]=true;
            dfs(i);
            visited[i]=false;
        }
    }
}

int main(){
    cin>>N>>M;
    ll a,b;
    for(int i=0;i<M;i++){
        cin>>a>>b;
        graph[a][b]=graph[b][a]=1;
    }
    visited[1]=true;
    dfs(1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;
struct edge {
  int to, cost;
};
#define MAX_V 100010
vector<edge> G[MAX_V];
int color[MAX_V];

void dfs(int v, int c) {
  color[v] = c;
  vector<edge> e = G[v];
  for(int i = 0; i < e.size(); ++i) {
    if(color[e[i].to] != 0) continue;
    if(color[e[i].to] == 0 && e[i].cost % 2 != 0) dfs(e[i].to, -c);
    if(color[e[i].to] == 0 && e[i].cost % 2 == 0) dfs(e[i].to, c);
  }
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  rep(i, 0, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    edge e;
    e.to = --v;
    e.cost = w;
    G[--u].push_back(e);
    e.to = u;
    e.cost = w;
    G[v].push_back(e);
  }
  rep(i, 0, n) {
    if(color[i] == 0) dfs(i, 1);
  }
  rep(i, 0, n) {
    if(color[i] == -1) cout << 0 << endl;
    else cout << 1 << endl;
  }
}


Measured memory_bytes: 10752
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
		int max = Math.max(a,Math.max(b, c));
        int min = Math.min(a, Math.min(b, c));
        int mid = a + b + c - max - min;
      
      	int cnt = max - mid;
        min += cnt;
      	cnt += (max - min + 1) / 2;
        if((max - min) % 2 != 0) cnt++;
        System.out.println(cnt);
    }
}


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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

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

    int A[N];
    rep(i, N) cin >> A[i];
    int B[N];
    rep(i, N) cin >> B[i];

    rep(i, N - 1) A[i + 1] += A[i];
    rep(i, N - 1) B[N - 2 - i] += B[N - 1 - i];

    int ans = 0;
    rep(i, N) ans = max(ans, A[i] + B[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define no {cout<<"NO"<<endl;return;}
#define yes {cout<<"YES"<<endl;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=3e5;
int arr[maxn+2];

set<pii> st;
int x[maxn+2]={0},y[maxn+2]={0};
int max_a=0,max_b=0;
void solve(){

    int h,w,m,a,b,c;
    cin>>h>>w>>m;
    while(m--){
        cin>>a>>b;
        x[a]++;
        y[b]++;
        st.insert(pii(a,b));
        if(x[a]>max_a){
            max_a=x[a];
        }
        if(y[b]>max_b){
            max_b=y[b];
        }
    }
    set<int> vx,vy;
    for(int i=1;i<=h;i++){
        if(x[i]==max_a) vx.insert(i);
    }
    for(int j=1;j<=w;j++){
        if(y[j]==max_b) vy.insert(j);
    }
    ll tot=vx.size()*vy.size();
    for(auto pp:st){
        if(vx.count(pp.first) && vy.count(pp.second)) tot--;
    }
    if(tot==0) cout<<max_a+max_b-1;
    else cout<<max_a+max_b;
}

int main(){
    IO

    //TEST
    solve();

    return(0);
}



Measured memory_bytes: 48124
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=998244353;
ll a[100009];
ll dis[100009];
ll ksm(ll x,ll y){
	ll ans=1;
	while(y){
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y=y>>1;
	}
	return ans%mod;
}
int main(){
	ll n;scanf("%lld",&n);
	for(ll i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		dis[a[i]]++;
	}
	if(a[1]!=0) {
		cout<<"0";return 0;
	}
	ll cnt=1;
	ll ans=1;
	for(ll i=1;dis[i];i++){
		ans=ans*ksm(dis[i-1],dis[i])%mod;
		cnt+=dis[i];
	}
	if(cnt==n) cout<<ans;
	else cout<<"0";
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse4")
#include <cassert>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long  ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
mt19937 rnd(random_device{}());
#define all(a) a.begin(), a.end()
#define fr(i, n) for (ll i = 0; i < n; ++i)
#define fr1(i, n) for (ll i = 1; i <= n; ++i)
const int N = 1000001;
void solve() {
    string s; cin >> s;
    int ans = 0;
    if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') ans = 1;
    if (s[0] == s[1] && s[1] == 'R') ans = 2;
    if (s[1] == s[2] && s[2] == 'R') ans = 2;
    if (s[1] == 'R' && s[2] == 'R' && s[0] == 'R') ans = 3;
    cout << ans;
}
void pre_calc() {
}
int main() {
    pre_calc();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#endif
    int tst = 1;
    if (tst != 1) cin >> tst;
    while (tst--)
        solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> mx(N);
    vector<pii> all(N);
    REP(i, N) {
        int t, d;
        cin >> t >> d;
        t--;
        chmax(mx[t], d);
        all[i] = {d, t};
    }
    sort(RALL(all));

    vector<pii> tops;
    REP(i, N) {
        if (mx[i] > 0) tops.push_back({mx[i], i});
    }
    sort(RALL(tops));

    int r = 0;
    map<int, int> mp;
    int S = 0;
    REP(i, K) {
        S += all[i].first;
        if (r < SZ(tops) && tops[r].second == all[i].second) {
            r++;
        }
        mp[all[i].second]++;
    }

    int ans = S + r * r;

    if (r < SZ(tops)) {
        REPR(i, K - 1) {
            if (mp[all[i].second] == 1) {
                continue;
            }
            mp[all[i].second]--;
            S -= all[i].first;
            S += tops[r].first;
            mp[tops[r].second]++;
            r++;
            chmax(ans, S + r * r);
            if (SZ(tops) == r) break;
        }
        chmax(ans, S + r * r);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 7540
'use strict';
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
        const r = parseInt(input[0]);
        if(r < 1200){
                console.log("ABC");
        }else if(r < 2800){
                console.log("ARC");
        }else{
                console.log("AGC");
        }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

N,M,L = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*M]
Q = int(input())
ST = [list(map(int,input().split())) for _ in [0]*Q]


INF = (L+1)*N
d = [[INF]*N for _ in [0]*N]
for i in range(N):
    d[i][i] = 0
for a,b,c in ABC:
    a-=1;b-=1
    d[a][b] = c
    d[b][a] = c

def Warshall_Floyd(d,N=None):
    if N==None : N = len(d)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])

Warshall_Floyd(d,N)

d2 = [None]*N
for i,row in enumerate(d):
    d2[i] = [1 if e<=L else INF for e in row]
    d2[i][i] = 0

Warshall_Floyd(d2,N)

for s,t in ST:
    s-=1;t-=1
    ans = (d2[s][t]%INF)-1
    print(ans)


Measured memory_bytes: 71644
import scala.io.StdIn.readLine
class Stack[T](val stack: List[T]) {
    def push(e: T): Stack[T] = new Stack[T](e :: stack)
    def pop(): Stack[T] = stack match {
        case Nil => new Stack[T](Nil)
        case x :: xs => new Stack[T](xs)
    }
    def top(): Option[T] = stack match {
        case Nil => None
        case x :: xs => Option(x)
    }
    def isEmpty(): Boolean = stack == Nil
    def toList(): List[T] = stack
}
object Stack {
    def apply[T]() = new Stack[T](Nil)
}
object Main {
    def main(args: Array[String]): Unit = {
        val input = readLine.split("").toList
        val (areas, sum) = calcArea(input)
        if (sum == 0) {
            println("0")
            println("0")
        } else {
            println(sum)
            println(areas.length + " " + areas.mkString(" "))
        }
        
    }
    def calcArea(input: List[String]): (List[Int], Int) = {
        def go(list: List[(String, Int)], stack1: Stack[Int], stack2: Stack[(Int, Int)], sum: Int): (List[Int], Int) = list match {
            case Nil => (stack2.toList.map(_._2).reverse, sum)
            case (x @ (symbol, index)) :: xs => symbol match {
                case "_" => go(xs, stack1, stack2, sum)
                case "\\" => go(xs, stack1.push(index), stack2, sum)
                case "/" => stack1 match {
                    case s1 if s1.isEmpty => go(xs, stack1, stack2, sum)
                    case _ => {
                        val top = stack1.top.get
                        val area = index - top
                        go(xs, stack1.pop, sumStack(stack2, top, area), sum + area)
                    }
                }
            }
        }
        def sumStack(stack2: Stack[(Int, Int)], index: Int, area: Int): Stack[(Int, Int)] = stack2 match {
            case s if stack2.isEmpty => stack2.push((index, area))
            case s => s.top.get match {
                case (i, a) if i > index => sumStack(s.pop, index, area + a)
                case _ => s.push((index, area))
            }
        }
        go(input.zipWithIndex, Stack[Int](), Stack[(Int, Int)], 0)
    }
}


Measured memory_bytes: 50940
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 2e6 + 10 , P = 1e9 + 7;
int x[6] , y[6] , fac[N] = {1} , ifac[N];
int inv(int x){return x==1?1:P-ll(P/x)*inv(P%x)%P;}
inline void pp(int &x,int d){if((x+=d)>=P)x-=P;}
inline int way(int x,int y){
    if(x<0||y<0) return 0;
    return ll(fac[x+y])*ifac[x]%P*ifac[y]%P;
}
inline int way(int sx,int sy,int tx,int ty){
    return way(tx-sx,ty-sy);
}

int solve(int sx,int sy,int tx,int ty){
    int res=0;
    int x0=x[2],x1=x[3],y0=y[2],y1=y[3];
    for(int i=x0;i<=x1;++i) {
        pp(res,P-ll(way(sx,sy,i,y0-1))*way(i,y0,tx,ty)%P*(i+y0)%P);
        pp(res,ll(way(sx,sy,i,y1))*way(i,y1+1,tx,ty)%P*(i+y1+1)%P);
    }
    for(int j=y0;j<=y1;++j) {
        pp(res,P-ll(way(sx,sy,x0-1,j))*way(x0,j,tx,ty)%P*(x0+j)%P);
        pp(res,ll(way(sx,sy,x1,j))*way(x1+1,j,tx,ty)%P*(x1+1+j)%P);
    }
    //cout << sx << " " << sy << " " << tx << " " << ty << " " << res << endl;
    return res;
}

int main(){
    rep(i,1,N) fac[i]=ll(fac[i-1])*i%P;
    ifac[N-1]=inv(fac[N-1]);
    per(i,1,N) ifac[i-1]=ll(ifac[i])*i%P;
    rep(i,0,6) scanf("%d",x+i);
    rep(i,0,6) scanf("%d",y+i);
    x[0]--,y[0]--,x[5]++,y[5]++;
    int ans=0;
    rep(ai,0,2) rep(aj,0,2) rep(bi,0,2) rep(bj,0,2) {
        int t=solve(x[ai],y[aj],x[4+bi],y[4+bj]);
        if(ai^aj^bi^bj) pp(ans,P-t);
        else pp(ans,t);
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
      ll n;
      cin>>n;
      ll a[5];
      rep0(i,5) cin>>a[i];
      sort(a,a+5);
      cout<<(n+a[0]-1)/a[0]+4<<endl;
      return 0;
}

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

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m), c(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i] >> c[i];

    vector<P> p;
    REP(i, m)
    {
        p.pb(make_pair(c[i], b[i]));
    }

    sort(all(a));
    sort(all(p));
    vector<int> num(m);
    REP(i, m)
    {
        num[i] = distance(a.begin(), lower_bound(all(a), p[i].first));
    }
    
    vector<int> ans;
    int index = m - 1;
    REP(i, n)
    {
        if(p[index].first <= a[n-i-1]) continue;
        ans.push_back(p[index].first);
        p[index].second--;
        if(p[index].second == 0) index--;
    }

    LL ansnum = 0;
    REP(i, n) ansnum += a[i];
    vector<int> ruiseki(n+5, 0);
    vector<int> ruiseki2(n+5, 0);
    REP(i, n+1) ruiseki[i+1] += ruiseki[i] + a[i];
    REP(i, ans.size()) ruiseki2[i+1] += ruiseki2[i] + ans[i];

    REP(i, ans.size())
    {
        ansnum = max(ruiseki2[ans.size() - i] + ruiseki[n] - ruiseki[ans.size() - i], ansnum);
    }
   
    cout << ansnum << endl;
}

Measured memory_bytes: 7536
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

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

using namespace std;

map<int, int> mpp;

int main(){
    int n;

    cin >> n;

    rep(i, n){
        int a;
        cin >> a;
        mpp[a]++;
    }
    
    int over = 0;
    int less = 0;
    for(auto itr = mpp.begin(); itr != mpp.end(); itr++){
        if( itr->first < itr->second ) over += itr->second - itr->first;
        else if( itr->first > itr->second ) less += itr->second;
    }
    cout << min(over + less, n) << endl;

    return 0;
}

Measured memory_bytes: 4736
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lis = [a, b, c, d, e]
x = min(lis)
if n%x == 0:
    x = n//x
else:
    x = n//x + 1
print(5 + x-1)

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

int main()
{
	int n, t;
	int mc = 10000;
	cin >> n >> t;
	for (int i = 0; i < n; i++)
	{
		int c, u;
		cin >> c >> u;
		if (u <= t) mc = min(c, mc);
	}
	if (mc == 10000) cout << "TLE" << endl;
	else cout << mc << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 2e5+5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

char x[20];

int main()
{
        scanf("%s",x+1);
    for(int i=1;i<=4;i++)
    {
    	printf("%c",x[i]);
    }
    printf(" ");
    for(int i=5;i<=12;i++)
    {
    	printf("%c",x[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int rgt(int t,int f){
	if(t==1){
		if(f==3) return 5;
		if(f==5) return 4;
		if(f==4) return 2;
		if(f==2) return 3;
	}
	if(t==2){
		if(f==3) return 1;
		if(f==1) return 4;
		if(f==4) return 6;
		if(f==6) return 3;
	}
	if(t==3){
		if(f==1) return 2;
		if(f==2) return 6;
		if(f==6) return 5;
		if(f==5) return 1;
	}
	if(t==4){
		if(f==1) return 5;
		if(f==5) return 6;
		if(f==6) return 2;
		if(f==2) return 1;
	}
	if(t==5){
		if(f==3) return 6;
		if(f==6) return 4;
		if(f==4) return 1;
		if(f==1) return 3;
	}
	if(t==6){
		if(f==3) return 2;
		if(f==2) return 4;
		if(f==4) return 5;
		if(f==5) return 3;
	}
}
int main(){
	while(true){
		int n;
		scanf("%d",&n);
		if(!n) break;
		int height[210][210]={},up[210][210]={};
		int med=105;
		rep(i,n){
			int t,f,r,x=med,y=med;
			scanf("%d%d",&t,&f);
			r=rgt(t,f);
//			cout << t << " " << f << " " << r << endl;
			while(true){
				int di=-1,num=-1;
				int rot[4]={f,r,7-f,7-r};
				rep(j,4){
					int nx=x+dx[j],ny=y+dy[j];
					if(rot[j]<4 || height[x][y]<=height[nx][ny]) continue;
					if(num<rot[j]) num=rot[j],di=j;
				}
				if(di==-1){
					height[x][y]++;
					up[x][y]=t;
//					cout << x-med << " " << y-med << endl;
					break;
				}
				x+=dx[di],y+=dy[di];
				int tc,fc,rc;
				if(di==0) tc=7-f,fc=t,rc=r;
				if(di==1) tc=7-r,fc=f,rc=t;
				if(di==2) tc=f,fc=7-t,rc=r;
				if(di==3) tc=r,fc=f,rc=7-t;
				t=tc,f=fc,r=rc;
			}
		}
		int cnt[6]={};
		rep(i,210) rep(j,210) if(up[i][j]>0) cnt[up[i][j]-1]++;
		rep(i,5) printf("%d ",cnt[i]);
		printf("%d\n",cnt[5]);
	}
}

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

int main() {
  long long int x;
  cin >> x;

  long long int total = 0;

  total += x / 11;

  x = x % 11;
  if(x == 0) {
    cout << 2 * total << endl;
  } else if(x <= 6) {
    cout << 2 * total + 1 << endl;
  } else {
    cout << 2 * total + 2 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
using namespace std;

int main()
{
	int H, W, N;
	cin >> H >> W >> N;

	int Hpaint = N / W;
	int Wpaint = N / H;

	Hpaint += ((float)(N % W) > 0) ? 1 : 0;
	Wpaint += ((float)(N % H) > 0) ? 1 : 0;

	int ans = (Hpaint < Wpaint) ? Hpaint : Wpaint;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first]
#define se second
using namespace std;

ll n,w;
vector<ll> v[5];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
    freopen("out","w",stdout);
#endif
  cin>>n>>w;
  ll one=0;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    if(i==0)one=a;
    v[a-one].push_back(b);
  }
  for(int i=0;i<4;i++){
    sort(v[i].begin(),v[i].end());
    reverse(v[i].begin(),v[i].end());
  }
  for(int i=0;i<4;i++){
    for(int j=1;j<(int)v[i].size();j++){
      v[i][j]+=v[i][j-1];
    }
  }
  ll res=0;
  for(int i=0;i<=(int)v[0].size();i++){
    for(int j=0;j<=(int)v[1].size();j++){
      for(int k=0;k<=(int)v[2].size();k++){
        for(int l=0;l<=(int)v[3].size();l++){
          ll ans=0;
          if(i*one+j*(one+1)+k*(one+2)+l*(one+3)<=w){
            ans+=(i==0?0:v[0][i-1]);
            ans+=(j==0?0:v[1][j-1]);
            ans+=(k==0?0:v[2][k-1]);
            ans+=(l==0?0:v[3][l-1]);
            res=max(ans,res);
          }
        }
      }
    }
  }
  cout<<res<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

using namespace std;

const int INF = 1e9;

int main(){
  int n; cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a, a+n);
  int a_i = a[n-1];
  int t1 = *lower_bound(a, a+n, (a_i+1)/2);
  int t2 = *(lower_bound(a, a+n, (a_i+1)/2) - 1);
  // cout << t1 << " " << t2 << endl;
  int a_j = -1;
  if((a_i+1)/2 - t2 <= t1 - (a_i+1)/2){
    a_j = t2;
  }else{
    a_j = t1;
  }
  cout << a_i << " " << a_j << endl;
}

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

#define lint long long


int main()
{
	lint nn, kk, sum = 0, min, max;
	scanf("%lld %lld", &nn, &kk);
	for(lint ii = kk;ii <= nn;ii++)
	{
		min = (ii - 1) * ii / 2;
		max = ((nn + 1) * nn / 2) - ((nn - ii + 1) * (nn - ii) / 2);
		sum += (max - min + 1);
	}
	
	printf("%lld\n", ((sum+1) % (long long int)(pow(10, 9) + 7)));
	
	return 0;
}

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


int main() {

  int64_t a,b,k;
  cin>>a>>b>>k;

  for(int i=0;i<k;i++){
    if(i%2==0){
      if(a%2!=0)
        a--;

      b+=a/2;
      a/=2;
    }else{
      if(b%2!=0)
        b--;

      a+=b/2;
      b/=2;
    }
  }

  cout<<a<<' '<<b<<endl;

  return 0;
}


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

int main () {
  int N;
  cin >> N;
  if ( N == 1 ) cout << "Hello World" << endl;
  if ( N == 2 ) {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8

N = int(input())
S = input()

# .......####### という形を目指す

#累積和を計算
sum_black = [0]
sum_white = [0]
for n in range(0,N):
    if S[n] == '#': #black
        sum_black.append(sum_black[n] + 1)
        sum_white.append(sum_white[n] + 0)
    else:
        sum_black.append(sum_black[n] + 0)
        sum_white.append(sum_white[n] + 1)

num_min = N
for n in range(0,N+1):
    num = sum_black[n] + (sum_white[-1] - sum_white[n]) 
    if num < num_min:
        num_min = num

print(num_min)


Measured memory_bytes: 19412
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
long long k,ans;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> k;
    for(int i = 1; i <= k; i++)
    {
        for(int g = 1; g <= k; g++)
        {
            for(int j = 1; j <= k; j++)
                ans += __gcd(__gcd(i,g),j);
        }
    }
    cout << ans;
}


Measured memory_bytes: 3616
a,b,k=map(int,input().split())
S=[]

for i in range(k):
    if a+i>b:
        break
    S.append(a+i)
    
for i in range(k):
    if b-i<a:
        break
    S.append(b-i)
    
S=sorted(list(set(S)))
for i in S:
    print(i)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int [] a=new int[5];
		int c=0;
		for(int i=0;i<5;i++)
		{
			a[i]=scan.nextInt();
			if(a[i]==0) c=i;
		}
		System.out.println(c+1);

	}

}


Measured memory_bytes: 26940
package main

import (
	"fmt"
)

// (x^y)をmodで割った余り
func modPow(x, y, mod int) int {
	ret := 1
	x = x % mod
	for i := 0; i < y; i++ {
		ret = (ret * x) % mod
	}
	return ret
}

func main() {
	const mod int = 998244353
	var n int
	fmt.Scan(&n)
	d := make(map[int]int)
	var D int
	var maxDist int = 0
	for i := 0; i < n; i++ {
		fmt.Scan(&D)
		if i == 0 && D != 0 {
			fmt.Println(0)
			return
		}
		if D > maxDist {
			maxDist = D
		}
		d[D]++
	}

	if d[0] != 1 {
		fmt.Println(0)
		return
	}

	ans := 1
	for i := 1; i <= maxDist; i++ {
		ans = (ans * modPow(d[i-1], d[i], mod)) % mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8064