akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

struct Node {
    int key;
    Node *left,*right,*parent;
};

Node *gRoot,*NIL;

void insert(int value){
    Node *y = NIL;
    // 親
    Node *x = gRoot;
    // 自身
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = value;
    z->left = NIL;
    z->right = NIL;
    
    // rootから自身を挿入する場所を探す
    while(x != NIL){
        // rootから検索
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    // 親に子を持たせる
    if(y == NIL){
        gRoot = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}
// 先行順巡回
void preOrder(Node *u){
    if(u == NIL)return;
    printf(" %d",u->key);
    preOrder(u->left);
    preOrder(u->right);
}

// 中間順巡回
void inOrder(Node *u){
    if(u == NIL)return;
    inOrder(u->left);
    printf(" %d",u->key);
    inOrder(u->right);
}

int main(){
    int n,x;
    string com;
    
    cin >> n;
    for(int i = 0;i < n;++i){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }
        else if(com == "print"){
            inOrder(gRoot);
            cout << "\n";
            preOrder(gRoot);
            cout << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 26656
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, p;
	while (cin >> n >> p && n) {
		vector<int> line(n, 0);
		int hn = 0;
		for (int i = 0; i < n; ++i) {
			line[i] = p / n + (p%n > i ? 1 : 0);
			if (line[i])++hn;
		}
		int place = p % n;
		p = 0;
		while (true) {
			if (p == 0) {
				if (line[place])--hn;
				p = line[place];
				line[place] = 0;
			}
			else {
				if (line[place] == 0)++hn;
				++line[place];
				--p;
			}
			if (p == 0 && hn == 1) {
				cout << place << endl;
				break;
			}
			place = (place + 1) % n;
		}
	}
	return 0;
}


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

int main() {
    int N;
    cin>>N;
    vector<pair<long, long> > robots;
    long X, L;
    for(int i=0;i<N;++i){
        cin>>X>>L;
        robots.push_back(make_pair(X+L, X-L));
    }
    sort(robots.begin(), robots.end());
    int ans = 1;
    long ue = robots[0].first;
    for(int i=1;i<N;++i){
        if(robots[i].second >= ue){
            ans++;
            ue = robots[i].first;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define MaxLen 10003

const int Mod = 1e9 + 7;
char K[MaxLen];
int D, len, ans;
int f[2][105], a[MaxLen];

inline int inmod(int aa, int mo) {
	if(aa >= mo) aa %= mo;
	return aa;
}
inline void add(int &aa, int bb, int mo) {
	aa += bb;
	if(aa < Mod) aa += mo;
	if(aa > Mod) aa -= mo;
	return;
}

int main() {
	scanf("%s", K + 1), cin >> D;
	len = strlen(K + 1);
	for(reg int i = 1; i <= len; ++i)
		a[i] = K[i] - '0';
	for(reg int i = 0; i <= a[1]; ++i)
		++f[0][inmod(i, D)];
	int sum = a[1] % Mod;
	for(reg int i = 2; i <= len; ++i) {
		for(reg int j = 0; j < sum; ++j)
			for(reg int k = 0; k <= 9; ++k)
				add(f[1][inmod(j + k, D)], f[0][j], Mod);
		for(reg int k = 0; k <= 9; ++k) {
			if(k <= a[i])
				add(f[1][inmod(sum + k, D)], f[0][sum], Mod);
			else
				add(f[1][inmod(sum + k, D)], f[0][sum] - 1, Mod);
		}
		for(reg int j = sum + 1; j < D; ++j)
			for(reg int k = 0; k <= 9; ++k)
				add(f[1][inmod(j + k, D)], f[0][j], Mod);
		memcpy(f[0], f[1], sizeof f[0]), memset(f[1], 0, sizeof f[1]);
			sum = inmod(sum + a[i], D);
	}
	cout << f[0][0] - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
m = [list(map(int,input().split())) for i in range(q)]
count = [0]*(n+1)
 
for i in range(n):
    if s[i:i+2] == 'AC':
        count[i+1] = count[i] + 1
    else:
        count[i+1] = count[i]
 
for l,r in m:
    print(count[r-1]-count[l-1])

Measured memory_bytes: 30664
#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 a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') cout << a + b << endl;
    else if (op == '-') cout << a - b << endl;

    return 0;
}

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

int n;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    ll k = 0;
    int ans = 1;
    for (; k < n; ++ans) {
        k += ans;
    }
    cout << ans - 1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#define ll long long
using namespace std;
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x=b*d;
	ll y=b*c;
	ll z=a*c;
	ll w=a*d;
	cout<<fixed;
	cout<<setprecision(0)<<max(max(max(x,y),z),w)<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<set>
using namespace std;

int main() {
  int X,N,i,p;
  set<int> P;
  cin>>X>>N;
  for (i=0;i<N;i++) {
    cin>>p;
    P.insert(p);
  }
  int ans = X;
  if (P.count(X)) {
    for (i=1;i<=100;i++) {
      if (!P.count(X-i)) {
        ans = X-i;
        break;
      }
      if (!P.count(X+i)) {
        ans = X+i;
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, N) for(int i{};i<N;i++)
using namespace std;
int M = 1e9+7;
int p[100001][13];
string S;
int d(int n){
  return (13 + n%13)%13;
}
void f(int i, int j, int l){
  int k{};
  k = l + d(j*pow(10, i%3)) * pow(-1, i/3);
  (p[i+1][d(k)] += p[i][l]) %= M;
}
int main(){
  cin >> S;
  reverse(S.begin(), S.end());
  p[0][0] = 1;
  rep(i, S.size()) rep(l, 13){
    if(S[i] == '?') rep(j, 10) f(i, j, l);
    else f(i, S[i] - '0', l);
  }
  cout<<p[S.size()][5]<<"\n";
}

Measured memory_bytes: 5504
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll n, q;
	string s;

	cin >> n >> q;

	cin >> s;

	vecll l(q), r(q),dp(n);

	forll(i, 0, q)
		cin >> l[i] >> r[i];

	dp[0] = 0;

	forll(i, 1, n)
	{
		dp[i] = dp[i-1];
		if (s[i-1] == 'A'&&s[i] == 'C')
		{
			dp[i]++;
		}
	}

	forll(i,0,q)
		cout << dp[r[i]-1]-dp[l[i]-1] << "\n";
}


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

int main(){
    int a,b;
    cin >> a>>b;
    if (a >b){
        cout << "a > b" << endl;
    } 
    if (a == b){
        cout << "a == b" << endl;
    }
    if ( a < b){
        cout << "a < b" << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m;
    cin >> n >> m;
    if(m==1||n>=m){
        cout << "0" << endl;
        return 0;
    }
    vector<int>x(m);
    vector<pair<int,int>>dist;
    for(int i=0;i<m;i++){
        cin >> x.at(i);
        x.at(i)+=100000;
    }
    sort(x.begin(),x.end());
    for(int i=1;i<m;i++){
        int dif=x.at(i)-x.at(i-1);
        dist.push_back(make_pair(dif,i));
    }
    sort(dist.begin(),dist.end());
    reverse(dist.begin(),dist.end());
    vector<int>koma(n);
    koma[0]=-1;
    for(int i=0;i<n-1;i++){
        koma[i+1]=dist[i].second-1;
    }
    sort(koma.begin(),koma.end());
    int ans=0;
    for(int i=1;i<n;i++){
        ans+=x[koma[i]]-x[koma[i-1]+1];
    }
    ans+=x[m-1]-x[koma[n-1]+1];
    cout << ans << endl;
}


Measured memory_bytes: 4644
def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


Q, H, S, D = readmap()
N = read()

ls = [4 * Q, 2 * H, S]
idx = ls.index(min(ls))

if idx == 0:
    S = 4 * Q
elif idx == 1:
    S = 2 * H

if 2 * S <= D:
    print(S * N)
else:
    print((N // 2) * D + (N % 2) * S)


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

int n, a[100010];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	long long ans_1 = 0, ans_2 = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			ans_2 = ans_1;
			ans_1 = a[i];
			if (i != n - 2)
				i += 1;
		}
	}
	cout << ans_1 * ans_2 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main (void){
  char rowCol[100000][50];/*行列*/
  int numRow,numCol;
  int i,j,k,l;
  int rowColNum[100000][51]={0};
  
  if(scanf("%d %d\n",&numRow,&numCol));
  
  for(i=0;i<numRow;i++){
      if(scanf("%s\n",rowCol[i])); 
  }
  
  //for(i=0;i<numRow;i++){
      //printf("i=%d row[i]=%s\n",i,&rowCol[i]);/*(注意)star型の時は、&をつけ出力*/
  //}
  
  for(i=0;i<numRow;i++){
    for(j=0;j<numCol;j++){      
      //printf("%s",&rowCol[i][j]);      
      //rowCol[i][j] == "#"
      
      //if(strncmp(".",&rowCol[k][l],1)==0){
         //rowColNum[i][j] = 0;  
      //}
      if(strncmp("#",&rowCol[i][j],1)==0){
         rowColNum[i][j] = 9;
         for(k=i-1;k<=i+1;k++){
           for(l=j-1;l<=j+1;l++){ 
             if(k==i&&l==j || rowColNum[k][l]==9){
               continue;
             }
             rowColNum[k][l] += 1;
      	   }
         }
      }
         
    }    
  }
    //printf("i=%d %s\n",i,&rowCol[i]);
  
    
  //for(i=0;i<numRow;i++){
      //printf("i=%d row[i]=%s\n",i,rowCol[i]);/*(注意)star型の時は、&をつけ出力*/
  //}
  
  for(i=0;i<numRow;i++){
    for(j=0;j<numCol;j++){
      if(rowColNum[i][j]==9){
        printf("#");
        continue;
        //rowColNum[i][j] = "#";  
      }
      else{
        printf("%d",rowColNum[i][j]);
      }
      //rowCol[i][j] = (char)rowColNum[i][j];
    }
    printf("\n");
  }
  //printf("rowCol=%s",rowColNum[0]);
  
  //for(i=0;i<numRow;i++){
      //printf("i=%d row[i]=%s\n",i,rowCol[i]);/*(注意)star型の時は、&をつけ出力*/
  //}
    
  return 0;
}

Measured memory_bytes: 22016
#include <bits/stdc++.h>
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    char a;
    cin >> a;
    if('a'==a||'i'==a||'u'==a||'e'==a||'o'==a)pr("vowel");
    else pr("consonant");
}

Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7;

void solve() {
    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No");
}
/*
*/
main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000000000;
vector<int> integer_to_vector(int bit, int n){
  vector<int> S;
  for(int i=0;i<n;i++){
    if(bit & (1<<i)){
      S.push_back(i);
    }
  }
  return S;
}

int main(){
  int N,M;
  ll X;
  cin >> N >> M >> X;
  vector<ll> C(N);
  vector<vector<ll>> A(N,vector<ll>(M));
  for(int i=0;i<N;i++){
    cin >> C.at(i);
    for(int j=0;j<M;j++){
      cin >> A.at(i).at(j);
    }
  }
  
  ll min=inf;
  for(int bit=0;bit<(1<<N);bit++){
    vector<int> S(N);
    S = integer_to_vector(bit,N);
    vector<ll> understand(M,0);
    ll cost=0;
    for(int e : S){
      for(int i=0;i<M;i++){
        understand.at(i) += A.at(e).at(i);
      }
      cost += C.at(e); 
    }
    
    bool achieve = true;
    for(int i=0;i<M;i++){
      if(understand.at(i) < X){
        achieve = false;
      }
    }
    
    if(achieve && cost < min){
      min = cost;
    }
  }
  
  if(min == inf){
    cout << "-1" << endl;
  }else{
    cout << min << endl;
  }
   
  return(0);
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int H, W, K;
vector<string> s;

int main(void) {
    cin >> H >> W >> K;

    rep(y, H) {
        string ss;
        cin >> ss;
        s.push_back(ss);
    }

    vector<vector<int>> ans(H, vector<int>(W, 0));
    int cutIdx = 1;
    for (int y = 0; y < H; ++y) {
        int lx = -1;
        for (int x = 0; x < W; ++x) {
            if (s[y][x] == '#') {
                // そこまでを全部島にする
                for (int xx = lx + 1; xx <= x; ++xx) {
                    ans[y][xx] = cutIdx;
                }
                lx = x;
                cutIdx++;
            }
            else {
                // もうそのラインで誰か見つかっているとき
                if (lx >= 0) {

                    ans[y][x] = ans[y][lx];
                }
                else {
                    if (y > 0) {
                        ans[y][x] = ans[y - 1][x];
                    }
                }
            }
        }
    }

    // 先頭行の処理
    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (ans[y][x] != 0) {
                for (int yy = y; yy >= 0; --yy) {
                    ans[yy][x] = ans[y][x];
                }
                break;
            }
        }
    }

    rep(y, H) {
        rep(x, W) {
            cout << ans[y][x];
            if (x != W - 1) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
import scala.io.StdIn._
import scala.util.control.Breaks
object Main extends App {
  val k = readLine.trim.split(' ').map(_.toInt).apply(0)
  val Array(a, b) = readLine.trim.split(' ').map(_.toInt)

  val break = new Breaks
  var is_find = false
  break.breakable{
    (a/k to b/k+1).foreach(i => {
      val ki = k*i
      if(a <= ki && ki <= b){
        is_find = true
        break.break()
      }
    })
  }

  println(if(is_find) "OK" else "NG")
}


Measured memory_bytes: 54884
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int[] h = new int[100000001];
		boolean flag=false;
		for(int i=0;i<n;i++) {
			h[i]=sc.nextInt();
			if( i!=0 && h[i]>h[i-1] ) {
					h[i]--;
			}
		}
		for(int i=0;i<n;i++) {
			if(i!=0 && h[i]<h[i-1]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


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

for i in range(m):
    l, r=map(int, input().split())
    if i==0:
        l_big=l
        r_min=r
    else:
        if l_big<l:
            l_big=l
        if r_min>r:
            r_min=r
if r_min-l_big+1>=0:
    print(r_min-l_big+1)
else:
    print(0)


Measured memory_bytes: 45288
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
ll a[101][3],dp[101][100009];
int n,w;
ll f(int item,int wight){
    if (item==n+1)
        return 0;
    if (wight<a[item][1])
        return f(item+1,wight);
    if (dp[item][wight]!=-1)
        return dp[item][wight];
    return dp[item][wight]=max(a[item][2]+f(item+1,wight-a[item][1]),f(item+1,wight));
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    map<char,int>m;
    m[s[0]]++,m[s[1]]++,m[s[2]]++;
    if (m['a']&&m['b']&&m['c'])
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


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

using namespace std;

long double dp[301][301][301];
bool vis[301][301][301];
int n;

long double calc(int a, int b, int c) {
    if (a < 0 || b < 0 || c < 0) return 0;
    if (vis[a][b][c]) return dp[a][b][c];
    vis[a][b][c] = 1;
    long double apb = a, bpb = b, cpb = c, tot = a + b + c;
    if (tot == 0) return 0;
    apb /= tot; bpb /= tot; cpb /= tot;
    // p is probability of hitting one
    // S = p * 1 + q * p * 2 + ...
    // p * S = p + q * p + q^2 * p + ...
    // p * S = p / p, S = 1 / p
    dp[a][b][c] = n; dp[a][b][c] /= tot;
    dp[a][b][c] += apb * calc(a - 1, b, c) + bpb * calc(a + 1, b - 1, c) + cpb * calc(a, b + 1, c - 1);
    return dp[a][b][c];
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    int cnt[3]; for (int i = 0; i < 3; i++) cnt[i] = 0;
    for (int i = 0; i < n; i++) {
        int c; cin >> c;
        cnt[--c]++;
    }
    cout << fixed << setprecision(10) << calc(cnt[0], cnt[1], cnt[2]);
    return 0;
}


Measured memory_bytes: 452992
import java.util.*;

public class Main{
	public static void main(String args[]){
		int N,result;
		Scanner sc=new Scanner(System.in);
		N=Integer.parseInt(sc.next());
		result=N;
		if(N%2==1)result+=1;
		while(result%N!=0){
			result+=2;
		}
		System.out.println(result);
	}
}
		


Measured memory_bytes: 22996
package main

import(
	"fmt"
)

func getMinInt(numbers ...int) int {
	var min int
	min = numbers[0]
	for _, v := range numbers {
		if v < min {
			min = v
		}
	}
	return min
}

func getMaxInt(numbers ...int) int {
	var max int
	max = numbers[0]
	for _, v := range numbers {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)
	ab := getMinInt(a+b, 2*c)
	cost := 1 << 31
	for i := 0; i < 100001; i++ {
		cost = getMinInt(cost, i*ab+getMaxInt(0, x-i)*a+getMaxInt(0, y-i)*b)
	}
	fmt.Println(cost)
}


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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef pair <ll ,ll> pll;
typedef pair <int ,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 2e5 + 2;
const double PI = 3.141592653589 , eps = 1e-8;


void solve(){
    string s; cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i += 2){
        if (i + 1 >= n || s.substr(i , 2) != "hi"){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #endif
    cout.precision(20);

    for (int t = 1; t--;) solve();

    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


Measured memory_bytes: 256
from bisect import bisect_left

def LIS(arr):
    n = len(arr)
    lis = [arr[0]]
    for a in arr:
        if a > lis[-1]:
            lis.append(a)
        else:
            lis[bisect_left(lis,a)] = a
    return len(lis)

import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

print(LIS(A))


Measured memory_bytes: 10356
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int N = 411111;
vector<int> a[N];

int main() {
	int n = nxt(), m = nxt();
	for (int i = 0; i < m; ++i) {
		int u = nxt() - 1, v = nxt() - 1;
		a[u].push_back(v + n);
		a[v].push_back(u + n);
		a[u + n].push_back(v);
		a[v + n].push_back(u);
	}

	long long ans = 0;

	int cl = 0;
	vector<int> used(n + n, 0);
	for (int i = 0; i < n; ++i) {
		if (used[i]) {
			continue;
		}
		vector<int> st = {i};
		++cl;
		used[i] = 2 * cl;
		int cnt_ev = 0, cnt_od = 0;
		while (!st.empty()) {
			int v = st.back();
			st.pop_back();
			if (used[v] % 2) {
				cnt_od += 1;
			} else {
				cnt_ev += 1;
			}
			for (int x : a[v]) {
				if (used[x]) {
					continue;
				}
				// cerr << v + 1 << " <-> " << x + 1 << "\n";
				used[x] = 4 * cl - 1 - used[v];
				st.push_back(x);
			}
		}
		// cerr << cnt_od << " " << cnt_ev << "\n";
		ans += cnt_od * 1ll * cnt_ev;
	}

	for (int i = 0 ; i < n; ++i) {
		if ((used[i] - 1) / 2 == (used[i + n] - 1) / 2) {
			--ans;
		}
	}

	cout << ans / 2 - m << "\n";

	return 0;
}

Measured memory_bytes: 17152
let N = Int(readLine()!)!

let a = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }
let b = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }
let c = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }

var ret = 0

for i in 0..<a.count {
  ret += b[a[i] - 1]
  if (i != 0) && (a[i] == a[i - 1] + 1) {
    ret += c[a[i - 1] - 1]
  }
}

print(ret)


Measured memory_bytes: 4208
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

char word[100];
int cnt[1000];
int glbl[1000];

int main()
{
	int n;
	scanf("%d", &n);
	
	int fl = 0;
	while (n--) {
		scanf("%s", word);
		for (int i = 'a'; i <= 'z'; i++) cnt[i] = 0;
		for (int i = 0; word[i]; i++) cnt[word[i]]++;
		for (int i = 'a'; i <= 'z'; i++) glbl[i] = (fl == 0 ? cnt[i] : MIN(glbl[i], cnt[i]));
		fl = 1;
	}

	for (int i = 'a'; i <= 'z'; i++) {
		for (int j = 1; j <= glbl[i]; j++) printf("%c", i);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>c>>b>>c;
  if(a!=b) cout<<1<<endl;
  else cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
using namespace std;
 int is_prime( long long int n)
{
    if(n==2){ return 1;}
    else{ for(int i=2;i*i<=n;i++)
        {
            if( n%i ==0){ return 0;
            break;
            }
        }
    }
    return 1;
}
int main()
{
    int a,b;
    cin>>a>>b;
    int q=b*10;
    bool f1=1;
    for(int i=q;i<q+10;i++){
        if((i*2)/25==a){
            cout<<i;
            f1=0;
            break;
        }
    }
    if(f1)cout<<"-1";
}


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

using namespace std;

const int MOD = 1e9 + 7;

int cnt[1000005];

int main() {
	int n;
	scanf("%d", &n);
	
	cnt[0] = 3;
	
	long long res = 1LL;
	
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		x++;
		
		res = (res * cnt[x - 1]) % MOD;
		cnt[x - 1]--;
		cnt[x]++;
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 640
using Microsoft.VisualBasic.CompilerServices;
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            int[] F = new int[] {3,5,7};
            foreach(var f in F)
            {
                DFS(f,false);
            }
            Console.WriteLine(cnt);
        }
        static public int n,y;
        static public int cnt=0;
        static public void DFS(long v,bool flag)
        {
            if (v > n) return;
            if (flag || Chk(v)) { cnt++; flag = true; }
            else flag = false;
            DFS(10 * v + 3, flag);
            DFS(10 * v + 5, flag);
            DFS(10 * v + 7, flag);
        }
        static public bool Chk(long v)
        {
            if (v < 357) return false;
            bool three=false, five=false,seven=false;
            while (v > 0)
            {
                int a =(int)( v % 10);
                if (a == 3) three = true;
                if (a == 5) five = true;
                if (a == 7) seven = true;
                v /= 10;
            }
            if (three && five && seven) return true;
            else return false;
        }
    }
}


Measured memory_bytes: 27520
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int W[10],K[10];
  int score1=0,score2=0;
  for(int i=0;i<10;i++){
    cin >>W[i];
  }
  for(int i=0;i<10;i++){
    cin >>K[i];
  }
  
  sort(W,W+10);
  sort(K,K+10);

  for(int i=9;i>6;i--){
    score1+=W[i];}
  cout <<score1<<" ";
  for(int i=9;i>6;i--){
   score2+=K[i];}
  cout <<score2<<endl;
  return 0;
}

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

using namespace std;
using vi = vector<int>;

const int AMAX = 1e6 + 11;

int main(void)
{
    int n;
    vi  a, freq;
    cin >> n;

    a.resize(n);

    for (auto &ai : a)
        cin >> ai;

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

    freq.resize(AMAX);

    freq[a[0]]++;

    int ans = a[0] != a[1];
    for (int i = 1; i < n; ++i)
    {
        bool ok = true;
        if (i < n - 1 and a[i] == a[i + 1])
            ok = false;
        if (ok)
        {
            for (int d = 1; d * d <= a[i]; ++d)
            {
                if (a[i] % d == 0)
                {
                    if (freq[d] or freq[a[i] / d])
                    {
                        ok = false;
                        break;
                    }
                }
            }
        }
        ans += ok;
        freq[a[i]]++;
    }

    cout << ans << endl;

    return 0;
}


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


int main(){
  string S;
  cin >> S;

  
  int dis = 1000000;
  string str = S;
  for(int i = 0; i < S.size(); i++){
    str = S;
   string substr = str.substr(i,3);

   int num;
   num = stoi(substr);
   if(dis > abs(753 - num)){ dis = abs(753 - num); }

  }

  cout << dis << endl;
  return 0;
}


Measured memory_bytes: 256
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
// }}}

// misc {{{
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
// }}}

// debug(...) {{{
static bool debug_enabled = false;
static int debug_max_elms = 10;

static int debug_max_count = 50;
static int debug_current_count = 0;

void debug1(char const * x) { cout << x; }
template<class T> void debug1(const T& x) { cout << x; }
template<class T1, class T2> void debug1(const pair<T1, T2>& x) { cout << "(" << x.first << ", " << x.second << ")"; }
template<class T> void debug1(const vector<T>& x) {
  cout << "[";
  auto i = x.begin();
  while(i != x.end()) {
    debug1(*i);
	++i;
	if(i != x.end()) cout << ", ";
    if(std::distance(x.begin(), i) > debug_max_elms) {
      cout << "...";
      break;
    }
  }
  cout << "]";
}
template<class K, class V> void debug1(const map<K, V>& x) {
  cout << "{";
  auto i = x.begin();
  while(i != x.end()) {
    debug1(get<0>(*i));
    cout << ": ";
    debug1(get<1>(*i));
    ++i;
    if(i != x.end()) cout << ", ";
  }
  cout << "}";
}

void debug2() { cout << endl; }
template<class T, class... Ts> void debug2(const T& x, const Ts&... xs) {
  cout << ' ';
  debug1(x);
  debug2(xs...);
}

template<class T, class... Ts> void debug(const T& x, const Ts&... xs) {
  if(debug_enabled) {
    ++debug_current_count;
    if(debug_current_count > debug_max_count) debug_enabled = false;
	cout << "[D] ";
	debug1(x);
	debug2(xs...);
  }
}
// }}}

// main {{{
void solve();
int main() {
  auto v = getenv("DEBUG");
  if(v && string(v) == "1") debug_enabled = true;
  if(false) debug("dummy for suppress warnings", vector<int>(0));
  solve();
}
// }}}

void solve() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red";
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//int dx[] = { 1, -1 , 0 , 0 };
//int dy[] = { 0,  0,  1, -1 };
int dx[] = { 1, 0 };
int dy[] = { 0, 1 };
ll MOD = 1000000007;

unsigned long long str_to_int(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve(){
	string s;
	cin >> s;
	map<char,int> m;
	rep(i,s.length()){
		m[s[i]]++;
	}
	for(auto it = m.begin();it != m.end();it++){
		if(it->second % 2 != 0){
			P("No");
			return;
		}
	}
	P("Yes");
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s[3];
  for (int i = 0; i < 3; i++) cin >> s[i];
  
  int cur = 0;
  while (s[cur].size() > 0) {
    int next = s[cur][0];
    s[cur].erase(0, 1);
    switch (next) {
      case 'a':
        cur = 0;
        break;
      case 'b':
        cur = 1;
        break;
      case 'c':
        cur = 2;
        break;
    }
  }
  
  switch (cur) {
    case 0:
      cout << "A" << endl;
      break;
    case 1:
      cout << "B" << endl;
      break;
    case 2:
      cout << "C" << endl;
      break;
  }

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;



// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

vector<ll> num(1010);

int main(){
    ll n;
    cin>>n;

    if(n==1){
        cout<<1<<endl;
        return 0;
    }

    for(int i=2;i<=n;i++){
        auto pf=prime_factorize(i);
        for(auto e : pf) num[e.first]+=e.second;
    }

    ll ans=1;
    rep(i,1010){
        ans=(ans*(num[i]+1))%MOD;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
typedef pair<long long, double> pii;

long long q, h, s, d;
long long p[4];
vector<pii> price;
long long n;

int main(){
    cin >> q >> h >> s >> d;
    cin >> n;

    price.push_back(make_pair(q*8, 0.25));
    price.push_back(make_pair(h*4, 0.5));
    price.push_back(make_pair(s*2, 1.0));
    price.push_back(make_pair(d, 2.0));
    sort(price.begin(), price.end());

    long long sum = 0;
    if(price[0].second == 2.0){
        if((long long)n % 2==0){
            sum = n/2 * price[0].first;
        } else {
            sum = n/2 * price[0].first + price[1].first / 2;
        }
    } else {
        sum = n * price[0].first / 2;
    }

    cout << sum << endl;

    /*
    long long sum = 0;
    REP(i, 4){
        long long c = floor(n / price[i].second);
        sum += c * price[i].first * price[i].second / 2.0;
        n -= c * price[i].second;
    }
    cout << sum << endl;
    */
}


Measured memory_bytes: 256
package main

/*
最大・最小ヒープ
*/

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

func printHeap(heap []int) {
	var buf bytes.Buffer
	for i := 1; i < len(heap); i++ {
		buf.WriteString(fmt.Sprintf(" %d", heap[i]))
	}
	fmt.Println(buf.String())
}

func buildMaxHeap(heap []int) {
	size := len(heap) - 1
	startID := size / 2 // 最後尾の親
	for i := startID; i >= 1; i-- {
		maxHeapify(heap, i)
	}
}

func maxHeapify(heap []int, i int) {
	size := len(heap) - 1
	leftID := i * 2
	rightID := i*2 + 1

	largest := i
	if leftID <= size && heap[leftID] > heap[i] {
		largest = leftID
	}
	if rightID <= size && heap[rightID] > heap[largest] {
		largest = rightID
	}

	if largest != i {
		heap[i], heap[largest] = heap[largest], heap[i]
		maxHeapify(heap, largest)
	}
}

func main() {
	scanner := makeWordScanner()
	h := eGetInt(scanner)
	heap := append([]int{0}, make([]int, 0, h)...)
	for i := 0; i < h; i++ {
		heap = append(heap, eGetInt(scanner))
	}
	buildMaxHeap(heap)
	printHeap(heap)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	buf.WriteString("[")
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = ", "
	}
	buf.WriteString("]")
	return buf.String()
}

func reverse(a ints) ints {
	r := make(ints, len(a))
	for i := 0; i < len(a); i++ {
		r[i] = a[len(a)-1-i]
	}
	return r
}
func max(a ints) (int, bool) {
	if len(a) == 0 {
		return 0, false
	}
	m := a[0]
	for _, e := range a {
		if e > m {
			m = e
		}
	}
	return m, true
}
func min(a []int) int {
	m := a[0]
	for _, v := range a {
		if v < m {
			m = v
		}
	}
	return m
}

func sum(a ints) int {
	if len(a) == 0 {
		return 0
	}
	sum := 0
	for _, e := range a {
		sum += e
	}
	return sum
}
func find(n int, a ints) int {
	for i, v := range a {
		if n == v {
			return i
		}
	}
	return -1
}



Measured memory_bytes: 24248
#include<iostream>

using namespace std;

int main(){
 int K,X;
 cin >> K>>X;
 for(int i=0;i<K;i++){
   cout << X-K+i+1<<endl;
 }
 for(int i=1;i<K;i++){
   cout << X+i<<endl;
 }


 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==1&&b==1&&c==0){
		printf("Open\n");
	}
	else if(a==0&&b==0&&c==1){
		printf("Open\n");
	}
	else{
		printf("Close\n");
	}
}


Measured memory_bytes: 2612
#include <iostream>
#include <vector>
#include <cstring>
#include <string>

using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '?') s[i] = 'D';
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 3772
n = int(input())
p = [ int(i) for i in input().split()]
ans = 0

for j in range(n-2):
    if p[j] < p[j+1] and p[j+1] <= p[j+2]:
        ans += 1
    elif p[j] >= p[j+1] and p[j+1] > p[j+2]:
        ans += 1

print(ans) 


Measured memory_bytes: 2940
N = gets.to_i
AS = gets.split.map(&:to_i)

MAX = 2 * 10**5 * 10**9
dp = Array.new(2 * 10**5 + 1, MAX+1)

s = 0
a = AS.inject(:+)
diff = 0

index = 1
while i = AS.shift
  break if AS.empty?
  s += i
  a -= i
  dp[index] = (s - a).abs
  index += 1
end

puts(dp.min)

Measured memory_bytes: 16772
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n;
  cin>>n;
  vector<int>l(n);
  for(int i=0;i<n;i++)
    cin>>l[i];
  int ans=0;
  sort(l.begin(),l.end());
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]+l[j]>l[k]){
          if(l[i]!=l[j] && (l[j]!=l[k] && l[k]!=l[i]))
            ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int n,m,i,j,k,a,b,sum=0;
    scanf("%d%d",&n,&m);
    int array[n];
    int h[n];
    memset(h, 0 , sizeof(h));
    for( i = 0; i < n; i++)
    {
         scanf("%d",&array[i]);
    }

    for ( j = 0; j < m; j++)
    {
         scanf("%d%d",&a,&b);
         if(array[a-1]>array[b-1])
        {
            h[b-1]=1;
        }
        else if(array[b-1]>array[a-1])
        {
             h[a-1]=1;
        }
        else
        {
            h[b-1]=1;
             h[a-1]=1;
        }
        
        
        
    }
    for ( k = 0; k < n; k++)
    {
        if(h[k]==0)
       sum++;
    }
    
 printf("%d\n",sum);
    
    


    
    
       
   
}

Measured memory_bytes: 2508
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        m:usize,
        roads:[(usize,usize);m],
    }
    let mut ans:Vec<i32> = vec![0;n+1];
    for i in 0..m {
        let mut a = roads[i].0;
        let mut b = roads[i].1;
        ans[a] += 1;
        ans[b] += 1;
    }
    for i in 1..(n+1) {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n,m;
  cin >> n >> m;
  vint A(n-1+m),B(n-1+m);
  vvint to(n);
  vint in(n);
  vint dist(n,0);
  rep(i,0,n-1+m){
    cin >> A[i] >> B[i];
    A[i]--;B[i]--;
    to[A[i]].push_back(B[i]);
    in[B[i]]++;
  }
  queue<int> que;
  vint ans(0,0);
  rep(i,0,n){
    if(in[i] == 0) que.push(i);
  }
  while(!que.empty()){
    int now = que.front();
    que.pop();
    ans.push_back(now);
    for(auto p : to[now]){
      in[p]--;
      if(in[p] == 0) que.push(p);
      dist[p] = max(dist[now]+1,dist[p]);
    }
  }
  vint par(n,-1);
  rep(i,0,n-1+m){
    int a = A[i];
    int b = B[i];
    if(dist[b] - dist[a] == 1) par[b] = a; 
  }
  rep(i,0,n) cout << par[i]+1 << endl;
}

Measured memory_bytes: 11124
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll a,b,c;
int main() 
{
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0) {
		cout<<0;
		return 0;
	}
	cout<<min(min(a*b,a*c),b*c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for(ll i = 0; i < N; i++)
using ll = long long;
using namespace std;
#define MOD 1000000007
typedef pair<ll,ll> Pl;
typedef vector<int> vi;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    int ggg = a[0];
    rep(i,n-1) ggg = __gcd(ggg, a[i+1]);
    int cnt = 0, flag = 1;
    rep(i,n){
        if(a[i]%2 == 0){
            while(a[i]%2 == 0) a[i] /= 2;
            cnt++;
        }
    }
    if(cnt > 1){
        flag = 0;
    }
    if(flag){
        for(int j = 3; j < 1000; j += 2){
            cnt = 0;
            rep(i,n){
                if(a[i]%j == 0) {
                    if(a[i]%j == 0){
                        while(a[i]%j == 0) a[i] /= j;
                        cnt++;
                    }
                }
            }
            if(cnt > 1){
                flag = 0;
                break;
            }
        }
    }
    if(flag){
        int ch[1010101] = {0};
        rep(i,n) {
            if(a[i] != 1){
                if(ch[a[i]]){
                    flag = 0;
                    break;
                }else{
                    ch[a[i]]++;
                }
            }
        }
    }

    if(flag){
        puts("pairwise coprime");
    }else if(ggg == 1){
        puts("setwise coprime");
    }else{
        puts("not coprime");
    }
}


Measured memory_bytes: 11044
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
l=[]
sum=a1[0]
for i in range(n):
  sum+=a2[i]
l.append(sum)
for j in range(n-1):
  sum+=(a1[j+1]-a2[j])
  l.append(sum)
print(max(l))

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    ll x, y, a, b, c, ans = 0;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    for(int i = 0; i < a; i++){
        cin >> p[i];
    }
    for(int i = 0; i < b; i++){
        cin >> q[i];
    }
    for(int i = 0; i < c; i++){
        cin >> r[i];
    }
    sort(rbegin(p), rend(p));
    sort(rbegin(q), rend(q));
    sort(rbegin(r), rend(r));
    priority_queue<ll, vector<ll>, greater<ll>>pq;
    for(int i = 0; i < x; i++){
        pq.push(p[i]);
        ans += p[i];
    }
    for(int i = 0; i < y; i++){
        pq.push(q[i]);
        ans += q[i];
    }
    for(int i = 0; i < c; i++){
        ll t = pq.top();
        if(t < r[i]){
            ans -= t;
            ans += r[i];
            pq.pop();
        }else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int r,g;
	while(cin>>r>>g)
	{
		int n;
		n=2*g-r;
		cout<<n<<endl;
	}
	return 0;
}


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

int main(){
    int A, B; cin >> A >> B;
    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) cout << "Possible";
    else cout << "Impossible";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
class Dice{
private:
    int tmp;
public:
    int d[6];
 
    void rollN(){
	tmp = d[0];
	d[0] = d[1];
	d[1] = d[5];
	d[5] = d[4];
	d[4] = tmp;
    }
    void rollE(){
	tmp = d[0];
	d[0] = d[3];
	d[3] = d[5];
	d[5] = d[2];
	d[2] = tmp;
    }
    void rotation(){
	tmp = d[1];
	d[1] = d[3];
	d[3] = d[4];
	d[4] = d[2];
	d[2] = tmp;
    }
    bool operator < (const Dice &die)const{
	for(int i = 0 ; i < 6 ; i++){
	    if(d[i] != die.d[i]) return d[i] < die.d[i];
	}
	return false;
    }
};
 
int N,ans,p[4];
map<string,int> mp;
vector<Dice> dice[4];
 
int getCost(){
    int res = 0;
    for(int i = 0 ; i < 6 ; i++){
	int cnt[25] = {0}, max = 0;
	for(int j = 0 ; j < N ; j++){
	    cnt[dice[j][p[j]].d[i]]++;
	    max = std::max(max,cnt[dice[j][p[j]].d[i]]);
	}
	res += N-max;
    }
    return res;
}
 
void solve(int x){
    if(x == N){
	ans = min(ans,getCost());
	return;
    }
    for(int i = 0 ; i < (int)dice[x].size() ; i++){
	p[x] = i;
	solve(x+1);
    }
}
 
vector<Dice> make(Dice die){
    vector<Dice> res;
    set<Dice> visited;
    for(int i = 0 ; i < 4 ; i++){
	for(int j = 0 ; j < 4 ; j++){
	    if(!visited.count(die)){
		visited.insert(die);
		res.push_back(die);
	    }
	    die.rollN();
	}
	for(int j = 0 ; j < 4 ; j++){
	    if(!visited.count(die)){
		visited.insert(die);
		res.push_back(die);
	    }
	    die.rollE();
	}
	die.rotation();
    }
    return res;
}
 
int main(){
    Dice in;
    while(cin >> N, N){
	int n = 0;
	mp.clear();
	for(int i = 0 ; i < N ; i++){
	    p[i] = -1;
	    for(int j = 0 ; j < 6 ; j++){
		string s;
		cin >> s;
		if(mp.find(s) != mp.end()){
		    in.d[j] = mp[s];
		}else{
		    mp[s] = n++;
		    in.d[j] = mp[s];
		}
	    }
	    dice[i] = make(in);
	}
	ans = 1e9;
	solve(0);
	cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	long long ans = 0;
	for (int n = 1; n <= N; ++n) {
		int num = N / n;
		ans += (long long)n * (1+num)*num / 2; 
		//cout << ans <<" "<<num<< endl;
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define range(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
using namespace std;

bool prime[50010];

void init(){
	range(i,2,50010){
		prime[i]=true;
		for(int j=2;j*j<=i;++j){
			if(i%j==0) prime[i]=false;
		}
	}
	return ;
}

int main(void){
	int n;
	init();
	while(cin >> n,n){
		int res=0;
		range(i,2,n+1){
			int j=n-i;
			if(i>j) break;
			if(prime[i]&&prime[j]) res++;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1208