akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;

int main(){
  int N;
  cin >> N;
  pair<double,string> p;
  double sum=0;
  rep(i,N){
    cin >> p.first >> p.second;
    sum += p.first*((p.second=="JPY")?1:380000);
  }
  cout << setprecision(10) << sum << endl;
}


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

int main(){
  
  int A, B;
  cin >> A >> B;
  
  if (A==1){
    A = 14;
  }
  if (B==1){
    B = 14;
  }
  
  if (A>B){
    cout << "Alice" << endl;
  }
  else if (A<B){
    cout << "Bob" << endl;
  }
  else {
    cout << "Draw" << endl;
  }
}

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

int main(){
    string a,b; cin >> a >> b;
    int a_d=a.size();
    int b_d=b.size();
    int check = -1;
    if(a_d>b_d){
        cout << "GREATER" << endl;
        return 0;
    }
    else if(b_d>a_d){
        cout << "LESS" << endl;
        return 0;
    }
    else{
        for(int i=0; i<a_d;i++){
            if(a[0]==b[0]) continue;
            else if(a[0]>b[0]){
                check = 1;
                break;
            }
            else {
                check = 0;
                break;
            }
        }
    }
    if(check == 1) cout << "GREATER" << endl;
    else if(check == 0) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

N = int(stdin.readline().rstrip())

r = N % 10

if(r == 2) or (r == 4) or (r == 5) or (r == 7) or (r == 9):
    print("hon")
elif (r == 0) or (r == 1) or (r == 6) or (r == 8):
    print("pon")
else:
    print(" bon")

Measured memory_bytes: 9100
fun main(args: Array<String>) {
  val N = readInt()
  var sum = 0L
  for (i in 1..N) {
    if (i % 3 != 0 && i % 5 != 0) sum += i
  }
  println(sum)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


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


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

int ctoi(char c) {
	return c - '0';
}


int main()
{
	long long int n, cnt = 0;
	bool b = true;

	cin >> n;

	vector<long long int> h(n);

	for (int i = 0; i < n; i++)
		cin >> h[i];

	for (int i = n - 2; i >= 0; i--) {
		if (h[i] - 1 > h[i + 1]) {
			b = false;
			break;
		}
		else if(h[i] > h[i + 1]) {
			h[i] -= 1;
		}
	}

	if(b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int n;
int *arrA;

bool solve(int i, int m){
  bool res;

  if(m == 0) return true;
  if(i >= n) return false;

  res = solve(i+1, m) || solve(i+1, m-arrA[i]);

  return res;
}

int main(){
  int q,i,j;
  int *arrm;

  // input and allocation
  scanf("%d",&n);
  arrA = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++) scanf("%d ",&arrA[i]);
  scanf("%d",&q);
  arrm = (int *)malloc(sizeof(int) * q);
  for(i=0; i<q; i++) scanf("%d ",&arrm[i]);

  // solve
  for(i=0; i<q; i++){
    if(solve(0, arrm[i])) printf("yes\n");
    else printf("no\n");
  }

  free(arrA);
  free(arrm);

  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int imos[200001][30];

int main(){
    cin.sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    memset(imos, 0, sizeof(imos));
    rep(i, n) {
        int s, t, r;
        cin >> s >> t >> r;
        imos[s * 2 - 1][r - 1]++;
        imos[t * 2][r - 1]--;
    }
    int maxi = 0;
    repl(i, 1, 200001) {
        int tmp = 0;
        rep(j, c) imos[i][j] += imos[i - 1][j], tmp += (imos[i][j] > 0);
        maxch(maxi, tmp);
    }
    cout << maxi << endl;
    return 0;
}

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

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

  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += (r - l) + 1;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
typedef long long ll;
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  int n, m;
  cin >> n >> m;

  int s = 0;
  unordered_map<int, int> mp;
  rep(i, n) {
    int a;
    cin >> a;
    s += a;
    s %= m;
    mp[s]++;
  }

  ll ans = 0;
  for(auto x : mp) {
    int cnt = x.second;
    ans += (ll)cnt * (cnt - 1) / 2;
    if(x.first == 0) ans += (ll)cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

primes = primes(1000)
counts = [1]*len(primes)

n = int(input())
for k in range(2, n+1):
    i = 0
    prime = primes[0]
    while k > 1:
        if k%prime == 0:
            k //= prime
            counts[i] += 1
        else:
            i += 1
            prime = primes[i]

counts = list(filter(lambda x: x > 1, counts))

ans = 1
MOD = 10**9+7
for c in counts:
    ans = ans*c%MOD
print(ans)


Measured memory_bytes: 3192
N, W = gets.split.map(&:to_i)

goods = N.times.map { gets.split.map(&:to_i) }

dp = Array.new(W + 1, -1)
dp[0] = 0

goods.each do |w, v|
  (W - w).downto(0) do |i|
    next if dp[i] < 0

    nv = dp[i] + v
    nw = i + w

    dp[nw] = nv if dp[nw] < nv
  end
end

puts dp.max


Measured memory_bytes: 2556
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  int64_t result = (int64_t)N * (N + 1) * (N + 2) / 6;
  rep(i, N - 1) {
    int u, v;
    cin >> u >> v;
    if (u > v) {
      swap(u, v);
    }

    result -= (int64_t)u * (N - v + 1);
  }
  cout << result << endl;
  return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    int w[n];
    for(int i = 0; i < n; ++i)
      cin >> w[i];
    
    int dp[n][n];
    for(int i = 0; i < n; ++i){
      fill(dp[i],dp[i]+n,0);
    }
    
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	if(j+i+1 > n-1) break;
	if(dp[j+1][j+i] == i && abs(w[j]-w[j+i+1]) < 2){
	  dp[j][j+i+1] = dp[j+1][j+i] + 2;
	}else{
	  for(int k = 0; k <= i; ++k){
	    dp[j][j+i+1] = max(dp[j][j+i+1],dp[j][j+k]+dp[j+k+1][j+i+1]);
	  }
	}
      }
    }
    //Debug
    /*
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
      cout << dp[i][j] << " ";
      }
      cout << endl;
    }

    */
    cout << dp[0][n-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3340
# C
N = int(input())
a_list = list(map(int, input().split()))

cnt_4 = 0
cnt_2 = 0

for a in a_list:
    if a % 4 == 0:
        cnt_4 += 1
    elif a % 2 == 0:
        cnt_2 += 1
        
cnt_1 = N - cnt_4 - cnt_2

if cnt_4 >= cnt_1:
    print("Yes")
elif cnt_4 + 1 == cnt_1 and cnt_2 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [usize; n]
    }
    if k == 0 {
        println!("{}", v.iter().map(|x| *x).sum::<usize>());
        return;
    }
    let m = 40;
    let mut tab: Vec<usize> = vec![0; m];
    let mut dp1: Vec<usize> = vec![0; m];
    for i in 0..m {
        let b = 1 << i;
        let mut c = 0;
        for j in 0..n {
            if v[j] & b > 0 {
                c += 1;
            }
        }
        tab[i] = c << i;
        dp1[i] = max(tab[i], (n << i) - tab[i]);
    }
    for i in 1..m {
        dp1[i] += dp1[i - 1];
    }
    let mut dp2: Vec<usize> = vec![0; m];
    if k & 1 > 0 {
        dp2[0] = dp1[0];
    } else {
        dp2[0] = tab[0];
    }
    for i in 1..m {
        let b = 1 << i;
        if k & b > 0 {
            dp2[i] = max(tab[i] + dp1[i - 1], (n << i) - tab[i] + dp2[i - 1]);
        } else {
            dp2[i] = tab[i] + dp2[i - 1];
        }
    }
    println!("{}", dp2[m - 1]);
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

const ll INF = 1e18;
string y;
ll dp[1001000][2];

signed main() {
  rep(i, 1001000) rep(c, 2) dp[i][c]=INF;
  cin >> y;
  reverse(begin(y), end(y));
  y = "0" + y + "0";
  dp[0][0]=0;

  for (ll i = 0; i + 1 < y.size(); i++) rep(c, 2) rep(nx, 10) {
    ll ni = i+1;
    ll p = dp[i][c];
    ll ny = y[ni]-'0';
    ll np = p + (nx + (nx-c-ny));
    ll nc = 0;
    if (nx-c < ny) {
      // ni において繰り下がりが必要
      np = p + (nx + (10+nx-c-ny));
      nc = 1;
    }
    chmin(dp[ni][nc],np);
  }

  cout << dp[y.size()-1][0] << endl;
  return 0;
}


Measured memory_bytes: 17924
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    vector<vector<ll>> dp(N+1, vector<ll> (N+1,0));
    vector<P> p(N);
    for(int i=0; i<N; i++){
        p[i].first = A[i];
        p[i].second = i;
    }
    sort(p.begin(),p.end(),greater<P>());
    for(int i=0; i<N; i++){
        ll pos = p[i].second;
        for(ll l=0; l<=i; l++){
            ll r = i-l;
            chmax(dp[i+1][l+1], dp[i][l] + A[pos] * (pos - l));
            chmax(dp[i+1][l], dp[i][l] + A[pos] * ((N-r-1LL) - pos));
        }
    }
    ll ans = 0;
    for(int i=0; i<=N; i++) chmax(ans,dp[N][i]);
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 34596
from itertools import accumulate
from bisect import bisect_right
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


A = [0] + list(accumulate(A))
B = [0] + list(accumulate(B))
ans = 0

for i in range(N + 1):
    remain = K - A[i]
    if remain < 0:
        continue
    bi = max(0, bisect_right(B, remain) - 1)
    ans = max(ans, i + bi)

print(ans)


Measured memory_bytes: 41132
N= int(input())
A  = list(map(int,input().split()))
B  = list(map(int,input().split()))
short = []
margine = []
for a,b in zip(A,B):
    if a > b :
        margine.append(a-b)
    elif b > a:
        short.append(b-a)
        
ss = sum(short)
sc = len(short)
margine.sort()
if ss>sum(margine):
    print(-1)
    exit()
while ss>0:
    ss -= margine.pop()
    sc += 1
print(sc)


Measured memory_bytes: 24244
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

	readChars(): string[] {
		let S = this.readLine();
		return new Array(S.length).fill(null).map((_, i) => S.charAt(i));
	}

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}


class DisjointSet {
	parents: number[]
	components: number
	constructor(readonly size: number) {
		this.parents = new Array(size).fill(null).map((value, index) => index);
		this.components = size;
	}
	find(index: number): number {
		if (index != this.parents[index])
			this.parents[index] = this.find(this.parents[index]);
		return this.parents[index]
	}
	union(index1: number, index2: number): void {
		let parent1 = this.find(index1),
			parent2 = this.find(index2);
		if (parent1 != parent2) {
			this.parents[parent1] = parent2;
			this.components -= 1;
		}
	}
}


let reader = new Reader();
let [N, M] = reader.readInts();
let disjoint_set = new DisjointSet(N);

for(let i=0; i<M; i++) {
	let [X, Y, Z] = reader.readInts();
	disjoint_set.union(X-1, Y-1);
}

console.log(disjoint_set.components);


Measured memory_bytes: 55240
function main(arg) {
    var arg2 = arg.split(/\n/g);
    var kosuu = parseInt(arg2[0]);
    var yum_array = arg2[1].split(/\s+/g);
    var kaifuku = 0;
    for(i=0;i<kosuu;i++){
    	for(j=i+1;j<kosuu;j++){
    		kaifuku += parseInt(yum_array[i])*parseInt(yum_array[j]);
    	}
    }
    console.log(kaifuku);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
N = int(input())
count = 1
inputs = [int(i) for i in input().split()]
if 0 in inputs:
    print(0)
    quit()
else:
    for daude in inputs:
        if daude > 10 ** 18:
            count = -1
            break
        count *= daude
        if count > 10 ** 18:
            count = -1
            break
    print(count)


Measured memory_bytes: 84696
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
//ll n;
//ld ;
// string s,t;
char c;

int main() {
  cin >> c;
  string al = "abcdefghijklmnopqrstuvwxyz";
  char c1;
  for(ll i=0;i<al.length();i++){
    if(al[i]==c)c1=al[i+1];
  }
  cout << c1 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())

xs = set();ys = set()
P = []
for i in range(N):
    x1,y1,x2,y2 = map(int, input().split())
    xs.add(x1);xs.add(x2)
    ys.add(y1);ys.add(y2)
    P.append((x1,x2,y1,y2))
    
X = sorted(xs);Y = sorted(ys)
MX = {x: i for i, x in enumerate(X)}
MY = {y: i for i, y in enumerate(Y)}

H = len(Y);W = len(X)
S = [[0]*(W+1) for i in range(H+1)]
for x1, x2, y1, y2 in P:
    p1 = MY[y1]; q1 = MX[x1]
    p2 = MY[y2]; q2 = MX[x2]
    
    S[p1][q1] += 1
    S[p1][q2] -= 1
    S[p2][q1] -= 1
    S[p2][q2] += 1


for i in range(H):
    for j in range(W):
        S[i][j+1] += S[i][j]
ans = 0
for j in range(W):
    for i in range(H):
        S[i+1][j]+= S[i][j]
        ans = max(ans,S[i][j])
print(ans)



Measured memory_bytes: 63384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(12); }; }aaaa;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    vector<pair<bool, int>> T, U;
    for (int i = 0, j; i < N; i = j) {
        for (j = i + 1; j < N; ++j) {
            if (S[j] != S[i]) break;
        }

        T.emplace_back(S[i] == 'R', j - i);
    }

    int ans = 0;

    {
        int k = K;
        U = T;
        int M = U.size();
        rep(i, 1, M - 1) {
            if (k > 0) {
                if (!U[i].first) {
                    U[i].first ^= 1;
                    k--;
                }
            }
        }

        if (k > 0 && !U[0].first && M > 1 && U[1].first) {
            U[0].first ^= 1;
            k--;
        }
        if (k > 0 && !U.back().first && M > 1 && U[M - 2].first) U.back().first ^= 1;

        int a = 0;
        rep(i, M) {
            a += U[i].second - 1;
            if (!U[i].first && i > 0 && !U[i - 1].first) a++;
            else if (U[i].first && i < M - 1 && U[i + 1].first) a++;
        }

        ans = max(ans, a);
    }

    {
        int k = K;
        U = T;
        int M = U.size();
        rep(i, 1, M - 1) {
            if (k > 0) {
                if (U[i].first) {
                    U[i].first ^= 1;
                    k--;
                }
            }
        }

        if (k > 0 && U[0].first && M > 1 && !U[1].first) {
            U[0].first ^= 1;
            k--;
        }
        if (k > 0 && U.back().first && M > 1 && !U[M - 2].first) U.back().first ^= 1;

        int a = 0;
        rep(i, M) {
            a += U[i].second - 1;
            if (!U[i].first && i > 0 && !U[i - 1].first) a++;
            else if (U[i].first && i < M - 1 && U[i + 1].first) a++;
        }

        ans = max(ans, a);
    }

    write(ans);
}

Measured memory_bytes: 2116
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> x(n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
        sum += x[i];
    }
    ll a1 = sum / n;
    ll ans1 = 0;
    for (int i = 0; i < n; i++)
    {
        ans1 += pow(x[i] - a1, 2);
    }
    ll a2 = sum / n + 1;
    ll ans2 = 0;
    for (int i = 0; i < n; i++)
    {
        ans2 += pow(x[i] - a2, 2);
    }
    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
import itertools
n, m, x = map(int, input().split())
books = []
for i in range(n):
  ins = list(map(int, input().split()))
  books.append({"c": ins[0], "a": ins[1: m+1]})
ans = float('inf')
for i in range(1, n+1):
  book_list = list(itertools.combinations(list(range(n)), i))
  for lis in book_list:
    cost_sum = 0
    a_sum = [0] * m
    ok = 0
    ok_list = [False] * m
    for j in lis:
      cost_sum += books[j]['c']
      for k in range(m):
        a_sum[k] += books[j]['a'][k]
        if not ok_list[k] and a_sum[k] >= x:
          ok += 1
          ok_list[k] = True
    if ok == m and ans > cost_sum:
      ans = cost_sum
if ans == float('inf'):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9320
//20200510 D
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		long K=sc.nextLong();
		int[] A=new int[N];
		for(int i=0;i<N;i++){
			A[i]=sc.nextInt()-1;
		}
		List<Integer> Q=new ArrayList<>();
        boolean[] C=new boolean[N];
		Q.add(0);
		int lsn;
		int len;
        int t=0;
        C[0]=true;
		while(true){
			int a=A[t];
			if(C[a]){
				lsn=Q.indexOf(a);
				len=Q.size()-1;
				break;
			}
			Q.add(a);
            C[a]=true;
            t=a;
		}
      	/*for(Integer i:Q){
          System.out.println(i);
        }
      	System.out.println(lsn);
      	System.out.println(len);
      	System.out.println("");*/
		if(K<lsn){
			System.out.println(Q.get((int)K)+1);
		}else{
			int n=(int)((K-lsn)%(len-lsn+1))+lsn;
			System.out.println(Q.get(n)+1);
		}
	}
}

Measured memory_bytes: 50000
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}


int main(){
	int N, W;
	cin >> N >> W;
	hei(llint) w(N), v(N);
	rep(i, 0, N)cin >> w[i] >> v[i];
	whei(llint) dp(N+1, hei(llint)(W + 1, 0));
	rep(i, 0, N) {
		rep(j, 0, W + 1) {
			if (j >= w[i])dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<char>>;
using info = vector<vector<int>>;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
info dist;
Graph G;
queue<vector<int>> que;
int H, W;

void bfs(Graph &G, info &dist, vector<int> v, queue<vector<int>> &que) {
  for (int i = 0; i < 4; ++i) {
    vector<int> nv = {v[0] + dy[i], v[1] + dx[i]};
    if (nv[0] < 0 || nv[0] >= H || nv[1] < 0 || nv[1] >= W) continue;

    if (G[nv[0]][nv[1]] == '#') continue;

    if (dist[nv[0]][nv[1]] != -1) continue;

    if (G[nv[0]][nv[1]] == '.') {
      dist[nv[0]][nv[1]] = dist[v[0]][v[1]] + 1;
      que.push(nv);
    }
  }
}

int main() {
  cin >> H >> W;
  G.assign(H+1, vector<char>(W+1));
  dist.assign(H+1, vector<int>(W+1, -1));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> G[i][j];
      if (G[i][j] == '#') {
        que.push({i, j});
        dist[i][j] = 0;
      }
    }
  }

  while (!que.empty()) {
    vector<int> v = que.front() ; que.pop();
    bfs(G, dist, v, que);
  }

  int ans = -2; 
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      ans = max(dist[i][j], ans);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 60724
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int compare(string a, string b) {
	int i;
	for (i = 0; i < a[i] != '\0'; i++) {
		if (b[i] == '\0')
			return -1;
		else if (a[i] < b[i])
			return 1;
		else if (a[i] > b[i])
			return -1;
	}
	if (b[i] != '\0')
		return 1;
	else
		return 0;
}
int main() {
	int n, q, s[222222], t[222222], x[222222], d[222222],i,g[222222],l,r,c,l2,r2[222222],j,w[222222];
	cin >> n >> q;
	vector<pair<int,pair<int,int>>> m(n);
	for (i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> x[i];
		s[i] -= x[i];
		t[i] -= x[i];
		m[i] = make_pair(x[i], make_pair(s[i], t[i]));
	}
	sort(m.begin(), m.end());
	for (i = 0; i < q; i++) {
		cin >> d[i];
		g[i] = -1;
	}
	for (i = 0; i < n; i++) {
		s[i] = m[i].second.first;
		t[i] = m[i].second.second;
      if(s[i]<=d[q-1]&&t[i]>d[0]){
		l = 0;
		r = q - 1;
		while (l != r) {
			c = (l + r) / 2;
			if (s[i] <= d[c]) {
				if (l + 1 == r) {
					c = l;
					if (s[i] <= d[c])
						r--;
					else
						l++;
				}
				else {
					r = c;
				}
			}
			else {
				if (l + 1 == r) {
					c = l;
					if (s[i] <= d[c])
						r--;
					else
						l++;
				}
				else {
					l = c;
				}
			}
		}
		l2 = l;
		l = 0;
		r = q - 1;
		while (l != r) {
			c = (l + r) / 2;
			if (t[i] > d[c]) {
				if (l + 1 == r) {
					c = r;
					if (t[i] > d[c])
						l++;
					else
						r--;
				}
				else {
					l = c;
				}
			}
			else {
				if (l + 1 == r) {
					c = r;
					if (t[i] > d[c])
						l++;
					else
						r--;
				}
				else {
					r = c;
				}
			}
		}
		r2[i] = l;
		for (j = l2; j <= r2[i]; j++) {
			if (g[j] != -1)
				j = r2[w[j]];
			else {
				g[j] = m[i].first;
				w[j] = i;
			}
		}
      }
	}
	for (i = 0; i < q; i++)
		cout << g[i] << endl;
}


Measured memory_bytes: 14848
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1,class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, R;
	cin >> N >> R;
	if (N >= 10)cout << R << "\n";
	else cout << R + 100 * (10 - N) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
ll rand_int(ll l,ll r){	//[l,r]
	using D = uniform_int_distribution<ll>;
	static random_device rd;
	static mt19937 gen(rd());
	return D(l,r)(gen);
}
ll rand_int(ll n){	//[0,n)
	return rand_int(0,n-1);
}
int main(){
	int N;
	cin>>N;
	vector<int> a(N);
	rep(i,N) cin>>a[i];

	map<int,ll> hsh;
	rep(i,N){
		if(hsh.count(a[i])) continue;
		hsh[a[i]] = rand_int(1000000000000000000);
	}
	ll x=0;

	vector<int> ans;
	rep(i,N){
		x += hsh[a[i]];
		x -= hsh[a[N-1-i]];
		if(x==0) ans.pb(i+1);
	}
	int K = ans.size();
	rep(i,K) cout<<ans[i]<<(i==K-1?"\n":" ");
}



Measured memory_bytes: 6392
#include <bits/stdc++.h>
#define SZ(c)       int(c.size())
#define FOR(i,a,b)  for (int i=a; i<(b); ++i)
#define DOWN(i,a,b) for (int i=(a)-1; i>=(b); --i)
using namespace std;
using i64 = long long;

void check(char c) {
  if (c=='V') exit(0);
}

int ask(int x) {
  cout<<x<<endl;
  string s;
  cin>>s;
  check(s[0]);
  return s[0];
}

int main() {
  ios_base::sync_with_stdio(0);

  int n;
  cin>>n;
  int x=ask(0);
  int l=0,r=n-1;
  while (r-l>1) {
    int m=(l+r)/2;
    int z=ask(m);
    if (m%2==0) {
      if (z==x) l=m; else r=m;
    } else {
      if (z!=x) l=m; else r=m;
    }
  }
  ask(l+1);
  
  return 0;
}


Measured memory_bytes: 852
import itertools
n,m,x = map(int, input().split())
a = []
res = 10000000
for i in range(n):
  a.append(list(map(int, input().split())))
for i in range(1,n+1):
  l = itertools.combinations(range(n),i)
  for j in l:
    tmp = [0]*(m+1)
    for k in j:
      for o in range(m+1):
        tmp[o] += a[k][o]
    flg = 0
    for o in range(1,m+1):
      if tmp[o] < x:
        flg = 1
    if flg == 0:
      res = min(res, tmp[0])
if res == 10000000:
  print(-1)
else:
  print(res)


Measured memory_bytes: 9224
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 10e-8;

vector<int> split(string delim,string str){
	vector<int> res;
	str += delim;
	for(int i=0;i<str.size();i++){
		for(int j=1;i+j<=str.size();j++){
			if(str.substr(i,j).find(delim) != string::npos){
				int num = atoi(str.substr(i,j-1).c_str());
				if(str.substr(i,j-1).size() >0 ) res.push_back(num);
				i+=j-1;
				break;
			}
		}
	}

	return res;
}

int main(){

	string str;
	while(getline(cin,str)){
		vector<int> data = split(" ",str);
		if(data.size() == 1 && data[0] == 0) break;

		int res=0;
		for(int i=data[0];i<=data[1];i++){
			int tmp = i;
			while(tmp % 2 == 0){
				tmp /=2;
			}

			while(tmp % 3 == 0){
				tmp /=3;
			}

			while(tmp % 5 == 0){
				tmp /=5;
			}

			if(tmp==1) res++;
		}

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

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

int main(){
  int n, a[100], b[100], c[100], ans=0, bef=-100;
  cin >> n;
  for(int i=1;i<=n;i++)cin >> a[i];
  for(int i=1;i<=n;i++)cin >> b[i];
  for(int i=1;i<=n-1;i++)cin >> c[i];
  for(int i=1;i<=n;i++){
    ans+=b[a[i]];
    if(bef+1==a[i])ans+=c[bef];
    bef=a[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b, c, cnt = 0;
	//数値を3つ入力
	scanf("%d %d %d", &a, &b, &c);
	//約数の数の計算
	while(a <= b){
		if((c % a) == 0){
			cnt++;
		}
		a++;
	}
	//結果を出力
	printf("%d\n", cnt);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    string s, t;
    cin >> s >> t;
    bool ans = false;
    rep(i,s.length()){
        if(s.substr(i,s.length()-i)+s.substr(0,i)==t){
            ans = true;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Two Coins
https://beta.atcoder.jp/contests/abc091/tasks/abc091_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    A, B, C = map(int, input().split())
    if A + B >= C:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int h,n;
    int a;
    int sum=0;
    cin>>h>>n;
    while(cin>>a){
        sum+=a;
    }
    if(sum>=h){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "6", "1 1 1 2 2 3", "1 1 1 2 2 3" ].solve == "Yes\n2 2 3 1 1 1" );
	assert( [ "3", "1 1 2", "1 1 3" ].solve == "No" );
	assert( [ "4", "1 1 2 3", "1 2 3 3" ].solve == "Yes\n3 3 1 2" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	
	// 可否を判定
	auto cs = new long[ n + 1 ];
	foreach( a, b; lockstep( as, bs ) )
	{
		cs[ a ]++;
		cs[ b ]++;
	}
	foreach( c; cs )
	{
		if( n < c ) return "No";
	}
	
	// a!=bになるように入れ替え
	for( auto i = 0L, j = 0L, k = 0L; i < n; i++ )
	{
		if( as[ i ] != bs[ i ] ) continue;
		if( as[ i ] != as[ k ] )
		{
			j = 0;
			k = i;
		}
		for( ; j < n; j++ )
		{
			if( as[ i ] != bs[ j ] && as[ j ] != bs[ i ] )
			{
				bs.swapAt( i, j );
				break;
			}
		}
	}
	return "Yes\n" ~ bs.to!( string[] ).join( " " );
}


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

int main() {
  int N;

  cin >> N;
  
  if (N/1000 == (N%1000)/100 && (N%1000)/100 == (N%100)/10){
  	cout << "Yes" << endl;
  }
  else if ((N%1000)/100 == (N%100)/10 && (N%100)/10 == N%10) {
    cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1)/A;
    
    
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Apl 30 19:23:25 2018

@author: Fujiichang
"""

if __name__ == "__main__":
    value = input().split()
    W = int(value[0])
    H = int(value[1])
    x = int(value[2])
    y = int(value[3])
    r = int(value[4])

    if W - r - x >= 0 and H - r - y >= 0 and x - r >= 0 and y - r >= 0:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 5612
#include <stdio.h>
#include <iostream>
using namespace std;

class Fibonacci{
private:
	int f[45];
	int len;
public:
	Fibonacci(){ f[0] = f[1] = 1; len = 2; }
	int calc(int n);
};

int Fibonacci::calc(int n)
{
	if (n < len) return f[n];
	f[n] = calc(n - 1) + calc(n - 2);
	len++;
	return f[n];
}

int main(void)
{
	Fibonacci fib;
	int n;
	cin >> n;
	cout << fib.calc(n) << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	string o,e;
	cin >> o;
	cin >> e;
	if(o.length()==e.length()){
		rep(i,o.length()){
			cout<<o[i]<<e[i];
		}
		cout << endl;
	}else{
		rep(i,e.length()){
			cout<<o[i]<<e[i];
		}
		cout<<o[o.length()-1]<<endl;
	}
}

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

    public static void main(String[] args) {
        // write your code here
        Scanner scr = new Scanner(System.in);
        int s =scr.nextInt();
        int[] ip= new int[s];
        for(int i=0;i<s;i++){
            ip[i]= scr.nextInt();
        }
        int[] op= new int[s];
        for(int i=0;i<s;i++){
            op[ip[i]-1]=i+1;
        }
        for (int g: op
             ) {
            System.out.print(g+" ");
        }
    }
}


Measured memory_bytes: 57164
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    ll a,b,c,d; cin >> a >> b >> c >> d;
    cout << max(a*c,max(a*d,max(b*c,b*d))) << endl;
}

Measured memory_bytes: 3540
#include<cstdio>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1)
    {
        a=14;
        
    }
    if(b==1)
    {
        b=14;
    }
    if(a>b)
    {
        printf("Alice\n");
    }
    else
    if(a<b)
    {
        printf("Bob\n");
    }
    else
    {
        printf("Draw\n");
    }
    return 0;
    
}

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

int main()
{
	int n;
	cin >> n;
	int num[3][200], check[3][101] = {0}, ans[200] = {0};
	for(int i = 0; i < n; i++)
		for(int j = 0; j < 3; j++){
			cin >> num[j][i];
			check[j][num[j][i]]++;
		}

	for(int i = 0; i < 3; i++)
		for(int j = 0; j < n; j++)
			if(check[i][num[i][j]] == 1)
				ans[j] += num[i][j];

	for(int i = 0; i < n; i++)
		cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n; cin>>n;
	int maxh;
	cin>>maxh;
	bool ans = true;
	bool al = false;
	rep(i,n-1){
		int nowh;
		cin>>nowh;
		if(maxh-1>nowh){
			ans = false;
			break;
		}
		if(maxh-1==nowh){
			al = true;
			continue;
		}
		if(maxh<nowh){
			maxh = nowh;
			al = false;
		}
	}
	cout<<((ans)?"Yes":"No")<<endl; return 0;
}


Measured memory_bytes: 256
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
	while(z[++Z]=x%10+48,x/=10);
	while(sr[++C]=z[Z],--Z);
	//sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}

int a[100100],p;

int main()
{
	int n;
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
		if (a[i]<0) p=i;
		else break;
	p=max(p,1);p=min(p,n-1);
	for (int i=1;i<=p;i++) ans-=a[i];
	for (int i=p+1;i<=n;i++) ans+=a[i];
	print(ans);
	sr[++C]='\n';
	for (int i=p+1;i<n;i++)
	{
		print(a[p]);sr[++C]=' ';
		print(a[i]);sr[++C]='\n';
		a[p]-=a[i];
	}
	print(a[n]);sr[++C]=' ';
	print(a[p]);sr[++C]='\n';
//	printf("%d %d\n",a[n],a[p]);
	a[n]-=a[p];
	for (int i=1;i<p;i++)
	{
		print(a[n]);sr[++C]=' ';
		print(a[i]);sr[++C]='\n';
//		printf("%d %d\n",a[n],a[i]);
		a[n]-=a[i];
	}
	Ot();
	return 0;
}









Measured memory_bytes: 8576
#include <iostream>
 
using namespace std;
 
int main() {
 
  int a,b,c;
 
  while(1) {
  cin >> a >> b >> c;
  if(a == 0 && b == 0 && c == 0) break;
 
  int n;
  cin >> n;
 
  int flg[301];
 
  for(int i=0;i<301;i++) flg[i] = 2;
 
  int d[1001],m[1001],k[1001],r;
 
  for(int i=0;i<n;i++) {
    cin >> d[i]>> m[i] >> k[i] >> r;
    if(r == 1) {
      flg[d[i]] = flg[m[i]] = flg[k[i]] = 1;
      i--;
      n--;
    }
  }
  int sum;
  for(int i=0;i<n;i++){
    sum = 0;
    if(flg[d[i]] == 1 ) sum++;
    if(flg[m[i]] == 1)  sum++;
    if(sum == 2) {
      flg[k[i]] = 0;
      continue;
    }
    if(flg[k[i]] == 1) sum++;
    if(sum == 2) {
      if(flg[d[i]] == 2) flg[d[i]] = 0;
      else flg[m[i]] = 0;
    }
  }
   
   
  for(int i=1;i<=a+b+c;i++) {
    cout << flg[i] << endl;
  }
   
   
   
  }
 
  return 0;
}

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

int main()
{
  int X, A, B;
  int res=0;
  cin >> X >> A >> B;

  X -= A;

  cout << X%B << endl;
}

Measured memory_bytes: 256
(function() {
    'use strict';
    var lines = [];
    require('readline').createInterface({
        input: process.stdin,
        output: process.stdout
    })
        .on('line', function(line) {
            lines.push(line);
        });

    process.stdin.on('end', function() {
        main(lines);
    });
})();
String.prototype.replaceAt=function(index, character) {
    return this.substr(0, index) + character + this.substr(index+character.length);
}
function main(lines) {
    var input = lines[0], numOps = lines[1];
    for (var i=0; i<input.length; i++) {
        var distToA = (123 - input.charCodeAt(i)) % 26;
        if (numOps >= distToA) {
            input = input.replaceAt(i, 'a');
            numOps -= distToA;
        }
        if (numOps === 0) {
            break;
        }
    }
    numOps = numOps % 26;
    input = input.replaceAt(input.length-1, String.fromCharCode(input.charCodeAt(input.length-1) + numOps));
    console.log(input);
}


Measured memory_bytes: 38216