akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long l = -1000001, s = 1000001, sum = 0;

    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;
        l = max(l, x);
        s = min(s, x);
        sum += x;
    }

    cout << s << " " << l << " " << sum << "\n";
}



Measured memory_bytes: 3104
def main():
  N,K,S=map(int,input().split())
  MAX=10**9
  ans=[]
  if S!=MAX:
    for i in range(K):
      ans.append(str(S))
    for i in range(K,N):
      ans.append(str(MAX))
  else:
    for i in range(K):
      ans.append(str(S))
    for i in range(K,N):
      ans.append(str(MAX-1))
  print(" ".join(ans))
main()

Measured memory_bytes: 13464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 100;
ll f[N];
ll a[N], u[N];
ll q[N], ans, n, k;

void init() {
	f[0] = 1;
	for(int i=1;i<=31;i++) {
		f[i] = f[i - 1] * 2;
	}	
}

ll g(ll x) {
	ll t = 0;
	for(int i=0;i<n;i++) {
		if((a[i] | x) == x)t += u[i];
	}
	return t;
}

void solve(ll x) {
	ans = g(x);
	int cnt = 0;
	memset(q, 0, sizeof(q));
	ll tmp;
	while(x) {
		q[cnt ++] = (x & 1);
		x = x / 2;
	}
//	for(int i=0;i<cnt;i++)cout<<q[i]<<" ";
//	cout<<endl;
	
	for(int i=1;i<cnt;i++) {
		tmp = 0;
		if(!q[i])continue;
		for(int j=0;j<i;j++)tmp += f[j];
		for(int j=i+1;j<cnt;j++)
			if(q[j])tmp += f[j];
	//	cout<<tmp<<endl;
		ans = max(ans, g(tmp));
	}
}
int main(int argc, char** argv) {
	//freopen("in.txt","r",stdin);
	init();
	cin>>n>>k;
	for(int i=0;i<n;i++)scanf("%lld%lld",&a[i],&u[i]);
	solve(k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
/*program by mangoyang*/
#include <bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
	int ch = 0, f = 0; x = 0;
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
	for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	if(f) x = -x;
}
const int N = 2000005, mod = 1e9 + 7;
int js[N], inv[N], X[7], Y[7], ans;
inline void up(int &x, int y){ 
	x = x + y >= mod ? x + y - mod : x + y; 
}
inline int Pow(int a, int b){
	int ans = 1;
	for(; b; b >>= 1, a = 1ll * a * a % mod)
		if(b & 1) ans = 1ll * ans * a % mod;
	return ans;
}
inline int C(int x, int y){
	return 1ll * js[x] * inv[y] % mod * inv[x-y] % mod;
}
inline int GAO(int X1, int Y1, int X2, int Y2){
	int res = 0;
	up(res, C(X2 + Y2 + 2, Y2 + 1));
	up(res, C(X1 + Y1, Y1));
	up(res, mod - C(X2 + Y1 + 1, X2 + 1));
	up(res, mod - C(Y2 + X1 + 1, Y2 + 1));
	return res;
}

inline int gao1(int x, int y){
	return 1ll * GAO(x - X[2], y - Y[2] - 1, x - X[1], y - Y[1] - 1)
		* GAO(X[5] - x, Y[5] - y, X[6] - x, Y[6] - y) % mod;
}
inline int gao2(int x, int y){
	return 1ll * GAO(x - X[2], y - Y[2], x - X[1], y - Y[1])
		* GAO(X[5] - x, Y[5] - y - 1, X[6] - x, Y[6] - y - 1) % mod;
}
inline int gao3(int x, int y){
	return 1ll * GAO(x - X[2] - 1, y - Y[2], x - X[1] - 1, y - Y[1])
		* GAO(X[5] - x, Y[5] - y, X[6] - x, Y[6] - y) % mod;
}
inline int gao4(int x, int y){
	return 1ll * GAO(x - X[2], y - Y[2], x - X[1], y - Y[1])
		* GAO(X[5] - x - 1, Y[5] - y, X[6] - x - 1, Y[6] - y) % mod;
}
int main(){
	js[0] = inv[0] = 1;
	for(int i = 1; i < N; i++){
		js[i] = 1ll * js[i-1] * i % mod;
		inv[i] = Pow(js[i], mod - 2);
	}
	for(int i = 1; i <= 6; i++) read(X[i]);
	for(int i = 1; i <= 6; i++) read(Y[i]);
	for(int i = X[3]; i <= X[4]; i++){
		up(ans, 1ll * gao1(i, Y[3]) * (mod - i - Y[3]) % mod);
		up(ans, 1ll * gao2(i, Y[4]) * (i + Y[4] + 1) % mod);
	}
	for(int i = Y[3]; i <= Y[4]; i++){
		up(ans, 1ll * gao3(X[3], i) * (mod - X[3] - i) % mod);
		up(ans, 1ll * gao4(X[4], i) * (X[4] + i + 1) % mod);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()
//#define max(a,b) (a>b ? a : b)
//#define min(a,b) (a<b ? a : b)
 
const int MOD = 998244353;
const int INF = 100000002;
const double PI =4*atan(1);
const double eps = 1e-7;
const long long oo = 1e18;

int main(){
  ll H, W;
  cin >> H >> W;
  if (H==1 || W==1){
    cout << 1 << endl;
  }else{
    cout << (H*W%2==0 ? H*W/2 : H*W/2+1) << endl;
  }
}

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


typedef pair<ll, int> P;
vector<ll> dijkstra(int s, const vector<vector<pair<int, int> > >& G) {
	priority_queue< P, vector<P>, greater<P> > que;
	vector<ll> d(G.size(), LINF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		int curr = que.top().second;
		ll  dcurr = que.top().first;
		que.pop();
		if (d[curr] < dcurr) continue;
		int i;
		for (i = 0; i < (int)G[curr].size(); i++) {
			int next = G[curr][i].first;
			ll  dist = G[curr][i].second;
			if (d[next] > d[curr] + dist) {
				d[next] = d[curr] + dist;
				que.push(P(d[next], next));
			}
		}
	}
	return d;
}


char str[50][55];

void solve()
{
	int h, w;
	scanf("%d%d", &h, &w);
	int i, j;
	int cnt = 0;
	for (i = 0; i < h; i++) {
		scanf("%s", str[i]);
		for (j = 0; j < w; j++) {
			if (str[i][j] == '#') cnt++;
		}
	}
#define POSI(i,j) ((i)*w+(j))
	int N = h * w;
	vector<vector<pair<int, int> > > g(N);
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (i > 0) {
				int p0 = POSI(i, j), p1 = POSI(i - 1, j);
				if (str[i][j] == '.' && str[i - 1][j] == '.') {
					g[p0].push_back(make_pair(p1, 1));
					g[p1].push_back(make_pair(p0, 1));
				}
			}
			if (j > 0) {
				int p0 = POSI(i, j), p1 = POSI(i, j-1);
				if (str[i][j] == '.' && str[i][j - 1] == '.') {
					g[p0].push_back(make_pair(p1, 1));
					g[p1].push_back(make_pair(p0, 1));
				}
			}
		}
	}

	vector<ll> dist = dijkstra(0, g);
	ll dd = dist[POSI(h - 1, w - 1)];

	if (dd<LINF) {
		int ans=h*w -1 - dd - cnt;
		printf("%d\n", ans);
	}
	else {
		printf("-1\n");
	}

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    bool ok = 0;
    pii a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    int  cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i].first == a[i].second) {
            cnt++;
        } else {
            cnt = 0;
        }
        ok |= (cnt >= 3);
    }
    
    if (ok) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}



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

using namespace std;


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

	int h,w;
	cin >> h >> w;
	vector<string> a(h);

	for(int i  = 0; i < h; ++i){
		cin >> a[i];
	}
	vector<vector<long long>> dp(h+5,vector<long long>(w+5));
	for(int i = 0; i < h + 5; ++i){
		dp[i][0] = 0;
	}
	for(int i = 0; i < w + 5; ++i){
		dp[0][i] = 0;
	}
	dp[1][1] = 1;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(i || j){
				if(a[i][j] == '#'){
					dp[i+1][j+1] = 0;
				}else{
					dp[i+1][j + 1] = (dp[i][j + 1] + dp[i+1][j])%1000000007;
				}
			}
		}
	}
	cout << dp[h][w];

	return 0;
}

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

#define int long long

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

int N, A, B, C, D;
int mod = 1e9 + 7;
int dp[1100][1100];
int fact[1100];
int fact_inv[1100][1100];

//拡張ユークリッドの互除法
int extgcd(int a, int b, int& x, int& y) {
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

// mod逆元
int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

//繰り返し二乗法
int mod_pow(int x, int n, int m) {
    if (n == 0)
        return 1;
    int res = mod_pow(x * x % m, n / 2, m);
    if (n & 1)
        res = res * x % m;
    return res;
}

int DP(int n, int a) {
    if (dp[n][a] != -1) {
        return dp[n][a];
    }
    if (n == 0) {
        return dp[n][a] = 1;
    }
    if (a > B) {
        return dp[n][a] = 0;
    }
    dp[n][a] = DP(n, a + 1);
    for (int i = C; i <= D && n >= a * i; i++) {
        int pattern = fact[n] * fact_inv[1][n - a * i] % mod * fact_inv[i][a] %
                      mod * fact_inv[1][i] % mod;
        (dp[n][a] += DP(n - a * i, a + 1) * pattern % mod) %= mod;
    }
    return dp[n][a];
}

signed main() {
    cin >> N >> A >> B >> C >> D;
    fact[0] = 1;
    for (int i = 1; i < 1100; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    for (int i = 0; i < 1100; i++) {
        fact_inv[1][i] = mod_inverse(fact[i], mod);
    }
    for (int i = 2; i < 1100; i++) {
        for (int j = 0; j < 1100; j++) {
            fact_inv[i][j] = fact_inv[i - 1][j] * fact_inv[1][j] % mod;
        }
    }
    for (int i = 0; i < 1100; i++) {
        for (int j = 0; j < 1100; j++) {
            dp[i][j] = -1;
        }
    }
    cout << DP(N, A) << endl;
}

Measured memory_bytes: 19328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long max = inputLongArray.Max();
            long min = inputLongArray.Min();

            Console.WriteLine(max-min);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }



int main() {
    string s, t; cin >> s >> t;
    bool f = true;

    rep(i, s.size()){
        if(s[i] != t[i]){ f = false; break;}
    }
    if(f) cout << "Yes" << ln;
    else cout << "No" << ln;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main() {
  int n,q,l,r;
  scanf("%d %d",&n,&q);
  char s[n+1];
  scanf("%s",s);
  int pop[n+1];
  int cnt,flag=0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'A') flag=1;
    else if (s[i] == 'C' && flag == 1) {
      cnt++;
      flag = 0;
    }
    else flag = 0;
    pop[i+1] = cnt;
  }
  int ans;
  for (int i = 0; i < q; i++) {
    scanf("%d %d",&l,&r);
    ans = pop[r] - pop[l];
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 1280
N,K = map(int,input().split())
Klist = []
temp = K
ans = 0
amari = 0

#Klist作成
while temp>=1:
    Klist.append(temp)
    temp = -(-temp//2)
    if temp==1:
        Klist.append(temp)
        break

powcount = 0
#powcount導出
while True:
    if N >= Klist[powcount]:
        amari = N - Klist[powcount]
        break
    powcount += 1
    
for i in range(powcount,len(Klist)):
    if i==powcount:
        ans += (N-Klist[powcount]+1)/pow(2,powcount)
        #print(i,ans)
    else:
        ans += (Klist[i-1]-Klist[i])/pow(2,i)
        #print(i,ans)
        
print(ans/N)

Measured memory_bytes: 3064
# abc128_a.py
# https://atcoder.jp/contests/abc128/tasks/abc128_a

# A - Apple Pie /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 林檎が A個、林檎の欠片が P個あります。
# 林檎 1個は、砕くことで林檎の欠片 3 個になります。また、林檎の欠片 2 個を鍋で煮込むことで、アップルパイが 1個作れます。
# 今ある材料で作れるアップルパイの最大数を求めてください。

# 制約
#     入力は全て整数である。
#     0≤A,P≤100

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A P

# 出力
# 今ある材料で作れるアップルパイの最大数を出力せよ。

# 入力例 1
# 1 3

# 出力例 1
# 3

# 3つある林檎の欠片のうち 2 つを鍋で煮込むことで、まず 1 つのアップルパイを作ることができます。
# 林檎の欠片が 1 つ残りますが、これと、1 つある林檎を砕いて新しく得た 3 つの林檎の欠片から、さらに 2つのアップルパイを作れます。

# 入力例 2
# 0 1

# 出力例 2
# 0

# 残念ながら 1つもアップルパイを作ることができません。

# 入力例 3
# 32 21

# 出力例 3
# 58


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, P = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = (A*3+P) // 2

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1 3']
        lines_export = [3]
    if pattern == 2:
        lines_input = ['0 1']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['32 21']
        lines_export = [58]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int h,w,c;
int map[6][8][8];
int visited[8][8];

void change_color(int stage,int x,int y,int src_color,int dist_color) {
	if(x<0 || x>=w || y<0 || y>=h)return;
	if(map[stage][y][x]!=src_color || src_color==dist_color)return;
	map[stage][y][x]=dist_color;
	change_color(stage,x-1,y,src_color,dist_color);
	change_color(stage,x+1,y,src_color,dist_color);
	change_color(stage,x,y-1,src_color,dist_color);
	change_color(stage,x,y+1,src_color,dist_color);
}

int get_color_num(int x,int y,int color) {
	int result=1;
	if(x<0 || x>=w || y<0 || y>=h)return 0;
	if(visited[y][x] || map[5][y][x]!=color)return 0;
	visited[y][x]=1;
	result+=get_color_num(x-1,y,color);
	result+=get_color_num(x+1,y,color);
	result+=get_color_num(x,y-1,color);
	result+=get_color_num(x,y+1,color);
	return result;
}

int tansaku(int stage,int prev_color) {
	int i,j,now_color;
	int result=0,now;
	for(now_color=1;now_color<=6;now_color++) {
		if((stage<5 && prev_color==now_color) ||
			(stage>=5 && now_color!=c))continue;
		for(i=0;i<h;i++) {
			for(j=0;j<w;j++)map[stage][i][j]=map[stage-1][i][j];
		}
		change_color(stage,0,0,map[stage][0][0],now_color);
		if(stage<5) {
			now=tansaku(stage+1,now_color);
			if(result<now)result=now;
		} else {
			memset(visited,0,sizeof(visited));
			result=get_color_num(0,0,c);
		}
	}
	return result;
}

int main(void) {
	int i,j;
	while(1) {
		scanf("%d%d%d",&h,&w,&c);
		if(h==0 && w==0 && c==0)break;
		for(i=0;i<h;i++) {
			for(j=0;j<w;j++)scanf("%d",&map[0][i][j]);
		}
		printf("%d\n",tansaku(1,0));
	}
	return 0;
}

Measured memory_bytes: 408
import java.util.Scanner;

class Main {
	public static final long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		Integer A[] = new Integer[N];
		for(int i=0; i<N; i++){
		      A[i] = sc.nextInt();
		}
		int ans;
		ans = (N-2) / (K-1) +1;
		System.out.println(ans);
	}
}

Measured memory_bytes: 62480
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX_N 100000
int N,M,X,Y;
char a[MAX_N][8];
vector<int> G[MAX_N];

map< vector< int > , int > mp;

int update(char* s,int n){
  int t=X;
  if(s[4]=='Y')t=Y;
  if(s[3]=='&')return n&t;
  if(s[3]=='|')return n|t;
  if(s[3]=='^')return n^t;
}

int rec(int pos,int prev,int depth,int num){
  
  if(prev!=-1){
    num=update(a[pos],num);
    if(G[pos].size()==1) return num;
  }
  
  bool f=depth&1;
  int res=(f?X|Y:0);
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(f)res=min(res,rec(to,pos,depth+1,num));
    else res=max(res,rec(to,pos,depth+1,num));
  }
  return res;
}

int solve(){
  if(N==1)return 0;
  vector< int> w;
  vector< P > v;
  v.push_back( P(X,0) );
  v.push_back( P(Y,1) );
  v.push_back( P(X|Y,2) );
  v.push_back( P(X&Y,3) );
  v.push_back( P( (X|Y)-X ,4) );
  v.push_back( P( (X|Y)-Y ,5) );
  v.push_back( P( (X|Y)-(X&Y) , 6 ) );
  v.push_back( P( 0 , 7 ) );

  sort(v.begin(),v.end());
  for(int i=0;i<8;i++)w.push_back(v[i].second);
  
  if(mp.count(w)){
    int id=mp[w];
    for(int i=0;i<8;i++)
      if(id==v[i].second)return v[i].first;
  }
  int ans=rec(0,-1,0,0);
  for(int i=0;i<8;i++){
    if(ans==v[i].first)
      mp[w]=v[i].second;
  }
  return ans;
}

int main(){
  scanf("%d %d",&N,&M);
  for(int i=1;i<N;i++)scanf("%s",a[i]);
  for(int i=1;i<N;i++){
    int x,y;
    scanf("%d %d",&x,&y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  while(M--){
    scanf("%d %d",&X,&Y);
    printf("%d\n",solve());
  }
  return 0;
}

Measured memory_bytes: 17356
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long A,B,K;
    cin >> A >> B >> K;
    if(K>=A+B){
        cout << 0 << " " << 0 << endl;
    }
    else if(K>A){
        cout << 0 << " " << A+B-K << endl;
    }
    else{
        cout << A-K << " " << B << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();

		String[] x = line.split(" ");

		int a = Integer.parseInt(x[0]);
		int b = Integer.parseInt(x[1]);

		System.out.println(a * b + " " + (a * 2 + b * 2));

	}

}


Measured memory_bytes: 26136
#include <stdio.h>
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define INF 1000000000


using namespace std;

long long int x, y;

void init(){
	scanf("%lld", &x);
	scanf("%lld", &y);
	long long res = INF + 1;
	if(x <= y){
		res = min(res, y - x);
		//printf("%lld\10 -10n", res);
	}
//	else 
	if(-x <= y){
		res = min(res, y - (-x) + 1);	
		//printf("%lld\n", res);
	}
	//else 
	if(x <= -y){
		res = min(res, (-y) - (x) + 1);
		//printf("%lld\n", res);
	}
	//else 
	if(-x  <= -y){
			res = min(res, (-y) - (-x) + 2);
			//printf("%lld\n", res);
		}
	printf("%lld\n", res);


}

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

Measured memory_bytes: 256
#include <iostream>

int nums[4];
char ops[3];

bool dfs(int depth, int n) {
	if (depth == 4)
		return n == 7;

	if (dfs(depth + 1, n + nums[depth])) {
		ops[depth - 1] = '+';
		return true;
	}
	if (dfs(depth + 1, n - nums[depth])) {
		ops[depth - 1] = '-';
		return true;
	}

	return false;
}

int main() {
	for (auto&& v : nums) {
		char c;
		std::cin >> c;

		v = c - '0';
	}

	dfs(1, nums[0]);

	for (int i = 0; i < 3; ++i)
		std::cout << nums[i] << ops[i];

	std::cout << nums[3] << "=7" << std::endl;
}

Measured memory_bytes: 256
#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;
  if ((n % 10 == 7)  || (n / 10 % 10 == 7) || (n / 100 == 7)) cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int N, M;
set<int> ab[202000];
int ans = 0;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> M;
    
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        ab[a].insert(b);
        ab[b].insert(a);
    }
    
    for (int x : ab[1]) {
        if (ab[N].count(x)) {
            ans++;
        }
    }
    
    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 28544
#


def main():
    a, b, c = input().split(" ")
    dic = dict({a: 0, b: 0, c: 0})
    dic[a] += 1
    dic[b] += 1
    dic[c] += 1
    if dic[a] == 2 or dic[b] == 2 or dic[c] == 2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
K = int(input())
As = list(map(int, input().split()))

def f(n):
    for a in As:
        n = a * (n//a)
    return n

ng,ok = 1, 10**20
while ok-ng > 1:
    m = (ok+ng)//2
    if f(m) >= 2: #2以上ならTrue
        ok = m
    else:
        ng = m
mn = ok
# print(ng,ok)

ok,ng = 1, 10**20
while ng-ok > 1:
    m = (ok+ng)//2
    if f(m) <= 2: #2以下の範囲
        ok = m
    else:
        ng = m
mx = ok

# print(ok,ng)
if mn > mx:
    print(-1)
else:
    print(mn,mx)


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


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
    
    vector<long> t(n+1), x(n+1), y(n+1);
    long i;
    t[0]=x[0]=y[0]=0;
    for(i=1; i<=n; i++) {
        scanf("%ld%ld%ld", &t[i], &x[i], &y[i]);
    }

    for(i=0; i<n; i++) {
        long tt = t[i+1]-t[i];
        long xx = x[i+1]-x[i];
        long yy = y[i+1]-y[i];
        if(abs(xx+yy)>tt || (xx+yy-tt)%2!=0) {
            printf("No\n"); return 0;
        }
    }
    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 2560
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from collections import deque

def main():
    s = IS()
    dq = deque()
    dq.append(s[0])
    cnt = 0
    for i in range(1, len(s)):
        if len(dq) == 0: dq.append(s[i]); continue
        a = dq[-1]
        b = s[i]
        if a == b: dq.append(b)
        else: dq.pop(); cnt += 2
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4204
D = int(input())
C = list(map(int,input().split()))
 
s = [[] for _ in range(D)]
last = [0]*26
 
for i in range(D):
    s[i] = list(map(int,input().split()))

def evaluation(d, x, y, z):
    P = [0]*26
    for i in range(26):
        P[i] += x[i]
        for j in range(26):
            if i == j:
                continue
            P[i] -= z[j] * (d+1 - y[j])
    return P.index(max(P))
 
 
for d in range(D):
    d_maxP = evaluation(d, s[d], last, C)
    last[d_maxP] = i+1
    print(d_maxP + 1)

Measured memory_bytes: 9484
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};


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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

int main(void){
  string S;
  cin >> S;
  ll cntS = 0;
  ll loseT = 0;
  rep(i, S.size()){
    if(S[i] == 'S'){
      cntS++;
    }else{
      if(cntS){
        cntS--;
        loseT++;
      }
    }
  }
  cout << S.size() - loseT * 2 << endl;

}


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

ll alph[26];

int main(){
    string s;
    cin >> s;
    ll n = s.size();
    rep(i, n){
        int p = (s[i] -'a');
        alph[p]++;
    }

    ll res = 0;
    rep(i, 26){
        res += alph[i] * (alph[i] - 1) / 2;
    }
    cout << n * (n - 1) / 2 - res + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
from collections import Counter
    
n = int(input())
v = list(map(int, input().split()))
odd = v[::2]
even = v[1::2]
    
c_even = Counter(even).most_common(2)
c_odd = Counter(odd).most_common(2)

    
if(c_even[0][0] != c_odd[0][0]):
    print(n - c_even[0][1] - c_odd[0][1])
else:
    if(len(c_even) == 1):
        print(n//2)
    else:
        second = max([c_even[1][1], c_odd[1][1]])
        print(n - c_even[0][1] - second)

Measured memory_bytes: 15972
#include<stdio.h>
int main()
{
	int n,t=0,x=0,y=0;
	for(scanf("%d",&n);n>0;n--)
	{
		int t0,x0,y0;
		scanf("%d%d%d",&t0,&x0,&y0);
		int dt=t0-t,dx=x0-x,dy=y0-y;
		if(dx+dy>dt || (dt-dx-dy)%2)
		{
			puts("No");
			return 0;
		}
		t=t0;x=x0;y=y0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;
	int ans[123456];
	ans[0] = 0;
	for (int i = 1; i < s.size(); i++) {
		ans[i] = ans[i - 1];
		if (s[i - 1] == 'A'&&s[i] == 'C')ans[i]++;
	}
	for (int i = 0; i < q; i++) {
		int l, r; cin >> l >> r;
		l--; r--;
		cout << ans[r] - ans[l] << endl;
	}
}

Measured memory_bytes: 1792
#include<stdio.h>
#define N 100

int main(){
  int num,i,j,temp=0;
  int Bubble[N];
  int count=0,flag=0;
  

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&Bubble[i]);
  }

  flag=1;
  while(flag){
    flag=0;
    for(j=num-1;j>0;j--){
      if(Bubble[j]<Bubble[j-1]){
	temp=Bubble[j];
	Bubble[j]=Bubble[j-1];
	Bubble[j-1]=temp;
	count++;
	flag=1;
      }
    }
  }
  
  for(i=0;i<num-1;i++){
    printf("%d ",Bubble[i]);
  }
  
  printf("%d\n%d\n",Bubble[num-1],count);
  return 0;
}



Measured memory_bytes: 2140
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::*;
use std::collections::*;

const NOTHING: usize = std::usize::MAX;

fn main() {
    let (n, lim): (usize, i64) = readln();
    let a: Vec<i64> = readln();

    let mut k = NOTHING;
    for i in 0..n - 1 {
        if a[i] + a[i + 1] >= lim {
            k = i;
            break;
        }
    }

    let mut res = Vec::with_capacity(n - 1);
    if k == NOTHING {
        println!("Impossible")
    } else {
        for i in 0..k {
            res.push(i);
        }
        for i in (k + 1..n).rev() {
            res.push(i - 1);
        }
        let strs: Vec<String> = res.iter().map(|x| (x + 1).to_string()).collect();
        println!("Possible\n{}", strs.join("\n"));
    }
}


fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_string()
}

fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

trait Read {
    fn read(s: &str) -> Self;
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}


Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << 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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll d;
  cin >> d;
  vl c(27);
  for(ll i=1;i<=26;i++){
    cin >> c[i];
  }
  vll s(d + 1, vl(27));
  for (ll i = 1; i <= d;i++){
    for (ll j = 1; j <= 26;j++){
      cin >> s[i][j];
    }
  }
  vl last(27, 0);
  ll satisfy = 0;
  for (ll i = 1; i <= d;i++){
    ll t;
    cin >> t;
    last[t] = i;
    satisfy += s[i][t];
    ll minus = 0;
    for (ll j=1; j <= 26;j++){
      minus += c[j] * (i - last[j]);
    }
    satisfy -= minus;
    print(satisfy);
  }
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>
#include <complex>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    int N;
    ll M;
    cin >> N >> M;
    vector<ll> A, S;
    rep(i, 0, N) {
      ll a;
      cin >> a;
      A.pb(a);
    }
    
    sort(all(A));
    S.pb(0);
    rep(i, 1, N+1) {
      S.pb(S[i-1]+A[i-1]);
    }
    
    ll l = 0, r = 2000000;
    while (r-l>1) {
      ll m = (r+l)/2;
      ll c = 0;
      rep(i,0, N) {
        ll t = A.en - lower_bound(all(A), m - A[i]);
        c += t;
      }
      if (c<M) r = m;
      else l = m;
    }
    
    
    ll c = 0;
    ll sn = (ll)sz(S);
    rep(i,0, N) {
      auto itr = lower_bound(all(A), l - A[i]);
      int p = itr - A.bg;
      ll num = A.en-itr;
      ans += S[sn-1] - S[p] + A[i]*num;
      c += num;
    }
    

    ans -= (c-M)*l;
  
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5612
// https://atcoder.jp/contests/agc047/tasks/agc047_a
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

// namespace mp = boost::multiprecision;
// using cpp_dec = mp::cpp_dec_float_50;
// using cpp_int = mp::cpp_int;
using namespace std;

#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define Aint(obj) (obj).begin(), (obj).end()
#define AintR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<pair<int, int>, int> cnt;
    REP(i, N) {
        // cpp_dec x;
        // cin >> x;
        // int t = static_cast<int>(x * 1e9);
        long double x;
        cin >> x;
        int t = llround(x * 1e9);
        // 2で割り切れる回数、5で割り切れる回数
        pair<int, int> p = {-9, -9};
        while (t % 2 == 0) {
            t /= 2;
            p.first++;
        }
        while (t % 5 == 0) {
            t /= 5;
            p.second++;
        }
        cnt[p]++;
    }
    // mapだと要素指定のアクセスができないのでvectorへ変換
    vector<pair<int, int>> ps;
    vector<int> cs;
    for (auto w : cnt) {
        ps.emplace_back(w.first);
        cs.emplace_back(w.second);
    }

    int ans = 0;
    REP(i, ps.size()) {
        pair<int, int> p = ps[i];
        if (p.first >= 0 && p.second >= 0) {
            ans += cs[i] * (cs[i] - 1) / 2;
        }
        REP(j, i) {
            if (p.first + ps[j].first >= 0 && p.second + ps[j].second >= 0) {
                ans += cs[i] * cs[j];
            }
        }
    }

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


Measured memory_bytes: 3748
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
char s[500010];
int a[500020],n,b[500020];
int check(int c)
{
	//printf("--------------------------\n");
	//printf("%d\n",c);
	memcpy(a,b,sizeof(a));
	int ans=0,len=0;
	while(c) a[++len]+=c%10,c/=10;
	for(int i=1;i<=max(len,n)+1;i++)
	{
		if(a[i]>9) a[i]-=10,a[i+1]+=1;
		ans+=a[i];
	}
	//printf("%d\n",ans);
	return ans;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++) b[n-i+1]=s[i]-'0',b[n-i+1]*=9;
	//for(int i=n;i>=1;i--) printf("%d ",b[i]);puts("");
	n+=9;for(int i=1;i<=n;i++) b[i+1]+=b[i]/10,b[i]%=10;
	int l=1,r=1e8,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid)<=mid) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d",ans%9==0?ans/9:ans/9+1);
}

Measured memory_bytes: 4608
use proconio::input;

#[proconio::fastout]
pub fn main() {
    input! {
    n:usize,
    k:usize,
    a:[usize;n],
    }
    for i in k..n {
        if a[i] > a[i - k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 5640
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,m;
  cin >> n >> m;
  
  int a[n] = {};
  
  REP(i,m){
    int x,y;
    cin >> x >> y;
    a[--x]++;
    a[--y]++;
  }
  
  REP(i,n){
    cout << a[i] << endl;
  }

  return 0;
}

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

Measured memory_bytes: 256
n,x,y=map(int,input().split())

c=min(x,y)-1
d=max(x,y)-1

e=[0]*n

for i in range(n):
    for j in range(i+1,n):
        a=j-i
        if i<c and d<j:
            b=c-i+j-d+1
        elif c<=i and d<j:
            b=i-c+j-d+1
        elif i<c and j<=d:
            b=c-i+d-j+1
        elif c<=i and j<=d:
            b=i-c+d-j+1
        t=min(a,b)
        #print(i,j,t)
        e[t]+=1
for f in e[1:]:
    print(f)

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

#define N 100

int n;

int main()
{
	int ans = 0;

	cin >> n;
	vector< pair<int, int> > r(n);
	vector< pair<int, int> > b(n);

	for( int i = 0; i < n; i++ ) {
		cin >> r[i].first >> r[i].second;
	}
	for( int i = 0; i < n; i++ ) {
		cin >> b[i].first >> b[i].second;
	}

	sort( r.begin(), r.end() );
	sort( b.begin(), b.end() );
	vector<bool> use(n, false);
	for( int i = 0; i < n; i++ ) {
		int ma = -1;
		int idx = -1;
		for( int j = 0; j < n; j++ ) {
			if( use[j] ) {
				continue;
			}
			if( b[i].first > r[j].first && b[i].second > r[j].second ) {
				if( ma < r[j].second ) {
					ma = r[j].second;
					idx = j;
				}
			}
		}
		if( idx != -1 ) {
			use[idx] = true;
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    vector<vector<int>> d(26, vector<int>(26, 0));
    for (int j = 0; j < 26; j++){
      for (int k = 0; k < 26; k++){
        d[j][k] += s[i][j];
        d[j][k] += c[j] * (i - last[j]) * 2;
        if (i < D - 1){
          d[j][k] += s[i + 1][k];
          d[j][k] += c[k] * (i - last[k] + 1);
        }
      }
    }
    int a = 0, b = 0;
    if (i % 2 == 0){
      for (int j = 0; j < 26; j++){
        for (int k = 0; k < 26; k++){
          if (d[j][k] > d[a][b]){
            a = j;
            b = k;
          }
        }
      }
    } else {
      for (int j = 25; j >= 0; j--){
        for (int k = 25; k >= 0; k--){
          if (d[j][k] > d[a][b]){
            a = j;
            b = k;
          }
        }
      }
    }
    cout << a + 1 << endl;
    last[a] = i;
  }
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   if(n%2==0) {
      cout << n/2 << endl;
   } else {
      cout << n/2+1 << endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    queue<pair<int,int> >q;
    int vis[50][50];
    int dis[50][50];
    vector<string>v;
    int main()
    {
        fastread;
        int n,i,j,k,l,m;
        cin>>n>>m;
        for(i=1;i<=n;i++)
        {
        	string s;
        	cin>>s;
        	v.pb(s);
		}
		int maxim=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				if(v[i][j]=='.'){
					for(int zz=0;zz<n;zz++){
						for(int kk=0;kk<m;kk++){
							vis[zz][kk]=0;
							dis[zz][kk]=0;
						}
					}
					q.push({i,j});
					vis[i][j]=1;
					while(!q.empty()){
						int kola=q.front().fi;
						int mola=q.front().se;
						q.pop();
						if(kola-1>=0&&vis[kola-1][mola]==0&&v[kola-1][mola]=='.'){
							q.push({kola-1,mola});
							vis[kola-1][mola]=1;
							dis[kola-1][mola]=dis[kola][mola]+1;
						}
							if(kola+1<n&&vis[kola+1][mola]==0&&v[kola+1][mola]=='.'){
							q.push({kola+1,mola});
							vis[kola+1][mola]=1;
							dis[kola+1][mola]=dis[kola][mola]+1;
						}
							if(mola-1>=0&&vis[kola][mola-1]==0&&v[kola][mola-1]=='.'){
							q.push({kola,mola-1});
							vis[kola][mola-1]=1;
							dis[kola][mola-1]=dis[kola][mola]+1;
						}
							if(mola+1<m&&vis[kola][mola+1]==0&&v[kola][mola+1]=='.'){
							q.push({kola,mola+1});
							vis[kola][mola+1]=1;
							dis[kola][mola+1]=dis[kola][mola]+1;
						}
					}
					int maxi=0;
					for(int bb=0;bb<n;bb++){
						for(int cc=0;cc<m;cc++){
							maxi=max(dis[bb][cc],maxi);
						}
					}
					maxim=max(maxi,maxim);
				}
			}
		}
		cout<<maxim;
    	return 0;
    }

Measured memory_bytes: 256
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if min(a,b,c,d,e)>=n:
  print(5)
else:
  print((n+min(a,b,c,d,e)-1)//min(a,b,c,d,e)+4)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define INF 1e9+5
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)
		cin>>a[i][j];
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			if(j==0)
			a[i][j]+=max(a[i-1][1],a[i-1][2]);
			else if(j==1)
			a[i][j]+=max(a[i-1][0],a[i-1][2]);
			else
			a[i][j]+=max(a[i-1][0],a[i-1][1]);
		}
	}
	cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int V,E,ans;
ll edge[64];
ll sum_edge[64];
void MDS(int cur,int cost,ll mask){
	if(cost>=ans)return;
	if(mask==(1LL<<V)-1){
		ans=min(ans,cost);
		return;
	}
	if(cur>=V)return;
	//if((mask|sum_edge[cur])!=(1LL<<V)-1)return;
	MDS(cur+1,cost,mask);
	MDS(cur+1,cost+1,mask|edge[cur]);
}
int main(){
	while(cin>>V>>E,V){
		memset(edge,0,sizeof(edge));
		memset(sum_edge,0,sizeof(sum_edge));
		for(int i=0;i<V;i++)edge[i]|=(1LL<<i);
		for(int i=0;i<E;i++){
			int A,B;
			cin>>A>>B;
			edge[A]|=(1LL<<B);
			edge[B]|=(1LL<<A);
		}
		for(int i=V-1;i>=0;i--) sum_edge[i] |= edge[i];
		for(int i=V-2;i>=0;i--) sum_edge[i] |= sum_edge[i+1];
		ans=1e9;
		MDS(0,0,0);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF (1LL<<59)

ll d[20][100][100];
vector<int> q[20];
vector<int> r[20];

ll f(ll dist,int c){
	if(dist==INF)return INF;
	ll ret=0;
	for(int i=1;;i++){
		if(q[c][i]<dist){
			ret+=(q[c][i]-q[c][i-1])*r[c][i-1];
		}
		else return ret+(dist-q[c][i-1])*r[c][i-1];
	}
}


int main(){
	int n,m,c,s,g;
	while(cin>>n>>m>>c>>s>>g&&(n||m||c||s||g)){
		rep(i,20)rep(j,100)rep(k,100)d[i][j][k]=INF;
		rep(i,m){
			int x,y,di,cam;
			cin>>x>>y>>di>>cam;
			x--,y--,cam--;
			d[cam][x][y]=min<ll>(di,d[cam][x][y]);
			d[cam][y][x]=min<ll>(di,d[cam][y][x]);
		}
		
		vector<int> b(c);
		rep(i,c)cin>>b[i];
		rep(i,c){
			q[i].resize(b[i]+1);
			q[i][0]=0, q[i][b[i]]=200000000;
			r[i].resize(b[i]);
			rep(j,b[i]-1)cin>>q[i][j+1];
			rep(j,b[i])cin>>r[i][j];
		}

		
		rep(p,20) rep(wk,n) rep(wi,n) rep(wj,n) d[p][wi][wj] = min(d[p][wi][wk]+d[p][wk][wj],d[p][wi][wj]);
		rep(p,20) rep(wi,n) rep(wj,n) d[p][wi][wj] = f(d[p][wi][wj],p);
		
		ll pass[100][100];
		rep(i,100)rep(j,100)pass[i][j]=INF;
		rep(wi,n) rep(wj,n) rep(p,20) pass[wi][wj] = min(pass[wi][wj],d[p][wi][wj]);
		
		rep(wk,n) rep(wi,n) rep(wj,n) pass[wi][wj] = min(pass[wi][wk]+pass[wk][wj],pass[wi][wj]);
		
		if(pass[s-1][g-1]==INF)cout<<-1<<endl;
		else cout<<pass[s-1][g-1]<<endl;
	}
}

Measured memory_bytes: 4716
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

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



int main(void) {

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

  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK\n";
      return 0;
    }

  }
  cout << "NG\n";
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <ctype.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int   d[ 1024 ] = { 0 };
  char  b[ 128 ];
  int i;

  while ( isdigit ( fgets ( b, 128, stdin )[ 0 ] ) )
  {
    sscanf ( b, "%d", &i );
    d[ i ] = ( ( d[ i ] & 0x03 ) | 0x01 )
           | ( ( ( d[ i ] >> 2 ) + 1 ) << 2 );
  }
  while ( fgets ( b, 128, stdin ) != NULL )
  {
    sscanf ( b, "%d", &i );
    d[ i ] = ( ( d[ i ] & 0x03 ) | 0x02 )
           | ( ( ( d[ i ] >> 2 ) + 1 ) << 2 );
  }

  for ( i = 0; i < 1024; ++i )
  {
    if ( ( d[ i ] & 0x03 ) != 0x03 ) continue ;
    printf ( "%d %d\n", i, d[ i ] >> 2 );
  }

  return ( 0 );
}

Measured memory_bytes: 0