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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int r;

int main() {
	cin >> r;
	
	
	cout << (r < 1200 ? "ABC" : (r < 2800 ? "ARC" : "AGC")) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Bound = 1e9 + 10;

unordered_map<ll , int> mp;
#define cnv(x , y) (ll(x) * Bound + ll(y))

int res[10];
int main()
{
    int h , w , n;cin >> h >> w >> n;
    for(int i = 0;i < n ;i++)
    {
        int a , b;cin >> a >> b;
        for(int j = 0;j < 3;j++)
        {
            if(j >= a)
                break;
            for(int k = 0;k < 3;k++)
            {
                if(k >= b)
                    break;
                if(a - j <= h - 2 && b - k <= w - 2)
                    mp[cnv(a - j , b - k)]++;
            }
        }
    }
    int num = 0;
    for(auto v : mp)
    {
        num++;
        res[v.second]++;
    }
    cout << ll(h - 2) * ll(w - 2) - num << "\n";
    for(int i = 1;i < 10;i++)
        cout << res[i] << "\n";
}



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

int main()
{
  vector<int> a(4);
  for(int i = 0;i < 4;i++) cin >> a[i];
  if(a[0] >= a[3] || a[2] >= a[1]) cout << 0 << endl;
  else{
    sort(a.begin(),a.end());
    cout << (a[2] - a[1]) << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		Scanner sc = new Scanner(System.in);
		//FastReader sc = new FastReader();
		String st = sc.next();
		if(st.charAt(0)=='7'||
		st.charAt(1)=='7'||
		st.charAt(2)=='7')
		System.out.println("Yes");
		else System.out.println("No");
		
		
		
	}
	
	
	/*public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.valueOf(o1.diff).compareTo(Long.valueOf(o2.diff));
		}
	}*/
		
	static class FastReader 
		{ 
		final private int BUFFER_SIZE = 1 << 16; 
		private DataInputStream din; 
		private byte[] buffer; 
		private int bufferPointer, bytesRead; 
  
		public FastReader() 
		{ 
			din = new DataInputStream(System.in); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public FastReader(String file_name) throws IOException 
		{ 
			din = new DataInputStream(new FileInputStream(file_name)); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public String readLine() throws IOException 
		{ 
			byte[] buf = new byte[64]; // line length 
			int cnt = 0, c; 
			while ((c = read()) != -1) 
			{ 
				if (c == '\n') 
					break; 
				buf[cnt++] = (byte) c; 
			} 
			return new String(buf, 0, cnt); 
		} 
  
		public int nextInt() throws IOException 
		{ 
			int ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do
			{ 
				ret = ret * 10 + c - '0'; 
			}  while ((c = read()) >= '0' && c <= '9'); 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public long nextLong() throws IOException 
		{ 
			long ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public double nextDouble() throws IOException 
		{ 
			double ret = 0, div = 1; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
  
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
  
			if (c == '.') 
			{ 
				while ((c = read()) >= '0' && c <= '9') 
				{ 
					ret += (c - '0') / (div *= 10); 
				} 
			} 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		private void fillBuffer() throws IOException 
		{ 
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
			if (bytesRead == -1) 
				buffer[0] = -1; 
		} 
  
		private byte read() throws IOException 
		{ 
			if (bufferPointer == bytesRead) 
				fillBuffer(); 
			return buffer[bufferPointer++]; 
		} 
  
		public void close() throws IOException 
		{ 
			if (din == null) 
				return; 
			din.close(); 
		} 
	} 
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if( a+b >= 10 ){
		cout << "error" << endl;
	} else {
		cout << a+b << endl;
	}
	return 0;
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

int main()
{
  IOS;
  int a;
  cin >> a;
  cout << pow(a,1)+pow(a,2)+pow(a,3) << endl;
  return 0;
}

Measured memory_bytes: 4304
n=list(input())
a=int(n[len(n)-1])
if(a==0 or a==1 or a==6 or a==8):
  print('pon')
elif(a==2 or a==4 or a==5 or a==7 or a==9):
  print('hon')
elif(a==3):
  print('bon')

Measured memory_bytes: 9120
a, b, c, x, y = map(int, input().split())

ans = float("inf")
for i in range(200000):
    tmp = 0
    tmp += c * i * 2
    if x - i>0:
        tmp += a *(x-i)
    if y - i>0:
        tmp += b *(y-i)
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

int main()
{
	int K, N;
	std::cin >> K >> N;
	int* A = new int[N];
	for (int i=0; i<N; i++) std::cin >> A[i];
	int* d = new int[N];
	for (int i=0; i<N-1; i++) d[i] = A[i+1] - A[i];
	d[N-1] = A[0] + K - A[N-1];
	std::sort(d, d+N);
	int res = 0;
	for (int i=0; i<N-1; i++) res += d[i];
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 5196
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n, k) = scan "%d %d" Tuple.Tuple2.make
let arr = Array.make n false

let () =
  ListL.iter (0++^k) ~f:(fun _ ->
      let _ = scan "%d" id in
      scan_list (Some ' ') Int.of_string
      |> ListL.iter ~f:(fun i -> arr.(pred i) <- true));
  Array.filter ((=) false) arr
  |> Array.length
  |> Printf.printf "%d\n"


Measured memory_bytes: 6308
#include <iostream>

int main(){
    
    int n,d;
    int count = 0;
    std::cin >> n >> d;
    
    while(n > 0){
        count++;
        n = n - (d * 2 + 1);
    }
    
    std::cout << count << "\n";
    
    return 0;
}


Measured memory_bytes: 256
// abc158_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, A, B;
    cin >> N >> A >> B;

    if (A == 0){
        print(0);
        return 0;
    }
    
    ll x = N / (A + B);
    ll y = min(N % (A + B), A);
    print(x * A + y);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inv(x) power(x,Mod-2)
#define upd(a,b) a=add(a,b)
using namespace std;
typedef long long ll;
ll Mod;
ll add(ll a,const ll b){a+=b;if(a>=Mod)a-=Mod;return a;}
ll sub(ll a,const ll b){a-=b;if(a<0)a+=Mod;return a;}
ll mul(const ll a,const ll b){return (ll)a*b%Mod;}
ll power(ll x,ll cs)
{
	ll ras=1;
	while(cs)
	{
		if(cs&1) ras=mul(ras,x);
		x=mul(x,x);cs>>=1;
	}
	return ras;
}
ll fpwr(ll x,ll cs)
{
	ll ret;
	Mod--;ret=power(x,cs);Mod++;
	return ret;
}
const ll N=3050;
ll n,ans=0;
ll g[N][N],f[N],cf[N],zp[N],fp[N];
int C(int a,int b){return mul(zp[a],mul(fp[b],fp[a-b]));}
int main()
{
	ll i,j,K,w;
	cin>>n>>Mod;
	cf[0]=1;
	for(i=1;i<=n;i++) cf[i]=mul(cf[i-1],2);
	zp[0]=fp[0]=1;
	for(i=1;i<=n;i++) zp[i]=mul(zp[i-1],i);
	fp[n]=inv(zp[n]);
	for(i=n-1;i>=1;i--) fp[i]=mul(fp[i+1],i+1);
	for(i=0;i<=n;i++)
	{
		g[i][0]=1;
		for(j=1;j<=i;j++)
		{
			g[i][j]=add(g[i-1][j-1],mul(j+1,g[i-1][j]));
		}
	}
	for(K=1;K<=n;K++)
	{
		for(i=0,w=1;i<=K;i++,w=mul(w,cf[n-K]))
		{
			upd(f[K],mul(g[K][i],w));
		}
		f[K]=mul(f[K],C(n,K));
		f[K]=mul(f[K],power(2,fpwr(2,n-K)));
	}
	f[0]=power(2,fpwr(2,n));
	for(i=0;i<=n;i++)
	{
		//printf("#%lld  %lld\n",i,f[i]);
		if(i&1ll) ans=sub(ans,f[i]);
		else ans=add(ans,f[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 70272
#include <stdio.h>
int main(void){
	int time[5],ans=0,M=0,i,m=10;
	for(i=0;i<5;i++){
		scanf("%d",&time[i]);
		if(time[i]%10<m && time[i]%10!=0){
			M = i;
			m = time[i]%10;
		}
	}
	for(i=0;i<5;i++){
		if(i!=M){
			if(time[i]%10!=0)	ans += (time[i]/10+1)*10;
			else ans += time[i];
		}else{
			ans += time[i];
		}
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
package main

import (
  "fmt"
  "os"
  "bufio"
  "strconv"
  "math"
)

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  l, _ := strconv.Atoi(sc.Text())
  sc.Scan()
  r, _ := strconv.Atoi(sc.Text())

  min := math.MaxInt32
  for i := l; i < r; i++ {
      for j := l + 1; j <= r; j++ {
      tmp := ((i % 2019) * (j % 2019)) % 2019
      if tmp < min {
        min = tmp
      }
      if min == 0 {
        break
      }
    }
    if min == 0 {
      break
    }
  }
  fmt.Println(min)
}



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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll ans = 0;
    ans += A * (N / (A+B));
    ll rem = N - (A+B) * (N / (A+B));
    ans += min(rem, A);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

const int MAX = 1010101;

long long fac[MAX], finv[MAX], inv[MAX];

void binom_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long binom(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * finv[n - k] % MOD;
}

ll N, M;

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

  ll complement = 0;
  repe(i, 1, N) {
    if (i % 2 == 1) {
      complement += binom(N, i) * perm(M - i, N - i) % MOD;
    } else {
      complement += MOD;
      complement -= binom(N, i) * perm(M - i, N - i) % MOD;
    }
    complement %= MOD;
  }
  complement *= perm(M, N);
  complement %= MOD;

  ll total = perm(M, N) * perm(M, N) % MOD;
  ll ans = (total + MOD) - complement;
  ans %= MOD;

  cout << ans << endl;
}


Measured memory_bytes: 27272
def solve():
  K = int(input())
  if K==49:
    print(2)
    return [27,24]
  print(50)
  a,b = K//50,K%50
  ans = [49+a]*50
  for i in range(50):
    if i<b:
      ans[i] += 51-b
    else:
      ans[i] -= b
  return ans
print(*solve())

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n,h,H = 0,count = 0;
  cin >> n;
  
  for ( int i = 0; i < n; i++){
    cin >> h;
    if ( h >= H ){
      count++;
      H = h;
    }
  }
  
  cout << count << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long dist[1010][1010];

int main(){
	int n,m,s,g1,g2;
	while(cin >> n >> m >> s >> g1 >> g2 &&n!=0){
		s--,g1--,g2--;
		long long mi = 1000000000;
		for(int i=0;i<1010;i++){
			for(int j=0;j<1010;j++){
				if(i!=j)dist[i][j] = mi;
			}
		}
		for(int i=0;i<m;i++){
			int a,b;
			long long c;
			cin >> a >> b >> c;
			a--,b--;
			dist[a][b] = c;
		}
		for(int k=0;k<n;k++){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
				}
			}
		}
		mi = dist[s][g1]+dist[s][g2];
		for(int i=0;i<n;i++){
			mi = min(mi,dist[s][i]+dist[i][g1]+dist[i][g2]);
		}
		cout << mi << endl;
	}
	return 0;
}

Measured memory_bytes: 10960
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn next(a: u32, b:u32) -> (u32, u32) {
    if b==31 { return (a+1, 1) }

    (a, b+1)
}

fn solve(a: u32, b: u32) -> usize {
    let mut cnt = 0;
    let (mut i,mut j) = (1,1);

    loop {
        if i == j { cnt += 1}
        if i==a && j==b { break }
        let t = next(i, j);
        i = t.0;
        j = t.1;
    }

    cnt
}

fn main() {
    let (a,b) = parse_line!(u32, u32);

    println!("{}", solve(a,b));
}

#[test]
fn solve_test() {
    assert_eq!(solve(5,5), 5);
    assert_eq!(solve(2,1), 1);
    assert_eq!(solve(11,30), 11);
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    vector<int> e(12);
    REP(i,12){
        cin >> e[i];
    }
    sort(All(e));
    if(e[0]==e[3]&&e[4]==e[7]&&e[8]==e[11])cout << "yes\n";
    else cout << "no\n";
}



Measured memory_bytes: 3192
#include <iostream>
#include <map>
#include <cmath>
#define ll long long
using namespace std;

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

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s;
    cin >> n >> s;
    rep(si, 2) rep(ti, 2) {
        vi d(n);
        d[0] = si;
        d[1] = ti;
        rep(i, n) {
            int ni = (i+1)%n, nni = (i+2)%n;
            d[nni] = d[i] ^ d[ni] ^ (s[ni] == 'x'); 
        }
        if (d[0] == si && d[1] == ti) {
            rep(i, n) {
                cout << "SW"[d[i]];
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

int main() 
{
    ll n,k; cin>>n>>k;
    cout<<min(n%k,k-n%k)<<endl;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    while (true){
      String str1 = br.readLine();
      int[] digit = new int[str1.length()];
      int sum = 0;
      for(int i = 0; i < str1.length(); i++){
        digit[i] = Character.getNumericValue(str1.charAt(i));
        sum += digit[i];
      }
      if (sum == 0) {break;}
      else
        System.out.println(sum);
    }
  }
}

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

template <typename Edge>
class graph {
    using graph_t = std::vector<std::vector<Edge>>;
public:
    using reference = std::vector<Edge>&;
    using const_reference = std::vector<Edge> const&;
    using iterator = typename graph_t::iterator;
    using const_iterator = typename graph_t::const_iterator;
    using reverse_iterator = typename graph_t::reverse_iterator;

    graph() : g() {}
    graph(int n) : g(n) {}

    reference operator[](int x) { return g[x]; }
    const_reference operator[](int x) const { return g[x]; }

    iterator begin() { return std::begin(g); }
    iterator end() { return std::end(g); }
    reverse_iterator rbegin() { return std::rbegin(g); }
    reverse_iterator rend() { return std::rend(g); }

    int size() const { return g.size(); }

    void add_node(std::vector<Edge> es) {
        g.push_back(std::move(es));
    }

    void add_edge(int node_idx, Edge e) {
        g[node_idx].push_back(std::move(e));
    }

private:
    std::vector<std::vector<Edge>> g;
};


class directed_edge {
public:
    directed_edge(int t) : to(t) {}

    int to;
};

class directed_graph : public graph<directed_edge> {
public:
    directed_graph(int n) : graph(n) {}

    using graph::add_edge;
    void add_edge(int from, int to) {
        add_edge(from, directed_edge{to});
    }
};

template <typename Cost>
class weighted_edge {
public:
    using cost_type = Cost;

    weighted_edge(int t, Cost c) : to(t), cost(c) {}

    int to;
    cost_type cost;
};

template <typename Cost>
class weighted_graph : public graph<weighted_edge<Cost>> {
    using base_t = graph<weighted_edge<Cost>>;
public:
    weighted_graph(int n) : base_t(n) {}

    using base_t::add_edge;
    void add_edge(int from, int to, Cost cost) {
        add_edge(from, weighted_edge<Cost>{to, cost});
    }
};

template <typename Edge>
std::vector<int> scc(graph<Edge> const& g) {
    const int n = g.size();
    int idx = 0, k = 0, s = 0;
    std::vector<int> ord(n, -1), low(n), on_s(n), cmp(n), stk(n);
    std::function<void(int)> dfs = [&] (int v) {
        ord[v] = low[v] = idx++;
        stk[s++] = v;
        on_s[v] = true;
        for(const auto& e : g[v]) {
            if(ord[e.to] == -1) {
                dfs(e.to);
                low[v] = std::min(low[v], low[e.to]);
            } else if(on_s[e.to]) {
                low[v] = std::min(low[v], ord[e.to]);
            }
        }
        if(low[v] == ord[v]) {
            while(true) {
                const int w = stk[--s];
                on_s[w] = false;
                cmp[w] = k;
                if(w == v) break;
            }
            ++k;
        }
    };
    for(int v = 0; v < n; ++v) {
        if(ord[v] == -1) dfs(v);
    }

    return cmp;
}

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    directed_graph g(n);
    for(int i = 0; i < m; ++i) {
        int s, t; cin >> s >> t;
        g.add_edge(s, t);
    }
    auto cmp = scc(g);
    int q; cin >> q;
    while(q--) {
        int u, v; cin >> u >> v;
        cout << (cmp[u] == cmp[v]) << "\n";
    }
}



Measured memory_bytes: 4392
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int persons = sc.nextInt();
      int metro = sc.nextInt();
      int cab = sc.nextInt();
      if ((metro * persons) > cab){
      	System.out.println(cab);
      } else {
      	System.out.println(metro * persons);
      }
    }
}

Measured memory_bytes: 22224
N, Y = map(int, input().split())

for k in range(N+1):
	for l in range(N-k+1):
		if 10000*k + 5000*l + 1000*(N-k-l) == Y:
			print(k, l, (N-k-l))
			exit(0)

print("-1 -1 -1")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int a,b,c;
    bool is=false;
    cin>>a>>b>>c;
    if(a==b+c)is=true;
    if(b==a+c)is=true;
    if(c==a+b)is=true;
    cout<<(is?"Yes":"No")<<endl;
}

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

int main() {
	string n;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n.size(); i++) {
		if (n[i] == '2') {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{
    i64,
    f64,
    cmp,
};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };

    (stream = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };

    ($($r:tt)*) => {
        use std::io::*;
        let mut stream = stdin();
        let stream = &mut stream;
        input_inner!{stream, $($r)*}
    };
}

macro_rules! input_inner {
    ($stream:expr) => {};
    ($stream:expr, ) => {};

    ($stream:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($stream, $t);
        input_inner!{$stream $($r)*}
    };
}

macro_rules! read_value {
    ($stream:expr, ( $($t:tt),* )) => {
        ( $(read_value!($stream, $t)),* )
    };

    ($stream:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($stream, $t)).collect::<Vec<_>>()
    };

    ($stream:expr, chars) => {
        read_value!($stream, String).chars().collect::<Vec<char>>()
    };

    ($stream:expr, usize1) => {
        read_value!($stream, usize) - 1
    };

    ($stream:expr, $t:ty) => {
        $stream.by_ref().bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<$t>()
            .expect("Parse error")
    };
}

fn main() {
    input!{n: i64, m: i64}
    let mut dp: Vec<i64> = vec![i64::MAX; 1 << n];
    dp[0] = 0;
    for _ in 0 .. m {
        input!{
            a: i64,
            b: i64,
            c: [i64; b]
        };

        let mask = c.iter().fold(0, |acc, i| {acc | (1 << (i - 1))});
        for idx in 0 .. (1 << n) {
            if dp[idx] < i64::MAX {
                dp[idx | mask] = cmp::min(dp[idx | mask], dp[idx] + a);
            }
        }
    }

    println!("{}", if dp[(1 << n) - 1] < i64::MAX {dp[(1 << n) - 1]} else {-1});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
template <long long mod>
class Combination
{
    std::vector<long long> fact, finv, inv;
public:
    Combination(int sz)
    {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for (int i = 2; i < sz; ++i)
        {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        finv[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
    }
    long long P(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fact[n] * finv[n - k] % mod;
    }
    long long H(long long n, long long k)
    {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i)
    {
        return fact[i];
    }
    long long getinv(int i)
    {
        return inv[i];
    }
    long long getfinv(int i)
    {
        return finv[i];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Combination<MOD> comb(1000010);
  int n; cin >> n;
  vll a(n);
  vector<map<ll, ll>> vmp(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
    ll m = a[i];
    for(ll j=2;j*j<=m;++j) {
      while(m % j == 0) {
        vmp[i][j]++;
        m /= j;
      }
    }
    if(m != 1) vmp[i][m]++;
  }
  vector<ll> memo(1000010, 0);
  for(int i=0;i<n;++i) {
    for(auto &e: vmp[i]) {
      memo[e.first] = max(memo[e.first], e.second);
    }
  }
  ll l = 1;
  for(int i=1;i<1000010;++i) {
    if(memo[i] != 0) l *= mod_pow<ll>(i, memo[i], MOD);
    l %= MOD;
  }
  ll su = 0;
  for(int i=0;i<n;++i) {
    su += l * comb.getinv(a[i]) % MOD;
    su %= MOD;
  }
  cout << su << endl;
}


Measured memory_bytes: 35200
#include <iostream>
#include <cstdio>
#include <string>
#include <utility>
using namespace std;
char *alp[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};

void saiki(pair<string, int> in, int cnt) {
  if (cnt == 0) {
    cout << in.first << endl;
    return;
  }
  
  for (int i = 0; i < in.second; i++) {
    saiki(make_pair(in.first + alp[i], in.second), cnt-1);
  }
  saiki(make_pair(in.first + alp[in.second], in.second+1), cnt-1);
  
}

int main() {
  int N;
  cin >> N;
  saiki(make_pair("a", 1), N-1);
  
  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file

int main()
{
    int n;
    cin>>n;
    string ss;
    cin>>ss;
    int cnt=0;
    int st=0,ed=ss.size()-1;
    while(st<=ed)
    {
        if(ss[st]=='W'&&ss[ed]=='R')
        {
            cnt++;
            st++;
            ed--;
        }
        if(ss[st]=='R'&&ss[ed]=='R')
        {
            st++;
        }
        if(ss[st]=='W'&&ss[ed]=='W')
        {
            ed--;
        }
        if(ss[st]=='R'&&ss[ed]=='W')
        {   
            st++;
            ed--;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <string>
using namespace std;
#pragma warning (disable: 4996)

string S;

int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '?') S[i] = 'D';
	}
	cout << S << endl;
	return 0;
}

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

using namespace std;

int main() {
	int k; cin >> k;
	set<int> s;
	vector<int> dp(k + 6);

	for (int i = 1; i < dp.size(); ++i) {
		dp[i] = (dp[i-1] * 10 + 7) % k;
		if (dp[i] == 0) {
			cout << i;
			return 0;
		}
		if (s.count(dp[i])) {
			cout << -1;
			return 0;
		}
		s.insert(dp[i]);
	}
}

Measured memory_bytes: 53852
data = list(map(int, input().split()))
N = data[0]
K = data[1]

N=N%K

start = N
ans = 0

def hoge(i, j):
  return abs(i - j)

ans = hoge(N, K)

if start <= ans:
  print(start)
else:
  while ans >= hoge(ans, K):
    ans = hoge(ans, K)
  print(ans)

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

int main(){
  int n;
  while(cin>>n && n){
    int table[100][100]={0};
    int w,h;
    cin>>w>>h;
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      table[--x][--y]=1;
    }
    int s,t;
    cin>>s>>t;
    int max=0;
    for(int i=0;i+s<=w;i++){
      for(int j=0;j+t<=h;j++){
	int cnt=0;
	for(int a=0;a<s;a++){
	  for(int b=0;b<t;b++){
	    cnt+=table[a+i][b+j];
	  }
	}
	if(max < cnt) max=cnt;
      }
    }
    cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
l,r = map(int, input().split())
m = 2019
for i in range(l,min(r+1,l+2020)):
    for j in range(i+1, min(r+1,l+2020)):
        i %= 2019
        j %= 2019
        m = min(m, (i*j)%2019)
print(m%2019)

Measured memory_bytes: 9184
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val n = jin.readLine().toInt()
    val freq = Array(51) { LongArray(51) }
    for (j in 1..n) {
        val s = jin.readLine()
        var res = s.substringBefore('.').toLong()
        if ('.' in s) {
            val t = s.substringAfter('.')
            for (j in 1..t.length) {
                res *= 10L
            }
            res += t.toLong()
            for (j in 1..9 - t.length) {
                res *= 10L
            }
        } else {
            for (j in 1..9) {
                res *= 10L
            }
        }
        var e = 0
        while (res % 2L == 0L) {
            e++
            res /= 2L
        }
        var f = 0
        while (res % 5L == 0L) {
            f++
            res /= 5L
        }
        freq[e][f]++
    }
    var answer = 0L
    for (e1 in 0..50) {
        for (f1 in 0..50) {
            for (e2 in 0..50) {
                for (f2 in 0..50) {
                    if (e1 + e2 >= 18 && f1 + f2 >= 18) {
                        answer += freq[e1][f1] * freq[e2][f2]
                        if (e1 == e2 && f1 == f2) {
                            answer -= freq[e1][f1]
                        }
                    }
                }
            }
        }
    }
    answer /= 2L
    println(answer)
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b && b == c){
        cout << 1 << endl;
    }
    else if(a==b || b == c || c == a){
        cout << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==',') cout<<" ";
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)

long long a[200010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,1,10)a[i]=i;
	int cnt=9;
	int pos=1;
	for(int pos=1;cnt<n;pos++){
		long long t=a[pos];
		int x=t%10;
		if(x!=0)a[++cnt]=t*10+x-1;
		a[++cnt]=t*10+x;
		if(x!=9)a[++cnt]=t*10+x+1;
	}
	printf("%lld",a[n]);
}

Measured memory_bytes: 2456
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);
 
vector<int> g[100111];
int n,dgr[100111],l,a[100111];
 
 
void dfs(int x,int f=0)
{
	a[++l]=(int)g[x].size()-dgr[x];
	for(int i=0;i<(int)g[x].size();i++)if(g[x][i]!=f&&(int)g[g[x][i]].size()>1)
		dfs(g[x][i],x);
}
 
int ans1[100111],ans2[100111];
int main()
{
	get1(n);
	if(n==2)
	{
		puts("1 2");
		return 0;
	}
	
	for(int i=1,u,v;i<n;i++)
	{
		get2(u,v);
		dgr[u]++;
		dgr[v]++;
		g[u].pb(v);g[v].pb(u);
	}
	for(int i=1;i<=n;i++)if((int)g[i].size()==1)dgr[g[i][0]]--;
	for(int i=1;i<=n;i++)if(dgr[i]>2)
	{
		puts("-1");
		return 0;
	}
	
	for(int i=1;i<=n;i++)if(dgr[i]<=1&&(int)g[i].size()>1)
	{
		dfs(i);
		break;
	}
	a[l]--;a[++l]=0;
	for(int i=l;i>=1;i--)a[i+1]=a[i];
	l++;a[2]--;a[1]=0;
	
	int cur=n;
	for(int i=1;i<=l;i++)
	{
		int tmp=cur-a[i];
		for(int j=cur-a[i];j<cur;j++)ans1[j]=j+1;
		ans1[cur]=tmp;
		cur-=a[i]+1;
	}
	reverse(a+1,a+l+1);
	cur=n;
	for(int i=1;i<=l;i++)
	{
		int tmp=cur-a[i];
		for(int j=cur-a[i];j<cur;j++)ans2[j]=j+1;
		ans2[cur]=tmp;
		cur-=a[i]+1;
	}
	for(int i=1;i<=n;i++)if(ans1[i]!=ans2[i])
	{
		if(ans1[i]>ans2[i])swap(ans1,ans2);
		break;
	}
	
	for(int i=1;i<=n;i++)printf("%d ",ans1[i]);puts("");
	return 0;
}

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

using namespace std;
using LL = long long;

constexpr int MAXN = 1e5 + 5;

int main () {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int x;
    cin >> x;
    if (400 <= x && x <600) cout << 8 << endl;
    else if (600 <= x && x < 800) cout << 7 << endl;
    else if (800 <= x && x < 1000) cout << 6 << endl;
    else if (1000 <= x && x < 1200) cout << 5 << endl;
    else if (1200 <= x && x < 1400) cout << 4 << endl;
    else if (1400 <= x && x < 1600) cout << 3 << endl;
    else if (1600 <= x && x < 1800) cout << 2 << endl;
    else if (1800 <= x && x < 2000) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
        int H,W;
        int i,j;
        while(true){
            H=sc.nextInt();
            W=sc.nextInt();
            if(H==0&&W==0){
                break;
            }
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if((i+j)%2==0){
                        System.out.printf("#");
                    }
                    else{
                        System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 64344
import std.math;
import std.algorithm;
import std.stdio;
 
void main() {
  int n, x, y;
  readf(" %s %s %s", &n, &x, &y);
  --x;
  --y;
  auto answer = new int[n];

  foreach (i;0..n - 1) {
    foreach (j;i + 1..n) {
      auto d = min(
        abs(i - x) + abs(j - y) + 1,
        abs(j - x) + abs(i - y) + 1,
        j - i
        );
      ++answer[d];
	}
  }

  foreach (e;answer[1..$]) {
    writeln(e);
  }
}


Measured memory_bytes: 256
// AOJ 1192: Tax Rate Changed
// 2017.9.14 bal4u@uu
// 2017.12.22

#include <stdio.h>
 
 char buf[15], *p;
 
 int in()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
    int x, y, s, p1, p2, t, ans;
 
    while (fgets(p=buf, 15, stdin) && *p != '0') {
		x = in(), y = in(), s = in();
		ans = 0;
        for (p1 = 1; p1 < s; p1++) for (p2 = p1; p2 < s; p2++) {
			t = p1 + p2 + (p1*x)/100 + (p2*x)/100;
			if (t > s) break;
			if (t != s) continue;
            t = p1 + p2 + (p1*y)/100 + (p2*y)/100;
			if (t > ans) ans = t;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(long long (i)=0;(i)<(n);(i)++)
#define ll long long
#define pr_qu priority_queue
#define vec(name,size,common) vector<ll> (name)((size),(common))
 
 
 
 
 
int main(){
  long long n,k;
  cin>>n>>k;
  k = k/1000;

  long long x,y,z;
  int j = 0;

  for(long long i=0;i<=n;i++){
    if((k-n-(4*i))%9==0){
      y=i;
      x=(k-n-(4*i))/9;
      z = n-(x+y);
      break;
    }else{
      if(i==n){
        cout<<-1<<" "<<-1<<" "<<-1;
        j=1;
        break;
      }

    }
  }
  
      if(z<0||x<0){
        cout<<-1<<" "<<-1<<" "<<-1;
        j=1;
      }
if(j==0){
  cout<<x<<" "<<y<<" "<<z;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int a[3]={0,0,0},n=s.length();
    rep(i,0,n){
        a[(int)(s[i]-'a')]++;
    }
    int m = min({a[0],a[1],a[2]});
    int M = max({a[0],a[1],a[2]});
    cout<<(M-m<=1?"YES":"NO")<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int H,W;
    cin >> H >> W;
    vec<vec<int>> G(10,vec<int>(10));
    rep(i,10)rep(j,10){
        int d;
        cin >> d;
        G[i][j] = d;
    }
    vec<vec<int>> mn(10,vec<int>(10,(int)1e9));

    function<void(int,int,int)> dfs = [&](int start,int now, int starttonowd) {
        if(now==1){
            mn[start][1] = min(mn[start][1],starttonowd);
        } else {
            if(mn[start][now] <= starttonowd) return;
            mn[start][now] = starttonowd;
            for(int i=0;i<=9;++i){
                dfs(start,i,starttonowd+G[now][i]);
            }
        }
    };
    rep(i,10) dfs(i,i,0);
    ll ans = 0;
    rep(i,H*W){
        int k;cin >> k;
        if(k==-1)continue;
        ans+=mn[k][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_2.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))

    # write code
    maxL = max(L)
    minR = min(R)
    print(max(minR-maxL+1, 0))


Measured memory_bytes: 12884
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<lint, lint>;
const int mod = 1e9 + 7;
const int MAXN = 2000005;

int n, a[MAXN];

void fuck(){
	puts("No");
	exit(0);
}

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	sort(a, a + n);
	if(a[n-1] == 0){
		puts("Yes");
		return 0;
	}
	if(n % 3) fuck();
	for(int i=1; i<n/3; i++){
		if(a[i-1] != a[i]) fuck();
		if(a[i-1+n/3] != a[i+n/3]) fuck();
		if(a[i-1+n/3+n/3] != a[i+n/3+n/3]) fuck();
	}
	if((a[0] ^ a[n/3]) != a[2*n/3]) fuck();
	puts("Yes");
}


Measured memory_bytes: 640
def main():
    n = int(input())
    s = input()
    ans = 0
    for i in range(n-2):
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

int N;

int main()
{
  cin >> N;
  vector<ll> X(N);
  vector<ll> copyX(N);
  for (int i = 0; i < N; i++)
  {
    cin >> X[i];
    copyX[i] = X[i];
  }
  /////////////
  sort(X.begin(), X.end());
  ll chuo = X[N / 2 - 1];
  for (int i = 0; i < N; i++)
  {
    if (copyX[i] <= chuo)
    {
      cout << X[N / 2] << endl;
    }
    else
    {
      cout << X[N / 2 - 1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5376