akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const int INF = numeric_limits<int>::max();
int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a( N ), b( N );
    REP( i, N )
    {
        cin >> a[ i ] >> b[ i ];
    }
    vector<int> c( M ), d( M );
    REP( i, M )
    {
        cin >> c[ i ] >> d[ i ];
    }
    vector<pair<int, int>> p;
    REP( i, N )
    {
        REP( j, M )
        {
            p.emplace_back( j + 1, abs( a[ i ] - c[ j ] ) + abs( b[ i ] - d[ j ] ) );
        }
    }
    int tmp = INF, res = 0;
    REP( i, N * M )
    {
        if( tmp > p[ i ].second )
        {
            tmp = p[ i ].second;
            res = p[ i ].first;
        }
        if( p[ i ].first == M )
        {
            cout << res << endl;
            tmp = INF;
            res = 0;
        }
    }
    return 0;
}

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


int main()
{
	int A, B,D=0;
	cin  >> A >> B;
	int C[4] = { 4,6,9,11 };
	for (int i = 0; i < 4; i++) {
		if (A == C[i]) {
			D++;
		}
		if (B == C[i]) {
			D++;
		}
	}
	if (A==2||B==2) {
		cout << "No" << endl;
	}
	else if(D==2||D==0){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
    return 0;
}

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

int main(){
  string s;
  int sum=700;
  
  cin >> s;

  if ( s.at(0) == 'o'){
    sum += 100;
  }if ( s.at(1) == 'o'){
    sum += 100;
  }if ( s.at(2) == 'o'){
    sum += 100;
  }
    cout << sum << endl;
    

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long int ll;

const ll maxN = 1e5 + 11;

bool isP[maxN];
ll pref[maxN];

ll func(ll x){
	return (x+1)/2;
}

void init(){
  	memset(isP, true, sizeof(isP));
	isP[0] = isP[1] = 0;
	pref[0] = pref[1] = 0;
	for(ll i=2; i<maxN; i++){
		if(isP[i]){
			for(ll j=(i<<1); j<=maxN; j+=i)
				isP[j] = 0;
		}
		if(i&1){
			if(isP[func(i)] and isP[i])
				pref[i] = pref[i-1] + 1;
			else
				pref[i] = pref[i-1];
		}
		else
			pref[i] = pref[i-1];
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	init();
	ll t;
	cin >> t;
	ll a, b;
	while(t--){
		cin >> a >> b;
		cout << pref[b]-pref[a-1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 4408
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <climits>
#include <queue>
#include <assert.h>
#include <set>
#include <numeric>
#include <memory.h>

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

//#define int long long
typedef long long ll;

const ll INF = 1e18;

using namespace std;

const int MAX_N = 300100;
int n, dat[2*MAX_N-1];

void init(int n_)
{
    n = 1;
    while (n < n_) n *= 2;
    for (int i=0; i<2*n-1; i++) dat[i] = INT_MAX;
}

void update(int k, int a)
{
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
}

int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b) return dat[k];
    else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, Q;
    int com, x, y;

    cin >> N >> Q;
    init(N + 100);
    REP(i,Q) {
        cin >> com >> x >> y;
        if (com == 0) {
            update(x, y);
        } else {
            cout << query(x, y + 1, 0, 0, n) << endl;
        }
    }
}

Measured memory_bytes: 4112
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

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

int main(){
    int n; cin >> n;
    vi dp(n+10,0);


    dp[0] = 1;
    dp[1] = 1;
    rep(i,n){
        dp[i+2] = dp[i+1]+ dp[i];
    }

    cout << dp[n] << endl;

}


Measured memory_bytes: 3108
a, b, c, d, e, f = map(int, input().split())

ans = -1
ans_water = -1
ans_sugar = -1
for ia in range(f//(a*100)+2):
    water = 100*a*ia
    if water > f or water == 0: continue
    for ib in range(f//(b*100)+2):
        if ib != 0: water += 100*b
        if water > f or water == 0: continue
        for ic in range(f//c+1):
            sugar = c*ic
            if sugar/(water//100) > e: continue
            for id in range(f//d+1):
                if id != 0: sugar+=d
                if sugar/(water//100) > e: continue
                if sugar + water > f: continue
                if (100*sugar)/(sugar+water) > ans:
                    ans = (100*sugar)/(sugar+water)
                    ans_water = water
                    ans_sugar = sugar
print(ans_sugar+ans_water, ans_sugar)

Measured memory_bytes: 9168
// AOJ 0245: Time Sale
// 2017.12.16 bal4u@uu

#include <stdio.h>
#include <string.h>

#define QMAX 100000
typedef struct { char r, c, t; int d, b; } Q;
Q q[QMAX+2]; int top, end;

#define WALL 64
#define COR  32

typedef struct { int d, s, e; } G;
G sell[10];
char map[22][22];
char mk[22][22][101][1024];
char buf[50], *p;
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int X, Y, r, c, n, i, j, sr, sc, ans;
	int d, t, b, r2, c2, max, lim;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		X = in(), Y = in();
		memset(map, WALL, sizeof(map));
		for (r = 1; r <= Y; r++) {
			fgets(p=buf, 50, stdin);
			for (c = 1; c <= X; c++) {
				if (*p == '.') map[r][c] = COR;
				else if (*p == 'P') sr = r, sc = c, map[r][c] = COR;
				else map[r][c] = *p & 0xf;
				p += 2;
			}
		}
		fgets(p=buf, 5, stdin);
		n = *p & 0xf, max = 0, lim = 0;
		for (i = 0; i < n; i++) {
			fgets(p=buf, 50, stdin);
			j = in();
			sell[j].d = in(), sell[j].s = in(), sell[j].e = t = in();
			lim |= 1 << j; if (t > max) max = t;
		}

		ans = 0;
		memset(mk, 0, sizeof(mk));
		q[0].r = sr, q[0].c = sc, q[0].t = 0, q[0].d = 0, q[0].b = 0;
		top = 0, end = 1;
		while (top != end) {
			r = q[top].r, c = q[top].c, t = q[top].t, d = q[top].d, b = q[top].b;
			if (++top == QMAX) top = 0;

			if (t > max) continue;

			if (mk[r][c][t][b]) continue;
			mk[r][c][t][b] = 1;
			if (d > ans) ans = d;

			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if ((j = map[r2][c2]) > 10) continue;
				if (!(b & (1 << j)) && sell[j].s <= t && t < sell[j].e) {
					d += sell[j].d;
					b |= 1 << j;
				}
			}
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (map[r2][c2] != COR) continue;
				q[end].r = r2, q[end].c = c2, q[end].t = t+1, q[end].d = d, q[end].b = b;
				if (++end == QMAX) end = 0;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 51776
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll
const int mod = 998244353;
const int N = 3e5+7;

int n, a, b, k, ans;

int fact[N];
int inv[N];

int fpow(int a, int b)
{
	int res = 1;

	while(b)
	{
		if(b&1)
			res = res*a%mod;

		a = a*a%mod;
		b /= 2;
	}

	return res;
}

int kom(int n, int k)
{
	if(k>n)
		return 0;

	if(k<0)
		return 0;

	return fact[n]*inv[n-k]%mod*inv[k]%mod;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	inv[0] = fact[0] = 1;

	for(int i = 1; i < N; ++i)
	{
		fact[i] = i*fact[i-1]%mod;
		inv[i] = fpow(fact[i], mod-2);
	}

	cin >> n >> a >> b >> k;

	for(int i = 0; i <= n; ++i)
	{
		int zos = k-a*i;

		if(zos%b==0)
		{
			ans += kom(n, i)*kom(n, zos/b)%mod;
			ans %= mod;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<deque>
#include<utility>
#include<string>
using namespace std;

int main(){
  int n,q,time,total=0;
  string name;
  deque<pair<string,int>> deq;

  cin >> n >> q;
  for(int i=0;i<n;i++){
    cin >> name >> time;
    deq.push_back(make_pair(name,time));
  }
  while(!deq.empty()){
    pair<string,int> x = deq.front(); deq.pop_front();
    if(x.second <= q){
      total += x.second;
      cout << x.first << " " << total << endl;
    }else{
      total += q;
      deq.push_back(make_pair(x.first,x.second - q));
    }
  }
}


Measured memory_bytes: 6332
N,K=map(int,input().split())
p=[int(i)-1for i in input().split()]
q=[int(i)-1for i in input().split()]
T=lambda s,t:[s[t[i]]for i in range(N)]
m=[[0for i in[0]*N]for i in[0]*6];m[0]=p;m[1]=q
def I(s):
 r=[0]*N
 for i in range(N):r[s[i]]=i
 return r
for i in range(4):m[i+2]=T(m[i+1],I(m[i]))
E=lambda s,k:T(E(T(s,s),k//2),s)if k%2 else (E(T(s,s),k//2)if k else list(range(N)))
t=E(T(T(T(q,I(p)),I(q)),p),~-K//6);print(" ".join([str(i+1)for i in T(T(t,m[~-K%6]),I(t))]))

Measured memory_bytes: 40668
#include "algorithm"
#include "cmath"
#include "iostream"
#include "map"
#include "string"
#include "unordered_map"
#include "vector"
constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9;
using namespace std; // std::を省略して書くことができる

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> ABC = {A, B, C};
  sort(ABC.begin(), ABC.end());
  int ans = (ABC[1] - ABC[0]) / 2;
  ABC[0] += 2 * ans;
  if (ABC[0] == ABC[1]) {
    ans += ABC[2] - ABC[0];
  } else {
    ans += ABC[2] - ABC[1];
    ans += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.text.DecimalFormat;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			int n = sc.nextInt();
			
			if (n == 0) break;
			
			int num[][] = new int[n+1][n+1];
			for (int i = 0; i < n; i++)
			{
				int j;
				int lineTotal = 0;
				for (j = 0; j < n; j++)
				{
					num[i][j] = sc.nextInt();
					lineTotal += num[i][j];
				}
				num[i][j] = lineTotal;
			}
			for (int i = 0; i <= n; i++)
			{
				int colTotal = 0;
				for (int j = 0; j < n; j++)
				{
					colTotal += num[j][i];
				}
				num[n][i] = colTotal;
			}		

			for (int i = 0; i <= n; i++)
			{
				for (int j = 0; j <= n; j++)
				{
					System.out.printf("%5d", num[i][j]);
				}
				System.out.println();
			}
		}
	}
}

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

int main() {
  long long N;
  cin >> N;
  long long B[100000];
  for (long long i = 0; i < N - 1; i++) {
    cin >> B[i];
  }
  long long ans = 0;
  for (long long i = 0; i < N - 1; i++) {
    ans += min(B[i],B[i+1]);
  }
  ans += B[0];
  ans += B[N-2];
  cout << ans << endl;  
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
static const int INF = 99999999;
int cost[101][101];
int mincost[101];
bool used[101];
int n;

int prim()
{
	for(int i = 0; i < n; ++i)
	{
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	int res = 0;
	while(true)
	{
		int v = -1;
		for(int i = 0; i < n; ++i)
		{
			if(!used[i] && (v == -1 || mincost[i] < mincost[v]))
			{
				v = i;
			}
		}
		if(v == -1)
		{
			break;
		}
		used[v] = true;
		res += mincost[v];
		for(int i = 0; i < n; ++i)
		{
			mincost[i] = min(mincost[i], cost[v][i]);
		}
	}
	return(res);
}

void solve()
{
	while(cin >> n, n)
	{
		for(int i = 0; i < 101; ++i)
		{
			for(int j = 0; j < 101; ++j)
			{
				cost[i][j] = INF;
			}
		}
		int m;
		cin >> m;
		for(int i = 0; i < m; ++i)
		{
			int a, b, dist;
			char c;
			cin >> a >> c >> b >> c >> dist;
			cost[a][b] = dist / 100 - 1;
			cost[b][a] = dist / 100 - 1;
		}
		
		cout << prim() << endl;
	}
}

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

Measured memory_bytes: 1200
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  map<char, long> mp;
  for (auto it: S) mp[it]++;
  for (auto it: mp) {
    if (it.second != 2) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		String s = sc.next();
		
		// 計算
		String result = "";
		n = n%26;
		for(int i = 0; i < s.length(); i++){
		    char c = s.charAt(i);
		    int d = (c - 'A' + n)%26;
		    char e = (char)(d + 'A');
		    System.out.print(e);
		}
		
		// 出力
		//System.out.println(result);
	}
	
}


Measured memory_bytes: 25684
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
main(){
    #define task "TASK"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;

    string s,t,x;
    map<string,int> mp;

    cin>>s>>t;
    cin>>mp[s]>>mp[t];
    cin>>x;
    mp[x]--;
    cout<<mp[s]<<" "<<mp[t]<<"\n";
}


Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break

    price = 0
    for _ in range(n):
        x, y, h, w = map(int, input().split())
        size = x + y + h

        if size <= 60 and w <= 2:
            price += 600
        elif size <= 80 and w <= 5:
            price += 800
        elif size <= 100 and w <= 10:
            price += 1000
        elif size <= 120 and w <= 15:
            price += 1200
        elif size <= 140 and w <= 20:
            price += 1400
        elif size <= 160 and w <= 25:
            price += 1600

    print(price)



Measured memory_bytes: 5612
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	llint cnt = 0;
	llint ans = -1;
	rep(i, n) {
		llint d, c;
		cin >> d >> c;
		ans += c;
		cnt += d * c;
	}
	ans += (cnt - 1) / 9;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
ll h, w, n, a, b, c[15];
map<pair<ll,ll>,ll> mp;
int main() {
	ll i, j, k;
	scanf("%d%d%d", &h, &w, &n);
	c[0] = (h-2) * (w-2);
	while(n--) {
		scanf("%d%d", &a, &b);
		for(i=a; i<a+3; i++) for(j=b; j<b+3; j++) {
			if(i>2 && j>2 && i<=h && j<=w) {
				k = mp[{i,j}]++;
				c[k]--; c[++k]++;
			}
		}
	}
	for(i=0; i<=9; i++) printf("%lld\n", c[i]);
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
	int n; cin >> n;
	map<int , int> mp;
	for(int i = 0; i < n; i++){
		int temp;
		cin >> temp;
		mp[temp]++;
	}

	int ans = 0;
	for(auto x : mp){
		int X = x.first;
		int Y = x.second;
	
		if(X < Y){
			ans += Y - X;
		}else if(X > Y){
			ans += Y;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

stack<llong> st;
llong in_stack[1005];
llong l;
llong c;

int main() {
    cin >> l;

    for (int i = 0; i < l; i++) {
        cin >> c;

        if (c > 0) {
            if (in_stack[c] == 1) {
                cout << i + 1 << endl;
                return 0;
            }
            
            st.push(c);
            in_stack[c] = 1;
        }
        else {
            if (st.empty() || st.top() != -c) {
                cout << i + 1 << endl;
                return 0;
            }
            
            st.pop();
            in_stack[-c] = 0;
        }
    }

    cout << "OK" << endl;

    return 0;
}




Measured memory_bytes: 3092
#include <stdio.h>

int main(void) {
	int n, i, num, min = 100000000, max = -100000000;
	long int sum = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d ", &num);
		if (max <= num) {
			max = num;
		}
		if (min >= num) {
			min = num;
		}
		sum = sum + num;
	}
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 2096
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str, token string) []string {
	cols := strings.Split(str, token)
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

type SortSlice []int

func (s SortSlice) Len() int {
	return len(s)
}

func (s SortSlice) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
	return s[i] < s[j]
}

func reverseString(str string) string {
	buf := []rune(str)
	for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
		buf[i], buf[j] = buf[j], buf[i]
	}
	return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := nextLine()
	spl := strSprit(line, " ")
	H := parseInt(spl[0])
	W := parseInt(spl[1])

	maps := [][]string{}

	for i := 0; i < H; i++ {
		line = nextLine()
		mapline := strSprit(line, "")
		maps = append(maps, mapline)
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if maps[i][j] != "." {
				continue
			}
			maps[i][j] = checkmine(maps, i, j, H, W)
		}
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Print(maps[i][j])
		}
		fmt.Println()
	}
}

func checkmine(maps [][]string, i, j, H, W int) string {
	count := 0
	if i-1 >= 0 && maps[i-1][j] == "#" {
		count++
	}
	if i+1 < H && maps[i+1][j] == "#" {
		count++
	}
	if j-1 >= 0 && maps[i][j-1] == "#" {
		count++
	}
	if j+1 < W && maps[i][j+1] == "#" {
		count++
	}

	if i-1 >= 0 && j-1 >= 0 && maps[i-1][j-1] == "#" {
		count++
	}
	if i+1 < H && j-1 >= 0 && maps[i+1][j-1] == "#" {
		count++
	}
	if i-1 >= 0 && j+1 < W && maps[i-1][j+1] == "#" {
		count++
	}
	if i+1 < H && j+1 < W && maps[i+1][j+1] == "#" {
		count++
	}

	return strconv.Itoa(count)
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
int inf = 1000000007;
using namespace std;
int NextInt() { int x; cin >> x; return x; }

int main()
{
	vector<char> m(4);
	for (int i = 0; i < 4; i++)cin >> m[i];
	sort(m.begin(), m.end());

	if (m[0] == m[1] && m[1] != m[2] && m[2] == m[3])cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define eps 1e-9
#define nmax 200
#define f(c,a,b) for(int c=a; c<=b; c++)

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){}
    P(db x, db y) : x(x) , y(y) {}
    P operator - (P a){ return P(x-a.x, y-a.y); }
    db times(P a){ return x*a.y-y*a.x; }
}po[nmax];
typedef P V;
int n;

bool isconvex(){
    po[0] = po[n];
    f(i,2,n) if( (po[i]-po[i-1]).times(po[i-1]-po[i-2]) > eps ) return false;
    if( (po[1]-po[n]).times(po[n]-po[n-1]) > eps ) return false;
    return true;
}

int main(){
    //freopen("owo.in","r",stdin);
    cin >> n;
    f(i,1,n) scanf("%lf%lf", &po[i].x, &po[i].y);
    printf("%d\n", isconvex());
    return 0;
}


Measured memory_bytes: 3208
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout <<15 - (a+b+c+d+e) << endl;
}

Measured memory_bytes: 3636
n = int(input())
w = list(map(int,input().split()))
s = [0]
for i in range(n):
    s.append(s[i]+w[i])
    
max = s[-1]
last = 9999999999999999
for i in range(n+1):
    temp = max - s[i]
    if last > abs(temp-s[i]):
        last = abs(temp-s[i])
    else:
        break
        
print(last)

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int k;
  string s;
  cin>>k>>s;
  if(size(s)>k)cout<<s.substr(0,k)<<"..."<<endl;
  else cout<<s<<endl;

}

Measured memory_bytes: 3572
import java.util.*;
import java.io.*;

class Main{
  static int n = 0;
  public static void main(String args[]){

    StringBuilder build = new StringBuilder();
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();

    int A[] = new int[n+1];

    for(int i = 1; i<n+1; i++){
      A[i]  = sc.nextInt();
    }

    buildMaxHeap(A);

    for(int i = 1; i<n+1; i++){
      System.out.print(" "+A[i]);
    }
    System.out.println("");

  }

  static void maxHeapify(int A[], int i ){
    int l =i*2;
    int r = i*2+1;
    int largest = 0;
    int tmp;

    if(l<=n && A[l] > A[i]) largest = l;
    else largest = i;

    if(r<=n && A[r] > A[largest] ) largest = r;

    if(largest != i){
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      maxHeapify(A, largest);
    }
  }

  static void buildMaxHeap(int []A){
    for(int i = n/2; i>0; i--){
      maxHeapify(A,i);
    }
  }

}



Measured memory_bytes: 167048
#include <iostream>
using namespace std;
#include <math.h>
 

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

  	int ansA = 0, ansB = 0;
	for(int i=1 ;i <= b;i++)
    {
      ansA += a*pow(10,(i-1));
    }
  	
  	for(int i=1;i <= a;i++)
    {
      ansB += b*pow(10,(i-1));
    }
  
  	if(ansA > ansB)
    {
      cout << ansA;
    }
  	else
    {
      cout << ansB;
    }
  
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    int r; cin >> r;
    if(r < 1200) cout << "ABC";
    else if (r < 2800) cout << "ARC";
    else cout << "AGC";
}

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

Measured memory_bytes: 256
#include<stdio.h>


int partition(int A[],int p,int r){
  int temp,i,x,j;
  x = A[r];
  i = p-1;
  for(j = p;j<=r-1;j++){
    if(A[j]<= x){
      i = i+1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }

  temp = A[i+1];
  A[i+1]=A[r];
  A[r] = temp;
    
   
  
  return i+1;
}
  





int main(){
  int n;
  int i;
  int A[200001];
  int s;
   scanf("%d",&n);
  for(i = 0;i<n;i++){
    scanf("%d",&A[i]);

  }
  s = partition(A,0,n-1);//s is 配列の添字
  for(i = 0;i<n;i++){
    if(i > 0)printf(" ");
    if(i != s){
      printf("%d",A[i]);
    }
    else{
      printf("[%d]",A[i]);
    }
    
  }
  printf("\n");
 return 0;
}



Measured memory_bytes: 2108
n = int(input())
a = list(map(int, input().split()))


def sadness(b):
  sad = 0
  for i, e in enumerate(a):
    i += 1
    sad += abs(e - (b + i))
  return sad


left, right = -10**9, 10**9 + 1
while right - left > 1:
  mid = (left + right) // 2

  if sadness(mid) > sadness(mid + 1):
    left = mid
  else:
    right = mid

# for b in range(-20, 20):
#   print(b,sadness(b))

print(min(sadness(left), sadness(right)))


Measured memory_bytes: 87108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		return lcm(A, B);
	}

	public static long gcd(long a, long b) {
		if (a == 0 || b == 0) {
			return a + b;
		} else {
			long absA = Math.abs(a);
			long absB = Math.abs(b);
			long mx = Math.max(absA, absB);
			long mn = Math.min(absA, absB);
			return gcd(mx % mn, mn);
		}
	}

	public static long lcm(long a, long b) {
		if (a == 0 || b == 0)
			return 0;
		else {
			long gcd = gcd(a, b);
			return Math.abs(a * b) / gcd;
		}
	}
}


Measured memory_bytes: 21972
from math import gcd

n,m=map(int, input().split())
s=input()
t=input()

g=gcd(n,m)

ng=n//g
mg=m//g

for i in range(0,g):
    if s[ng*i]!=t[mg*i]:
        print(-1)
        exit()
print(ng*mg*g)


Measured memory_bytes: 9292
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);
    auto mn = inf;
    int ans;
    foreach (ai ; a) {
        if (ai < mn) {
            ans++;
            mn = ai;
        }
    }
    writeln(ans);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 11280
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, l;
  cin >> n >> l;
  int r[n];
  for (int i = 0; i < n; ++i) r[i] = l + i;
  int sum = 0;
  for (int i = 0; i < n; ++i) sum += r[i];
  int ans = 0, d = 1e9;
  for (int i = 0; i < n; ++i) {
    int tmp = 0;
    for (int j = 0; j < n; ++j) {
      if (j == i) continue;
      tmp += r[j];
    }
    if (abs(sum - tmp) < d) {
      ans = tmp;
      d = abs(sum - tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	ll K;
	cin >> K;

	vector<ll> sei, fu;
	int zero = 0;
	rep(i, N) {
		int a;
		cin >> a;
		if (a > 0) sei.pb(a);
		else if (a < 0) fu.pb(-a);
		else zero++;
	}
	sort(sei.begin(), sei.end());
	sort(fu.begin(), fu.end());

	ll L = -2e18, R = 2e18;
	while (L + 1 < R) {
		ll M = (L + R) / 2;
		ll k = 0;
		if (M >= 0) {
			k += ll(sei.size()) * fu.size();
			k += ll(zero) * (zero - 1) / 2;
			k += ll(zero) * (N - zero);
			for (auto itr = sei.begin(); itr != sei.end(); itr++) {
				ll kari = M / *itr;
				auto tmp = upper_bound(itr + 1, sei.end(), kari);
				k += tmp - itr - 1;
			}
			for (auto itr = fu.begin(); itr != fu.end(); itr++) {
				ll kari = M / *itr;
				auto tmp = upper_bound(itr + 1, fu.end(), kari);
				k += tmp - itr - 1;
			}
		}
		else {
			for (auto itr = sei.begin(); itr != sei.end(); itr++) {
				ll kari = (-M + *itr - 1) / *itr;
				auto tmp = lower_bound(fu.begin(), fu.end(), kari);
				k += fu.end() - tmp;
			}
		}
		if (k >= K) R = M;
		else L = M;
	}

	co(R);

	Would you please return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll A[N];
    ll i;
    ll ans=1;
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    ll n=0,m=0;
    for(i=1;i<N;i++){
        if(A[i]-A[i-1]>0)m=1;
        if(A[i]-A[i-1]<0)m=-1;
        if(n*m==-1){
            ans++;
            m=0;
        }
        n=m;
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define INF 2147483647
pair<int,int> data[4000001];
int n,_n;
void init(int n){
  _n=1;
  while(_n<1100000)_n*=2;
}
void update(int i,int x){
  int p=i;
  i+=_n-1;
  data[i].f+=x;
  data[i].s=p+1;
  while(i>0){
    i=(i-1)/2;
    if(data[2*i+1].f==data[2*i+2].f){
      if(data[2*i+1].s<data[2*i+2].s)
        data[i]=data[2*i+1];
      else data[i]=data[2*i+2];
    }
    else if(data[2*i+1].f>data[2*i+2].f)
      data[i]=data[2*i+1];
    else data[i]=data[2*i+2];
  }
}
int main(){
  int q;
  cin>>n>>q;
  init(n);
  while(q--){
    int a,b;
    cin>>a>>b;
    update(a-1,b);
    cout<<data[1].second<<' '<<data[1].first<<endl;
  }
}

Measured memory_bytes: 34352
//grid problem
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#define ll long long
#define mod 1000000007
using namespace std;
bool check(ll i,ll j,ll row,ll col)
{
	if(i<0||i>row)
	return false;
	
	if(j<0||j>col)
	return false;
	
	return true;
}
int main()
{
	ll row,col;
	cin>>row>>col;
	vector< vector<char> > grid(row);
	vector< vector<ll> > dp(row);
	for(ll i=0;i<row;i++)
	{
		grid[i].resize(col);
		dp[i].resize(col,0);
	}
	
	//input grid
	for(ll i=0;i<row;i++)
	{
		for(ll j=0;j<col;j++)
		{
			cin>>grid[i][j];
		}
	}
	
	//accumilating dp table
	for(ll i=0;i<row;i++)
	{
		for(ll j=0;j<col;j++)
		{
			if(i==0&&j==0)
			{
				dp[i][j]=1;
				continue;
			}
			if(grid[i][j]=='.')
			{
				if(check(i,j-1,row,col))
				{
					dp[i][j]=dp[i][j-1];
				}
				if(check(i-1,j,row,col))
				{
					dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				}
			}
			else
			{
				dp[i][j]=0;
			}
		}
	}
	cout<<dp[row-1][col-1]<<endl;
	return 0;
}


Measured memory_bytes: 9088
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = INT()
y = ceil(s/10**9)
x = y*10**9 - s
print(0,0,10**9,1,x,y)

Measured memory_bytes: 10260
#include <bits/stdc++.h>
using namespace std;
const int INF = pow(2,31)-1;
const int MAX_N = 1<<17;
int n_;
int dat[2*MAX_N-1];

void init(int n) {
  n_ = 1;
  while (n_<n) {
    n_ *= 2;
  }
  for (int i=0; i<2*n_-1; i++) {
    dat[i] = INF;
  }
}
void update(int i,int x) {
  i += n_-1;
  dat[i] = x;
  while (i>0) {
    i = (i-1)/2;
    dat[i] = min(dat[i*2+1],dat[i*2+2]);
  }
}
int find(int x,int y,int k,int l,int r) {
  if (r<=x || y<=l) {
    return INF;
  }
  if (x<=l && r<=y) {
    return dat[k];
  } else {
    int vl = find(x,y,k*2+1,l,(l+r)/2);
    int vr = find(x,y,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  init(n);
  for (int i=0; i<q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com==0) {
      update(x,y);
    } else {
      cout << find(x,y+1,0,0,n_) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum_a = 0;
    ll sum = 0;
    rep(i,n) sum_a += a[i];
    ll b = sum_a;
    rep(i,n-1) {
        b = b - a[i];
        int c = b%1000000007;
        sum += (a[i]*c)%1000000007;;
        sum = sum%1000000007;
        // cout << sum << endl;
    }
    int ans = sum%1000000007;
    // cout << sum_a << endl;
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n,m;cin>>n>>m;
    vector<bool>one(n,false);
    vector<bool>enu(n,false);
    rep(i,m)
    {
        ll a,b;
        cin>>a>>b;
        if(a==1)one[b]=true;
        else if(b == n)enu[a]=true;
    }

    rep(i,n)if(one[i]&&enu[i]){cout<<"POSSIBLE\n";return 0;}

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

Measured memory_bytes: 256
//from PKU1125
#define M 101
double dist[M][M],d;
next[M][M],x[M],y[M];
main(){
	int a,b,k,n,i,j;
	for(;scanf("%d",&n),n;){
		/*initialize*/
		for(i=1;i<=n;i++)scanf("%d",&a),scanf("%d%d",x+a,y+a);
		for(i=1;i<=n;i++)for(j=1;j<=n;next[i][j]=j,j++)
			dist[i][j]=(d=hypot(x[i]-x[j],y[i]-y[j]))<50.1?d:299;

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[i][k];
					}
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d",&a,&b);
				if(dist[a][b]>=299)puts("NA");
				else{
					for(j=a;j!=b;j=next[j][b])printf("%d ",j);
					printf("%d\n",b);
				}
			}
		}
	}exit(0);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll ans = a[0] / 2;
  a[0] -= a[0] / 2 * 2;
  for (int i = 1; i < n; ++i) {
    if (a[i-1] == 1 && a[i] > 0) {
      a[i-1]--;
      a[i]--;
      ans++;
    }
    ans += a[i] / 2;
    a[i] -= a[i] / 2 * 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
using ll=long long;
template <typename T1, typename T2> struct less_second 
{ 
	typedef pair<T1, T2> type; 
	bool operator ()(type const& a, type const& b) 
	const { return a.second > b.second; } 
};
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,i,d;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		d=s[i]-'A';
		d=d+n;
		d=d%26;
		s[i]=(char)('A'+d);
	}
	cout<<s;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    int N,X; cin >> N >> X;
    int L[101],D[101]; 
    int cnt = 1;
    for(int i = 0; i < N; i++){
        cin >> L[i];
    } 
    D[0] = 0;
    for(int i = 1; i < N+1; i++){
        D[i] = D[i-1]+L[i-1];
        if(D[i] <= X) cnt++;
    }
    cout << cnt << endl;
}




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

int main(){
  string s, t;
  cin >> s >> t;
  
  int ans = 0;
  for (int i=0 ; i<3 ; i++){
    if (s.at(i) == t.at(i))
      ans++;
  }
  
  cout << ans << endl;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,p; cin >> n >> p;
    string s; cin >> s;
    ll ans = 0;
    if(p==5 || p==2){
        ll cnt = 1;
        rep(i,0,n)if((s[i]-'0')%p==0)ans +=i+1;
    }else{
        vector<int> pnum(p,0); //modpの個数を格納
        pnum[0] = 1; //割り切れている場合は Uiのみで簡潔してるため
        int base = 1;
        int sum=0;
        rel(i,n,0){
            sum = (sum + base * (s[i]-'0')) % p;
            ans += pnum[sum]++;
            base = base * 10 % p;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 720
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N;
	cin >> N;
	vector<int>W(N);
	REP(i, N)cin >> W[i];

	int all = accumulate(W.begin(), W.end(), 0);
	int left = 0;
	int res = INF;
	REP(i, N) {
		left += W[i];
		int r = all - left;
		int tmp = abs(left - r);
		res = min(res, tmp);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();   
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        Set<String> sets = new HashSet<>();
        for (int i = 0; i < n; i++) {
            sets.add(s[i]);
        }
        Map<String, Integer> map = new HashMap<>();
        for (String set : sets) {
            map.put(set, 0);
        }
        for (int i = 0; i < n; i++) {
            map.put(s[i], map.get(s[i])+1);
        }
        Set<String> results = new HashSet<>();
        int max = map.get(s[0]);
        results.add(s[0]);
        for (int i = 1; i < n; i++) {
            if (map.get(s[i]) > max) {
                max = map.get(s[i]);
                results.clear();
                results.add(s[i]);
            } else if (map.get(s[i]) == max) {
                results.add(s[i]);
            }
        }
        List<String> list = new ArrayList<>();
        for (String result : results) {
            list.add(result);
        }

        Collections.sort(list);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        
    }
}

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

int main(){
    list<int> L;
    
    int n,m;
    string command;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> command;
        if(command=="insert"){
            cin >> m;
            L.push_front(m);
        }else if(command=="delete"){
            cin >> m;
            for(list<int>::iterator it=L.begin(); it!=L.end(); it++){
                if(*it==m){
                    L.erase(it);
                    break;
                }
            }
        }else if(command=="deleteFirst"){
            L.pop_front();
        }else if(command=="deleteLast"){
            L.pop_back();
        }
    }
    
    int i=0;
    for(list<int>::iterator it=L.begin(); it!=L.end(); it++){
        if(i++) cout <<  ' ';
        cout << *it;
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 34456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long Li, n;
  long long L0 = 2, L1 = 1;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
  }
  else {
    for (int i = 0; i < n-1; i++) {
      Li = L0 + L1;
      L0 = L1;
      L1 = Li;
    }
    cout << Li << endl;
  }
}

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

int main(){
  std::cout<<std::fixed<<std::setprecision(10);
  ll n, k;
  cin >> n >> k;
  double base = 1.0/n;
  // cout << base << endl;
  double ans = 0;
  FOR(i, 1, n+1) {
    double now = base;
    ll target = i;
    while (target < k) {
      now /= 2;
      target *= 2;
    }
    ans += now;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(x, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  ll ans = 0;
  
  int a; cin >> a;
  ans = a * a;

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

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    long long int a, b, n, max, diff;
    scanf("%lld%lld%lld", &a, &b, &n);
    if(n >= b)
    {
        diff = n - b;
        n = n - diff-1;
    }
    max = floor(a*n/b);
    printf("%lld\n", max);
}


Measured memory_bytes: 1728