akhauriyash/Code-Regression huggingface dataset:
<?php
$answer = 0;
$memo = [];
fscanf(STDIN, '%d', $personCnt);
$infoCnts = [];
$infoList = [];
for ($i=0; $i < $personCnt; $i++) { 
    $num = $i;
    fscanf(STDIN, '%d', $infoCnts[$num]);
    for ($j=0; $j < $infoCnts[$num]; $j++) { 
        fscanf(STDIN, '%d %d', $target, $request);
        $infoList[$num][$target-1] = $request;
        if ($request == 1 && !in_array($num.'-'.$target, $memo)) {
            $memo[] = $num.'-'.$target;
        }
    }
}

for ($i=0, $I=2**$personCnt; $i < $I; $i++) { 
    $bits = sprintf('%0'.$personCnt.'b', $i);
    $flag = true;
    foreach ($infoList as $person => $map) {
        if ($bits[$person] == '1') {
            foreach ($map as $key => $value) {
                if ($bits[$key] != $value) {
                    $flag = false;
                }
            }
        }
    }
    if ($flag) {
        $total = 0;
        for ($j=0; $j < $personCnt; $j++) { 
            $total += $bits[$j];
        }
        $answer = max($answer, $total);
    }
}

echo $answer . "\n";

Measured memory_bytes: 4604
#include <cstdio>
#include <utility>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

#define IN (int) in

int main() {
	int n {in};
	for (;;) {
		char c = gcu(); gcu();
		switch(c) {
		case '+': n += IN; break;
		case '-': n -= IN; break;
		case '*': n *= IN; break;
		case '/': n /= IN; break;
		default: outl(n); return 0;
		}
	}
}


Measured memory_bytes: 2452
import java.util.Arrays;
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int lake = scanner.nextInt();
        int house = scanner.nextInt();
        int[] position = new int[house];
        for(int i = 0; i < house; i++) position[i] = scanner.nextInt();
        int[] distance = new int[house];
        distance[0] = lake - position[house - 1] + position[0];
        for(int i = 1; i < house; i++) {
        	distance[i] = position[i] - position[i - 1];
        }
        int ans = Arrays.stream(distance).sum() - Arrays.stream(distance).max().getAsInt();
        System.out.println(ans);
    }

}


Measured memory_bytes: 85620
#include<stdio.h>
#define INFINITY 1000000001
#define N 100000

typedef struct{
  int number;
  char mark;
}Card;

void merge(Card *, int, int, int);
void mergeSort(Card *, int, int);
int partition(Card *, int, int);
void quickSort(Card *, int , int);

int main(){
  Card out1[N], out2[N];
  int n, v, f = 1;
  int i;
  char c;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf(" %c %d", &c, &v);
    out1[i].mark = c;
    out2[i].mark = c;
    out1[i].number = v;
    out2[i].number = v;
  }

  /*for(i=0;i<n;i++){
    printf("%c %d\n", out1[i].mark, out1[i].number);
    }*/

  mergeSort(out1, 0, n);
  quickSort(out2, 0, n-1);

  for(i=0;i<n;i++){
    if(out1[i].mark != out2[i].mark) f = 0;
  }

  /*for(i=0;i<n;i++){
    printf("%c %d\n", out1[i].mark, out1[i].number);
    }*/
  
  if(f == 0) printf("Not stable\n");
  else printf("Stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n", out2[i].mark, out2[i].number);
  }
  
  return 0;
}

void merge(Card *s, int left, int mid, int right){
  int n1, n2;
  int i, j, k;
  
  n1 = mid - left;
  n2 = right - mid;
  Card l[n1+1], r[n2+1];

  for(i=0;i<n1;i++){
    l[i] = s[left + i];
  }
  for(i=0;i<n2;i++){
    r[i] = s[mid + i];
  }
  l[n1].number = INFINITY;
  r[n2].number = INFINITY;

  i = 0;
  j = 0;
  for(k=left;k<right;k++){
    if(l[i].number <= r[j].number){
      s[k] = l[i];
      i++;
    }
    else{
      s[k] = r[j];
      j++;
    }
  }
}

void mergeSort(Card *s, int left, int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right) / 2;
    mergeSort(s, left, mid);
    mergeSort(s, mid, right);
    merge(s, left, mid, right);
  }
}

int partition(Card *a, int p, int r){
  int x;
  int i, j;
  Card v;
  x = a[r].number;
  i = p - 1;
  for(j=p;j<r;j++){
    if(a[j].number <= x){
      i++;
      //a[i]とa[j]を交換
      v = a[i];
      a[i] = a[j];
      a[j] = v;
    }
  }
  //a[i+1]とa[r]を交換
  v = a[i+1];
  a[i+1] = a[r];
  a[r] = v;

  return i+1;
}

void quickSort(Card *a, int p, int r){
  int q;
  if(p < r){
    q = partition(a, p, r);
    quickSort(a, p, q-1);
    quickSort(a, q+1, r);
  }
}



Measured memory_bytes: 4028
#include <iostream>
using namespace std;
const int MC = 200010;
int N,M;
bool x[MC] , y[MC];

bool judge(){
	for (int v=0;v<N;v++)
		if(x[v] && y[v]) return 1;
	return 0;
}

int main(){
	cin>>N>>M;
	for (int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		if(a==1) x[b] = 1;
		if(b==N) y[a] = 1;
	}
	if (judge()==true)
        cout<<"POSSIBLE";
    else
        cout<<"IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
 
struct item{
	int val;
	int weight;
};
 
 
int main(){
 
	int N,W;
 
	cin >> N >> W;
 
	vector<vector<long long>> DP(W+1,vector<long long>(N,0));
 
	item temp = {0,0};
	vector<item> items_arr(N,temp);
 
	//vector<int> Weights(N,0);
	//vector<int> Value(N,0);
 
	for(int k=0;k<N;k++){
 
		cin >> items_arr[k].weight >> items_arr[k].val;
	}
 
	//init
	//sort(items_arr.begin(),items_arr.end(),compare);
	
 
	for(int i=1;i<=W;i++){
		if(i>=items_arr[0].weight){
			DP[i][0] = items_arr[0].val;
		}
	}
 
	for(int i=1;i<=W;i++){
		for(int j=1;j<N;j++){
			if(i>=items_arr[j].weight){
				DP[i][j] = max(items_arr[j].val+DP[i-items_arr[j].weight][j-1],DP[i][j-1]);
			}else{
				DP[i][j] = DP[i][j-1];
			}
		}
	}
 
	cout << DP[W][N-1] << endl;
	
	//system("pause");
	return 0;
 
}

Measured memory_bytes: 85132
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long 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 dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

int main(){
    int N;
    cin >> N;
    vector<ll>a(N);
    REP(i, N) cin >> a.at(i);
    vector<ll>b(N);
    REP(i, N) cin >> b.at(i);
    ll ans = 0;
    REP(i, N){
        if(a.at(i) < b.at(i)) ans += (b.at(i) - a.at(i)) / 2;
        else ans -= a.at(i) - b.at(i);
    }
    
    ans >= 0 ? yes : no;
    return 0;

}

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

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

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

#define INF INT_MAX/3

#define MAX_N 1000

int t;
string s;

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>t>>s;
		if(t==0)break;
		int res=-1;
		bool rejected=false;
		vector<string> ans;
		rep(i,1<<(s.length()-1)){
			string ss="";
			vector<string> a;
			int sum=0;
			rep(j,s.length()-1){
				ss+=s[j];
				if(i>>j&1){
					sum+=stoi(ss);
					a.pb(ss);
					ss="";
				}
			}
			ss+=s[s.length()-1];
			a.pb(ss);
			sum+=stoi(ss);
			if(sum<=t){
				if(res==sum)rejected=true;
				else if(res<sum){
					res=sum;rejected=false;
					ans=a;
				}
			}
		}
		if(rejected)cout<<"rejected"<<endl;
		else if(res==-1)cout<<"error"<<endl;
		else{
			cout<<res;
			rep(i,ans.size())cout<<" "<<ans[i];
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define sz size()
#define en end()
#define ro return 0
#define br break
#define con continue;
#define um unordered_map<ll,ll>
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define forr(i,a,b) for(ll i=a;i<b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
int main()
{
    ios;
    ll n ;
    cin >> n;
    string s , t ;
    cin >> s >> t;
    unordered_map<ll , string > suff , pref ;
    string ss = "";
    ll len = 1 ;
    for(ll i = n-1 ; i >=0 ; --i){
        if(i == n-1){
            ss = ss + s[i];
            suff[len] = ss ;
            ++len ;
            con ;
        }
        else {
            string ans = "" ;
            ans = ans + s[i] ;
            ss.insert(0 , ans) ;
        }
        suff[len] = ss ;
        ++len;
    }
    ss = "";
    len = 1 ;
    forn(i , 0 , n-1 ){
        ss = ss + t[i] ;
        pref[len] = ss ;
        ++len ;
    }
    ll maxxlen = 0;
    for(ll i = n ; i >= 1 ; --i){
        if(suff[i] == pref[i]){
            maxxlen = i ;
            br ;
        }
    }
    cerr << "maxlen is " << maxxlen << el ;
    forn(i , 1 , n ){
       cerr << suff[i] << el ;
    }
    cerr << el ;
    forn(i , 1 , n ){
        cerr << pref[i] << el ;
    }
    string anss="";
    anss = anss + s;
    forn(i , maxxlen, n -1){
       anss  = anss + t[i];
    }
    cout << anss.size() << el ;
    ro ;

}





























Measured memory_bytes: 256
a, b = map(int, input().split())
if a < 0 and b < 0:
    if (abs(a) - abs(b)) % 2 == 0:
        print("Negative")
    else:
        print("Positive")
elif a > 0 and b > 0:
    print("Positive")
else:
    print("Zero")


Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

using i64 = int64_t;

int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<i64> A, B;
  copy_n(istream_iterator<i64>(cin), N, back_inserter(A));
  copy_n(istream_iterator<i64>(cin), N, back_inserter(B));

  i64 sumA = accumulate(begin(A), end(A), 0LL);
  i64 sumB = accumulate(begin(B), end(B), 0LL);

  set<pair<i64, int>> S;
  for (auto i = 0u; i < B.size(); ++i) {
    S.emplace(B[i], i);
  }

  auto ret = [&]() -> i64 {
    i64 ret = 0;
    while (sumB > sumA) {
      const auto it_max = --S.end();
      auto i = it_max->second;
      S.erase(it_max);

      if (A[i] == B[i]) continue;

      i64 l = B[(i - 1 + N) % N];
      i64 r = B[(i + 1) % N];

      if (B[i] <= max(l, r)) return -1;

      i64 k = min((B[i] - max(l, r) + l + r - 1) / (l + r),
                  (B[i] - A[i]) / (l + r));
      if (k <= 0) return -1;

      ret += k;

      sumB -= k * (l + r);
      B[i] -= k * (l + r);

      if (B[i] <= 0) return -1;
      S.emplace(B[i], i);
    }

    return std::equal(A.begin(), A.end(), B.begin()) ? ret : -1;
  }();

  cout << ret << '\n';
  return 0;
}


Measured memory_bytes: 15856
# -*- coding: utf-8 -*-

sx,sy,tx,ty = map(int, input().split())
ans = ['U'] * (ty - sy) + ['R'] * (tx - sx)
ans += ['D'] * (ty - sy) + ['L'] * (tx - sx)
ans += ['L'] + ['U'] * (ty - sy + 1) + ['R'] * (tx - sx + 1) + ['D']
ans += ['R'] + ['D'] * (ty - sy + 1) + ['L'] * (tx - sx + 1) + ['U']
print(''.join(ans))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
#define vi vector<int>
#define ll long long
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define MOD 998244353
#define endL << '\n'
#define ii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define endL << '\n'
#define vii vector<ii>
#define pb push_back

/*
ll powmod(ll x, ll y, ll mod){
	ll res = 1;
	while (y > 0){
		if (y%2) res = (res*x) % mod;
		x = (x*x) % mod;
		y /= 2;
	}
	return res;
}
*/

/*const int N = 1000000;
int lp[N+1];
vector<ll> pr;

void sieve(){
	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}*/

vvi graph, rev;
vi vis, ans;

void dfs(int v){
	vis[v] = true;

	for (auto u : graph[v]){
		if (vis[u]) continue;
		dfs(u);
	}

	ans.pb(v);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1; //cin >> t;
	while(t--){
		int w, n, m; cin >> n >> m;
		graph.resize(n); rev.resize(n);
		vis.resize(n, false);
		for (int i = 0; i < m; i++){
			int x, y; cin >> x >> y; x--; y--;
			graph[x].pb(y);
			rev[y].pb(x);
		}

		for (int i = 0; i < n; i++){
			if (vis[i]) continue;
			dfs(i);
		}
		reverse(ans.begin(), ans.end());
		vi dp(n, 0);
		for (int i = 1; i < n; i++){
			w = ans[i];
			for (auto u : rev[w]) dp[w] = max(dp[w], dp[u] + 1);
		}
		cout << *max_element(dp.begin(), dp.end());
	}
}

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

int main() {
	int list[30] = {},black[30],cnt = 0,data,num,i;
	for(i = 0;i < 28;i++){
		scanf("%d",&data);
		data = data - 1;
		list[data] = 1;
	}
	for(i = 0;i < 30;i++){
		if(list[i] == 0){
			black[cnt] = i + 1;
			cnt++;
		}
	}
	for(i = 0;i < (cnt - 1);i++){
		if(black[i] > black[(i + 1)]){
			num = black[i],black[i] = black[(i + 1)],black[(i + 1)] = num;
		}
	}
	for(i = 0;i < cnt;i++){
		printf("%d\n",black[i]);
	}
}

Measured memory_bytes: 1192
N=int(input())
A=list(map(int,input().split()))

front=[]
end=[]

for i in range(N):
    if i%2==0:
        end.append(A[i])
    else:
        front.append(A[i])

front.reverse()
data=front+end
if N%2==1:
    data.reverse()
data=list(map(str,data))
print(" ".join(data))


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

int main() {
    vector<pair<int, int>> v(5);
    int amari = 100;
    int idx = -1;
    for (int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        v[i].first = x / 10;
        v[i].second = x % 10;
        if (v[i].second < amari && v[i].second != 0) {
            amari = v[i].second;
            idx = i;
        }
    }
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        if (i == idx) {
            ans += 10 * v[i].first;
            ans += v[i].second;
        } else {
            ans += 10 * (v[i].first + (v[i].second == 0 ? 0 : 1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll A = 0, B = 0;
  cin >> A >> B;
  if(A % B == 0){
    cout << A/B;
  }
  else{
    cout << A/B +1;
  }
}

Measured memory_bytes: 3636
using System;
 
class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        int x = Int32.Parse(s);
        int happy = 0;
		
		if(x >= 500){
			var coin = x / 500;
			happy += coin * 1000;
			x = x % 500;
		}
		if(x >= 5){
			var coin = x / 5;
			happy += coin * 5;
			x = x % 5;
		}
		
		Console.WriteLine(happy);
    }
}
 

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

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

  if (a > b) {
    cout << "a > b" << ln;
  } else if (a < b) {
    cout << "a < b" << ln;
  } else {
    cout << "a == b" << ln;
  }

  return 0;
}


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

ll solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    for ( ll i = 1; i <= N; i++ ) {
        ll j = N/i;
        ans += (i+j*i) * j / 2;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    String str;
    Map<String, Integer> map = new HashMap<>();
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	boolean flg = true;
	for(int i = 0, l = str.length(); i < l; i++) {
	    String c = str.substring(i, i + 1);
	    if(map.get(c) != null) flg = false;
	    map.put(c, 1);
	}
	
	if(flg) out("yes");
	else    out("no");
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	str = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int ans)
    {
	System.out.println(ans);
    }

    void out(String ans)
    {
	System.out.println(ans);
    }
}


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

namespace atcoder135
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] ct = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long sm = 0;
            for(int i = 0; i < n; ++i)
            {
                int tp = M(ct[i], h[i]);
                ct[i] -= tp;
                h[i] -= tp;
                sm += tp;
                tp = M(ct[i + 1], h[i]);
                ct[i + 1] -= tp;
                h[i] -= tp;
                sm += tp;
            }
            Console.WriteLine(sm);
        }
        

        static int M(int ct, int h)
        {
            if (ct <= h)
                return ct;
            return h;
        }
    }
}


Measured memory_bytes: 36188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
vector<string> S;
int N;
void dfs(string s){
  if(sz(s)==N){
    S.pb(s);
    return;
  }
  for(int i=1; i<=N; i++){
    char x  = '0' + i;
    bool contain = false;
    rep(i,sz(s)){
      if(s[i] == x) contain = true;
    }
    if(!contain){
      dfs(s+x);
    }
  }
}

int main(){
  cin >> N;
  vector<int> P(N); rep(i,N) cin >> P[i];
  vector<int> Q(N); rep(i,N) cin >> Q[i];
  string s = "";
  string Pstr="";
  string Qstr="";
  rep(i,N){
    Pstr += ('0'+P[i]);
    Qstr += ('0'+Q[i]);
  }
  cerr << Pstr << " " << Qstr << endl;
  dfs(s);
  sort(all(S));
  int p=0;
  int q=0;
  rep(i,sz(S)){
    if(S[i] == Pstr) p = i;
    if(S[i] == Qstr) q = i;
  }
  cout << abs(p-q) << endl;
  return 0;
}


Measured memory_bytes: 2424
#include<stdio.h>
#include<string.h>

int main(){
  int len1 = 0, len2 = 0;
  char s1[101], s2[101];
  
  scanf("%s %s", s1, s2);
  
  while(s1[len1]){
    len1++;
  }
  while(s2[len2]){
    len2++;
  }
  if(len1 > len2 || (len1 == len2 && strcmp(s1, s2) > 0)){
    printf("GREATER\n");
  } else if(strcmp(s1, s2) == 0){
    printf("EQUAL\n");
  } else {
    printf("LESS\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
 long N;
 cin>>N;
 long A[N+1];
 long NUM[N+1];
 long MATCH[N+1];
 long sum=0;
 for(int i=0;i<N+1;i++){
     A[i]=0;
     NUM[i]=0;
     MATCH[i]=0;
 }
 for(int i=0;i<N;i++){
     cin>>A[i];
     NUM[A[i]]=NUM[A[i]]+1;
 //    cout<<"NUM"<<A[i]<<"is"<<NUM[A[i]]<<endl;
 }
 for(int i=0;i<N+1;i++){
     MATCH[i]=NUM[i]*(NUM[i]-1)/2;
     sum=sum+MATCH[i];
 }
 for(int i=0;i<N;i++){
     cout<<sum-NUM[A[i]]+1<<endl;
 }

}

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

using namespace std;

int a[100100],dp[100100];

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k; cin>>n>>k;
    for(int i=1;i<=n;i++) {cin>>a[i]; dp[i]=INT_MAX;} dp[1]=0;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=k;j++) {
            if(i+j<=n) dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
        }
    }
    cout<<dp[n]<<endl;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    string s,t;
    cin >> s;
    cin >> t;
    string r="";
    for(i=0;i<n;i++){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())

ans = 0
ls = ['3','5','7']
for x in ls:
    st = deque([])
    flag = False
    st.append((x, flag))
    while st:
        cur, f = st.pop()
        if f:
            ans += 1
        else:
            if '3' in set(list(cur)) and '5' in set(list(cur)) and '7' in set(list(cur)):
                # print(cur)
                f = True
                ans += 1
        for y in ls:
            if int(cur + y) <= N:
                st.append((cur+y, f))
print(ans)

Measured memory_bytes: 75164
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
// #define MOD 1000000007
// #define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

template<int N, int M>
struct ModFact {
    int inv[N+1];
    int fact[N+1];
    constexpr ModFact() : fact() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i < N; i++) {
            f = f*(i+1)%M;
            fact[i+1] = f;
        }
        f = power(f, M-2);
        for (int i = N-1; i >= 0; i--) {
            inv[i] = fact[i] * f % M;
            f = f * (i+1) % M;
        }
    }
    inline constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%M;
            a = (a*a)%M;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}
};

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int MOD = 1000000007;

ModFact<100000, MOD> fact;

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a = (a + fact[i]) % MOD;
        ans += a * d % MOD;
    }
    printf("%lld\n", ((ans%MOD)*fact.fact[N-1])%MOD);
	return 0;
}


Measured memory_bytes: 1024
function Main(input) {
    var n = parseInt(input);
    var res = null;

    if (n < 1200) res = 'ABC';
    else if(n < 2800) res = 'ARC';
    else res = 'AGC';

    console.log(res);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
n, m = list(map(int, input().split()))

moves = [list(map(int, input().split())) for i in range(m)]

possibilities = [False] * n
possibilities[0] = True
nums = [1] * n

for i in range(m):
    x = moves[i][0] - 1
    y = moves[i][1] - 1

    if possibilities[x]:
        possibilities[y] = True

    nums[x] -= 1
    nums[y] += 1
    if nums[x] == 0:
        possibilities[x] = False

print(sum(possibilities))


Measured memory_bytes: 28836
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,a[1005];
vector<ll>v;
int main()
{
    scanf("%lld%lld",&n,&k);
    a[0]=0;
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]),a[i]+=a[i-1];
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
            v.push_back(a[j]-a[i-1]);//把区间和全部加入到v中
    ll ans=0;
    for(int i=40;i>=0;i--)
    {
        ll p=1ll<<i,cot=0;
        vector<ll>s;
        for(int j=0;j<v.size();j++)
            if(v[j]&p) s.push_back(v[j]),cot++;//把1<<i位的过滤到s中
        if(cot>=k)//如果元素个数大于k，则s中被过滤的元素可用，其它更小的低位元素可以抛弃
            v=s,ans+=p;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 6384
s = input()

lAlp = [0 for i in range(26)]

for i in range(len(s)):
    num = ord(s[i]) - ord('a')
    lAlp[num] += 1
    
for i in range(26):
    if(lAlp[i] % 2 == 1):
        print('No')
        break

else:
    print('Yes')

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

int a[105];
double x=0.250000;
bool cmp(int i,int j)
{
	return i>j;
}
int main()
{
	int n,m,sum=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	x=x/m*sum;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=m;i++)
	{
		if(a[i]<x)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    string s,t; cin>>s>>t;
    int cnt = 0;
    for(int i=0; i<3; i++){
        if(s[i] == t[i]) cnt++;
    }
    OUT(cnt);
}


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

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  llong n;
  cin >> n;

  vector<llong> v(n);
  int minus = 0;
  REP(i,n){
    cin >> v[i];
    if(v[i] < 0) minus++;
  }

  llong mn = llabs(v[0]);
  llong ans = 0;
  REP(i,n){
    mn = min(mn, llabs(v[i]));
    ans += llabs(v[i]);
  }
  if(minus % 2 == 0){
    cout << ans << endl;
  }else{
    cout << ans - mn * 2 << endl;
  }

  return 0;
}



Measured memory_bytes: 1024
#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<pair<int, int>, int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  priority_queue<P, vector<P>, greater<P> > pq;
  int min_x = 1e9;
  rep(i, m) {
    int x, y; cin >> x >> y;
    min_x = min(min_x, x);
    pq.push(make_pair(make_pair(x, y), i));
  }
  
  vector<ll> ans(m);
  int cnt = 1;
  rep(i, m) {
    pair<pair<int, int>, int> q = pq.top(); pq.pop();
    int nx = q.first.first;
    
    if(min_x != nx) {
      cnt = 1;
      min_x = nx;
    }
    ans[q.second] = nx * pow(10, 6) + cnt;
    ++cnt;
  }
  for(auto aa : ans) printf("%012lld\n", aa);
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vector<pint> a(N);
    REP(i,N){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(ALL(a));

    vint ans(N);
    REP(i,N){
        if(i<N/2) ans[a[i].second]=a[N/2].first;
        else ans[a[i].second]=a[N/2-1].first;
    }
    REP(i,N){
        cout<<ans[i]<<endl;
    }

}


Measured memory_bytes: 6912
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#define INF 100000000000000
using namespace std;
typedef long long ll;
int n;
int a[300000];
ll memo[100001];
int main(){
  cin >> n;
  for(int i=0;i<3*n;i++) cin >> a[i];
  ll fsum=0,bsum=0;
  priority_queue<int,vector<int>,greater<int> > fq;
  priority_queue<int> bq;
  for(int i=0;i<n;i++){
    fq.push(a[i]);
    fsum+=a[i];
    bq.push(a[i+2*n]);
    bsum+=a[i+2*n];
  }
  memo[0]=fsum;
  for(int i=0;i<n;i++){
    int d=a[i+n]-fq.top();
    if(d>0){
      fsum+=d;
      fq.pop();
      fq.push(a[i+n]);
    }
    memo[i+1]=fsum;
  }
  ll res=memo[n]-bsum;
  for(int i=0;i<n;i++){
    int d=bq.top()-a[2*n-1-i];
    if(d>0){
      bsum-=d;
      bq.pop();
      bq.push(a[2*n-1-i]);
      res=max(res,memo[n-1-i]-bsum);
    }
  }
  cout << res << "\n";
  

  
  return 0;
}


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0) break;
			printFrame(a, b);
			System.out.println();
		}
		sc.close();
	}
	static void printFrame (int h, int w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.out.print(i == 0 || i == h - 1 || j == 0 || j == w - 1 ? "#" : ".");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 32180
#include <iostream>
#include <string>

using namespace std;

int main() {
	int N;
	int H[20];
	int max = 0;
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		if (H[i] >= max) {
			ans++;
			max = H[i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;

bool compare(const pair<int, int>& F, const pair<int, int>& S) {
    return F.second < S.second;
}

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

    bool flag = true;
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
            if(c[i][j] + c[i + 1][j + 1] != c[i + 1][j] + c[i][j + 1]) flag = false;
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long LL;
const int N = 2015, M = 20005, inf = 0x3f3f3f3f;

int n, head[N], cur[N], tot = 1, s, t;
struct edge { int to, nxt, rem, cost; } e[M];

void link(int x, int y, int z, int w) {
	e[++tot] = (edge) { y, head[x], z, w }, head[x] = tot;
	e[++tot] = (edge) { x, head[y], 0, -w}, head[y] = tot;
}

LL ans = 0;
bool inq[N];
LL dis[N];

bool bellmanford() {
	std::memset(dis, -0x3f, sizeof dis);
	std::queue<int> q; q.push(s), inq[s] = 1, dis[s] = 0;
	while (q.size()) {
		int tmp = q.front(); q.pop(); inq[tmp] = 0;
		for (int i = head[tmp]; i; i = e[i].nxt)
			if (e[i].rem && dis[e[i].to] < dis[tmp] + e[i].cost) {
				dis[e[i].to] = dis[tmp] + e[i].cost;
				if (!inq[e[i].to]) inq[e[i].to] = 1, q.push(e[i].to);
			}
	}
	return dis[t] > -1e15;
}
bool vis[N];
int dinic(int x, int low) {
	if (x == t || !low) return low;
	int now = 0, t; vis[x] = 1;
	for (int &i = cur[x]; i; i = e[i].nxt)
		if (!vis[e[i].to] && e[i].rem && dis[e[i].to] == dis[x] + e[i].cost 
			&& (t = dinic(e[i].to, std::min(e[i].rem, low)))) {
				now += t, low -= t, e[i].rem -= t, e[i ^ 1].rem += t;
				ans += (LL) e[i].cost * t;
				if (!low) break;
			}
	vis[x] = 0;
	return now;
}


int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n, s = 0, t = n + n + 5;
	for (int i = 1; i <= n; ++i) {
		int x, y, c;
		std::cin >> x >> y >> c;
		link(s, i, c, 0);
		link(i, 2 * n + 1, c, x + y);
		link(i, 2 * n + 2, c, x - y);
		link(i, 2 * n + 3, c, -x + y);
		link(i, 2 * n + 4, c, -x - y);
	}
	for (int i = 1; i <= n; ++i) {
		int x, y, c;
		std::cin >> x >> y >> c;
		link(i + n, t, c, 0);
		link(2 * n + 1, i + n, c, -x - y);
		link(2 * n + 2, i + n, c, -x + y);
		link(2 * n + 3, i + n, c, x - y);
		link(2 * n + 4, i + n, c, x + y);
	}
	while (bellmanford()) std::memcpy(cur, head, sizeof head), dinic(s, inf);
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 640
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll ans=(ll)(n*(n-1))/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

const int maxn = 2E+5 + 5;

int n;
int son[maxn];

int main() {
	scanf("%d", &n);
	for(int i = 1; i < n; ++i) {
		int x;
		
		scanf("%d", &x);
		++son[x];
	}
	
	for(int i = 1; i <= n; ++i)
		printf("%d\n", son[i]);
}

Measured memory_bytes: 2456
N, K = map(int, input().split())
a = list(map(int, input().split()))

first_count = 0
second_count = 0
for i in range(N):
  for j in range(i, N):
    if a[i] > a[j]:
      first_count += 1
    if a[N-i-1] > a[N-j-1]:
      second_count += 1
      
      
print((first_count * K * (K + 1) // 2 + second_count * K * (K -1) // 2) % (10 ** 9 + 7))

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };

vector<P> factorize(int N) {
  vector<P> res;
  FOR(i,2,(int)sqrt(N)+1) {
    if (N%i==0) {
      int cnt=0;
      while (N%i==0) {
        N/=i;
        cnt++;
      }
      res.push_back({i,cnt});
    }
  }
  if (N>1) res.push_back({N,1});
  return res;
}

int main() {
  int N;cin>>N;
  const int MOD=1e9+7;
  // 素因数の数だけ増える

  map<int,int> mp;
  FOR(i,1,N+1) {
    vector<P> facs = factorize(i);
    for (P p:facs) {
      mp[p.first]+=p.second;
    }
  }

  ll ans = 1;
  for (auto m:mp) ans = ans*(m.second+1)%MOD;
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())

q = abs(x) // d

if q >= k:
    print(abs(x) - (d * k))
    exit()

mod = abs(x) % d


if (k - q) % 2 == 0:
    print(mod)
else:
    print(abs(d) - mod)


Measured memory_bytes: 9168
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Info{
	Info(int arg_left,int arg_right){
		left = arg_left;
		right = arg_right;
	}
	int left,right;
};

int N;
int table[NUM];
bool is_sea[NUM];
vector<int> V;
vector<Info> POS[NUM];
map<int,int> MAP;


int main(){

	scanf("%d",&N);

	int count = 0; //島の数

	//ダミー
	is_sea[0] = true;
	is_sea[N+1] = true;
	table[0] = 0;
	table[N+1] = 0;

	for(int i = 1; i <= N; i++){

		scanf("%d",&table[i]);

		if(table[i] == 0){

			is_sea[i] = true;

		}else{

			is_sea[i] = false;
			V.push_back(table[i]);
			if(is_sea[i-1]){
				count++;
			}
		}
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	//座標圧縮
	for(int i = 0; i < V.size(); i++){

		MAP[V[i]] = i;
	}

	//同じ高さを区間にまとめる
	int left,right,index = 1;

	while(index <= N){

		left = index;
		right = left;
		while(right <= N && table[left] == table[right])right++;

		index = right;

		right--;
		if(table[left] != 0){
			POS[MAP[table[left]]].push_back(Info(left,right));
		}
	}

	int ans = count;

	for(int i = 0; i < V.size(); i++){

		for(int k = 0; k < POS[i].size(); k++){

			if(is_sea[POS[i][k].left-1] == true && is_sea[POS[i][k].right+1] == true){ //左右が海なら島減

				count--;
			}else if(table[POS[i][k].left] < table[POS[i][k].left-1] &&
					table[POS[i][k].right] < table[POS[i][k].right+1]){ //左右が今回沈まない陸地なら島増

				count++;
			}
		}

		for(int k = 0; k < POS[i].size(); k++){
			for(int p = POS[i][k].left; p <= POS[i][k].right; p++){

				is_sea[p] = true;
			}
		}

		ans = max(ans,count);
	}

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

	return 0;
}




Measured memory_bytes: 13972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    if(N <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a=0,b=0,i;
	char c[20];
	scanf("%s",c);
	for(i=0;i<20;i++){
		if(c[i]=='o'){
			a ++;
		}else if(c[i]=='x'){
			b++;
		}
	}
	if(b<8){
		printf("YES");
	}else{
		printf("NO");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, flag;
    string s1, s2;
    cin >> n >> s1 >> s2;
    ll ans = 1;
    bool before = true; //前のドミノのパターン
    if (s1[0] == s2[0])
    {
        ans = 3;
        flag = 1;
        before = true;
    }
    else
    {
        ans = 6;
        flag = 2;
        before = false;
    }
    for (int i = flag; i < n; i++)
    {
        if (s1[i] == s2[i])
        {
            if (before)
                ans = ans * 2 % mod;
            else
                ans = ans * 1;
            before = true;
        }
        else
        {
            if (before)
                ans = ans * 2 % mod;
            else
                ans = ans * 3 % mod;
            i++;
            before = false;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
	
	int main(void){

	char alpha;
	
	scanf("%c",&alpha);
	
	if( (alpha >='a') && (alpha<='z') )
	{
		printf("a");
	}
	if( (alpha >='A') && (alpha<='Z') )
	{
		printf("A");
	}
    return 0;
}

Measured memory_bytes: 1600
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int n,k;
  cin>>n>>k;
  cout<<n-k+1<<endl;	
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 256
import sys
N = int(sys.stdin.readline().strip())
Vs = map(int, sys.stdin.readline().strip().split())
Cs = map(int, sys.stdin.readline().strip().split())
max_value = 0
for v, c in zip(Vs, Cs):
    if v-c > 0:
        max_value += v-c
print(max_value)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int a, b;
    cin >> a >> b;
    if(a <= b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
        cout << endl;
    }
    else{
        for(int i = 0; i < a; i++){
            cout << b;
        }
        cout << endl;
    }
    solve();
    return 0;
}



Measured memory_bytes: 256