akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int H, W, D;
	cin >> H >> W >> D;

	vector<int> vec(H*W + 1, 0);
	vector<pair<int, int>> xy(H*W + 1);
	REP(i, H) {
		REP(j, W) {
			int a;
			cin >> a;
			xy[a] = make_pair(i + 1, j + 1);
		}
	}

	FOR(i, D + 1, H*W + 1) {
		vec[i] = vec[i - D] + abs(xy[i].first - xy[i - D].first) + abs(xy[i].second - xy[i - D].second);
	}

	int Q, L, R;
	cin >> Q;
	REP(i, Q) {
		cin >> L >> R;
		cout << vec[R] - vec[L] << endl;
	}
	/*
	REP(i, H*W + 1) {
		cout << vec[i] << " ";
	}
	REP(i, H*W + 1) {
		cout << xy[i].first << " " << xy[i].second << endl;
	}*/

	return 0;
}

Measured memory_bytes: 2176
# include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    int ans=0;
    long long sum=100;
    while(sum<n)
    {
        sum=sum*0.01+sum;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b, c;
    cin >> a >> b >> c;
    int d = b / a;
    cout << min(c, d) << endl;
}

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

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

const int MN = 100010;

int N, M;
vector<pii> adj[MN];
int vis[MN], col[MN], cnt[3], ecnt;
bool ok;

void dfs(int u) {
    vis[u] = 1;
    cnt[ col[u] ]++;

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i].first;
        int w = adj[u][i].second;
        ecnt++;

        if(vis[v]) {
            if(col[v] != (col[u] + w) % 3) ok = false;
            continue;
        }
        col[v] = (col[u] + w) % 3;
        dfs(v);
    }
}

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

    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(pii(v, 1));
        adj[v].push_back(pii(u, 2));
    }

    ll ans = 0;
    for(int i = 0; i < N; i++) if(!vis[i]) {
        memset(cnt, 0, sizeof(cnt));
        ecnt = 0;
        ok = true;
        dfs(i);

        if(ok) {
            if(!cnt[0] || !cnt[1] || !cnt[2]) {
                ans += ecnt / 2;
                continue;
            }

            for(int j = 0; j < 3; j++) {
                ans += 1LL * cnt[j] * cnt[(j + 1) % 3];
            }
        }
        else ans += 1LL * (cnt[0] + cnt[1] + cnt[2]) * (cnt[0] + cnt[1] + cnt[2]);
    }
    printf("%lld", ans);
}


Measured memory_bytes: 11136
N = int(input())
nodes = [[-1,-1,-1] for i in range(N)]

for k in range(N):
    i,l,r = map(int,input().split())
    nodes[i][1] = l
    nodes[i][2] = r
    if l != -1:
        nodes[l][0] = i
    if r != -1:
        nodes[r][0] = i

#print(nodes)

sib = [-1 for i in range(N)]

for i in range(N):
    if nodes[i][1] != -1 and nodes[i][2] != -1:
        sib[nodes[i][1]] = nodes[i][2]
        sib[nodes[i][2]] = nodes[i][1]

#print(sib)

deg = [0 for i in range(N)]

for i in range(N):
    c = 0
    if nodes[i][1] != -1:
        c += 1
    if nodes[i][2] != -1:
        c += 1
    deg[i] = c

#print(deg)

dep = [-1 for i in range(N)]

def getDepth(node,node_id):
    d = 0
    while node[node_id][0] != -1:
        node_id = node[node_id][0]
        d += 1
    return d

for i in range(N):
    dep[i] = getDepth(nodes,i)

#print(dep)


hei = [0 for i in range(N)]
for i in range(N):
    h = 0
    node_id = i
    while nodes[node_id][0] != -1:
        hei[node_id] = max(hei[node_id], h)
        node_id = nodes[node_id][0]
        h += 1
    hei[node_id] = max(hei[node_id], h)

#print(hei)


typ = [-1 for i in range(N)]

for i in range(N):
    if nodes[i][0] == -1:
        typ[i] = 'root'
    elif deg[i] == 0:
        typ[i] = 'leaf'
    else:
        typ[i] = 'internal node'

for i in range(N):
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(i,nodes[i][0],sib[i],deg[i],dep[i],hei[i],typ[i]))



Measured memory_bytes: 5628
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    L, R, d = MI()
    ans = 0

    for i in range(L, R+1):
        if i % d == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  string n,a;
  cin >> n;
  a = n;
  reverse(a.begin(),a.end());

  if(n == a) printf("Yes\n");
  else printf("No\n");
 
  return 0;
}

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


int main() {
  int n;
  cin >> n;
  int a = n % 10;
  if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
    cout << "hon";
  } else if (a == 3) {
    cout << "bon";
  } else {
    cout << "pon";
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    int x; 
    ll an = 0;
    scanf("%d", &x);
    int rem = x / 500; 
    an = (1ll * rem * 1000);
    x -= (rem * 500);
    an += (1ll * (x / 5) * 5);
    printf("%lld\n", an);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    ll N, H;
    cin >> N >> H;
    vl A(N), B(N);
    ll amax = 0;
    rep(i, N) {
        cin >> A[i] >> B[i];
        amax = max(amax, A[i]);
    }

    vl bv;
    rep(i, N) {
        if (B[i] > amax) {
            bv.push_back(B[i]);
        }
    }
    sort(bv.begin(), bv.end());
    reverse(bv.begin(), bv.end());

    ll cnt = 0;
    rep(i, bv.size()) {
        H -= bv[i];
        cnt++;
        if (H <= 0) break;
    }
    if (H > 0) {
        cnt += (H / amax);
        if (H % amax != 0) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 5752
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while(true){
            String s1 = sc.nextLine();
            if(s1.equals(".")) break;
            String s2 = sc.nextLine();
            boolean flag = true;
            int cnt = 0;
            while(true){
                int i = s1.indexOf("\"");
                int j = s2.indexOf("\"");
                if(i != j) {
                    flag = false;
                    break;
                }
                if(i == -1 && j == -1){
                    if(! s1.equals(s2)){
                        flag = false;
                        break;
                    }else{
                        break;
                    }
                }
                String ss1 = s1.substring(0, i + 1);
                String ss2 = s2.substring(0, j + 1);
                if(! ss1.equals(ss2)){
                    flag = false;
                    break;
                }
                s1 = s1.substring(i + 1);
                s2 = s2.substring(j + 1);
                
                i = s1.indexOf("\"");
                j = s2.indexOf("\"");
                ss1 = s1.substring(0, i + 1);
                ss2 = s2.substring(0, j + 1);
                if(! ss1.equals(ss2)){
                    cnt++;
                }
                s1 = s1.substring(i + 1);
                s2 = s2.substring(j + 1);
            }
            
            if(! flag){
                System.out.println("DIFFERENT");
            }else if(cnt >= 2){
                System.out.println("DIFFERENT");
            }else if(cnt == 0){
                System.out.println("IDENTICAL");
            }else{
                System.out.println("CLOSE");
            }
            
        }
    }
}



Measured memory_bytes: 29108
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    int n ; 
    cin >> n ; 
    vector<int> v(n+2) ; 
    v[0] = 0 ; 
    v[n+1] = 0 ; 
    vector<int> left(n+2) ; 
    vector<int> right(n+2) ; 
    for(int i=1;i<=n;i++){
    	cin >> v[i] ; 
    	left[i] = abs(v[i]-v[i-1]) ; 
    	left[i] += left[i-1];
    }
    for(int i=n;i>=0;i--){
    	right[i] = abs(v[i]-v[i+1]) ; 
    	right[i] += right[i+1] ; 
    }
    debug() << imie(left) ; 
    debug() << imie(right) ; 
    for(int i=1;i<=n;i++){
    	cout << left[i-1] + abs(v[i+1] - v[i-1] ) + right[i+1] << endl;
    }
    return 0 ;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n;
  cin>>n;
  if(n%2==1)
    cout<<n/2+1<<endl;
  else
    cout<<n/2<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace C___Lower
{
    class Program
    {
        static void Main (string[] args)
        {
            var n = int.Parse (Console.ReadLine ());
            var input = Console.ReadLine ().Split (' ');
            var a = new int[n];
            for (var i = 0; i < n; i++)
            {
                a[i] = int.Parse (input[i]);
            }
            var max = 0;
            var b = 0;
            for (var i = 0; i < a.Length - 1; i = b)
            {
                var count = 0;
                for (var j = i + 1; j < a.Length; j++)
                {
                    if (a[j - 1] >= a[j])
                    {
                        count++;
                        if (j == a.Length - 1)
                            b = a.Length;
                    }
                    else
                    {
                        b = j;
                        break;
                    }
                }
                max = Math.Max (max, count);
            }
            Console.WriteLine (max);
        }
    }
}

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

    ll val = s == 1000000000 ? 1 : s + 1;
    rep(i, n)
    {
        if (i < k)
        {
            cout << s;
        }
        else
        {
            cout << val;
        }
        cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define ll long long
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
using namespace std;

int main() {
  ll n,t,a;
  cin>>n>>t>>a;
  vector<double>vec(n);
  vector<double>vek(n);
  for(ll i=0;i<n;i++) {
    ll h;
    cin>>h;
    double d=a;
    double b=t-h*0.006;
    vec.at(i)=abs(max(d,b)-min(d,b));
    vek.at(i)=abs(max(d,b)-min(d,b));
  }
  sort(vec);
  double c=vec.at(0);
  for(ll j=0;j<n;j++) {
    if(c==vek.at(j)) {
      cout<<j+1<<endl;
      break;
    }
  }
}

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

const LL mod = 1e9+7;
LL N, A[200010], sumAll=0, sumSq=0, ans=0;

int main () {
	cin >> N;
	for(int i=1; i<=N; i++) {
		cin >> A[i];
		sumAll += A[i]; sumAll %= mod;
		sumSq += (A[i]*A[i])%mod; sumSq %= mod;
	}
	ans = (sumAll*sumAll)%mod - sumSq;
	ans %= mod;
	ans += mod;
	ans %= mod;
	ans *= 500000004;
	ans %= mod;
	cout << ans << endl;
}


Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int d[N];
  vector<int> L;
  for (int i=0;i<N;i++) {
    cin >> d[i];
    L.push_back(d[i]);
  }
  sort(L.begin(),L.end());
  long long int ans=0;
  for(vector<int>::iterator e=L.end()-1;e-1!=L.begin();e--){
    for(vector<int>::iterator f=e-1;*f*2>*e;f--){
      for(vector<int>::iterator g=f-1;*g+*f>*e;g--){
        if(abs(*g-*f)<*e) ans++;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size();
const int INF=1e9;
int main(){
  int n,k;
  cin>>n>>k;
  if(n%k==0){cout<<0<<endl;}
  else{cout<<1<<endl;}
}

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

const ll mod = (1e9) + 7;

int main(){
    int n;
    cin >> n;
    vector<int> num(60);
    for(int i=0; i<n; i++){
        ll s;
        cin >> s;
        bitset<60> b(s);
        for(int bit=0; bit<60; bit++){
            if(b[bit]){
                num[bit]++;
            }
        }
    }
    ll ans = 0;
    ll x = 1;
    for(int bit=0; bit<60; bit++){
        ans+= (x * (ll)num[bit] % mod) * (ll)(n - num[bit]); 
        ans %= mod;
        x *= 2;
        x %= mod;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int val = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		string od = Console.ReadLine();
		string ev = Console.ReadLine();

		string re = "";
		int i=0;
		while(true){
			if (od.Length > i) {
				re += od[i];
			}
			if (ev.Length > i) {
				re += ev[i];
			}
			i++;

			if (i == 100) { break; }

		}

		Console.WriteLine(re);


		return;
	}



	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 11092
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    W, H, x, y = list(map(float, sys.stdin.buffer.readline().split()))
    ret = (W * H) / 2
    p = x == W/2 and y == H/2
    print(ret, 1 if p else 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	ll N;
  	cin>>N;
  	ll a[N];
  
  	rep(i,N) cin>>a[i];
  	
  	map<int,int> mp;
  	ll ans=0;
  
  	rep(i,N){
     	ll wa=a[i]+i;
      	ll sa=i-a[i];
      	mp[wa]++;
      	ans+=mp[sa];
    }
  	
  
  	cout<<ans<<endl;
}

Measured memory_bytes: 22180
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1e5+10;
vector<PII> V;
ll a[N],b[N],sum[N<<1],tota,totb;
vector<int> pos[N];
int n;
int main() {
    rd(n);
    for(int i=1;i<=n;++i) {
        rd(a[i]),rd(b[i]);
        tota+=a[i],totb+=b[i];
        V.PB(MP(a[i],i)),V.PB(MP(b[i],i));
    }
    ll ans=min(tota,totb);
    sort(V.begin(),V.end());
    for(int i=0;i<V.size();++i)
        pos[V[i].SEC].PB(i);
    sum[0]=V[0].FIR;
    for(int i=1;i<V.size();++i)
        sum[i]=sum[i-1]+V[i].FIR;
    for(int i=1;i<=n;++i) {
        int lim=n-1+(pos[i][0]<n)+(pos[i][1]<n);
        for(int j=n;j<=lim;++j) if(V[j].SEC==i) lim++;
        ans=min(ans,sum[lim]-(pos[i][0]<=lim)*V[pos[i][0]].FIR-(pos[i][1]<=lim)*V[pos[i][1]].FIR);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    if(a==0||b==0)return max(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];

    int gcdl[n+1],gcdr[n+1];
    gcdl[0]=gcdr[0]=0;
    for(int i=0;i<n;i++){
        gcdl[i+1]=gcd(gcdl[i],a[i]);
        gcdr[i+1]=gcd(gcdr[i],a[n-1-i]);
    }

    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,gcd(gcdl[i],gcdr[n-i-1]));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {

  vector<int> num(3);

  for(int i=0; i<3; i++) {

    cin >> num.at(i);
    
  }

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

  cout << num.at(0)  << " " << num.at(1) << " " << num.at(2) << endl;

  return 0;
  
}


Measured memory_bytes: 3172
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 1e9;

int main(void){
    ll N, M;
    ll answer;

    /*
    if N and M > 1
    corner: 4 
    side : 6

    if N or M = 1
    corner: 2 
    side : 3
    */

    cin >> N >> M;

    if (N == 1 && M == 1) answer = 1;
    else if (N == 1 || M == 1) answer = max(M - 2, N - 2);
    else if (N > 2 && M > 2) answer = max(ll(0), (N - 2) * (M - 2));
    else answer = 0;
    
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>

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

int main() {
	int r,g,b;
	cin>>r>>g>>b;
	r=(r*100)+(g*10)+b;
	if(r%4==0){
		cout<<"YES"<<endl;
	}
	else{
			cout<<"NO"<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 1000000000;
const double EPS = 1e-10;

				//  2      4  5  6      8
int dx[10] = {1,-1, 0, 0, -1, 0, 1, 0,  0, 0};
int dy[10] = {0, 0, 1,-1,  0, 0, 0, 0, -1, 0};

int main(){
	//freopen("test.txt", "r", stdin);
	while(1){
		int h, w;
		cin >> h >> w;
		if(!h && !w) break;
		vector<string> v(h);
		rep(i, h){
			cin >> v[i];
		}
		string pt;
		cin >> pt;

		P a, b;
		rep(i, h){
			rep(j, w){
				if(v[i][j] == 'A') a = MP(j,i);
				if(v[i][j] == 'B') b = MP(j,i);
			}
		}

		queue<P> next;
		next.push(a);
		int cnt = 0;
		while(1){
			queue<P> q = next;
			while(!q.empty()){
				P p = q.front(); q.pop();

				rep(i, 4){
					int x = p.X + dx[i];
					int y = p.Y + dy[i];
					if(x < 0 || x >= w || y < 0 || y >= h) continue;
					if(v[y][x] == '#' || v[y][x] == 'A' ) continue;
					v[y][x] = 'A';
					next.push(MP(x, y));
				}
			}
			int x = b.X + dx[pt[cnt%pt.size()]-'0'];
			int y = b.Y + dy[pt[cnt%pt.size()]-'0'];
			if(x >= 0 && x < w) b.X = x;
			if(y >= 0 && y < h) b.Y = y;
			cnt++;
			if(v[b.Y][b.X] == 'A') break;
			if(cnt > 1000) break;
		}


		if(cnt <= 1000) cout << cnt << ' ' << b.Y << ' ' << b.X << endl;
		else cout << "impossible" << endl;
	}

	return 0;
}

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

using pll = pair<long long int, long long int>;

int main(){
    long long int N, M;
    cin >> N >> M;

    vector<pll> drink(N);
    for(int i = 0; i < N; ++i) cin >> drink[i].first >> drink[i].second;

    sort(begin(drink), end(drink));

    long long int ans = 0;
    for(int i = 0; i < N; ++i){
        if(drink[i].second <= M){
            M -= drink[i].second;
            ans += drink[i].first*drink[i].second;
        }else{
            ans += drink[i].first*M;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#define _AOJ_
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)

int main(){
	lint n;
	double t;cin>>n>>t;
	double ans=0,x,h;
	rep(i,n)cin>>x>>h,ans=max(ans,h*t/x);
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;
}
//sub-EOF


Measured memory_bytes: 3272
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: int, B: int):
    ret = min(N * A, B)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int k;
	cin >> k;
	int ans = 0;
	int curr = 7;
	while(1 and ans < 1e7){
		curr %= k;
		if(curr % k == 0) break;

		curr = curr * 10 + 7;
		ans++;
	}
	if(ans == 1e7) cout << -1;
	else cout << ans + 1;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int a,b,c,d; cin>>a>>b>>c>>d;

    bool taka = false;

    while (a > 0 && c > 0) {
        taka ^= 1;
        if (taka) {
            c -= b;
        }
        else {
            a -= d;
        }

    }

    if (taka) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

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



int n;
int v[105];

int get_ans(int the){
    int ret = 0;
    for (int i=0;i<n;i++){
        ret += (v[i] - the)*(v[i] - the);
    }
    return ret;
}

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

    cin >> n;
    double avg = 0;
    for (int i = 0; i < n; i++) {
       cin >> v[i];
       avg += v[i];
    }
    avg = avg/(double)n;

    int d = floor(avg),u = d+1;
    cout << min(get_ans(d),get_ans(u)); 


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;

int main() {
    int l1,r1,l2,r2;
    cin >> l1 >> r1 >> l2 >> r2;
    int d[2][5][5][5][5];
    rep(i,2){
        rep(j,5){
            rep(k,5){
                rep(ii,5){
                    rep(jj,5) d[i][j][k][ii][jj]=0;
                }
            }
        }
    }
    rep(i,5){
        rep(j,5){
            d[0][0][0][i][j]=1;
            d[1][i][j][0][0]=1;
        }
    }
    rep(iii,100){
    rep(i,2){
        rep(j,5){
            rep(k,5){
                rep(ii,5){
                    rep(jj,5) {
                        if (d[i][j][k][ii][jj]!=0) continue;
                        int u=j+ii,uu=j+jj,y=k+ii,yy=k+jj;
                        bool t=true,tt=true,r=true,rr=true;
                        if (j==0 || ii==0) t=false;
                        if (j==0 || jj==0) tt=false;
                        if (k==0 || ii==0) r=false;
                        if (k==0 || jj==0) rr=false;
                        if (u>=5) u=0;
                        if (uu>=5) uu=0;
                        if (y>=5) y=0;
                        if (yy>=5) yy=0;
                        if (i==0){
                            if ((d[1][j][k][u][jj]==1 && t) ||(d[1][j][k][y][jj]==1 && r) || (d[1][j][k][ii][uu]==1 && tt) || (d[1][j][k][ii][yy]==1 && rr)) d[0][j][k][ii][jj]=2;
                            if ((d[1][j][k][u][jj]==2 || !t) && (d[1][j][k][y][jj]==2 || !r) && (d[1][j][k][ii][uu]==2 || !tt) && (d[1][j][k][ii][yy]==2 || !rr)) d[0][j][k][ii][jj]=1;
                        }
                        if (i==1){
                            if ((d[0][u][k][ii][jj]==1 && t) ||(d[0][uu][k][ii][jj]==1 && tt) || (d[0][j][y][ii][jj]==1 && r) || (d[0][j][yy][ii][jj]==1 && rr)) d[1][j][k][ii][jj]=2;
                            if ((d[0][u][k][ii][jj]==2 || !t) && (d[0][uu][k][ii][jj]==2 || !tt) && (d[0][j][y][ii][jj]==2 || !r) && (d[0][j][yy][ii][jj]==2 || !rr)) d[1][j][k][ii][jj]=1;
                        }
                    }
                }
            }
        }
    }
    }
    if (d[0][l1][r1][l2][r2]==1) cout << "NAKAJIMA" << endl;
    if (d[0][l1][r1][l2][r2]==2) cout << "ISONO" << endl;
}



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

int main() {
  int N, sum, order;
  cin >> N;
  sum = 0;
  order = 1;
  for (int i = 0; i < 8; i++) {
    if (order > N)
      break;
    else {
      sum += N / order % 10;
      order *= 10;
    }
  }
  if (N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

#define int long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define endl "\n"

const int N = 55;
int x[N];
int cache[N][N][N * N];


int32_t main()
{
	IOS;
	int n, a;
	cin >> n >> a;
	for (int i = 1; i <= n; i++)
		cin >> x[i];
	//cache[1][1][0] = 1;
	cache[0][0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			for (int k = 0; k <= 2500 - x[i + 1]; k++)
			{
				cache[i + 1][j + 1][k + x[i + 1]] += cache[i][j][k];
				cache[i + 1][j][k] += cache[i][j][k];
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans += cache[n][i][i * a];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 66560
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    vector< vector<int> > v(h+1, vector<int>(w+1, 0));
    vector<int> x(n);
    vector<int> y(n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> a[i];
    }

    for (int i = 0; i < n; ++i) {
        int xb, xe, yb, ye;
        if (a[i] == 1) {
            xb = 1;
            xe = x[i];
            yb = 1;
            ye = h;
        } else if (a[i] == 2) {
            xb = x[i]+1;
            xe = w;
            yb = 1;
            ye = h;
        } else if (a[i] == 3) {
            xb = 1;
            xe = w;
            yb = 1;
            ye = y[i];
        } else {
            xb = 1;
            xe = w;
            yb = y[i]+1;
            ye = h;
        }
        for (int j = yb; j <= ye; ++j) {
            for (int k = xb; k <= xe; ++k) {
                v[j][k] = 1;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (v[i][j] == 0) ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

class Edge{
	int s, t;
	public Edge(int _s, int _t) {
		s = _s; t = _t;
	}
}
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		if((N - 1) * (N - 2) < 2 * K) System.out.println(-1);
		else {
			LinkedList<Edge> edges = new LinkedList<Edge>();
			for(int i = 2; i <= N; i++) edges.add(new Edge(1, i));
			int add = (N - 1) * (N - 2) / 2 - K;
			for(int i = 2; i <= N; i++) {
				for(int j = i + 1; j <= N; j++) {
					if(add <= 0) break;
					else {
						edges.add(new Edge(i, j));
						add--;
					}
				}
			}
			System.out.println(edges.size());
			for(Edge e : edges) {
				System.out.println(e.s+" "+e.t);
			}
		}
	}
}

Measured memory_bytes: 23764
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,b,c,i,j;
    map<ll,ll>m;
    cin>>n;
    ll a[n];
    ll f=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        f=f+a[i];
        m[a[i]]++;
    }
    ll q;
    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        f=f-m[b]*b + m[b]*c;
        m[c]=m[c]+m[b];
        m[b]=0;
        cout<<f<<"\n";
    }
    return 0;

}


Measured memory_bytes: 10352
N = int(input())
d = {}
for _ in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1

n = max(d.values())

res = [kv[0] for kv in d.items() if kv[1] == n]

res.sort()

for s in res:
    print(s)

Measured memory_bytes: 32092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {
        if (i * i == n) {
            ret.push_back(i);
        } else if (n % i == 0) {
            ret.push_back(i);
            ret.push_back(n / i);
        }
    }
    return ret;
}

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

    ll N;
    cin >> N;
    vector<ll> divisors = divisor(N);
    ll ans = 0;
    for (ll d : divisors) {
        if (d == 1) continue;
        ll m = d - 1;
        if (N / m == N % m) ans += m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#define lop(i, n) for(i=1; i<=n; i++)

int main()
{
	int n, m, i;
	scanf("%d %d", &n, &m);
	
	int h[100005];
	lop(i, n){ scanf("%d", &h[i]); }
	
	int a, b, c[100005]={0};
	lop(i, m){
		scanf("%d %d", &a, &b);
		if(h[a]<h[b]){ c[a]=1; }
		else if(h[a]>h[b]){ c[b]=1; }
		else { c[a]=1; c[b]=1; }
	}
	
	int sum=0;
	lop(i, n){ if(c[i]==0)sum++; }
	
	printf("%d", sum);
	
	return 0;
}

Measured memory_bytes: 2512
N,M=map(int,input().split())
ls_pass=[list(map(int,input().split())) for i in range(M)]
#各iと繋がっている部屋の番号
ls=[[] for i in range(N+1)]
for i in range(M):
  ls[ls_pass[i][0]].append(ls_pass[i][1])
  ls[ls_pass[i][1]].append(ls_pass[i][0])
#各部屋に振る道標
ls_mark=[""]*2+[0]*(N-1)

#幅優先探索の実装
from queue import Queue 
S=Queue()
S.put(1)
while not S.empty():
  a=S.get()
  for i in ls[a]:
    if ls_mark[i]==0:
      ls_mark[i]=a
      S.put(i)
if 0 in ls_mark:
  print("No")
else:
  print("Yes")
  for i in range(2,N+1):
    print(ls_mark[i])

Measured memory_bytes: 58172
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<ll, ll> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	ll h;
	cin >> h;

	ll cnt = 0;
	while (h != 0) {
		h = h / 2;
		cnt++;
	}
	ll ans = 0;
	ll num = 2;
	for(ll i = 1; i < cnt; i++) {
		ans += num;
		num = num * 2;
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  int maxx=x;
  int miny=y;
  for(int i=0;i<n;i++){
    int s;
    cin>>s;
    maxx=max(maxx,s);
  }
  for(int i=0;i<m;i++){
    int s;
    cin>>s;
    miny=min(miny,s);
  }
  if(maxx<miny){cout<<"No War";}
  else{cout<<"War";}
}
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int main(){
	int n,k;
	cin >> n >> k;
	int sum = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i] >= k){
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int g[201][201][201];

int gcd(int a, int b);

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

	for (int i = 1; i <= k; i++) {
		for (int j = i; j <= k; j++) {
			for (int l = j; l <= k; l++) {
				g[i][j][l] = g[i][l][j] = g[j][i][l] = g[j][l][i] = g[l][i][j] = g[l][j][i] = gcd(i, gcd(j, l));
			}
		}
	}

	long long ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int l = 1; l <= k; l++) {
				ans += g[i][j][l];
			}
		}
	}
	cout << ans << endl;

	return 0;
}

int gcd(int a, int b)
{
	if (a < b) {
		int t = a;
		a = b;
		b = t;
	}

	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

Measured memory_bytes: 34996
#include<bits/stdc++.h>
using namespace std;
int cnt[59];

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    cnt[a]++;
    cnt[b]++;
  }
  for(int i=1;i<=n;i++){
    cout<<cnt[i]<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;
int main()
{
    fast_io
    ll i,n,k,st,en,ans=0;
    cin>>n>>k;
     for(i=k;i<=n+1;i++)
   {
       st=i*(i-1)/2;
       en=i*(2*n-i+1)/2;
       ans+=en-st+1;
       ans%=mod;

   }
    cout<<ans%mod<<endl;

    return 0;
}




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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    int a , b ;
    cin >> a >> b ;
    if (b % 2 == 0 )
    if (a >= 13)
        cout << b ;
    else if (a < 13 && a >= 6)
        cout << b/2 ;
    else
        cout << 0 ;


    return 0;
}


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

using namespace std;

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

int main() {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	q *= 4;
	h *= 2;
	ll dd = d;
	d += d % 2;
	d /= 2;

	vector<ii> v;
	v.push_back(ii(q, 1));
	v.push_back(ii(h, 2));
	v.push_back(ii(s, 3));
	v.push_back(ii(d, 4));

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

	if (v[0].second == 4) {
		if (n % 2) {
			cout << n / 2 * dd + v[1].first << '\n';
		} else {
			cout << n / 2 * dd << '\n';
		}
	} else {
		cout << n * v[0].first << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll h,w,d,q;
vector<PLL> ck;
Vi l,r;
ll ma[90010];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>h>>w>>d;
    ll aa;
    ck.resize(h*w+1);
    rep(i,h)rep(j,w){
        cin>>aa;
        ck[aa]=(mp(j+1,i+1));
    }
    cin>>q;
    l.resize(q); r.resize(q);
    ll ans = 0;
    ll tmp = 0;
    rep(i,90010)ma[i] = 0;
    rep(i,d+1){
        if(i==0)continue;
        tmp = i;
        while(1){
            if(tmp+d>h*w)break;
            ma[tmp+d] += ma[tmp] + abs(ck[tmp].first - ck[tmp+d].first) + abs(ck[tmp].second - ck[tmp+d].second);
            tmp += d;
        }

    }
    rep(i,q){
        cin>>l[i]>>r[i];
        // while(1){
        //     if(l[i]==r[i])break;
        //     ans += abs(ck[l[i]].first - ck[l[i]+d].first);
        //     ans += abs(ck[l[i]].second - ck[l[i]+d].second);
        //     l[i] += d;
        // }
        ans = ma[r[i]] - ma[l[i]];
        print(ans);
        ans = 0;
    }
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

int N, M;
vector<ll> dp(100010,INF);


int main(){
    cin >> N >> M;
    dp[0] = 1, dp[1] = 1;
    rep(i, M){
        int a;
        cin >> a;
        dp[a] = 0; // 壊れている段
    }
    for(int i = 2; i < N + 5; i++){
        if(dp[i] == INF)
            dp[i] = (dp[i - 1] +dp[i - 2]) % MOD;
        else{
            dp[i] = 0;
        }
    }
    cout << dp[N] << endl;
    return 0;


}


Measured memory_bytes: 1024
use std::collections::{BTreeMap, BTreeSet, BinaryHeap};

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let _: u64 = sc.read();
    let mut segments = vec![];
    for _ in 0..n {
        let left: u64 = sc.read();
        let right: u64 = sc.read();
        segments.push((left, right));
    }

    let seg_map = segments
        .iter()
        .flat_map(|&(l, r)| vec![l, r])
        .collect::<BTreeSet<_>>()
        .into_iter()
        .enumerate()
        .map(|(i, v)| (v, i))
        .collect::<BTreeMap<_, _>>();
    let segments = segments
        .into_iter()
        .map(|(l, r)| {
            let l = *seg_map.get(&l).unwrap();
            let r = *seg_map.get(&r).unwrap();
            (l, r)
        })
        .collect::<Vec<_>>();
    let length: usize = segments.iter().map(|&(_, r)| r).max().unwrap();
    let mut graph = vec![vec![]; length];
    for i in 0..n {
        let (l, r) = segments[i];
        graph[l].push(r);
    }

    let mut cost = vec![n as i64; length + 1];
    cost[0] = 0;
    let mut q = BinaryHeap::new();
    q.push((0, 0));
    while let Some((_, v)) = q.pop() {
        if v == length {
            break;
        }
        for &next in graph[v].iter() {
            if cost[next] > cost[v] + 1 {
                cost[next] = cost[v] + 1;
                q.push((-cost[next], next));
            }
        }
        if v > 0 && cost[v - 1] > cost[v] {
            cost[v - 1] = cost[v];
            q.push((-cost[v - 1], v - 1));
        }
    }

    let mut acc: Vec<i64> = vec![0; length + 1];
    for from in 0..length {
        for &to in graph[from].iter() {
            acc[from] += 1;
            acc[to] -= 1;
        }
    }
    for i in 0..length {
        acc[i + 1] += acc[i];
    }

    let min_acc = (0..length).map(|i| acc[i]).min().unwrap();
    println!("{} {}", cost[length], n as i64 + 1 - min_acc);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

ll A, B, C, K;

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

    cin >> A >> B >> C >> K;

    ll ans = 0;

    if (K <= A) {
        ans = K;
    } else if (A < K && K <= (A + B)) {
        ans = A;
    } else if (A + B < K && K < A + B + C) {
        ans = A - (K - (A + B));
    } else {
        ans = A - C;
    }

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

Measured memory_bytes: 3624