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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N = 3005;

int n;
ld a[N], res;
ld memo[N][N];

ld coins(int idx, int head, int tail) {
	if (idx == n) {
		if (head == 0 && tail == 0) return 1.00;
		else return 0.00;
	}
	if (memo[idx][head] != -1.00) return memo[idx][head];
	ld ans = 0.00;
	if (head) {
		ans += (coins(idx + 1, head - 1, tail) * a[idx]);
	}
	if (tail) {
		ans += (coins(idx + 1, head, tail - 1) * (1.00 - a[idx]));
	}
	return memo[idx][head] = ans;
}

void solve() {
	int i, j, k, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			memo[i][j] = -1;
		}
	}
	for (i = n / 2 + 1; i <= n; i++) {
		res += coins(0, i, n - i);
	}
	cout << setprecision(10) << fixed;
	cout << res;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 141568
def rec(frm, to):
    """return: [frm,to)の合体コスト最小値"""
    if to - frm == 1:
        return 0

    if memo[frm][to]:
        return memo[frm][to]

    res = inf
    for mid in range(frm + 1, to):
        res = min(res, rec(frm, mid) + rec(mid, to))
    res += cum_sum[to] - cum_sum[frm]

    memo[frm][to] = res
    return res


inf = float('inf')

n = int(input())
a = list(map(int, input().split()))

cum_sum = [0] * (n + 1)
for i, aa in enumerate(a):
    cum_sum[i + 1] = cum_sum[i] + aa

memo = [[None] * (n + 1) for _ in range(n + 1)]
# memo[frm][to] = メモ化

print(rec(0, n))


Measured memory_bytes: 47764
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
LL x,y;
int main()
{
	file();
	read(x),read(y);
	printf("%lld\n",x%y==0?-1:x*(y-1));
	return 0;
}


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

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

    int a, b, c;
    cin >> a >> b >> c;
    int counter = 0;
    if (a == b && a == c && b == c)
    {
        if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0)
        {
            cout << "0";
            return 0;
        }
        else
        {
            cout << "-1";
            return 0;
        }
    }
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
    {
        int tempa = a;
        int tempc = c;
        int tempa2 = a;
        int tempb2 = b;
        a = (b / 2) + (c / 2);
        b = (tempa / 2) + (tempc / 2);
        c = (tempa2 / 2) + (tempb2 / 2);
        counter++;
    }
    cout << counter;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n;cin >> n;
    vl a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll res = 0;
    rep(i,n){
        if(a[i] > 0){
            ll can = min(b[i],a[i]);
            a[i] -= can;
            b[i] -= can;
            res += can;
        }
        if(a[i+1] > 0){
            ll can = min(b[i],a[i+1]);
            a[i+1] -= can;
            b[i] -= can;
            res += can;
        }
    }
    out(res);
}


Measured memory_bytes: 1792
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();
  var m = o.a();
  var a = o.l();

  var arr = [];
  for (var i = 0; i < m; i++) {
    var b = o.a();
    var c = o.a();
    arr.push({b, c});
  }

  a.sort((a, b) => a - b);
  arr.sort((a, b) => a.c - b.c);

  var ans = [];
  while (ans.length < n) {
    var lastA = a[a.length - 1];
    var lastB = 0;
    if (arr.length > 0) {
      lastB = arr[arr.length - 1].c;
    }
    if (lastA >= lastB) {
      // console.log("A", {lastA})
      ans.push(lastA);
      a.pop();
    } else {
      // console.log("B", arr[arr.length - 1]);
      for (var j = 0; j < arr[arr.length - 1].b; j++) {
        ans.push(lastB);
      }
      arr.pop();
    }
  }

  console.log(ans.slice(0, n).reduce((acc, cur) => acc + cur));
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 56528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    cin >> n;
    int f = 0, l = 0, fl = 0;
    int ans  = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int i = 0; i < s.size()-1; i++){
            if(s[i] =='A' && s[i+1] == 'B'){
                ans++;
            }
        }
        if(s[0] == 'B' && s[s.size()-1] != 'A')f++;
        if(s[s.size()-1] == 'A' && s[0] != 'B')l++;
        if(s[0] == 'B' && s[s.size()-1] == 'A') fl++;
    }
    if(f==0 && l==0 && fl > 0){
        ans += fl-1;
    }else if(fl > 0 && (f==0 || l==0)){
        ans += fl;
    }else{
        ans += min(f+fl,l+fl);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        _v: [usize; n]
    }
    println!("{}", (n - 2) / (k - 1) + 1);
}


Measured memory_bytes: 4352
public class Main {

	private static void solve() {
		int n = ni();
		System.out.println((24 - n) + 24);
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


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

const int N = 13;
const int MOD = 1000000007;
ll dp[100005][N];

int main()
{
  string s;
  cin >> s;
  ll mul = 1;
  dp[s.size()][0] = 1;
  for (int i = s.size() - 1; i >= 0; --i)
  {
    // cout << "loop: " << i << endl;
    char c = s[i];
    if (c == '?')
    {
      rep(k, 10)
      {
        rep(j, N)
        {
          dp[i][((k * mul) + j) % N] += dp[i+1][j] %= MOD;
          dp[i][((k * mul) + j) % N] %= MOD;
        }
      }
    }
    else
    {
      int k = (int)(s[i] - '0');
      rep(j, N)
      {
        dp[i][((k * mul) + j) % N] += dp[i+1][j] %= MOD;
        dp[i][((k * mul) + j) % N] %= MOD;
      }
    }
    mul *= 10;
    mul %= N;
    // rep(j,N) cout << dp[i][j] << " ";
    // cout << endl;
  }
  cout << dp[0][5] << endl;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,f;
    cin>>n>>f;
    int ar[n];
    for(int i=0; i<n; i++)cin>>ar[i];
    sort(ar,ar+n);
    int s = 0;
    for(int i=0; i<f; i++)s+=ar[i];
    cout<<s;
}


Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string b = Console.ReadLine();
        string a1 = "", b1 = "";
        List<char> d1 = new List<char> { };
        List<char> d2 = new List<char> { };
        for (int i = 0; i < a.Length; i++)
        {
            d1.Add(a[i]);
        }
        for (int i = 0; i < b.Length; i++)
        {
            d2.Add(b[i]);
        }
        d1.Sort();
        d2.Sort();
        d2.Reverse();
        bool con = true;
        for (int i = 0; i < Math.Min(d1.Count(), d2.Count()); i++)
        {
            if (d1[i] > d2[i])
            {
                con = false;
            }
            if (d1[i] < d2[i])
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        if (con && d1.Count() < d2.Count) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi v(n);
    rep(i,n) cin >> v.at(i);
    // 全部同じはダメ
    vi a(100100,0);
    vi b(100100,0);
    rep(i,n){
        if(i%2){
            // 奇数
            a.at(v.at(i))++;
        }else{
            // 偶数
            b.at(v.at(i))++;
        }
    }
    vector<P> va;
    vector<P> vb;
    rep(i,a.size()){
        va.push_back(make_pair(a.at(i),i));
    }
    rep(i,b.size()){
        vb.push_back(make_pair(b.at(i),i));
    }
    sort(va.begin(), va.end(), greater<>());
    sort(vb.begin(), vb.end(), greater<>());
    ll a1=va.at(0).first;
    ll a2=va.at(1).first;
    ll b1=vb.at(0).first;
    ll b2=vb.at(1).first;
    ll a1i=va.at(0).second;
    ll b1i=vb.at(0).second;
    cerr << "a1:" << a1 << " b1:" << b1 << endl;
    cerr << "a2:" << a2 << " b2:" << b2 << endl;
    ll res = 0;
    if(a1i!=b1i){
        res += (n/2) - a1;
        res += (n/2) - b1;
    }else{
        if(a2 >= b2){
            res += (n/2) - a2;
            res += (n/2) - b1;
        }else{
            res += (n/2) - a1;
            res += (n/2) - b2;
        }
    }
    cout << res << endl;
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s= Console.ReadLine();
            //  var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

            var ans = s == "ABC" ? "ARC" : "ABC";
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25788
n,m=map(int,raw_input().split())
v=[0]*n
a=[int(raw_input()) for i in [1]*n]
b=[int(raw_input()) for i in [1]*m]
for c in b:
	for i in range(n):
		if a[i]<=c:
			v[i]+=1
			break
print v.index(max(v))+1

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n;
  cin >> n;
  vi a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  vi imos(100010);
  rep(i,n){
    imos[a[i]]++;
    imos[b[i]+1]--;
  }
  rep(i,imos.size()-1){
    imos[i+1] += imos[i];
  }
  dump(imos);
  ROF(i,n+2,0){ // i人で行く=> i-1人誘う
    if(imos[i] >= i-1){
      cout << i-1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}



Measured memory_bytes: 5124
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n, k;
    while (cin >> n >> k) {
        if (n % k == 0)
            cout << '0' << endl;
        else cout << '1' << endl;
    }
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=1e5+10;
const int inf=1e9;
int n,k,vis[N];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>k;
	rep(i,1,k){
		int d,x;
		cin>>d;
		while(d--){
			cin>>x;
			vis[x]=1;
		}
	}
	int ans=0;
	rep(i,1,n) if(!vis[i]) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
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; } 
using ll=long long;
 int main(){
  string s,t;
   cin>>s>>t;
   int n=s.size();
   rep(i,n){
   if(s[i]!=t[i]){
   cout<<"No"<<endl;
     return 0;
   }
   }
   cout<<"Yes"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

    int length = S.size() - 1;
    vector<char> left(length);
    vector<char> right(length);
    int ans = 1;
    while (length >= 2)
    {
        if (length % 2 != 0)
        {
            length -= 1;
            continue;
        }
        // left
        for (int i = 0; i < length / 2; i++)
        {
            left[i] = S[i];
        }

        // right
        for (int i = length / 2; i < length; i++)
        {
            right[i - length / 2] = S[i];
        }

        bool isEqual = true;
        int j;
        for (j = 0; j < length / 2; j++)
        {
            // printf("%d %c %c\n", i, left[i], right[i]);
            if (left[j] != right[j])
            {
                isEqual = false;
                break;
            }
        }
        if (isEqual == true)
        {
            ans = length;
            break;
        }
        length -= 1;
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long total=0;
    cin >> N;
    int A[N];
    long long T[N]={0};
    long long U[N]={0};
    for(int i=0; i<N; i++){
        cin >> A[i];
        T[A[i]-1]++;
    }
    for(int i=0; i<N; i++){
        if(T[i]>=2){
            total+=T[i]*(T[i]-1)/2;
            U[i]=T[i]-1;
        }
    }
    for(int i=0; i<N; i++){
        cout << total-U[A[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int l = 1, r = n;
    auto check = [&](int x) {
        vector<pair<int, int>> v;
        for (int i = 1; i < n; ++i) {
            if (a[i] > a[i - 1])
                continue;
            if (x == 1)
                return false;
            while (!v.empty() && v.back().first >= a[i])
                v.pop_back();
            if (!v.empty() && v.back().first == a[i] - 1)
                ++v.back().second;
            else
                v.emplace_back(a[i] - 1, 1);
            while (v.back().second == x) {
                if (v.back().first == 0)
                    return false;
                int p = v.back().first - 1;
                v.pop_back();
                if (!v.empty() && v.back().first == p)
                    ++v.back().second;
                else
                    v.emplace_back(p, 1);
            }
        }
        return true;
    };
    while (l < r) {
        int x = (l + r) / 2;
        if (check(x))
            r = x;
        else
            l = x + 1;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 100010
#define MO 1000000007
#define LL long long
int x[MAXN],n,m;
bool vis[MAXN];
void task1()
{
	static int dp[100010][3];
	dp[0][0]=1;
	for(int i=1;i<=m;i++)
		vis[x[i]]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=dp[i-1][0];
		dp[i][1]=(dp[i-1][0]+dp[i-1][1])%MO;
		dp[i][2]=((dp[i-1][0]+dp[i-1][1])%MO+(dp[i-1][1]+dp[i-1][2])%MO)%MO;
		if(!vis[i-1])
		{
			dp[i][0]=(dp[i][0]+dp[i-1][2])%MO;
			dp[i][1]=(dp[i][1]+dp[i-1][2])%MO;
			dp[i][2]=(dp[i][2]+dp[i-1][2])%MO;
		}
	}
	printf("%d\n",dp[n][2]);
}
struct node
{
	LL a[3][3];
}A,C,a,b,c,tmp;
void Mul(node &ret,node X,node Y)
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			tmp.a[i][j]=0;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				tmp.a[i][j]=(tmp.a[i][j]+X.a[i][k]*Y.a[k][j]%MO)%MO;
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			ret.a[i][j]=tmp.a[i][j];
}
void Pow(int X)
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			c.a[i][j]=C.a[i][j];
	while(X)
	{
		if(X&1) Mul(a,a,c);
		Mul(c,c,c);
		X>>=1;
	}
}
int f[3],g[3];
int main()
{
//	freopen("placing.in","r",stdin);
//	freopen("placing.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&x[i]);
	memset(A.a,0,sizeof A.a);
	memset(C.a,0,sizeof C.a);
	A.a[0][0]=A.a[1][1]=A.a[2][2]=A.a[1][2]=A.a[0][2]=1;
	A.a[0][1]=2;
	C.a[0][2]=C.a[1][0]=C.a[1][1]=C.a[1][2]=C.a[2][0]=C.a[2][2]=1;
	C.a[0][0]=C.a[0][1]=2;
	f[0]=1;
	x[++m]=n;
	for(int l=1,pos=0;l<=m;l++)
	{
		int k=x[l]-pos-1;
		memset(b.a,0,sizeof b.a);
		memset(a.a,0,sizeof a.a);
		for(int i=0;i<3;i++)
			a.a[i][i]=1;
		if(k) Pow(k);
		Mul(b,a,A);
		for(int i=0;i<3;i++)
		{
			g[i]=0;
			for(int j=0;j<3;j++)
				g[i]=(g[i]+f[j]*b.a[j][i]%MO)%MO;
		}
		for(int i=0;i<3;i++)
			f[i]=g[i];
		pos=x[l];
	}
	printf("%d\n",f[2]);
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	int N;
	char S[345][345];


	scanf("%d", &N);
	rep(i, N) scanf("%s", &S[i]);

	int count = 0;
	//rep(A, N) {
	int A = 0;
	rep(B, N) {
		bool next = false;
		rep(i, N) {
			rep(j, N) {
				if (S[(i + A) % N][(j + B) % N] != S[(j + A) % N][(i + B) % N]) {
					next = true;
					break;
				}
			}
			if (next) break;
		}
		//if (!next) count++;
		if (!next) count += N;
	}
	//}

	printf("%d\n", count);

	return 0;
}


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


const ll INF = 1e18;

int main() {
  ll n, t;
  cin >> n >> t;
  vector<P> v(n);
  rep(i,n){
    ll a1,b1;
    cin>>a1>>b1;
    v[i]=make_pair(a1,b1);
  }
  sort(v.begin(),v.end());
  ll dp[n+5][t+3000];
  dp[0][0]=0;
  ll ans=0;

  rep(i,n){
    rep(j,t){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      dp[i+1][j+v[i].first]=max(dp[i+1][j+v[i].first],dp[i][j]+v[i].second);
    }
    ans=max(ans,dp[i][t-1]+v[i].second);
  }
cout<<ans;

}


Measured memory_bytes: 144268
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

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

    int ans=0;
    while(ans<=b){
      ans+=k;
      if(ans>=a and ans<=b){
        cout<<"OK"<<endl;
        return 0;
      }
    }

    cout<<"NG"<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n, w, h;

	scanf("%d %d %d", &n, &w, &h);

	pair<int, int> xs[100001], ys[100001];

	for (int i = 0; i < n; i++){
		int x, y, wi;
		scanf("%d %d %d", &x, &y, &wi);
		xs[i] = make_pair(x - wi, x + wi);
		ys[i] = make_pair(y - wi, y + wi);
	}

	sort(xs, xs + n);
	sort(ys, ys + n);

	pair<int, int> bandx = xs[0], bandy = ys[0];
	for (int i = 1; i < n; i++){
		if (xs[i].first <= bandx.second){
			bandx.second = max(xs[i].second, bandx.second);
		}
		if (ys[i].first <= bandy.second){
			bandy.second = max(ys[i].second, bandy.second);
		}
	}

	if ((bandx.first <= 0 && w <= bandx.second) ||
		(bandy.first <= 0 && h <= bandy.second)) printf("Yes\n");
	else printf("No\n");

	return (0);
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)
 
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};
int main(){
    int n,m;
    cin>>n>>m;
    UnionFind un(n+1);
    for(int i = 0; i < m; i++){
        int a,b;
        cin>>a>>b;
        if(a==1||b==n)
            un.unite(a,b);
    }
    if(un.same(1,n))
        cout<<"POSSIBLE";
    else
        cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 1792
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        values = map(lambda x: int(x), line.rstrip("\n").split())
        left = values[0] + values[1]
        right = values[2] + values[3]
        if left == right:
            print "Balanced"
        elif left > right:
            print "Left"
        else:
            print "Right"

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n, m, p;
	while (cin >> n >> m >> p, n){
		vector<int> cik(n);
		int sum = 0;
		REP(i, n){
			cin >> cik[i];
			sum += cik[i];
		}
		sum = sum*(100 - p);
		int ans = 0;
		if (cik[m - 1] != 0)ans = sum / cik[m - 1];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3076
/*
  Contest 106
  B - 105
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

int divs(int n) {
    int count = 2;
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            ++count;
            const int t = n / i;
            if (i != t) {
                if (n % t == 0)
                    ++count;
            }
        }
    }
    return count;
}

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

    int n = 0;
    std::cin >> n;
    int r = 0;
    if (n > 104) {
        for (int i = 105; i <= n; ++i) {
            if ((i & 1) && (divs(i) == 8))
                ++r;
        }
    }
    std::cout << r << std::endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = k; i < n; i++)
    {
        if (a[i] > a[i - k])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

int N,T,H,L;
int ts[1001];
int hs[1001];

pii oturi(int money){
  int hyaku=money/100;
  int zyu=(money-hyaku*100)/10;
  if(T<zyu)return pii(-1,-1);
  T-=zyu;
  while(hyaku!=0&&T>=10){
    hyaku--;
    zyu+=10;
    T-=10;
  }
  H-=hyaku;
  if(H<0)return pii(-1,-1);
  return pii(hyaku,zyu);
}

int main(){
  cin>>N>>T>>H>>L;
  for(int i=0;i<N;i++)cin>>ts[i]>>hs[i];
  int has=0;
  for(int pos=0;;pos=(1+pos)%N){
    if(ts[pos]>=1){
      has+=10;
      ts[pos]--;
      T+=1;
    }
    else if(hs[pos]>=1){
      has+=100;
      hs[pos]--;
      H+=1;
    }
    else{
      cout<<pos+1<<endl;
      return 0;
    }
    if(L<T){
      cout<<pos+1<<endl;
      return 0;
    }
    if(has>=90){
      pii o=oturi(has-90);
      if(o.first==-1){
	//cout<<pos<<endl;
	cout<<pos+1<<endl;
	return 0;
      }
      ts[pos]+=o.second;
      hs[pos]+=o.first;
      has=0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1172
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  int n;
  scanf("%d", &n);

  std::vector<int> a(n);
  for (int i=0; i<n; ++i)
    scanf("%d", &a[i]);

  std::sort(a.begin(), a.end());

  // if (n == 2)
  //   return !printf("%d %d\n", a[1], a[0]);

  int N=a.back();
  int j=std::lower_bound(a.begin(), a.end()-1, N/2)-a.begin();

  if (a[j] == N/2)
    return !printf("%d %d\n", N, a[j]);

  // if (j > 0)
  //   fprintf(stderr, "%d (%d) %d\n", a[j]-N/2, N/2, N/2-a[j-1]);

  if ((j > 0 && a[j]-(N+1)/2 > N/2-a[j-1]) || j == n-1)
    --j;

  printf("%d %d\n", N, a[j]);
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
#define FastIO ios::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
typedef long long ll;


int main()
{
	FastIO;
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (auto& i : s) {
		int x = i - 'A';
		x = (x + n) % 26;
		cout << (char)('A' + x);
	}
}


Measured memory_bytes: 3628
#include <iostream>
#define int long long
using namespace std;

int n,q;
int all[300000],part[300000];

void init(){
	int nn = 1;
	while(nn < n) nn *= 2;
	n = nn;
}

void add(int a,int b,int x,int k,int l,int r){
	if(b <= l || r <= a) return;
	if(a <= l && r <= b){
		all[k] += x;
		return;
	}
	part[k] += (min(b,r) - max(a,l)) * x;
	add(a,b,x,k * 2 + 1,l,(l + r) / 2);
	add(a,b,x,k * 2 + 2,(l + r) / 2,r);
}

int get(int a,int b,int k,int l,int r){
	int res = 0;
	if(a <= l && r <= b) return all[k] * (r - l) + part[k];
	if(b <= l || r <= a) return 0;
	res += all[k] * (min(b,r) - max(a,l));
	res += get(a,b,k * 2 + 1,l,(l + r) / 2);
	res += get(a,b,k * 2 + 2,(l + r) / 2,r);
	return res;
}

signed main(){
	cin >> n >> q;
	init();
	for(int i = 0;i < q;i++){
		int v;
		cin >> v;
		if(v == 0){
			int s,t,x;
			cin >> s >> t >> x;
			add(s - 1,t,x,0,0,n);
		}else{
			int s,t;
			cin >> s >> t;
			cout << get(s - 1,t,0,0,n) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5460
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

void fill(int x, vector<int> &dp) {
	if(dp[x]) return;
	for(int i = 1; i*x <= 1e6; i++) {
		dp[i*x] = true;
	}
	return;
}

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

  vector<ll> T(N);
  rep(i, N) cin >> T[i];

  ll ans = T[0];
  rep(i, 1, N) {
    ans = lcm(ans, T[i]);
  }
  cout << ans << endl;
	return 0;
}


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

 using namespace std;

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

   for (int i = 0; i < S.length(); i++) {
     int tmp;
     tmp = (int)(S.at(i) - 'A');
     tmp += N;
     tmp %= 26;
     S.at(i) = (char)(tmp + 'A');
   }
   cout << S << endl;
}


Measured memory_bytes: 256
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007;
const int MAX = 100005;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
    if(n<1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
long long i,j,n,f[100005][5],a[100005][5];
int main()
    {
        cin>>n;
        for (i=1;i<=n;i++)
            for (j=1;j<=3;j++) cin>>a[i][j];
        for (i=1;i<=n;i++)
            for (j=1;j<=3;j++)
        {
            if (j==1) f[i][j]=max(f[i-1][2]+a[i][j],f[i-1][3]+a[i][j]);
            if (j==2) f[i][j]=max(f[i-1][1]+a[i][j],f[i-1][3]+a[i][j]);
            if (j==3) f[i][j]=max(f[i-1][1]+a[i][j],f[i-1][2]+a[i][j]);
        }
        cout<<max(f[n][1],max(f[n][2],f[n][3]));
        return 0;
    }


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
long long int in=50000000000,ax,n,a;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a>ax)ax=a;
        if(a<in)in=a;
    }
    cout<<abs(ax-in)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#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(perm),end(perm)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    vint array(n); rep(i,n)cin>>array[i];
    int need = 1; int ans = 0;
    rep(i,n){
        if(array[i] == need)need++;
        else ++ans;
    }
    cout<<((ans == n)?-1:ans) <<endl; return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//実行部
void Main()
{
  ll n; cin >> n;
  fin((n % 2 == 1?n * 2:n))
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

int main()
{
    map<string,int>mp;
    int n;
    char st[10];
    cin>>n;
    while(n--)
    {
        scanf("%s",st);
        mp[st]++;
    }
    cout<<"AC"<<" x "<<mp["AC"]<<endl;
    cout<<"WA"<<" x "<<mp["WA"]<<endl;
    cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
    cout<<"RE"<<" x "<<mp["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int d = n % 10;
        int c = n / 10 % 10;
        int b = n / 10 / 10 % 10;
        int a = n / 10 / 10 / 10 % 10;
        
        String op1 = "", op2 = "", op3 = "";
        if (a-b-c-d==7) {
            op1 = "-";
            op2 = "-";
            op3 = "-";
        }
        else if (a-b-c+d==7) {
            op1 = "-";
            op2 = "-";
            op3 = "+";
        }
        else if (a-b+c-d==7) {
            op1 = "-";
            op2 = "+";
            op3 = "-";
        }
        else if (a-b+c+d==7) {
            op1 = "-";
            op2 = "+";
            op3 = "+";
        }
        else if (a+b-c-d==7) {
            op1 = "+";
            op2 = "-";
            op3 = "-";
        }
        else if (a+b-c+d==7) {
            op1 = "+";
            op2 = "-";
            op3 = "+";
        }
        else if (a+b+c-d==7) {
            op1 = "+";
            op2 = "+";
            op3 = "-";
        }
        else if (a+b+c+d==7) {
            op1 = "+";
            op2 = "+";
            op3 = "+";
        }
        
        
        System.out.println(a + op1 + b + op2 + c + op3 + d + "=7");
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
const int maxn = 1000050;
using namespace std;
typedef long long ll;
ll p[maxn];
int main()
{
	int n,q;
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		p[x]++;
		sum+=x;
	}
	cin>>q;
	while(q--){
		int b,c;
		cin>>b>>c;
		sum+=p[b]*(c-b);
		p[c]+=p[b];
		p[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 4312