akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;

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

  cin >> N;

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  sort(A.begin(),A.end());

  int a = A[0];
  int c = a+2;
  int ans = 1;
  while(a<=A.back()){
    int dis = distance(A.begin(), upper_bound(ALL(A), c));
    int dis2 = distance(A.begin(), lower_bound(ALL(A), a));
    ans = max(ans, dis - dis2);
    a++; c++;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 640
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  if(n<600) cout<<8<<endl;
  else if(n<800) cout<<7<<endl;
  else if(n<1000) cout<<6<<endl;
  else if(n<1200) cout<<5<<endl;
  else if(n<1400) cout<<4<<endl;
  else if(n<1600) cout<<3<<endl;
  else if(n<1800) cout<<2<<endl;
  else cout<<1<<endl;
  

  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int a,b;
int main()
{
	cin>>a>>b;
	if(a<=8&&b<=8)
	{
		cout<<"Yay!";
	}
	else
	{
		cout<<":(";
	}
}


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

int main() {
  int n;
  long long sumb = 0,sumc = 0;
  cin >> n;
  vector<int> a(3*n);
  priority_queue<int> b,c;
  vector<long long> ans(n+1);
  for (int i = 0;i < 3*n;++i) cin >> a[i];
  for (int i = 0;i < n;++i) {
    b.push(-a[i]);
    sumb += a[i];
  }
  for (int i = 2*n;i < 3*n;++i) {
    c.push(a[i]);
    sumc += a[i];
  }

  for (int i = 0;i < n+1;++i) ans[i] = 0;
  ans[0] += sumb;
  ans[n] -= sumc;

  for (int i = n;i < 2*n;++i) {
    b.push(-a[i]);
    sumb += a[i]+b.top();
    b.pop();
    ans[i-n+1] += sumb;
  }
  for (int i = 2*n-1;i > n-1;--i) {
    c.push(a[i]);
    sumc += a[i]-c.top();
    c.pop();
    ans[i-n] -= sumc;
  }
  cout << *max_element(ans.begin(),ans.end()) << endl;
}

Measured memory_bytes: 3320
#include <cstdio>
#include <algorithm>

int main()
{
  long long a, b, k;
  scanf("%lld%lld%lld", &a, &b, &k);
  
  long long *p = &a, *q = &b;
  while (k-- > 0)
  {
    *p /= 2;
    *q += *p;
    std::swap(p, q);
  }
  printf("%lld %lld\n", a, b);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
 int A,B;
  cin >>A >> B;
  if(A>9||B>9)
    cout << -1 << endl;
  else
    cout << A*B << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if (a%2 == 0 || b%2 ==0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N = 5005;
const long long mod = 1000000007;
int n, x, y;
int size[N];
long long tmp[N], df[N];
long long f[N][N];
std::vector<int> to[N];
inline void dfs(int u, int fa) {
    f[u][1] = 1;
    size[u] = 1;
    for (auto v: to[u]) {
        if (v == fa) continue;
        dfs(v, u);
        for (int i = 0; i <= size[u]; ++i) tmp[i] = f[u][i], f[u][i] = 0;
        for (int i = 0; i <= size[u]; ++i) {
            for (int j = 0; j <= size[v]; ++j) {
                f[u][i + j] += tmp[i] * f[v][j] % mod;
            }
        }
        size[u] += size[v];
        for (int i = 0; i <= size[u]; ++i) ((f[u][i] %= mod) += mod) %= mod;
    }
    for (int i = 2; i <= size[u]; i += 2) f[u][0] += -df[i - 1] * f[u][i] % mod;
    ((f[u][0] %= mod) += mod) %= mod;
}
int main() {
    std::cin >> n;
    for (int i = 1; i < n; ++i) {
        std::cin >> x >> y;
        to[x].push_back(y);
        to[y].push_back(x);
    }
    df[0] = df[1] = 1;
    for (int i = 2; i <= n; ++i) df[i] = df[i - 2] * i % mod;
    dfs(1, 1);
    std::cout << mod - f[1][0] << std::endl;
    return 0;
}

Measured memory_bytes: 92668
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var amax = (int)((a + 1) / 0.08d);
        var amin = (int)((a - 1) / 0.08d);
        var bmax = (int)((b + 1) / 0.1d);
        var bmin = (int)((b - 1) / 0.1d);
        var ans = getAns(a, b, Min(amin, bmin), Max(amax, bmax));
        Console.WriteLine(ans);
    }
    static int getAns(int a, int b, int imin, int imax)
    {
        for (int i = imin; i <= imax; i++)
        {
            if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) return i;
        }
        return -1;
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

pair<int, int> calc_num(set<int>& used_idx, int idx, int N, bool is_L) {
    int first = N, second = N;
    int mul = 1;
    if (is_L == true) {
        first = -1; 
        second = -1;
        mul = -1;
    }
    
    auto r_first_it = used_idx.lower_bound(idx);
    if (r_first_it != used_idx.end()) {
        first = mul * *r_first_it;
        auto r_second_it = used_idx.upper_bound(*r_first_it);
        if (r_second_it != used_idx.end()) {
            second = mul * *r_second_it;
            //t = *r_second_it - *r_first_it;
        }
        else {
            //t = N;
            //t = N - *r_first_it;
        }
    }
  
    return make_pair(first, second);
}

int main() {
    int N;
    cin >> N;
    vint P(N);
    vector<pair<int, int>> Pidx(N);
    rep(i, N) {
        cin >> P[i];
        Pidx[i] = (make_pair(P[i], i));
    }
    sort(Pidx.begin(), Pidx.end(), greater<pair<int, int>>());
    ll ans = 0;
    set<int> used_idx;
    set<int> m_used_idx;

    REP(i, 0, N) {

        auto R = calc_num(used_idx, Pidx[i].second, N, false);
        auto L = calc_num(m_used_idx, -Pidx[i].second, N, true);
        ll t = ll(R.first - ll(Pidx[i].second)) * ll(L.first - L.second);
        t += ll(Pidx[i].second - L.first) * ll(R.second - R.first);
        used_idx.insert(Pidx[i].second);
        m_used_idx.insert(-Pidx[i].second);
        ans += t * ll(Pidx[i].first);

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

Measured memory_bytes: 10752
#include<stdio.h>

int main(){

  int i,j,u,k,v,A[1000][1000],n;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    A[i][i]=0;

  }

  for(i=0;i<n;i++){
  
    scanf("%d%d",&u,&k);

    for(j=0;j<k;j++){

      scanf("%d",&v);
      
      A[u-1][v-1]=1;



    }
  }



  for(i=0;i<u;i++){
    for(j=0;j<u-1;j++){

      
       printf("%d ",A[i][j]);

    }
    printf("%d",A[i][j]);
    printf("\n");
  }
 

  return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define  pb     push_back
#define  all(x) (x).begin(), (x).end()
#define  rep(i,a,b) for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)
#define  deb(x) cout << #x << " - " << x << "\n";
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  D2(x)  { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  ps(x,y) fixed<<setprecision(y)<<x
 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000000;
const ll MAX_N = 1e6 + 2;

void solve(){
    int n; cin >> n;
    if(n>=400 && n<=599) cout << "8";
    else if(n>=600 && n<=799) cout << "7";
    else if(n>=800 && n<=999) cout << "6";
    else if(n>=1000 && n<=1199) cout << "5";
    else if(n>=1200 && n<=1399) cout << "4";
    else if(n>=1400 && n<=1599) cout << "3";
    else if(n>=1600 && n<=1799) cout << "2";
    else cout << "1";
}
 
int main() {
    IOS;
    // int t; cin >> t;
    int t = 1; 
    while(t--) solve();
}

Measured memory_bytes: 3536
x=[0]*9
n=int(input())
a=[int(i) for i in input().split()]
for i in range(n):
    for j in range(8):
        if a[i]<400*(j+1):
            x[j]=1
            break
    else:
        x[8]+=1

if x[:-1].count(1)!=0:
    print(x[:-1].count(1),end=" ")
else:
    print(1,end=" ")
print(x[:-1].count(1)+x[-1])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
    return max(a,b)-min(a,b);
}
template<typename T> T lcm(T a,T b){//最小公倍数
  return (a*b)/gcd(a,b);
}
int  gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,e;
    int c,d;
    map<string,int> q;
    cin>>a>>b>>c>>d>>e;
    q[a]=c;
    q[b]=d;
    q[e]--;
    cout<<q[a]<<" "<<q[b]<<"\n";
}


Measured memory_bytes: 256
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
d = make_divisors(n)
for x in d:
    if x > 1 and n // (x-1) < (x-1):
        ans += x-1
print(ans)

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

int main() {
  int N,K,i,x,sum;
  cin >> N >> K;
  i = 0;
  
  while(i<N){
    cin >> x;
    sum += 2*min(x,K-x);
    i++;
  }
  cout << sum << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    if (N % 10 == 9 || N / 10 == 9) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    vector<pair<int, int>> f[2];
    for (int j = 0; j < 2; j++) {
        map<int, int> mp;
        for (int i = j; i < n; i+=2) {
            mp[a[i]]++;
        }
        for (auto& p: mp) {
            f[j].emplace_back(p.second, p.first);
        }
        f[j].emplace_back(0, -1);
        sort(f[j].begin(), f[j].end(), greater<pair<int,int>>());
    }
    int mx;
    if (f[0][0].second != f[1][0].second) mx = f[0][0].first + f[1][0].first;
    else mx = max(f[0][0].first + f[1][1].first, f[0][1].first + f[1][0].first);
    int res = n - mx;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 4216
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N, M = MAP()
ks = [LIST() for _ in range(M)]
p = LIST()
 
ans = 0
 
for i in range(1<<N):
	flg = True
	i = list("{:b}".format(i).zfill(N))
	#print(i)
	for j ,lis in enumerate(ks):
		lis = lis[1:]
		tmp = 0
		for l in lis:
			if i[l-1] == "1":
				tmp += 1
		if tmp%2 != p[j]:
			flg = False
			break
	if flg:
		ans += 1
 
print(ans)

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

int main() {
	// ----- 変数宣言 -----
	string s;
	int k = 0;

	int len;
	int sen;

	int left_l = 0;
	int right_l = 0;

	int sen_l;

	int i;


	// ----- 入力 -----
	cin >> s;

	// ----- 計算 -----

	// 長さの取得
	len = s.length();

	// 中央の位置の計算
	sen = (len - 1) / 2;

	// 中央から左に連続する数の計算
	for (i = sen; i >= 0; i--) {

		// 中央の数字と一致したら
		if (s[i] == s[sen]) left_l++;
		else				break;

	}

	// 偶数の場合、中央の計算しなおし
	if (len % 2 == 0)	sen = len / 2;

	// 中央から右に連続する数の計算
	for (i = sen; i < len; i++) {

		// 中央の数字と一致したら
		if (s[i] == s[sen])	right_l++;
		else				break;

	}

	// 小さい方を採用
	if (left_l < right_l)	sen_l = left_l;
	else					sen_l = right_l;

	// 偶数の場合、２回の中央の値が違う場合は０
	if (len % 2 == 0) {
		if (s[sen] != s[sen - 1])	sen_l = 0;
	}

	// k の取得
	k = len / 2 + sen_l;

	// ----- 出力 -----

	cout << k << endl;

}

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

int main() {
  int N, A[100000];
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N);
  int last = A[N - 1], dist = INF;
  for(int i = 0; i < N - 1; i++) {
    if(last % 2 == 0) dist = min(dist, abs(last / 2 - A[i]));
    else dist = min(dist, min(abs((last - 1) / 2 - A[i]), abs((last + 1) / 2 - A[i])));
  }

  for(int i = 0; i < N - 1; i++) {
    int dd = INF;
    if(last % 2 == 0) dd = abs(last / 2 - A[i]);
    else dd = min(abs((last - 1) / 2 - A[i]), abs((last + 1) / 2 - A[i]));
    if(dd == dist) {
      cout << last << " " << A[i] << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 640
def c_factors_of_factorial(MOD=10**9 + 7):
    from math import factorial as fac
    from functools import reduce
    from operator import mul
    from collections import defaultdict

    def prime_factorization(n):
        i, table = 2, defaultdict(int)
        table[2] = 0  # 1は素数の0乗の積とみなす(n==1のときのため)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1  # nが素数のとき
        return table

    N = int(input())
    return reduce(mul, [v + 1 for v in prime_factorization(fac(N)).values()]) % MOD

print(c_factors_of_factorial())

Measured memory_bytes: 3572
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

ll getdigit(ll n){
    ll res=0;
    while(n){
        res++;
        n /= 10;
    }
    return res;
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll ans = INF,n;
    sfl(n);
    for(ll i=1;i*i<=n;i++){
        if( n % i ==0 ){
            ans = min(ans,max(getdigit(i),getdigit(n/i)));
        }
    }
    pfl(ans);
    return 0;
}

Measured memory_bytes: 3812
using System;

class program{
	static void Main(string[] args){
      int a = int.Parse(Console.ReadLine());
      int b = int.Parse(Console.ReadLine());
      int n = int.Parse(Console.ReadLine());
      int m = int.Parse(Console.ReadLine());
      
      if(a>b){
        Console.WriteLine((a-b)*m+(b*n));
      }else{
        Console.WriteLine(a*n);
      }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int dp[2010][2010];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    dp[0][n+1]=1;
    for(int i=1;i<=m;i++)
    {
        int sum=dp[i-1][n+2-i];
        for(int j=n+1-i;j;j--)
        {
            sum=(sum+dp[i-1][j])%mod;
            dp[i][j]=sum;
        }
    }
    int ans=dp[m][1]-dp[m-1][1];
    ans=(ans%mod+mod)%mod;
    for(int i=1;i<n-m;i++)
    {
        ans=ans*2%mod;
    }
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
	int n ,maxn , minx;
	cin >> n;
	int *R = new int [n];
	for( int i = 0; i < n ; i++ )
	{
		cin >> R[i];
	}
	minx = R[0] , maxn = -20000000000000000000000;
	for( int i = 1; i < n ; i++ )
	{
		maxn = max( maxn , R[i] - minx);
		minx = min( minx , R[i]);
	}
	
	cout << maxn <<endl;
	
	return 0;
 } 


Measured memory_bytes: 3884
while True:
    n = int(input())
    if n==0:break
    a = list(map(int, input().split()))

    a = sorted(a)

    ans = 10000000

    for i in range(len(a)-1):
        if a[i+1]-a[i] < ans:
            ans = a[i+1]-a[i]

    print(ans)




Measured memory_bytes: 5636
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] data = new int[M][4];
		for(int i=0; i<M; i++){
			data[i][0] = i;
			data[i][1] = sc.nextInt();	//P
			data[i][2] = sc.nextInt();	//Y
			data[i][3] = 0;
		}
		Arrays.sort(data, (x, y) -> x[1]==y[1] ? x[2]-y[2] : x[1]-y[1]);
		int a = 0;
		int b = 0;
		for(int i=0; i<M; i++){
			if(data[i][1] != a){
				a = data[i][1];
				b = 0;
			}
			data[i][3] = ++b;
		}
		int[] count = new int[N+1];
		for(int i=0; i<=N; i++){
			count[i]=0;
		}
		int[] A = new int[M];
		int[] B = new int[M];
		for(int i=0; i<M; i++){
			A[data[i][0]] = data[i][1];
			B[data[i][0]] = ++count[data[i][1]];
		}
		StringBuilder string = new StringBuilder();
		for(int i=0;i<M;i++){
			string.append(String.format("%06d%06d\n", A[i], B[i]));
		}	
		System.out.print(string.toString());
		return;
	}
}

Measured memory_bytes: 171420
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,i,ans=0;
  cin>>n;
  vector<int64_t> a(n),b(n),c(n),bc(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  for(i=0;i<n;i++) cin>>b.at(i);
  for(i=0;i<n;i++) cin>>c.at(i);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  for(i=n-1;i>=0;i--){
    bc.at(i)=distance(upper_bound(c.begin(),c.end(),b.at(i)),c.end());
    if(i<n-1) bc.at(i)+=bc.at(i+1);
  }
  for(i=0;i<n;i++){
    if(upper_bound(b.begin(),b.end(),a.at(i))!=b.end()){
      ans+=bc.at(distance(b.begin(),upper_bound(b.begin(),b.end(),a.at(i))));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#include<algorithm>
#include<deque>
#include<string>
using namespace std;

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n;
  cin>>n;
  int cnt=0,cnt2=0;

  for(int j=1;j<=n;j=j+2){
    for(int i=1;i<=j;i++){
      if(j%i==0)cnt++;
    }
    if(cnt==8){cnt2++;}

    cnt=0;
  }
  cout<<cnt2<<endl;


return 0;}


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

int main() {
  int N; cin >> N;
  int mx=0,mn=1000;
  int a;
  for(int i=0; i<N; i++){
    cin >> a;
    mx=max(mx,a); mn=min(mn,a);
  }
  cout << mx-mn << endl;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan =new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		
		int C=A*B;
		System.out.println(C);
	}

}


Measured memory_bytes: 35700
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdint.h>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <tuple>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))

using namespace std;

#define PB push_back
#define MP make_pair

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;
typedef unsigned long long ULL;

int main() {
    int n, m;
    cin >> n >> m;
    VI a(n);
    REP(i, n) scanf("%d", &a[i]);

    LL num = 0, sum = 0;
    LL other = 0;
    // {at, {right, reduce}}
    vector< pair<int, PII> > events;
    REP(i, n - 1) {
        if (a[i] < a[i + 1]) {
            events.PB(MP(a[i] + 1, MP(a[i + 1], a[i + 1] - a[i])));
            events.PB(MP(a[i + 1] + 1, MP(-a[i + 1], a[i + 1] - a[i])));
            other += a[i + 1] - a[i];
        } else {
            events.PB(MP(a[i + 1] + 1, MP(-a[i + 1], a[i + 1] - a[i] + m)));
            events.PB(MP(a[i] + 1, MP(a[i + 1] + m, a[i + 1] - a[i] + m)));
            ++num;
            sum += a[i + 1];
        }
    }

    LL answer = -1;
    int iter = 0;
    SORT(events);
    #define x first
    #define y second
    for (int i = 1; i <= m; ++i) {
        while (iter < events.size() && events[iter].x == i) {
            sum += events[iter].y.x;
            if (events[iter].y.x < 0) {
                --num;
                other += events[iter].y.y;
            } else {
                ++num;
                other -= events[iter].y.y;
            }
            ++iter;
        }
        LL step = (sum - num * i + num) + other;
        // cout << "step is " << step << endl;
        if (answer == -1 || step < answer) {
            answer = step;
        }
    }
    cout << answer << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    int n, k; cin >> n >> k;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a >= k)cnt++;
    }
    cout << cnt;
    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n, 0);
    while(k--){
        int d;
        cin >> d;
        while(d--){
            int a;
            cin >> a;
            v[--a]++;
        }
    }
    int ret = 0;
    for(int i = 0; i < n; i++)  ret += v[i]==0;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#include <cstdio>
#include <queue>
#include <vector>
using namespace std;
typedef long long LL;

struct Edge {
  int u, v;
  LL cap, flow;
  Edge() {}
  Edge(int u, int v, LL cap) : u(u), v(v), cap(cap), flow(0) {}
};

struct Dinic {
  int N;
  vector<Edge> E;
  vector<vector<int>> g;
  vector<int> d, pt;

  Dinic(int N) : N(N), E(0), g(N), d(N), pt(N) {}

  void AddEdge(int u, int v, LL cap) {
    if (u != v) {
      E.emplace_back(Edge(u, v, cap));
      g[u].emplace_back(E.size() - 1);
      E.emplace_back(Edge(v, u, 0));
      g[v].emplace_back(E.size() - 1);
    }
  }

  bool BFS(int S, int T) {
    queue<int> q({S});
    fill(d.begin(), d.end(), N + 1);
    d[S] = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (u == T) break;
      for (int k : g[u]) {
        Edge &e = E[k];
        if (e.flow < e.cap && d[e.v] > d[e.u] + 1) {
          d[e.v] = d[e.u] + 1;
          q.emplace(e.v);
        }
      }
    }
    return d[T] != N + 1;
  }

  LL DFS(int u, int T, LL flow = -1) {
    if (u == T || flow == 0) return flow;
    for (int &i = pt[u]; i < g[u].size(); ++i) {
      Edge &e = E[g[u][i]];
      Edge &oe = E[g[u][i] ^ 1];
      if (d[e.v] == d[e.u] + 1) {
        LL amt = e.cap - e.flow;
        if (flow != -1 && amt > flow) amt = flow;
        if (LL pushed = DFS(e.v, T, amt)) {
          e.flow += pushed;
          oe.flow -= pushed;
          return pushed;
        }
      }
    }
    return 0;
  }

  LL MaxFlow(int S, int T) {
    LL total = 0;
    while (BFS(S, T)) {
      fill(pt.begin(), pt.end(), 0);
      while (LL flow = DFS(S, T)) total += flow;
    }
    return total;
  }
};
ll H, W;
char g[105][105];
int main() {
  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j)
    cin >> g[i][j];
  }
  const ll inf = H * W + 10;
  Dinic dinic(H + W + 2);
  const int s = H + W;
  const int t = s + 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      auto c = g[i][j];
      if (c == 'o') {
        dinic.AddEdge(i, H + j, 1);
        dinic.AddEdge(H + j, i, 1);
      } else if (c == 'S') {
        dinic.AddEdge(s, i, inf);
        dinic.AddEdge(s, H + j, inf);

        dinic.AddEdge(i, s, inf);
        dinic.AddEdge(H + j, s, inf);
      } else if (c == 'T') {
        dinic.AddEdge(t, i, inf);
        dinic.AddEdge(t, H + j, inf);
        dinic.AddEdge(i, t, inf);
        dinic.AddEdge(H + j, t, inf);
      }
    }
  }

  int r = dinic.MaxFlow(s, t);
  if (r >= inf) {
    r = -1;
  }
  cout << r << endl;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	ll sum = accumulate(ALL(A), 0ll);

	vector<ll> res(N, 0);

	REP(i, N/2)
		res[0] += A[(2*i+1)%N];
	res[0] = sum - 2*res[0];

	std::cout << res[0] << " ";
	FOR(i, 1, N)
	{
		res[i] = 2*A[i-1] - res[i-1];
		std::cout << res[i] << " ";
	}
	std::cout << std::endl;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define pb push_back
#define debug printf("OK")
using namespace std;
int n, k, a[505], sum;
int main() {
    scanf("%d %d", &n, &k);
    for (int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    vector <int> div;
    int z = (int)sqrt(sum);
    for (int i=z; i>=1; i--) {
        if (sum % i == 0) div.pb(i);
    }
    int size = div.size();
    for (int i=0; i<size; i++) {
        if (div[i] * div[i] != sum) div.pb(sum / div[i]);
    }
    sort (div.begin(), div.end());
    reverse (div.begin(), div.end());
    for (int i=0; i<div.size(); i++) {
        int x = div[i];
        vector <int> v;
        int used = 0, need = 0;
        for (int j=0; j<n; j++) {
            v.pb(a[j] % x);
            need += x - a[j] % x;
        }
        sort(v.begin(), v.end());
        for (int j=0; j<n; j++) {
            used += v[j];
            need -= (x - v[j]);
            if (used == need) {
                //cout << used << endl;
                if (used <= k) {
                    printf("%d\n", x);
                    return 0;
                }
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
int h,w,kx,ky,mx,my,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
bool visited[16][64][4];
bool can[16][64][4][16][64][4];
bool bring,ret;
string board[16];
void dfs(int ax,int ay,int ad,int bx,int by,int bd){
	if(can[ax][ay][ad][bx][by][bd]) return;
	can[ax][ay][ad][bx][by][bd]=true;
	//printf("a=(%d,%d),b=(%d,%d),di=%d\n",ax,ay,bx,by,di);
	if(ax==mx&&ay==my&&ax==bx&&ay==by&&board[ax+dx[ad]][ay+dy[ad]]=='#'&&board[bx-dx[bd]][by-dy[bd]]!='#') ret=true;
	if(board[ax+dx[ad]][ay+dy[ad]]!='#') dfs(ax+dx[ad],ay+dy[ad],ad,bx,by,bd);
	if(board[bx+dx[bd]][by+dy[bd]]!='#') dfs(ax,ay,ad,bx+dx[bd],by+dy[bd],bd);
	if(board[ax+dx[ad]][ay+dy[ad]]=='#'){
		int d1=(bd+1)%4,d2=(bd+3)%4;
		if(board[bx+dx[d1]][by+dy[d1]]=='#') dfs(ax,ay,(ad+3)%4,bx,by,d2);
		if(board[bx+dx[d2]][by+dy[d2]]=='#') dfs(ax,ay,(ad+1)%4,bx,by,d1);
	}
}
void dfs1(int x,int y,int di){
	if(visited[x][y][di]) return;
	visited[x][y][di]=true;
	if(x==mx&&y==my) bring=true;
	if(board[x+dx[di]][y+dy[di]]!='#'){
		dfs1(x+dx[di],y+dy[di],di);
	}else{
		dfs1(x,y,(di+1)%4);
		dfs1(x,y,(di+3)%4);
	}
}
void init(){
	rep(i,h) rep(j,w) rep(ad,4) rep(k,h) rep(l,w) rep(bd,4) can[i][j][ad][k][l][bd]=false;
	rep(i,h) rep(j,w) rep(di,4) visited[i][j][di]=false;
	bring=false;
	ret=false;
}
int main(){
	while(true){
		cin>>w>>h;
		if(h==0) break;
		rep(i,h) cin>>board[i];
		init();
		rep(i,h) rep(j,w){
			if(board[i][j]=='K') kx=i,ky=j;
			if(board[i][j]=='M') mx=i,my=j;
		}
		int kd;
		rep(i,4) if(board[kx+dx[i]][ky+dy[i]]!='#') kd=i;
		dfs1(kx,ky,kd);
		rep(i,4) dfs(kx,ky,kd,kx,ky,i);
		if(!bring) puts("He cannot bring tea to his master.");
		else if(!ret) puts("He cannot return to the kitchen.");
		else puts("He can accomplish his mission.");
	}
}

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

int main() {
  int64_t N,D;
  cin >> N >> D ;
  int64_t X[N];
  int64_t Y[N];
  for (int i=0;i<N;i++) cin >> X[i] >> Y[i];
  int ans=0;
  for (int i=0 ; i<N ; i++) {
    int64_t XX=X[i]*X[i];
    int64_t YY=Y[i]*Y[i];
    int64_t DD=D*D;
    if (XX+YY<=DD) ans++;
  }
  cout << ans << endl;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  char p, q, r;
  p=a[0]-32;
  q=b[0]-32;
  r=c[0]-32;
  cout << p << q << r << endl;
  return 0;
}


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

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  int l = n - (y - x) + 1;
  int r = y - x + 1;
  for (int k = 1; k < n; k++) {
    int score = 0;

    score += max(0, l - k);
//    cout << "*" << score << endl;

    if (k == 1) {
      score += r - 1;
//      cout << "**" << score << endl;
    } else if (r == k * 2) {
      score += r / 2;
//      cout << "***" << score << endl;
    } else if (r > k * 2) {
      score += r;
//      cout << "****" << score << endl;
    }

    if (k > 1) {
      int spl = (r - 1) / 2;
      int lpl = r / 2 - 1;
      int la = x - 1;
      int ra = n - y;

      score += max(0, min({k - 1, spl, la, la + spl + 1 - k}));
//      cout << "+" << score << endl;
      score += max(0, min({k - 2, lpl, la, la + lpl + 2 - k}));
//      cout << "+" << score << endl;
      score += max(0, min({k - 1, spl, ra, ra + spl + 1 - k}));
//      cout << "+" << score << endl;
      score += max(0, min({k - 2, lpl, ra, ra + lpl + 2 - k}));
//      cout << "+" << score << endl;

      /*
      int s1 = x - k + 1;
      int e1 = min(x, x - k + r / 2);
      if (s1 > 0) {
        int ds = (e1 - s1) * 2 - 1;
        if (ds > 0) {
          score += ds;
          if( r < k * 2){
            score -= (r % 2 == 0);
          }
        }
//        cout << "*****" << score << endl;
      }
      int s2 = y + k - 1;
      int e2 = max(y, y + k - r / 2);
      if (s2 <= n) {
        score += (s2 - e2 + 1) * 2 - 1 - (r % 2 == 0);
//        cout << "******" << score << endl;
      }*/
    }

    cout << score << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
 
  

int main() {

   int n,t;
   cin>>n>>t;
   
   int arr[n];
   int minn    = 1000000;
   for(int i=0;i<n;++i){
          int x,y;
          cin>>x>>y;
          if(y>t)
          continue;
          else
          minn = min(x,minn);
          
   }
   if(minn==1000000)
      cout<<"TLE";
      else
       cout<<minn;
   
	return 0;
}

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

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

		int sum = 0;
		for(int i=0; i<N; i++) {
			int start, end;
			cin >> start >> end;
			sum += (end - start + 1);
		}

		cout << sum << endl;
		return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i,j,k;
	int b,f,x;
	int v;
	int r[4][3][10]={0};
	
	scanf("%d",&n);
	
	for(i = 0;i < n;i++){
		scanf("%d %d %d %d",&b,&f,&x,&v);
		r[b-1][f-1][x-1] += v;
	}
	for(i = 0;i < 4;i++){
		for(j = 0;j < 3;j++){
			for(k = 0;k < 10;k++){
				printf(" %d",r[i][j][k]);
			}
		putchar('\n');
		}
		if(i < 3)
		puts("####################");
	}
	return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    loop {
        int A = next<int>(), B = next<int>();
        unless(A || B) break;

        vector<vector<bool>> available(A, vector<bool>(B, true));
        times(next<int>(), _){
            int x = next<int>() - 1, y = next<int>() - 1;
            available[x][y] = false;
        }
        #ifdef debug
            times(A, a) {
                times(B, b) cout << available[a][b] << " ";
                cout ln;
            }
        #endif

        vector<vector<int>> ans(A+1, vector<int>(B+1, 0));
        ans[1][1] = 1;
        times(A, a) times(B, b) ans[a+1][b+1] += (ans[a][b+1] + ans[a+1][b]) * available[a][b];
        #ifdef debug
            times(A + 1, a) {
                times(B + 1, b) cout << ans[a][b] << " ";
                cout ln;
            }
        #endif
        cout << ans[A][B] ln;
    }

    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int n,x,y,a[2002];
signed main()
{
	cin>>n>>x>>y;
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	{
		if(i<=x&&j>=y)
		a[j-i-y+x+1]++;
		if(i>x&&j<y)
		a[min(j-i,y-j+1+i-x)]++;
		if(i<=x&&j<y&&j>x)
		a[x-i+min(j-x,y-j+1)]++;
		if(i>x&&i<y&&j>=y)
		a[j-y+min(i-x+1,y-i)]++;
		if(j<=x)
		a[j-i]++;
		if(i>=y)
		a[j-i]++;
	}
	for(int i=1;i<n;i++)
	printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define UNDEF (1 << 31)

using namespace std;

unsigned int dp[1048576];
int N,M,S[100000],R[20][100001];

bool ibs(int bits,int ref)
{
	return ((1 << ref) & bits) == (1 << ref);
}

int cbt(int bits,int ref)
{
	return (((0xffffffff) xor (1 << ref)) & bits);
}

int sbt(int bits,int ref)
{
	return bits | (1 << ref);
}

unsigned int getcount(int s,int l,int i)
{
	
}

unsigned int dfs(int bits,int cnt)//???????????§???????????????????????????????????????
{
	if(dp[bits] == UNDEF)
	{
		int tb;
		for(int i = 0;i < M;i++)
		{
			if(ibs(bits,i))
			{
				tb = cbt(bits,i);
				dp[bits] = min(dp[bits],dfs(tb,cnt-R[i][N])+(R[i][N] - (R[i][cnt] - R[i][cnt-R[i][N]])));
			}
		}
	}
	return dp[bits];
}

int main(void)
{
	cin >> N >> M;
	for(int i = 0;i < 1048576;i++)
	{
		dp[i] = UNDEF;
	}
	dp[0] = 0;
	for(int i = 0;i < N;i++)
	{
		cin >> S[i];
		S[i]--;
		for(int k = 0;k < 20;k++)
		{
			R[k][i+1] = R[k][i];
		}
		R[S[i]][i+1]++;
	}
	int ref = 0;
	for(int i = 0;i < M;i++)
	{
		ref = sbt(ref,i);
	}
	int res = dfs(ref,N);
	cout << res << endl;
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N;
int A[100000];

int main(){
  int i, j, k;
  ll res = 0;

  reader(&N);
  rep(i,N) reader(A+i);
  rep(i,N){
    res += A[i] / 2;
    A[i] %= 2;
    if(i+1 < N){
      k = min(A[i], A[i+1]);
      res += k;
      A[i] -= k;
      A[i+1] -= k;
    }
  }

  writerLn(res);

  return 0;
}


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

typedef pair<int, int> PR;

int main()
{
	int n, m;

	PR pr;

	bool rfl[500 + 10] = { 0 };

	int i;

	int ans;

	bool onefl[500 + 10] = {0};

	while (cin >> n >> m, n != 0 && m != 0)
	{
		vector<PR> ffl;
		int ffn = 0;

		ans = 0;

		for (i = 0; i < m; i++)
		{
			cin >> pr.first >> pr.second;

			if ( min(pr.first, pr.second) == 1)
			{
				onefl[max(pr.first, pr.second)]=true;

				rfl[max(pr.first, pr.second)] = true;
			}

			else
			{
				ffl.push_back(pr);
				ffn++;
			}
		}

		for (i = 0; i < ffn; i++)
		{
			if (onefl[ffl[i].first])
			{
				rfl[ffl[i].second] = true;
			}
			if (onefl[ffl[i].second])
			{
				rfl[ffl[i].first] = true;
			}
		}

		for (i = 1; i <= n; i++)
		{
			if (rfl[i])
			{
				ans++;
			}
		}

		cout << ans << endl;

		memset(onefl,0, sizeof(onefl));
		memset(rfl,0, sizeof(rfl));
	}
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<28
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int n, a[100005];
int dp[MAX];

int main()
{
    FASTIO
   /* 
   double start_time = clock();
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  #endif
    */
    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 2){
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n]<<endl;

  //   double end_time = clock();
  //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
   
    return 0;
} 

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<ll, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    ll sum = 0LL;
    vi uu(n);
    set<ll> se;
    rep(i, n) {
        ll aa;
        cin >> aa;
        sum += aa;
        a[i] = P(aa, i);
        set<ll>::iterator k = se.upper_bound(aa);
        if(k == se.begin()) {
            uu[i] = 838247;
        } else {
            uu[i] = *prev(k);
        }
        se.insert(aa);
    }


    sort(all(a));
    ll sum2=0LL;
    vi x(n);
    while(true) {
        vector<P>::iterator itr = lower_bound(all(a), P(a[a.size()-1].first, 0));
        if((*itr).second == 0) {
            x[0] = sum-sum2;
            break;
        }
        int hhhh = (*itr).second;
        ll summ = 0;
        vector<P>::iterator itr2 = lower_bound(all(a), P(uu[(*itr).second], 0));
        while(true) {
            ll num = a.end() - itr;

            x[hhhh] += (n-(itr-a.begin()))*((*itr).first - (*(itr-1)).first);
            sum2 += (n-(itr-a.begin()))*((*itr).first - (*(itr-1)).first);
            rep(i, num) {
                a.pop_back();
            }
            if((*itr2).first == a[a.size()-1].first) {
                break;
            }
            itr = lower_bound(all(a), P(a[a.size()-1].first, 0));
        }
        //cout << summ << endl;
    }
    //cout << sum << endl;
    //cout << sum2 << endl;
    
    rep(i, n) {
        cout << x[i] << '\n';
    }
}

Measured memory_bytes: 8832
# https://atcoder.jp/contests/abc104/tasks/abc104_c


def solve(D, G, ps, cs):
  ans = 100000000
  for mask in range(1 << D):
    s = 0
    num = 0
    rest_max = -1
    for i in range(D):
      if mask >> i & 1:
        s += 100 * (i+1) * ps[i] + cs[i]
        num += ps[i]
      else:
        rest_max = i
    if s < G:
      s1 = 100 * (rest_max + 1)
      need = int((G - s + s1 - 1) / s1)
      if need >= ps[rest_max]:
        continue
      num += need
    ans = min(ans, num)
  return ans
  

if __name__ == '__main__':
  D, G = map(int, input().split(' '))
  ps = []
  cs = []
  for i in range(D):
    p, c = map(int, input().split(' '))
    ps.append(p)
    cs.append(c)
  print(solve(D, G, ps, cs))
  

Measured memory_bytes: 3064