akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int a[100010], c[100010];

int main(){
    int n;
    cin >> n;
    int b;
    rep(i, n+1) {
        cin >> a[i];
        if (c[a[i]] == 1) b = a[i];
        c[a[i]] = 1;
    }
    int l = -1, r = -1;
    rep(i, n+1){
        if (l == -1 && a[i] == b) l = i + 1;
        else if (a[i] == b) r = i + 1;
    }
    
    COMinit();

    for(int k = 1; k <= n+1; k++){
        cout << (COM(n+1,k) - COM(l+n-r, k-1) + MOD) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 13952
#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>;

int main() {
  int a, b;
  string op;
  cin >> a >> op >> b;

  int result = 0;
  if (op == "+") {
    result = a + b;
  } else {
    result = a - b;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
import itertools
import math

def dist(p1, p2):
    x1, y1 = p1
    x2, y2 = p2
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
n = int(input())
p = [tuple(map(int, input().split())) for _ in range(n)]
num = [i for i in range(n)]
avr = 0
for i, j in itertools.combinations(num, 2):
    avr += dist(p[i], p[j])
print(avr * 2 / n)

Measured memory_bytes: 3316
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        boolean f = false;
        for(int i = 3; i<=55555; i=i+2) {
            f = false;
            for(int j = 2; j*j<=i;j++) {
                if(i%j == 0) {
                    f=false;
                    break;
                }else f=true;
            }
            if(f && i%5==1) queue.add(i);
        }
        for(int i = 0; i<n; i++) {
            System.out.println(queue.poll());
        }

    }
}

Measured memory_bytes: 21972
a = list(input())
ans = 0
count = 0
for i in a:

    if i == 'A':
        count +=1
    elif i == 'C':
        count+=1
    elif i == 'G':
        count+=1
    elif i == 'T':
        count+=1
    else:
        ans = max(ans ,count)
        count = 0

print(max(ans,count))

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

template <typename Monoid>

struct SegmentTree
{
    using F = function<Monoid(Monoid, Monoid)>;
    int sz;
    vector<Monoid> seg;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
    {
        sz = 1;
        while (sz < n)
            sz *= 2;
        seg.assign(2 * sz, M1);
    }
    void set(int k, const Monoid &x)
    {
        seg[k + sz] = x;
    }
    void build()
    {
        for (int k = sz - 1; k > 0; k++)
        {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    void update(int k, const Monoid &x)
    {
        k += sz;
        seg[k] = x;
        while (k >>= 1)
        {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }
    void add(int k, const Monoid &x)
    {
        k += sz;
        seg[k] += x;
        while (k >>= 1)
        {
            seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
        }
    }

    Monoid query(int a, int b)
    {
        Monoid L = M1, R = M1;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1)
        {
            if (a & 1)
                L = f(L, seg[a++]);
            if (b & 1)
                R = f(seg[--b], R);
        }
        return f(L, R);
    }
    Monoid operator[](const int &k) const
    {
        return seg[k + sz];
    }
};

int f(int a, int b)
{
    return a + b;
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    SegmentTree<int> seg(N, f, 0);
    rep(i, Q)
    {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 0)
            seg.add(x, y);
        else
            cout << seg.query(x, y + 1) << endl;
    }
    return 0;
}


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


int c[7][7];
int a[5];
int b[5];

int main(){
    for(int i =1;i < 4;i++){
        for(int j = 1;j < 4;j++){
            cin >> c[i][j];
        }
    }

    //c[1][1] = a[1] + b[1];
    //c[2][1] = a[2] + b[1];
    //c[1][2] = a[1] + b[2];
    //c[2][2] = a[2] + b[2];

    if(c[2][2] != c[2][1] + c[1][2] - c[1][1]){
        cout << "No" << endl;
        exit(0);
    }
    if(c[2][2] != c[2][1] + c[3][2] - c[3][1]){
        cout << "No" << endl;
        exit(0);
    }
    if(c[2][2] != c[1][2] + c[2][3] - c[1][3]){
        cout << "No" << endl;
        exit(0);
    }
    if(c[2][2] != c[2][3] + c[3][2] - c[3][3]){
        cout << "No" << endl;
        exit(0); 
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

total = 0
for i in dic.values():
    total += i*(i-1)//2

for i in a:
    if i in dic:
        print(total-dic[i]+1)
    else:
        print(total)

Measured memory_bytes: 26012
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInput_long();
            var A_n = GetInput_long();
            long mod = 1000000007;
            List<long> _waList = new List<long>();

            long nowWa=0;
            for (int i = A_n.Length-1; i >=0; i--)
            {
                nowWa += A_n[i];
                nowWa %= mod;
                _waList.Add(nowWa);
            }
            long result = 0;
            for (int i = 0; i < A_n.Length-1; i++)
            {
                var num = A_n[i] * _waList[_waList.Count-2-i];
                var add = num % mod;
                result += add;
                result %= mod;
            }

            Console.WriteLine(result);
        }
        
        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
        
    }
}

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

int main(){
    const ll mod = 1000000007;
    int n, k; cin >> n >> k;
    int a[n]; rep(i, n) cin >> a[i];

    ll dp[n+1][k+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    loop(i, 1, n+1){
        ll cum[k+1];
        cum[0] = dp[i-1][0];
        loop(j, 1, k+1) cum[j] = (cum[j-1] + dp[i-1][j])%mod;
        rep(j, k+1) {
            if(j-a[i-1] > 0)dp[i][j] = (cum[j] - cum[j-a[i-1]-1] + mod)%mod;
            else dp[i][j] = cum[j] % mod;
        }
    }

    cout << dp[n][k] << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int a[100009] = {0};
    for (int i = 0; i < N;i ++) {
        int n;
        cin >> n;
        a[n]++;
    }

    int ans = 0;
    for (int i = 1; i <= 100000; i++) {
        ans = max(a[i-1] + a[i] + a[i+1], ans);
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 1; i < 1000000; i++) {
    for(int j = 1; j < 1000000; j++) {
      if(i * j < n) cnt++;
      if(i * j >= n) break;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,m;
char st[1000];
int a[1000][1000];
int num[1000][1000];
int main(){
	cin>>n;cin>>m;
	for(register int i=1;i<=n;i++){
		scanf("%s",st);
		for(register int j=0;j<m;j++){
			if(st[j]=='#')a[i][j]=1;
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=0;j<m;j++)if(a[i][j]==0){
			if(a[i+1][j])num[i][j]++;
			if(a[i-1][j])num[i][j]++;
			if(a[i][j+1])num[i][j]++;
			if(a[i][j-1])num[i][j]++;
			if(a[i+1][j+1])num[i][j]++;
			if(a[i-1][j-1])num[i][j]++;
			if(a[i-1][j+1])num[i][j]++;
			if(a[i+1][j-1])num[i][j]++;
		}
	for(int i=1;i<=n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j])putchar('#');
			else cout<<num[i][j];
		}cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 4480
sx, sy, tx, ty = list(map(int, input().split()))

vec = []
x, y = sx, sy
for i in range(ty - sy - 1):
    vec.append("U")
    y += 1

for i in range(tx - sx - 1):
    vec.append("R")
    x += 1

for i in range(ty - y):
    vec.append("U")
    y += 1

for i in range(tx - x):
    vec.append("R")
    x += 1

vec.append("R")
x += 1

for i in range(ty - sy + 1):
    vec.append("D")
    y -= 1

for i in range(x - sx):
    vec.append("L")
    x -= 1

vec.append("U")
y += 1
vec.append("L")
x -= 1

for i in range(ty + 1 - y):
    vec.append("U")
    y += 1

for i in range(tx - x):
    vec.append("R")
    x += 1

vec.append("D")
y -= 1

vec.append("D")
y -= 1

for i in range(ty - sy - 1):
    vec.append("D")
    y -= 1

for i in range(tx - sx - 1):
    vec.append("L")
    x -= 1

for i in range(y - sy):
    vec.append("D")
    y -= 1

for i in range(x - sx):
    vec.append("L")
    x -= 1

# print(vec)
# print(x, y)
for v in vec:
    print(v, end="")

Measured memory_bytes: 4724
// AUTHOR - RUTVIK KOTHARI
// DAIICT , GANDHINAGAR

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e6 + 5;
const ll M = 3e5 + 5;
const ll mod = 1e9 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 20;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}


int main()
{
    FIO;
    //pre();

    ll i,j;

    ll n;
    cin>>n;
    
    ll a[n+1],b[n+1];
    
    for(i=1;i<n;i++)
        cin>>b[i];
    
    b[n] = 1e5;
    
    ll ans = 0;
    
    for(i=n;i>=1;i--)
    {
        a[i] = min(b[i],b[i-1]);
        ans += a[i];
    }
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 3e5 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}


void solve()
{
	int n;
	cin >> n;
	int a[n];
	ll res = 0;
	int mx = 0;
	rep(i, n){
		cin >> a[i];
		mx = max(mx, a[i]);
		res += mx - a[i];
	}
	cout << res;
}




int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g(100005);

int main(void) {
	int n;
	cin >> n;

	string s = to_string(n);
	int sum = 0;
	rep (i, s.size()) sum += s[i] - '0';

	if (n % sum == 0) yn

	return 0;
}

Measured memory_bytes: 2560
r=input().split()
N=int(r[0])
K=int(r[1])
ans=0
for i in range(1,N+1):
    x=i
    n=0
    while x<=K-1:
        x=x*2
        n+=1
    ans+=(1/N)*((1/2)**n)
print(ans)

Measured memory_bytes: 9440
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>


using namespace std;


int main() {

    long N, M;
    long X;
    cin >> N >> M >> X;

    vector<long> cs;
    vector<vector<long>> As;

    for (int i = 0; i < N; ++i) {
        long C, A;
        cin >> C;
        cs.push_back(C);
        vector<long> a;
        for (int j = 0; j < M; ++j) {
            cin >> A;
            a.push_back(A);
        }
        As.push_back(a);
    }
    bool achieved = false;
    long result = 1000000 * 12 + 1;

    for (int bit = 0; bit < (1 << N); ++bit) {
        vector<long> ss(M, 0);
        long cost = 0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
                for (int j = 0; j < M; ++j) {
                    ss[j] += As[i][j];
                }
                cost += cs[i];
            }
        }
        bool ok = true;
        for (int j = 0; j < M; ++j) {
            if (ss[j] < X) {
                ok = false;
            }
        }
        if (ok) {
            result = min(result, cost);
            achieved = true;
        }
    }

    if (achieved) {
        cout << result << endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;

}

Measured memory_bytes: 3168
class BinaryIndexTree:  # 1-indexed
    def __init__(self, N):
        """
        INPUT
        N [int] -> 全部0で初期化
        N [list] -> そのまま初期化
        """
        if isinstance(N, int):
            self.N = N
            self.depth = N.bit_length()
            self.tree = [0] * (N + 1)
            self.elem = [0] * (N + 1)
        elif isinstance(N, list):
            self.N = len(N)
            self.depth = self.N.bit_length()
            self.tree = [0] + N
            self.elem = [0] + N
            self._init()
        else:
            raise "INVALID INPUT: input must be int or list"

    def _init(self):
        size = self.N
        for i in range(1, self.N):
            if i + (i & -i) > size:
                continue
            self.tree[i + (i & -i)] += self.tree[i]

    def add(self, i, x):
        self.elem[i] += x
        while i <= self.N:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):
        res = 0
        while i > 0:
            res += self.tree[i]
            i -= i & -i
        return res

    def lower_bound(self, val):
        if val <= 0:
            return 0
        i = 0
        k = 1 << self.depth
        while k:
            if i + k <= self.N and self.tree[i + k] < val:
                val -= self.tree[i + k]
                i += k
            k >>= 1
        return i + 1


N = int(input())
A = list(map(int, input().split()))
atoi = {a: i+1 for i, a in enumerate(sorted(set(A)))}

bit = BinaryIndexTree(len(atoi) + 5)

for a in A:
    i = atoi[a]
    bit.add(i, 1)


slime = []

p = bit.lower_bound(1 << N)
slime.append(p)
bit.add(p, -1)

for _ in range(N):
    next_slime = []
    for s in slime:
        tot = bit.sum(s - 1)
        p = bit.lower_bound(tot)
        if p == 0:
            print("No")
            exit()
        next_slime.append(p)
        bit.add(p, -1)
    slime += next_slime
print("Yes")

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

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

    int ans=0;
    for(int i=1; i<m+1; i++){
        int count = 0;
        for(int j=0; j<n; j++){
            for(int l=0; l<k[j]; l++){
                if(i==a[j][l]){
                    count++;
                    break;
                }
            }
        }
        if(count == n){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

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


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    while (cin >> n && n) {
        int l;
        cin >> l;
        l *= 2;
        // cout << n << " " << l << endl;
        vector<pair<char, int> > v;
        rep(i, n) { char d; int p; cin >> d >> p; p *= 2; v.eb(mp(d, p)); }
        
        int cnt = 0;
        rep(t, 10000000) {
            // rep(i, n) cout << v[i].S << " "; cout << endl;
            int tmp = -1; // 左から抜けるやつ
            int breakflg = 0;
            rep(i, n) { // 20
                if (v[i].S == 0 || v[i].S == l) continue;
                
                if (v[i].F == 'L') {
                    v[i].S--;
                    if (v[i].S == 0) {
                        cnt++;
                        tmp = i;
                    }
                } else {
                    v[i].S++;
                    if (v[i].S == l) {
                        cnt++;
                    }
                }
                if (cnt == n) {
                    if (v[i].F == 'R' && tmp != -1) cout << (t + 1) / 2 << " " << tmp + 1 << endl;
                    else cout << (t + 1) / 2 << " " << i + 1 << endl;
                    breakflg = 1;
                    break;
                }
                
                if (t % 2 == 0) continue;
                rep(j, n) { // collision
                    if (v[i].S == v[j].S) {
                        if (v[i].F == 'L') {
                            v[i].F = 'R';
                            v[j].F = 'L';
                        } else {
                            v[i].F = 'L';
                            v[j].F = 'R';
                        }
                        break;
                    }
                }
            }
            if (breakflg) break;
        }
    }
}



Measured memory_bytes: 3120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,m,q,i,j,k,r[10],a,b;
	ll c,d[225][225],ans=INFLL,tmp;
	vector<int> v;
	fill(d[0],d[225],INFLL);
	cin >> n >> m >> q;
	for(i=0; i<n; ++i){
		d[i][i] = 0ll;
	}
	for(i=1; i<=q; ++i){
		cin >> r[i];
		r[i]--;
		v.push_back(i);
	}
	for(i=0; i<m; ++i){
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	do{
		tmp = 0ll;
		for(i=1; i<q; ++i){
			tmp += d[r[v[i-1]]][r[v[i]]];
		}
		ans = min(tmp,ans);
	}while(next_permutation(v.begin(),v.end()));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
char u[N],v[N];
#define ll long long 
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
int main()
{
	ll n,m;cin>>n>>m;
	scanf("%s",u+1);
	scanf("%s",v+1);
	ll h=n*m/gcd(n,m);
	ll w=h/n,e=h/m;
	for(ll i=1;i<=n;i++)
		if( (w*(i-1))%e==0 && u[i]!=v[w*(i-1)/e+1]) 
			{printf("-1"); return 0;}
	cout<<h<<endl;
	return 0;
}

Measured memory_bytes: 384
//2004年
#include <stdio.h>

int fact(int);
void judge(int);

int main(){
  int a,b,c,d,e,f,sum,month;

  while(1){
    scanf("%d%d",&a,&b);
    if(a == 0 && b == 0)
      break;
    c = 1;
    d = 4;
    f = 6;
    e = fact(a);
    sum = b+c+d+e+f;
    month = sum%7;
    if(a == 1 || a == 2)
      month -= 1;
    judge(month);
  }
  return 0;
}
int fact(int a)
{
  switch(a){
  case 1: return 1;
    break;
  case 2: return 4;
    break;
  case 3: return 4;
    break;
  case 4: return 0;
    break;
  case 5: return 2;
    break;
  case 6: return 5;
    break;
  case 7: return 0;
    break;
  case 8: return 3;
    break;
  case 9: return 6;
    break;
  case 10: return 1;
    break;
  case 11: return 4;
    break;
  case 12: return 6;
    break;
  }
}
void judge(int month)
{
  switch(month){
  case 0: printf("Saturday\n");
    break;
  case 1: printf("Sunday\n");
    break;
  case 2: printf("Monday\n");
    break;
  case 3: printf("Tuesday\n");
    break;
  case 4: printf("Wednesday\n");
    break;
  case 5: printf("Thursday\n");
    break;
  case 6: printf("Friday\n");
    break;
  }
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int A = sc.nextInt();
			int B = sc.nextInt();
			int X = sc.nextInt();
			if(1 <= A && A <= 100 && 1 <= B && B <= 100 && 1 <= X && X <= 200)
			{if(A + B >= X && A <= X) {
				System.out.println("YES");
			}
			else System.out.println("NO");
			}
			}}

Measured memory_bytes: 22868
let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split(' ') |> Array.map int |> List.ofArray |> List.sort

let rec f xs =
    match xs with
        | [] -> 0
        | x::[] -> x
        | y::ys -> List.map (fun a -> a % y) ys |> Set.ofList |> Set.add y |> Set.remove 0 |> Set.toList |> List.sort |> f

f A |> printf "%d"


Measured memory_bytes: 38488
#include<stdio.h>

int main(void){
  int r,c;

  for(;;){
    scanf("%d%d",&r,&c);
    if(r==0 && c==0)
      break;
    
    if(r%2 && c%2)
      printf("no\n");
    else
      printf("yes\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
bool win[3005];
int a[3005];
vector<int> edge[3005];
vector<pair<int,int> > stone;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		a[i]=x;
		stone.push_back(make_pair(x,i));
	}
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	sort(stone.begin(),stone.end());
	for(int i=0;i<stone.size();i++){
		int u=stone[i].second;
		if(!win[u]){
			for(int j=0;j<edge[u].size();j++){
				if(a[u]<a[edge[u][j]]){
					win[edge[u][j]]=1;
				}
			}
		}
	}
	for(int i=1;i<=n;i++) if(win[i]) cout<<i<<" ";
}
	

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int n;
	cin >> n;

	vector<int> a;
	inputVector(a, n);

	map<int, int> cnt, left;
	cnt[0] = 0;
	rep(i, n) {
		if (cnt.find(a[i]) == cnt.end()) {
			cnt[a[i]] = 0;
			left[a[i]] = i;
		}
		cnt[a[i]]++;
	}

	vector<int> ret(n, 0);

	int mostleft = n + 5;
	int sum = 0;
	int prev = -1;
	for (auto it = cnt.rbegin(); it != cnt.rend(); it++) {
		int num = (*it).first;
		sum += (*it).second;

		auto it2 = it;
		it2++;

		if (it2 == cnt.rend()) break;

		int dif = num - (*it2).first;
		mostleft = min(mostleft, left[num]);
		ret[mostleft] += sum * dif;
	}

	rep(i, n) {
		cout << ret[i] << endl;
	}

    return 0;
}


Measured memory_bytes: 16384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;

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

class DPracticalSkillTest {
public:
    int H, W, D;
    vi S;
    vector<pii> A;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>H>>W>>D;
        S = vi(H*W, 0);
        A = vector<pii>(H*W);
        REP(i, H) REP(j, W){
            int a;
            in>>a;
            a--;
            A[a] = pii(i, j);
        }
    }

    void solve(std::istream& in, std::ostream& out){
        input(in, out);
        FOR(i, D, H*W){
            S[i] = S[i-D] + abs(A[i].first-A[i-D].first) + abs(A[i].second-A[i-D].second);
        }
        int Q;
        in>>Q;
        REP(i, Q){
            int l, r;
            in>>l>>r;
            l--, r--;
            out<<S[r]-S[l]<<'\n';
        }
    }
};


int main() {
	DPracticalSkillTest solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 2176
N = int(input())
S = []
for i in range(N):
    tmp = list(input())
    tmp.sort()
    S.append(''.join(tmp))
cnt = 0

mydict = {}

for i in range(N):
    if (S[i] in mydict.keys()) == False:
        mydict[S[i]] = 0
    else:
        cnt += mydict[S[i]]+1
        mydict[S[i]] += 1

print(cnt)

Measured memory_bytes: 19504
#include <stdio.h>
#define PIC (4)
#define RANK (13)

int main(){
int i,j,n,pic,rank,stuck[PIC][RANK];
char pic_s;
scanf("%d",&n);
for(i=0;i<RANK;i++){
	for(j=0;j<PIC;j++){
		stuck[j][i]=0;
	}
}
for(i=0;i<n;i++){
   scanf("%s %d",&pic_s,&rank);

   switch(pic_s){
      case 'S':{pic=0;break;}
      case 'H':{pic=1;break;}
      case 'C':{pic=2;break;}
      case 'D':{pic=3;break;}
   }
   stuck[pic][rank-1]=1;
}
for(i=0;i<PIC;i++){
   for(j=0;j<RANK;j++){
      if(stuck[i][j]!=1){
         switch(i){
            case 0:{printf("S %d\n",j+1);break;}
			case 1:{printf("H %d\n", j + 1);break;}
            case 2:{printf("C %d\n",j+1);break;}
            case 3:{printf("D %d\n",j+1);break;}
         }
      }
   }
}
return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(K: int, X: int):
    print(*range(X-K+1, X+K))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
S = input()
if N % 2 != 0:
    print('No')
else:
    sl = []
    sr = []
    for i in range(N // 2):
        sl.append(S[i])
        sr.append(S[i + N // 2])
    if sl == sr:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int L, R, d;
    
    cin >> L >> R >> d;
    
    int i = R/d;
    i = i - L/d;
    
    if(L%d == 0) i += 1;
    
    cout << i;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define N 100010
using namespace std;
int n,m,first[N],nxt[N<<1],tot=0;
int fa[N],sum[N],x,y,z,ans=0;
long long w[N];
long long Read()
{
	long long x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') 
	{
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0'&&c<='9') 
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
struct Edge
{
	int u,v;
	long long w;
}edge[N<<1];
bool cmp(const Edge a,const Edge b)
{
	if (a.w<b.w) return true;
	else return false;
}
void Add(int u,int v,int w)
{
	tot++;
	nxt[tot]=first[u];
	first[u]=tot;
	edge[tot]=(Edge){u,v,w};
	return;
}
int Get(int x)
{
	if (x==fa[x]) return x;
	else return fa[x]=Get(fa[x]);
}
void Join(int x,int y)
{
	fa[x]=y;
	w[y]+=w[x];
	sum[y]+=sum[x];
	return;
}
int main()
{
	memset(first,-1,sizeof(first));
	n=Read(),m=Read();
	for (int i=1;i<=n;i++) w[i]=Read();
	for (int i=1;i<=m;i++)
	{
		x=Read(),y=Read(),z=Read();
		Add(x,y,z);
	}
	for (int i=1;i<=n;i++) fa[i]=i;
	sort(edge+1,edge+tot+1,cmp);
	for (int i=1;i<=tot;i++)
	{
		int u=edge[i].u,v=edge[i].v;
		int f1=Get(u),f2=Get(v);
		if (f1!=f2) Join(f1,f2);
		sum[f2]++;
		if (w[f2]>=edge[i].w) ans+=sum[f2],sum[f2]=0;
	}
	printf("%d\n",m-ans);
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int A,B,C;
    cin >> A >> B >> C;

    cout << max({A*10+B+C,B*10+A+C,C*10+A+B}) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []
x = 1
path.append(x)
for i in range(n):
    x = a[x-1]
    path.append(x)
#print(path)
count = [0]*n
loop_st = 0
for town in path:
    count[town-1] += 1
    if count[town-1] == 2:
        loop_st = town
        break
loop_st_idx = path.index(loop_st)
loop_fin_idx = path.index(loop_st, loop_st_idx+1)
#print(loop_st_idx, loop_fin_idx)
if k >= loop_st_idx:
    k_mod = (k - loop_st_idx) % (loop_fin_idx - loop_st_idx)
    print(path[loop_st_idx + k_mod])
else:
    print(path[k])

Measured memory_bytes: 100248
#include <stdio.h>

char map[16][16];

void bomb(int x, int y)
{
	int i, j;
	
	if (map[y][x] == 0) return;
	map[y][x] = 0;
	for (i = -3; i <= 3; i++){
		bomb(x + i, y);
		bomb(x, y + i);
	}
}

int main(void)
{
	int n;
	int i;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		int j, k;
		int fx, fy;
		
		for (j = 0; j < 8; j++) scanf("%s", &map[j + 3][3]);
		for (j = 0; j < 8; j++){
			for (k = 0; k < 8; k++){
				map[j + 3][k + 3] -= '0';
			}
		}
		
		scanf("%d %d", &fx, &fy);
		bomb(fx + 2, fy + 2);
		printf("Data %d:\n", i + 1);
		for (j = 0; j < 8; j++){
			for (k = 0; k < 8; k++){
				printf("%d", map[j + 3][k + 3]);
			}
			puts("");
		}
	}
	
	return 0;
}

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

typedef struct trm{
	char name[10];
	int value;
} tramp;

int BubbleSort(tramp val[36],int n){
	for(int i = 0; i < n; i++){
		for(int u = n - 1; u > i; u--){
			if(val[u].value < val[u - 1].value){
				tramp flag = val[u - 1];
				val[u - 1] = val[u];
				val[u] = flag;
			}
		}
	}
}

int SelectionSort(tramp val[36],int n){
	for(int i = 0; i < n; i++){
		int min = i;
		for(int u = i; u < n; u++){
			if(val[u].value < val[min].value){
				min = u;
			}
		}
		if(min > i){
			tramp t = val[i];
			val[i] = val[min];
			val[min] = t;
		}
	}
}
int isStable(tramp be_val[36],tramp af_val[36],int n){
	int lastNo = 0;
	int lastval = 0;
	for(int i = 0; i < n; i++){
		if(lastNo != af_val[i].value){
			lastNo = af_val[i].value;
			lastval = 0;
		}
//		printf("lastNo = %d , af_val[%d].value = %d\n",lastNo,i,af_val[i].value);
		int u = lastval;
		for(; u < n;u++){
			if(strcmp(af_val[i].name, be_val[u].name) == 0){
				lastval = u + 1;
				u = 1000;
			}
		}
		if(u < 1000){
			return 0; //false
		}
	}
	return 1; //true
}

int main(){
	int n;
	tramp val[36];
	int changecount = 0;

	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%s",&val[i].name);
		val[i].value = val[i].name[1] - 48;
	}
	tramp BSval[36],SSval[36];
	memcpy(BSval, val, sizeof(val));
	memcpy(SSval, val, sizeof(val));
	
	BubbleSort(BSval,n);
	SelectionSort(SSval,n);
	
	//
	printf("%s",BSval[0].name);
	for(int i = 1; i < n; i++){
		printf(" %s",BSval[i].name);
	}
	printf("\n");
	
	//あとは安定かどうかを調べるだけ
	//（順番に上からチェック？）
	if(isStable(val,BSval,n)){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
	
	printf("%s",SSval[0].name);
	for(int i = 1; i < n; i++){
		printf(" %s",SSval[i].name);
	}
	
	printf("\n");

	if(isStable(val,SSval,n)){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
	
	return 0;

}


Measured memory_bytes: 2100
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 * @author RisaTozawa
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * Atcorder 提出
	 * @return
	 *
	 */

	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		final String a = "a";
		final String e = "e";
		final String i = "i";
		final String o = "o";
		final String u = "u";

		String text = "";

		/* コンソールから文字を受け取る */
		text = scanner.nextLine();

		/* 母音かどうかを検査する */
		switch (text) {
			case a:
				System.out.println("vowel");
				break;

			case e:
				System.out.println("vowel");
				break;

			case i:
				System.out.println("vowel");
				break;

			case o:
				System.out.println("vowel");
				break;

			case u:
				System.out.println("vowel");
				break;

			default:
				System.out.println("consonant");
				break;
		}
	}
}


Measured memory_bytes: 27024
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, k;
ll dp[110][maxn], arr[110], pref[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> arr[i];
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
    {
        pref[0] = dp[i - 1][0];
        for(int j = 1; j <= k; j++)
            pref[j] = dp[i - 1][j] + pref[j - 1];
        for(int cur = 0; cur <= k; cur++)
        {
            int fr = max(cur - arr[i], 0ll);
            dp[i][cur] += pref[cur] - pref[fr - 1];
            dp[i][cur] = (dp[i][cur] + mod) % mod;
        }
    }
    cout << dp[n][k] << "\n";
    return 0;
}


Measured memory_bytes: 79360
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);
#define int LL


int n, minl = INF;
pair<int, int>a[101010];
int ans[101010];
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a + 1, a + n + 1);
	for (int i = n; i >= 1; i--) {
		if (a[i].second < minl)minl = a[i].second;
		if (a[i].first != a[i - 1].first)ans[minl] += (a[i].first - a[i - 1].first)*(n + 1 - i);
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
	//system("pause");
}

Measured memory_bytes: 3456
#! /usr/bin/env python
# -*- coding: utf-8 -*-

(n, r) = map(int, raw_input().split())
while n!=0 and r!=0:
    list = [n-j for j in range(n)]
    for i in range(r):
        (p, c) = map(int, raw_input().split())
        p -= 1
        list = list[p:p+c] + list
        del list[p+c:p+c+c]

    print list[0]
    (n, r) = map(int, raw_input().split())

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 n, x, count;
        while(cin >> n >> x && !(n == 0 && x == 0)){
            count = 0;
            _for(i, 1, n + 1) {
                _for(j, i + 1, n + 1) {
                    _for(k, j + 1, n + 1) {
                        if(i + j + k == x) { count++; }
                    }
                }
            }
            cout << count << endl;
        }
    }
    return 0;
}


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

void solve() {
    int a, b; cin >> a >> b;
    if(a > 9 || b > 9) cout << -1 << '\n';
    else cout << a * b << '\n';
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223000000000000000
#define INF 2147000000
#define MOD 1000000007
using namespace std;

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

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }
    sort(a.begin(), a.end());

    ll ans=a[0];
    for(i=1; i<n; i++) {
        ans = gcd(ans, a[i]);
    }
    printf("%lld\n", ans);

    return 0;
}


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

int main()
{
	int N, L[201],ans = 0;

	cin >> N;

	N *= 2;

	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}

	sort(L, L + N);

	for (int i = 0; i < N; i += 2) {
		ans += L[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int niceNumber = 0;
		for(int i = 0 ; i <= s.length() - 3 ; i++) {
			String s2 = s.substring(i, i + 3);
			int t = Integer.valueOf(s2);
			niceNumber = Math.abs(niceNumber - 753) > Math.abs(t - 753) ? t : niceNumber;
		}
		System.out.println(Math.abs(niceNumber - 753));

	}
}



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K;
  cin >> N >> K;
  vector< int > A(N);
  cin >> A;
  for(int i = K; i < N; i++) {
    if(A[i - K] < A[i]) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
}


Measured memory_bytes: 3988