akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#define LL long long
using namespace std;
LL a[100010],n;
void priNo()
{
    printf("NO\n");
    exit(0);
}
int main()
{
    cin >> n;
    LL sum = 0;
    for (int i = 0;i < n;i++)
    {
        scanf("%lld",&a[i]);
        sum += a[i];
    }
    if (sum%((n*(n+1))/2) != 0) priNo();
    LL k = sum/((n*(n+1))/2);
    a[n] = a[0];
    for (int i = 1;i <= n;i++)
    {
        LL d = a[i]-a[i-1];
        if (k-d < 0||((k-d)%n) != 0) priNo();
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

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)*}
    };
}

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")
    };
}

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        x: i64,
    }
    let mut ans = (x / 11) as i64 * 2;
    if x % 11 > 6{
        ans += 2;
    }else if x % 11 > 0{
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n,mxjump;
int h[MAXN];

ll dp[MAXN];

ll solve() {
	dp[0]=0;
	FORE(i,1,n-1) {
		dp[i]=LLONG_MAX;
		FORE(j,1,mxjump) if(j<=i) dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
	}
	return dp[n-1];
}

void run() {
	scanf("%d%d",&n,&mxjump);
	REP(i,n) scanf("%d",&h[i]);
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 1408
import itertools

N = int(input())
N = list(range(1, N+1))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

cnt = 0
for i in list(itertools.permutations(N)):
    cnt += 1
    if i == P:
        a = cnt
    if i == Q:
        b = cnt
        
print(abs(a-b))

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll n, m, ans;
ll fact[2222222];
ll invfact[2222222];
ll dp[1111111];
ll dp2[1111111];

long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

ll nHr(ll n, ll r){
	ll A = n - 1;
	ll B = r;
	return mod_div(fact[A + B], fact[A] * fact[B] % MOD);
}

ll nCr(ll n ,ll r){
	if(r > n){
		return 0;
	}
	return mod_div(fact[n], fact[n - r] * fact[r] % MOD);
}

void init(){
	fact[0] = 1;
	for(ll i = 1;i < 2222222;i++){
		fact[i] = fact[i-1] * i % MOD;
		invfact[i] = mod_div(1, fact[i]);
	}
}

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

	cin >> n >> m;

	REP(i, 1111111){
		dp2[i] = nHr(n - 1, i);
		if(i){
			dp2[i] = (dp2[i] + dp2[i-1]) % MOD;
		}
	}
	REP(i, 1111111){
		dp2[i] = (dp2[i] * n) % MOD;
	}

	dp[0] = 1;
	for(ll i = 1;i < 1111111;i++){
		dp[i] = nHr(n, i);
		if(i > m){
			dp[i] = (dp[i] - dp2[i - (m+1)] + MOD) % MOD;
		}
	}

	for(ll i = 0;i <= m;i++){
		if((3 * m - i) % 2) {
			continue;
		}
		ll now_m = (3 * m - i) / 2;
		ll now_one = i;
		ll now = dp[now_m] * nCr(n, i);
		if(now_m >= m && i){
			ll tmp = nHr(n - 1, now_m - m) * nCr(n - 1, i - 1) % MOD;
			tmp = tmp * n % MOD;
			now = (now + MOD - tmp) % MOD;
		}
		//cout << i << " " << now_m << " " << dp[now_m] << " " << now << endl;
		ans = (ans + now) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 52352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W, N;
    cin >> H >> W >> N;
    int sr, sc;
    cin >> sr >> sc;
    string S, T;
    cin >> S >> T;
    // lc: 減る方向, rc: 増える方向
    auto check = [&](char lc, char rc, int mx, int pos) {
        int l = 1, r = mx;
        for (int i = N - 1; i >= 0; i--) {
            // 青木君
            if (T[i] == lc) {
                r++;
            }
            if (T[i] == rc) {
                l--;
            }
            if (l > r) {
                return false;
            }
            r = min(r, mx);
            l = max(l, 1);
            // 高橋君
            if (S[i] == lc) {
                l++;
            }
            if (S[i] == rc) {
                r--;
            }
            if (l > r) {
                return false;
            }
            r = max(r, 1);
            l = min(l, mx);
        }
        dump(l);
        dump(r);
        return l <= pos && pos <= r;
        
    };
    bool ans = true;
    ans &= check('L', 'R', W, sc);
    dump(ans);
    ans &= check('U', 'D', H, sr);
    dump(ans);
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 920
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
a = Line(N,1)

ans = 'second'
for x in a:
    if x%2==1:
        ans = 'first'
        break

print(ans)

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

Int n;
bool f[201][201];
Int d[201][201];
Int bin[201];

bool dfs(Int x, Int type) {
    bool ret = true;
    for (Int i = 0; i < n; i++) {
        if (f[x][i]) {
            if (bin[i] < 0) {
                bin[i] = (type + 1) % 2;
                ret = ret && dfs(i, (type + 1) % 2);
            }
            else {
                if (bin[i] != (type + 1) % 2) {
                    ret = false;
                }
            }
        }
    }
    return ret;
}

int main() {
    cin >> n;
    for (Int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (Int j = 0; j < n; j++) {
            f[i][j] = s[j] == '1';
            d[i][j] = f[i][j] ? 1 : INF;
        }
    }
    for (Int i = 0; i < n; i++) {
        bin[i] = -1;
    }
    bin[0] = 0;
    if (!dfs(0, 0)) {
        dump(-1);
        return 0;
    }
    for (Int k = 0; k < n; k++) {
        for (Int i = 0; i < n; i++) {
            for (Int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    Int ma = -1;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < n; j++) {
            if (d[i][j] == INF || i == j) {
                continue;
            }
            ma = max(ma, d[i][j]);
        }
    }
    dump(ma + 1);
    return 0;
}


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

long int myPow(long int _x, long int _n)
{
  long int ret = 1;
  while (0 < _n)
  {
    if ((_n % 2) == 0)
    {
      _x *= _x;
      _n >>= 1;
    }
    else
    {
      ret *= _x;
      --_n;
    }
  }
  return ret;
}

int main()
{

  long int H;
  long int result = 0;

  cin >> H;

  long int count = 0;

  while (H > 1)
  {
    H /= 2;
    count++;
  }

  for (long int i = 0; i < count + 1; i++)
  {
    result += myPow(2, i);
  }

  cout << result << endl;
}


Measured memory_bytes: 256
N = int(input())
count = [0]*(N+1)
modz = 10**9 + 7

def junretsu(a):
    if a <= 0: return 1
    if (a & 0x01) == 1:
        return 2*junretsu(a-1) % modz
    else:
        rr = junretsu(a>>1)
        return rr*rr % modz

pos = list(map(int, input().split()))
for i in range(N):
    count[pos[i]] += 1

diff = [0]*(N+1)
for i in range(1, N+1):
    d = abs((N - i) - (i-1))
    diff[d] += 1

invalid = False
total = 1
for i in range(N):
    if count[i] != diff[i]:
        invalid = True
        break

if invalid:
    print(0)
else:
    print(junretsu(int(N/2)))


Measured memory_bytes: 21336
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<int> v(n + 1);
  rep(i, 1, n + 1) cin >> v[i];

  int cur = 1, t = 0, ans = 0;
  bool flg = false;
  while (v[cur]) {
    ans++;
    int t = v[cur];
    v[cur] = 0;
    if (t == 2) {
      flg = true;
      break;
    }
    cur = t;
  }

  if (flg)
    cout << ans << endl;
  else
    cout << -1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  map<ll, ll> m1;
  map<ll, ll> m2;

  rep(i, N) {
    ll a;
    cin >> a;
    if (i % 2 == 0) {
      m1[a]++;
    } else {
      m2[a]++;
    }
  }

  ll m1_max_1 = 0;
  ll m1_max_2 = 0;
  ll m1_max_num1 = 0;
  for (auto m : m1) {
    if (m1_max_1 < m.second) {
      m1_max_2 = m1_max_1;
      m1_max_1 = m.second;
      m1_max_num1 = m.first;
    } else {
      if (m1_max_2 < m.second) {
        m1_max_2 = m.second;
      }
    }
  }

  ll m2_max_1 = 0;
  ll m2_max_2 = 0;
  ll m2_max_num1 = 0;
  for (auto m : m2) {
    if (m2_max_1 < m.second) {
      m2_max_2 = m2_max_1;
      m2_max_1 = m.second;
      m2_max_num1 = m.first;
    } else {
      if (m2_max_2 < m.second) {
        m2_max_2 = m.second;
      }
    }
  }

  // 同じ数字を多く使っているケース
  if (m1_max_num1 == m2_max_num1) {
    if (N == m1_max_1 + m2_max_1) {
      // 一種類しか使ってないケース
      COUT(N / 2);
      return 0;
    }

    // 使っている文字数も同じケース
    if (m1_max_1 == m2_max_1) {
      if (m1_max_2 < m2_max_2) {
        COUT(N - m1_max_1 - m2_max_2);
      } else {
        COUT(N - m1_max_2 - m2_max_1);
      }
      return 0;
    }

    if (m1_max_1 < m2_max_1) {
      COUT(N - m1_max_2 - m2_max_1);
      return 0;
    } else {
      COUT(N - m1_max_1 - m2_max_2);
      return 0;
    }
  }
  COUT(N - m1_max_1 - m2_max_1);
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007
#define pi 3.14159265358979323846264338327950

void solve()
{
    ll n, m;
    cin >> n >> m;
    if (n < m)
    {
        cout << min(n, m-n%m) << endl;
        return;
    }
    ll temp = n % m;
    cout << min(temp, m - temp) << endl;
}

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

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

class E
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		var a = read().OrderBy(x => -x).ToArray();
		var f = read().OrderBy(x => x).ToArray();

		long l = 0, r = a[0] * f.Last(), m;
		while (l < r)
		{
			m = (l + r) / 2;
			if (Enumerable.Range(0, (int)h[0]).Sum(i => Math.Max(0, a[i] - m / f[i])) <= h[1]) r = m;
			else l = m + 1;
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 49608
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x,y) memset(x,y,sizeof(x))
#define task "Knapsack"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)

using namespace std;
int n,lim,w[maxn],v[maxn];
int ans;
int s = 0;
ll dp[maxn];
int main()
{
//    #ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
//    freopen(task".inp","r",stdin);
//    freopen(task".out","w",stdout);
//    #endif
    cin >> n >> lim;
    for(int i=1; i<=n; ++i) cin >> w[i] >> v[i],s += v[i];
    fill(dp+1,dp+s+1,maxc);
    for(int j=1; j<=n; ++j)
    {
        for(int i=s; i>=1; --i)
        {
            if(i - v[j] < 0) continue;
            dp[i] = min(dp[i], dp[i-v[j]] + w[j]);
            if(dp[i] <= lim)
                ans = max(ans, i);
        }
    }
    cout << ans;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[][] x = new int[n][n];//index+1
		int[][] y = new int[n][n];//1or 0

		for(int i =0;i<n;i++) {
			a[i] = sc.nextInt();
			for(int j = 0;j<a[i];j++) {
				x[i][j]= sc.nextInt();
				y[i][j]=sc.nextInt();

			}
		}
		int max = 0;
		for(int i =1;i<Math.pow(2, n);i++) {
			boolean suc = true;
			int[] bits = new int[n];

			int c = i;
			for(int j=0;j<bits.length;j++) {
				bits[j]=0;
				if(c>=Math.pow(2, n-j-1)) {
					c-=Math.pow(2,n-j-1);
					bits[j]=1;
				}
			}
			for(int j=0;j<bits.length;j++) {
				if(bits[j]==1) {
					for(int k=0;k<a[j];k++) {
						if(bits[x[j][k]-1]!=y[j][k]) {
							suc = false;
							break;
						}
					}
				}
			}
			if(suc) {
				int counter =0;
				for(int j=0;j<bits.length;j++) {
					counter+=bits[j];
				}
				if(max<counter)max = counter;
			}
		}
		System.out.println(max);
	}
	public static long calc(int n,int c) {
		long ans = 1;
		for(int i =1;i<n+1;i++) {
			ans = (ans * i)%1000000007;
		}
		ans = ans * reverse(c)%1000000007;

		return ans*reverse(n-c)%1000000007;
	}
	public static long reverse(int c) {
		long divider =1;
		for(int i =1;i<c+1;i++) {
			divider = (divider * i)%1000000007;
		}
		long dividerholder=divider;
		for(int i=1;i<10000;i++) {
			divider = divider*dividerholder%1000000007;
		}
		long dividerholder2 = divider;
		for(int i=1;i<100000;i++) {
			divider = divider*dividerholder2%1000000007;
		}
		for(int i=0;i<5;i++) {
			divider = divider*dividerholder%1000000007;
		}
		return divider;
	}
}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 25224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	//assets vs liabilities
	//keeping cash = risk of losing money to inflation
	
	string s; cin>>s;
	cout<<"ABC" + s<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000000

int Partition(int* A,int p,int r){
  int x=A[r],i=p-1,j,tmp;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
    tmp=A[i+1];
    A[i+1]=A[r];
    A[r]=tmp;
    return i+1;
}

int main(){
  int i,k,n,a[N];
  scanf("%d",&n);
 
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  k=Partition(a,0,n-1);
  for(i=0;i<n;i++){
    if(i!=n-1){
      if(i!=k)printf("%d ",a[i]);
      else printf("[%d] ",a[i]);
    }
    else printf("%d\n",a[i]);
  }
  
  
  
  return 0;
}

Measured memory_bytes: 2888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  int a;
  cin >> a;
  vec.at(i) = a;
  }
  int tmp;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      if (vec.at(i) < vec.at(j)) {
        tmp =  vec.at(i);
        vec.at(i) = vec.at(j);
        vec.at(j) = tmp;
      }
    }
  }//降順並べ替え
  int A = 0;
  int i = 0;
  while (i < N) {
    A += vec.at(i);
      i += 2;
  }
  int B = 0;
  int j = 1;
    while (j < N) {
      B += vec.at(j);
      j += 2;
    }
  cout << A - B << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
/*
date:20180407
name:A - abc of ABC
written by youkan_koshian_gurentai
*/

int main(void){
    char S[3];
	scanf("%s", S);
	int temp =0;
	for(int i=0; i<3;i++) {
		if(S[i]=='a') temp+=100;
		if(S[i]=='b') temp+=10;
		if(S[i]=='a') temp+=1;
	}
	if (temp == 111) printf("Yes");
	else puts("No");
    return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
using namespace std;

int main() {
long long int A, V, B, W, T;cin >> A >> V >> B >> W >> T;
if(V <= W)cout << "NO";

if((V - W)*T >= abs(B - A))cout << "YES";

if((V - W)*T < abs(B - A) && V > W)cout << "NO";

}

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

int main(){
    int N,W; cin >> N >> W;
    int dp[10010];
    fill(dp,dp+W+1,-1);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        int v,w; cin >> v >> w;
        for(int j = w; j <= W; j++){
            if (dp[j-w] != -1) dp[j] = max(dp[j - w] + v, dp[j]);
        }
    }
    int ans = 0;
    for(int i = 0; i <= W; i++){
        ans = max(ans, dp[i]);
    }
    //cout << *max_element(dp,dp+W+1) << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3148
a, b, c, x, y = map(int, input().split())
if a + b <= 2 * c:
    print(a * x + b * y)
else:
    z = min([x,y])
    ans = min([c*z*2+a*(x-z)+b*(y-z), c*max([x,y])*2])
    print(ans)

Measured memory_bytes: 3060
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i + 1):
    if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
      print(i, j, n - i - j)
      exit()
print("-1 -1 -1")


Measured memory_bytes: 41324
#include <bits/stdc++.h>
using namespace std;
 
int X, Y;
 
int getRoutePatterns(int x, int y){
  if(x < 0 || y < 0) return 0;
  if(x == 0 && y==0) return 1;
  if(x == 0 && y==1) return 0;
  if(x == 1 && y == 0) return 0;
  // cout << "x:" <<x<<" y:"<<y <<"  "<< (getRoutePatterns(x-1, y-2) + getRoutePatterns(x-2,y-1)) % (int)(pow(10,9)+7)<< "\n";
  return (getRoutePatterns(x-1, y-2) + getRoutePatterns(x-2,y-1)) % (int)(pow(10,9)+7);
}

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

long long extGCD_tobeFixed(long long a, long long b, long long &x, long long &y){
  if(b ==0){
    x=1;
    y=0;
    return a;
  }
  long long d = extGCD_tobeFixed(b,a%b,y,x);
  y -= a*x/b;
  return d;
}

void extGCD(long long a, long long b, long long &x_, long long &y_){
  long long s, t, u,v,k,x,y;
  s = a;t = b;
  x = 1; y=0; u=0;v=1;
  while(t){
    k = s/t;
    s -= k*t;
    swap(s,t);
    x -= k*u;
    y -= k*v;
    swap(x,u);
    swap(y,v);
  }
  x_ = x; y_=y;
}

long long modinv(long long a, long long m){
  long long x,y;
  extGCD(a,m,x,y);
  if(x<0) return x+m;
  return x;
}

const int MAX = 700000;
const int MOD = pow(10,9) + 7;
long long fac[MAX], inv[MAX], finv[MAX];

void COMinit(){
  fac[0]=fac[1] = 1;
  inv[1] = 1;
  finv[0] = finv[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 COM(int n, int k){
  if(n<k) return 0;
  if(n <0 || k<0) return 0;
  return fac[n]* (finv[n-k]*finv[k] % MOD) % MOD;
}
 
void solve() {
  cin >> X >> Y;
  if((2*X-Y)%3 != 0 || (-X+2*Y)%3 != 0){
    cout << 0 << endl;
  }else{
    int n = (2*X-Y)/3;
    int m = (-X+2*Y)/3;
    COMinit();
    cout << COM(m+n,m) << endl;
  }
  return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 20040
#include <stdio.h>
#include <math.h>

int main(void) {
  long int n, k, h[100101], dp[100101];
  dp[0] = 0;
  scanf("%ld %ld", &n, &k);
  
  for (int i = 0; i < n; i++) {
    scanf("%ld", &h[i]);
  }

  for (int i = 1; i < 100101; i++) dp[i]=1E9;

  for (int i = 0; i < n; i++) {
	  for (int j = 1; j <= k; j++) {
		  dp[i + j] = fmin( dp[i + j], dp[i] + abs(h[i] - h[i + j]) );
	  }
  }
  printf("%ld", dp[n - 1]);

  return 0;
}

Measured memory_bytes: 1792
#!ruby -pal
def i c,d
[0,1].map{|j|d[j]?c[j]&&(i c[j],d[j]):(c[j]=nil)}
c
end
def u c,d
[0,1].map{|j|(c[j]||d[j]&&(c[j]||=[nil,nil]))&&(u c[j],d[j]||=[nil,nil])}
c
end
$_=eval($F[0]+" "+$F[1,2].map{|l|l.tr("()","[]").gsub(/(\[|,)(?=,|\])/,'\1nil')}*",").to_s.gsub(/nil| /,"").tr("[]","()")

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

int main()
{
	while ( true )
	{
		int n;
		char s, t, b;
		cin >> n;
		if ( n == 0 )
			break;
		cin >> s >> t >> b;

		vector<double> P(9);
		P[s-'A'] = 1;

		for ( int i=0; i<n; i++ )
		{
			vector<double> T = P;
			P = vector<double>(9);

			P[0] += T[0] / 4 * 2;
			P[1] += T[0] / 4 * 1;
			P[3] += T[0] / 4 * 1;
			P[0] += P[b-'A'],  P[b-'A'] = 0;

			P[1] += T[1] / 4 * 1;
			P[0] += T[1] / 4 * 1;
			P[2] += T[1] / 4 * 1;
			P[4] += T[1] / 4 * 1;
			P[1] += P[b-'A'],  P[b-'A'] = 0;

			P[2] += T[2] / 4 * 2;
			P[1] += T[2] / 4 * 1;
			P[5] += T[2] / 4 * 1;
			P[2] += P[b-'A'],  P[b-'A'] = 0;
			
			P[3] += T[3] / 4 * 1;
			P[0] += T[3] / 4 * 1;
			P[4] += T[3] / 4 * 1;
			P[6] += T[3] / 4 * 1;
			P[3] += P[b-'A'],  P[b-'A'] = 0;

			P[1] += T[4] / 4 * 1;
			P[3] += T[4] / 4 * 1;
			P[5] += T[4] / 4 * 1;
			P[7] += T[4] / 4 * 1;
			P[4] += P[b-'A'],  P[b-'A'] = 0;

			P[5] += T[5] / 4 * 1;
			P[2] += T[5] / 4 * 1;
			P[4] += T[5] / 4 * 1;
			P[8] += T[5] / 4 * 1;
			P[5] += P[b-'A'],  P[b-'A'] = 0;

			P[6] += T[6] / 4 * 2;
			P[3] += T[6] / 4 * 1;
			P[7] += T[6] / 4 * 1;
			P[6] += P[b-'A'],  P[b-'A'] = 0;
			
			P[7] += T[7] / 4 * 1;
			P[4] += T[7] / 4 * 1;
			P[6] += T[7] / 4 * 1;
			P[8] += T[7] / 4 * 1;
			P[7] += P[b-'A'],  P[b-'A'] = 0;

			P[8] += T[8] / 4 * 2;
			P[5] += T[8] / 4 * 1;
			P[7] += T[8] / 4 * 1;
			P[8] += P[b-'A'],  P[b-'A'] = 0;
		}

		printf( "%.20f\n", P[t-'A'] );
	}
}

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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


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

int main() {
  int N;
  cin >> N;
  
  cout << (N+1)/2 << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   string s;
   cin>>s;
   int count = 0;
   for(int i = 0; i<4;i++){
       if(s.at(i)=='+'){
           count++;
       }else{
           count--;
       }
   }
   cout<<count<<endl;
}

Measured memory_bytes: 3580
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a,k, o=0; cin>>a>>k;
    vec<ll> m(a);
    for(int q=0; q<a; q++) cin>>m[q];
    for(int k1=0; k1<=min(a,k); k1++){
        for(int k2=0; k2+k1<=min(a,k); k2++){
            int p = k-k1-k2, s=0;
            vec<int> n(k1+k2);
            for(int q=0; q<k1; q++) n[q] = m[q];
            for(int q=0; q<k2; q++) n[k1+q] = m[a-1-q];
            sort(n.begin(), n.end());
            for(int q=0; q<k1+k2; q++){
                if(n[q]>=0) s+=n[q];
                else if(q+1>p) s+=n[q];
            }
            o = max(o,s+0LL);
        }
    }
    cout<<o<<endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
Sum = A + B
if A == 0:
    print('0')
    exit()
if B == 0:
    print(N)
    exit()
ans = (N // Sum) * A
if N > Sum:
    if N % Sum >= A:
        ans += A
    if N % Sum < A:
        ans += N%Sum
if N < Sum:
    if N>=A:
        ans=A
    if N < A:
        ans=N
print(ans)

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

using namespace std;

#define WA(x) #x << " = " << x << '\n'
#define FOR(i, n) for(int i = 0; i<(int) n; i++)
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int INF = 1e9+10;

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

	int n; cin >> n;
	map<string,int> m;
	int maxi = 0;
	for(int i = 0; i < n; i++){
		string s; cin >> s;
		m[s]++;
		maxi = max(maxi, m[s]);
	}

	for(auto& p: m){
		if(p.S == maxi)
			cout << p.F << '\n';
	}	


	return 0;
}

Measured memory_bytes: 23808
import java.io.IOException;

public class Main{
    public static void main(String[] a) throws IOException {
		int s1 = 0,s2 = 0,i= 0;
		String Set;
		String[] stock = new String[2];
		String Input = null;
		java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
		try{
			while((Input = in.readLine()) != null){
				stock = Input.split(" ");
				s1 = Integer.parseInt(stock[0]);
				s2 = Integer.parseInt(stock[1]);
				Set = String.valueOf(s1 + s2);
				System.out.println(Set.length());
			}
			
		}catch(Exception e){
		}
    }
}

Measured memory_bytes: 17000
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,O,P=0,c=0,co=0,cou=0,minN=mod;
  double D,Do;
  char C,Ca;
  str S,T;
  cin>>N>>M;
  vint A(N);
  rep(0,N){
    cin>>A[i];
    c+=A[i];
  }
  sort(all(A));
  if(N>=M)rep(0,M){
    c-=A[A.size()-1-i];
  }
  else c=0;
  cout<<c<<endl;
}


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


int main()
{
     ll l; string s;
    cin>>l>>s;
    ll a=0,b=0,c=0,r=0;

        a=count(s.begin(),s.end(),'R');
        b=count(s.begin(),s.end(),'G');
        c=count(s.begin(),s.end(),'B');
    ll ans=a*b*c;
     for(ll i=0; i<l-1; i++)
    {
        for(ll j=i+1; j<l; j++)
        {
            ll k=2*j-i;
            //cout<<i<<" "<<s[i]<<" "<<j<<" "<<s[j]<<" "<<k<< " "<<s[k]<<endl;
            if(k<l)
                {
                    if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i])ans--;
                }
        }
    }


    cout<<ans<<endl;
}




Measured memory_bytes: 3636
h,w = map(int,input().split())
S = [input() for p in range(h)]

dx = [1,0,-1,0]
dy = [0,1,0,-1]

for i in range(h):
    for j in range(w):
        if S[i][j] == '.':
            continue
        else:
            count = 0
            for k in range(4):
                    if not 0<=i+dy[k]<h or not 0<=j+dx[k]<w:
                        continue
                    if S[i+dy[k]][j+dx[k]] == '#':
                        count += 1
            if count == 0:
                print('No')
                exit()

print('Yes')

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string s, t, u;
    int a, b;

    cin >> s >> t >> a >> b >> u;

    if(s == u){
        cout << a-1 << " " << b << endl;
    }

    else{
        cout << a << " " << b-1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,m;
 	cin>>n>>m;
 	ll h[n];
 	for(ll i=0;i<n;i++)
 	{
 		cin>>h[i];
 	}
 	vector<ll>g[n+1];
 	for(ll i=0;i<m;i++)
 	{
 		ll x,y;
 		cin>>x>>y;
 		g[x].push_back(y);
 		g[y].push_back(x);
 	}
 	ll ans=0;
 	for(ll i=1;i<=n;i++)
 	{
 		bool f=true;
 		for(ll x:g[i])
 		{
 			if(h[i-1]<=h[x-1])
 				f=false;
 		}
 		if(f)
 		{
 			++ans;
 		}
 	}
 	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10264
from bisect import bisect_right as br
from itertools import accumulate

def main():
  
  m, n = map(int, input().split())
  books = list(list(map(int, input().split())) for _ in range(m))
  ws = list(accumulate([0] + [book[0] for book in books]))
  ts = list(accumulate([0] + [book[1] for book in books]))
  shelf = list(list(map(int, input().split())) for _ in range(n))
  
  dic = {}
  rest = 2 ** n - 1
  def search(index, num):
    wlim, tlim = shelf[num]
    wind = br(ws, ws[index] + wlim)
    tind = br(ts, ts[index] + tlim)
    return min(wind, tind) - 1
  
  def dp(rest,  dic):
    if rest in dic:
      return dic[rest]
    if rest == 0:
      return 0
    
    mask = 1  
    ret = 0
    for i in range(n):
      if rest & mask:
        pre_rest = rest & ~mask
        temp = dp(pre_rest, dic)
        temp = search(temp, i)
        ret = max(ret, temp)
      mask <<= 1
    dic[rest] = ret
    return ret
  
  print(dp(rest, dic))

main()


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

int main(){
    string a,s,c;
    cin >> a >> s >> c;
    cout << a.front() << s.front() << c.front() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pb push_back
#define F first
#define S second
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define one(x) cout<<#x<<" : "<<x<<endl;
#define two(x,y) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<endl;
#define three(x,y,z) cout<<#x<<" : "<<x<<" , "<<#y<<" : "<<y<<" , "<<#z<<" : "<<z<<endl;
#define PI acos(-1)
const int M = 1000000007;
const int N=3e5+5;

void solve()
{
    int n , i , j ;
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
    else cout<<"No\n";
}
signed main()
{
    int tc;
//    cin >> tc;
    tc = 1;
    while(tc--)
        solve();
}




Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int a,b;
	scanf("%d %d", &a,&b);
	if (a+b==0) {
		printf("0\n");
	}else if(a+b>0) {
		printf("1\n");
	}
	else if (a+b<0) {
		printf("-1\n");
	}
	return 0;
}


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

int partition(vector<int> &A, int p, int r)
{
    int x = A.at(r);
    int i = p - 1;
    repi(j, r, p)
    {
        if (A.at(j) <= x)
        {
            i++;
            swap(A.at(i), A.at(j));
        }
    }
    swap(A.at(i + 1), A.at(r));

    return i + 1;
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    repi(i, n, 0)
    {
        cin >> A[i];
    }
    int p = partition(A, 0, A.size() - 1);
    repi(i, n, 0)
    {
        if (i != p)
        {
            cout << A.at(i) << ((i + 1) % n ? " " : "\n");
        }
        else
        {
            cout << "[" << A.at(i) << "] ";
        }
    }
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  set<int> cnt;
  rep(i, k) {
    int d; std::cin >> d;;
    rep(j, d) {
      int a; std::cin >> a;
      cnt.insert(a);
    }
  }
  std::cout << n - cnt.size() << "\n";
}


Measured memory_bytes: 3668
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

const MOD: i64 = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut v: Vec<i64> = vec![];
    let mut sum: i64 = a.iter().sum();
    for i in 0..a.len() {
        sum -= a[i];
        v.push(sum);
    }

    let mut ans = 0;
    for i in 0..a.len()-1 {
        let vi = v[i] % MOD;
        ans += a[i] * vi % MOD;
    }

    println!("{}", ans % MOD);
}


Measured memory_bytes: 7356
#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;

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

int main()
{ll N;vector<ll> A(N);
 cin >> N; for(ll i = 0; i < N ; i++){cin >> A[i];}
 //入力完了
 vector<ll> L(N), R(N);
 L[0] = A[0]; R[N-1] = A[N-1];//LとRのベース入力
 
 for(ll i = 0 ;i < N - 1 ;i++)
 {L[i+1] = gcd(L[i],A[i+1]);}
 for(ll j = N-2;j >=0 ;j--)
 {R[j] = gcd(R[j+1],A[j]);}//累積gcd定義完了
 
 ll max_gcd = 0;
 
 for(ll i = 1 ; i<=N-2 ;i++)
 {ll g = gcd(L[i-1],R[i+1]);
  max_gcd = max(max_gcd,g);}
 
 cout << max(max_gcd,max(R[1],L[N-2])) << endl;
 return 0;}


Measured memory_bytes: 51072
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int main(){
    int n, x; cin >> n >> x;
    vi p(n);
    rep(i,n){
        cin >> p[i];
    }
    
    Sort(p);
    
    int sumP = 0;
    rep(i,n) sumP += p[i];
    
    
    x -= sumP;
    
    int ans = n + (x/p[0]);
    
    cout << ans << endl;
}







Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll slime[2005][2005];

int main() {
  ll N, x;
  cin>>N>>x;
  ll a[N];
  for(int i=0;i<N;++i){
    cin>>a[i];
  }
  for(int i=0;i<N;++i){
    slime[i][0] = a[i];
  }
  for(int i=0;i<N;++i){
    for(int j=1;j<N;++j){
      slime[i][j] = min(slime[i][j-1], a[(i-j+N)%N]);
    }
  }
  ll ans = 0;
  for(int i=0;i<N;++i) ans += a[i];
  ll tmpans;
  for(int j=1;j<N;++j){
    tmpans = x*j;
    for(int i=0;i<N;++i){
      tmpans += slime[i][j];
    }
    ans = min(ans, tmpans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 34888
n = int(input())
s = input()
sl = list(s)
alph = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
out = ""
for i in range(len(sl)):
  id_a = alph.index(sl[i])
  id_b = (int(id_a) + n) % 26
  out += alph[id_b]
print(out)

Measured memory_bytes: 3188
#include<stdio.h>


int main(void){
    int a=0,answer=0;
    scanf("%d",&a);
    if(a>=100){
        answer++;
        a-=100;
    }
    if(a>=10){
        answer++;
        a-=10;
    }
    if(a==1){
        answer++;
    }
    printf("%d\n",answer);
return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a.begin(), a.end());

  cout << a[0] + a[1] << endl;

  return 0;
}

Measured memory_bytes: 256
def check(s):
    l=len(s)
    if l%2 :
        return 0
    for i in range(l//2):
        if s[i]!=s[i+l//2]:
            return 0
    return 1        

s = input()
ans = 0
for i in range(1,len(s)):
    if check(s[:len(s)-i]) :
        ans = len(s)-i
        break
print(ans)


Measured memory_bytes: 8972
object Main extends App {
  val n = io.StdIn.readInt
  val ps = io.StdIn.readLine.split(" ").map(_.toInt)

  /* TLE case
  def rec(count: Int, list: List[Int]): Int = list match {
    case Nil => count
    case head::Nil => count+1
    case head::tail => rec(count+1, tail.filter(_ <= head))
  }

  val result = rec(0, ps.toList)
  println(result)
  */        

  /* TLE case
  def enum_min(min: Int, list: List[Int], acc: List[Int]): List[Int] = list match {
    case Nil => acc
    // case head::Nil  => enum_min(math.min(min,head), tail, acc:+math.min(min,head))
    case head::tail => enum_min(math.min(min,head), tail, acc:+math.min(min,head))
  }
  val minPs = enum_min(ps.head, ps.toList, Nil)

  val result = (minPs.toArray zip ps).count { case (min, p) => min == p }
  println(result)
  */

  val result = enum_min(ps.head, ps.toList, 0)
  def enum_min(min: Int, list: List[Int], count: Int): Int = list match {
    case Nil => count
    case head::tail if head <= min => enum_min(head, tail, count+1)
    case head::tail if min < head  => enum_min(min, tail, count)
  }
  
  println(result)
}

Measured memory_bytes: 79760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <ctime>
using namespace std;

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

string s[2000],temp;

char str[30][30];

int main()
{
    int n,m,i,j,x,y;
    while(scanf("%d%d",&n,&m)==2)
    {
        if(!n&&!m)
            break;
        for(i=0;i<n;i++)
            scanf("%s",str[i]);
        int num=0,l=0,ans=0,l1,l2,d;
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                for(d=0;d<8;d++)
                {
                    x=i;
                    y=j;
                    temp="";
                    temp+=str[x][y];
                    while(1)
                    {
                        x+=dx[d];
                        y+=dy[d];
                     //   printf("%d %d %d %d %d\n",i,j,d,x,y);
                        if(x>=n)
                            x-=n;
                        if(y>=m)
                            y-=m;
                        if(x<0)
                            x+=n;
                        if(y<0)
                            y+=m;
                        if(x==i&&y==j)
                            break;
                        temp+=str[x][y];
                    }
                    s[num++]=temp;
               //     cout<<temp<<endl;
                }
            }
        }
        sort(s,s+num);
        for(i=1;i<num;i++)
        {
            l1=s[i-1].size();
            l2=s[i].size();
            for(j=0;j<l1&&j<l2;j++)
            {
                if(s[i-1][j]!=s[i][j])
                    break;
            }
            if(j>l)
            {
                l=j;
                ans=i;
            }
        }
        if(l<2)
            printf("0\n");
        else
        {
            for(i=0;i<l;i++)
                printf("%c",s[ans][i]);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1644
#include <iostream>
using namespace std;
 
int main() {
	int unco[28] = {};
	int tinko[31] = {};
	for (int i = 0; i < 28; i++){
		cin >> unco[i];
	}
 
	for (int i = 0; i < 28; i++){
		tinko[unco[i]] = 1;
	} 
 
	for (int i = 1; i < 31; i++){
		if (tinko[i] == 0){
			cout << i << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 1160