akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  string s = "";
  int base = 1;
  int cnt = 0;
  while(n!=0){
    int r = n%2;
    if(r<0) r += 2;
    n = (n-r)/(-2);
    s += (char)('0'+r);
  }
  reverse(ALL(s));
  cout << (s=="" ? "0" : s) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

struct Point{
  double x,y;
};

void koch(int n, struct Point a, struct Point b){
  if(n==0) return;
  struct Point s,t,u;
  double th = M_PI * 60.0 / 180.0;

  s.x=(2.0*a.x + 1.0*b.x)/3.0;
  s.y=(2.0*a.y + 1.0*b.y)/3.0;
  t.x=(1.0*a.x + 2.0*b.x)/3.0;
  t.y=(1.0*a.y + 2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  struct Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	cin >> n >> m;
	cout << n + m / 2;
	return Accepted;
}

// B...a

Measured memory_bytes: 18688
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int n, d;
	cin >> n >> d;
	cout << (n % (2 * d + 1) == 0 ? n / (2 * d + 1) : n / (2 * d + 1) + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
                            using namespace std;
                             
                            int main(){
                            // long long n; cin>>n;
                             // string str= to_string(n);
                            string str;
                              cin>>str;
                               long long sum=0;
                              unsigned long long i;
                              for( i=0;i<str.size();i++){
                                 sum+=str[i]-'0';
                              }
                              if(sum==0 || sum%9==0) cout<<"Yes"<<endl;
                              else cout<<"No"<<endl;
                              
                            return 0;}

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

int main() {
	int a1, a2, a3, a4, a5;
  cin >> a1 >> a2 >> a3 >> a4 >> a5;
  if (a1 == 0) {
    cout << '1';
  }
  if (a2 == 0) {
    cout << '2';
  }
  if (a3 == 0) {
    cout << '3';
  }
  if (a4 == 0) {
    cout << '4';
  }
  if (a5 == 0) {
    cout << '5';
  }
	return 0;
}

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

pair<int, int> dp[101010][16];

int main() {
  int n, m;
  cin >> n >> m;

  vector<vector<int>> G(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int q;
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    int v, d, c;
    cin >> v >> d >> c;
    dp[v - 1][d] = make_pair(i, c);
  }

  for (int d = 10; d > 0; --d) {
    for (int v = 0; v < n; ++v) {
      for (auto &u : G[v]) {
        dp[u][d - 1] = max(dp[u][d - 1], dp[v][d]);
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    pair<int, int> ans;
    for (int d = 0; d <= 10; ++d) {
      ans = max(ans, dp[i][d]);
    }

    cout << ans.second << endl;
  }
}


Measured memory_bytes: 18936
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = ((res % m) * (x % m)) % m;
        x = ((x % m) * (x % m)) % m;
        p >>= 1;
    }
    return res % m;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm(int a, int b){
    return a / gcd(a, b) * b;
}
ll phi(ll x){
    ll res = x;
    for(ll i = 2 ; i <= x/i ; i += 1 + (i&1)){
        if(x%i)    continue;
        while(x%i == 0)            x /= i;
        res -= res/i;
    }
    if(x!=1)    res -= res/x;
    return res;
}
const int N = 2e7 + 5;

int main() {
    int a = D(), b = D();
    int turn = 1;
    for(int i = 1; i <= 16; ++i){
        if(turn && a)
            a-= 1;
        if(!turn && b)
            b-= 1;
        turn ^= 1;
    }
    puts(!a && !b ? "Yay!": ":(");
}


Measured memory_bytes: 256
n = int(input())
an = list(map(int, input().split()))

dic = {}
for i in range(n):
  if an[i] not in dic.keys():
    dic[an[i]] = 1
  else:
    dic[an[i]] += 1

ans = {}
all_pattern = 0
for k,v in dic.items():
    if v >= 2:
        all_pattern += v*(v-1)//2
for k,v in dic.items():
    ans[k] = all_pattern - (v-1)
for v in an:
    print(ans[v])

Measured memory_bytes: 34900
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P=new int[N+1];
        int ans=1;
        int max=0;
        for(int i=0;i<N;i++){
            int p=sc.nextInt();
            P[p]=i+1;
        }
        for(int i=2;i<=N;i++){
            if(P[i-1]>P[i]){
                max=Math.max(max, ans);
                ans=1;
            }else{
                ans++;
            }
        }
        max=Math.max(ans,max);
        System.out.println(N-max);
    }
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	cin >> n >> k;
	
	if ((n + 1) / 2 >= k) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if (A >= 13) cout << B << endl;
	else if (A >= 6 && A <= 12) cout << B / 2 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
from queue import Queue

INF=float('inf')

n=int(input())
g=[[] for _ in range(n)]
for _ in range(n-1):
    u,v,w=map(int,input().split())
    g[u-1].append((v-1,w))
    g[v-1].append((u-1,w))

q,k=map(int,input().split())
ds=[INF]*n
ds[k-1]=0
que=Queue()
que.put((k-1,0))
while not que.empty():
    u,d=que.get()
    for v,w in g[u]:
        if ds[v]==INF:
            ds[v]=d+w
            que.put((v,d+w))

for _ in range(q):
    u,v=map(int,input().split())
    print(ds[u-1]+ds[v-1])


Measured memory_bytes: 90140
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static class Value {
        int type;
        int value;
        Value(int type, int value) {
            this.type = type;
            this.value = value;
        }

        public int getType() {
            return type;
        }

        public int getValue() {
            return value;
        }
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int X = scan.nextInt();
        int Y = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();

        PriorityQueue<Value> pq = new PriorityQueue<>(Comparator.comparing(Value::getValue).reversed());

        for(int i = 0 ; i < A; i++) {
            pq.add(new Value(0, scan.nextInt()));
        }
        for(int i = 0 ; i < B; i++) {
            pq.add(new Value(1, scan.nextInt()));
        }
        for(int i = 0 ; i < C; i++) {
            pq.add(new Value(2, scan.nextInt()));
        }

        long ans = 0;
        long ac = 0;
        long bc = 0;
        long cc = 0;
        for(; ac+bc+cc < X+Y;) {
            Value v = pq.remove();
            switch (v.getType()) {
                case 0:
                    if(ac < X){
                        ans += v.getValue();
                        ac++;
                    }
                    break;

                case 1:
                    if(bc < Y){
                        ans += v.getValue();
                        bc++;
                    }
                    break;

                case 2:
                    ans += v.getValue();
                    cc++;
                    break;
            }
        }

        os.println(ans);

    }

}

Measured memory_bytes: 164172
#include<iostream>

using namespace std;

int main(){
  int n;
 
  while(cin >> n&&n!=0){
    int dice[6]={1,2,3,5,4,6};

    int plus;
    int ans=1;
    for(int i=0;i<n;i++){
      string inp;
      
      cin >> inp;

      if(inp=="North"){
	plus=dice[1];
	dice[1]=dice[5];dice[5]=dice[3];dice[3]=dice[0];dice[0]=plus;
	ans+=plus;
      }else if(inp=="East"){
	plus=dice[4];
	dice[4]=dice[5];dice[5]=dice[2];dice[2]=dice[0];dice[0]=plus;
	ans+=plus;
      }else if(inp=="West"){
	plus=dice[2];
	dice[2]=dice[5];dice[5]=dice[4];dice[4]=dice[0];dice[0]=plus;
	ans+=plus;
      }else if(inp=="South"){
	plus=dice[3];
	dice[3]=dice[5];dice[5]=dice[1];dice[1]=dice[0];dice[0]=plus;
	ans+=plus;
      }else if(inp=="Right"){
	plus=dice[1];
	dice[1]=dice[2];dice[2]=dice[3];dice[3]=dice[4];dice[4]=plus;
	ans+=dice[0];
      }else if(inp=="Left"){
	plus=dice[1];
	dice[1]=dice[4];dice[4]=dice[3];dice[3]=dice[2];dice[2]=plus;
	ans+=dice[0];
      }else{
	cout << "error!" << endl;
	break;
      }

    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3136
/*
 * atcoder/abc140/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * 連続するL, Rの個数を表す数列aを考える.
 * 例えば、RRRLRLRLLであれば3 1 1 1 1 2
 * a_1とa_M以外の１つの要素を反転させることは、+2することに等しい
 * a_1またはa_Mを反転させることは+1することに等しい
 * M=1の時、+0 （これ以上幸福度は増やせない）
 */
template <class T, class T2>
void group(T &xs, vector<pair<T2, int> > &result) {
  int i=0, j;
  while (i<xs.size()) {
    j=i;
    while (j < xs.size() and xs[j] == xs[i]) j++;
    result.push_back({ xs[i], j-i });
    if (j==i) i++;
    i=j;
  }
}
int N, K;
string S;
void solve() {
  cin >> N >> K >> S;
  vector<pair<char, int> > A;
  group(S, A);
  int ans = 0;
  for (auto&& a: A) {
    ans += a.second - 1;
  }
  cout << min(ans + 2 * K, N - 1)  << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 4488
#include <iostream>
#include <string>

using namespace std;

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

	for (int i=0; i<(int)s.size()-1; i++)
		if (s[i]==s[i+1])
		{
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
	for (int i=0; i<(int)s.size()-2; i++)
		if (s[i]==s[i+2])
		{
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	cout<<"-1 -1"<<endl;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	// "github.com/pkg/profile"
)

func mkTbl(n int, ds []float64) [][]float64 {
	tbl := make([][]float64, n+1)
	for i := range tbl {
		tbl[i] = make([]float64, n+1)
	}
	for i := 0; i <= n; i++ {
		tbl[i][i] = ds[i]
	}
	return tbl
}

func mkWeights(n int, ps, ds []float64) [][]float64 {
	tbl := mkTbl(n, ds)
	for i := 0; i < n; i++ {
		w := ds[i]
		for j := i + 1; j <= n; j++ {
			w += ps[j] + ds[j]
			tbl[i][j] = w
		}
	}
	return tbl
}

func minCost(i, j int, tbl [][]float64) float64 {
	m := math.MaxFloat64
	for k := i + 1; k <= j; k++ {
		m = math.Min(m, tbl[i][k-1]+tbl[k][j])
	}
	return m
}

func solve(n int, ps, ds []float64) float64 {
	costs := mkTbl(n, ds)
	weights := mkWeights(n, ps, ds)
	for l := 1; l <= n; l++ {
		for i := 0; i <= n-l; i++ {
			j := i + l
			costs[i][j] = weights[i][j] + minCost(i, j, costs)
		}
	}
	return costs[0][n]
}

func main() {
	// defer profile.Start(profile.ProfilePath(".")).Stop()

	w := bufio.NewWriter(os.Stdout)
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	ps := make([]float64, n+1)
	ds := make([]float64, n+1)

	for i := 1; i <= n; i++ {
		s.Scan()
		ps[i], _ = strconv.ParseFloat(s.Text(), 64)
	}

	for i := 0; i < n+1; i++ {
		s.Scan()
		ds[i], _ = strconv.ParseFloat(s.Text(), 64)
	}

	if s.Err() != nil {
		log.Fatal("scan error")
	}

	fmt.Fprintf(w, "%.4f\n", solve(n, ps, ds))
	_ = w.Flush()
}



Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  ll n,c,k,t[100010],ans=0;
  std::cin >> n >> c >> k;
  rep(i,n) std::cin >> t[i];
  sort(t,t+n);

  ll j=0,next=0;
  while(j<n){
    ll mem=1;
    while(next<n && abs(t[j]-t[next])<=k && mem<=c){
      next++;
      mem++;
    }
    ans++;
    j=next;
  }

  std::cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> ju(n+1,1);
  vector<char> hu(n+1,'a');
  long long ans=1;
  int co=1;
  for(int i=0;i<n;i++){
    bool x=true;
    for(int j=0;j<co;j++){
      if(hu.at(j)==s.at(i)){
        ju.at(j)++;
        x=false;
        break;
      }
    }
    if(x){
      hu.at(co)=s.at(i);
      co++;
      ju.at(co-1)++;
    }
  }
  for(int i=0;i<co;i++){
   //cout << ju[i] << endl;
    ans=(long long)ans*ju[i]%1000000007;
  }
    cout << ans-1 << endl;
 }

Measured memory_bytes: 896
#include<iostream>
using namespace std;
void dfs(int x,int y,char z);
char a[100][100];
int h,w;
int ans = 0;
int main(){
 
    while(cin>>h>>w,h){
        ans = 0;
 
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>a[i][j];
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(a[i][j]!='.')dfs(i,j,a[i][j]),ans++;
            }
        }
        cout<<ans<<endl;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                a[i][j] = '.';
            }
        }
 
    }
 
 
    return 0;
}
void dfs(int x,int y,char z){
    a[x][y] = '.';
    if(z==a[x][y+1]&&y+1<w)dfs(x,y+1,z);
    if(z==a[x+1][y]&&x+1<h)dfs(x+1,y,z);
    if(z==a[x][y-1]&&y-1>=0)dfs(x,y-1,z);
    if(z==a[x-1][y]&&x-1>=0)dfs(x-1,y,z);
 
    return;
}

Measured memory_bytes: 1628
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, X;
  cin>>N>>X;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans = 0;
  if(A[0]>X) {
    ans += A[0]-X;
    A[0] = X;
  }
  for(int i=0;i<N-1;++i) {
    if(A[i]+A[i+1]>X) {
      ans += A[i]+A[i+1]-X;
      A[i+1] -= A[i]+A[i+1]-X;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
#define read FILE *fp;\
fp=freopen("testcase.txt","r",stdin);
#define ll long long
#define ull unsigned long long
#define sf(n) scanf("%I64d",&n)
#define pf(n) printf("%I64d\n",n)
#define loop for(long long i=0;i<n;i++)
#define lp(b,n) for(long long i=b;i<=n;i++)
#define pb(n) push_back(n)
#define srt(v) sort(v.begin(),v.end())
#define rvs(v) sort(v.begin(), v.end(), greater<long long>());
#define F first
#define S second
#define mp(a,b) make_pair(a,b);
#define fio ios::sync_with_stdio(false); cin.tie(),cout.tie();
ll llmax = numeric_limits<long long>::max();
ll llmin= numeric_limits<long long>::min();
ll mark[5010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    ll a[n+10],b=0,c=0,d=0;
    loop
    {
        cin>>a[i];
    }
    sort(a,a+n);
    loop
    {
        c=__gcd(c,a[i]);
    }
    cout<<c<<endl;
}



Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
int n,sum[N];
map<vector<int>,int>m;
int main(){
    for(int i=1;i<N;i++) for(int j=i;j<N;j+=i) sum[j]++;
    cin>>n;int ans=0;
    for(int i=1;i<=n-1;i++) ans+=sum[i];//cout<<sum[i]<<endl;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7536
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long k = sc.nextLong();
    long answer=a-b;
    if(k%2!=0){
      answer=(-1)*answer;
    }
    /*for(int i=0;i<k;i++){
      long total=a+b+c;

      a=total-a;
      b=total-b;
      c=total-c;
    }*/
    if(a-b>(long)Math.pow(10,18)||b-a>(long)Math.pow(10,18)){
      System.out.println("Unfair");
    }else{
      System.out.println(answer);
    }

  }
}


Measured memory_bytes: 22228
def main():
    X, Y = list(map(int, input().split()))
    # (1)単純に1ずつ増やすだけ：(5, 10), (-5, -2), (5, 5), (-5, -5), (-5, 0), (0, 5), (0, 0)
    if X * Y >= 0 and X <= Y:
        print(Y - X)
    # (2)反転して1ずつ増やして最後に反転：(-5, -10), (5, 2)
    elif X * Y > 0 and X > Y:
        print(X - Y + 2)
    # (3)1ずつ増やして最後に反転：(-5, 2), (5, -10), (0, -5)
    # (4)反転した後は1ずつ増やすだけ：(5, -2), (-5, 10), (5, 0)
    # (5)反転するだけ：(5, -5), (-5, 5)
    else:
        print(abs(X + Y) + 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
import sys

a, b = list(map(int, input().split()))

if a%2 == 0 and b%2 == 0:
    print(int((a+b)/2))
    sys.exit()

if a%2 != 0 and b%2 != 0:
    print(int((a+b)/2))
    sys.exit()

print("IMPOSSIBLE")

    


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const int MAX_X = 5000, MAX_N = 1000;

int dp[1000];
int dp2[MAX_N][2][MAX_X + 1];
vector<int> X;
typedef vector<vector<int>> Graph;
Graph G;
int N;

void dfs(int v)
{
    fill(dp2[v][0], dp2[v][0] + 2 * (MAX_X + 1), INF);
    int M = G[v].size(), t = 0;
    dp2[v][0][0] = 0;

#ifdef DEBUG
    cerr << "------------" << endl;
    DUMP(v);
#endif

    for (auto u : G[v]) {
        dfs(u);
        int b = dp[u], w = X[u];

#ifdef DEBUG
        DUMP(u);
        DUMP2(b, w);
#endif
        fill(dp2[v][(t+1)&1], dp2[v][(t+1)&1] + MAX_X + 1, INF);

        for (int x=MAX_X; x>=0; x--) {
            if (x+b <= MAX_X) dp2[v][(t+1)&1][x+b] = min(dp2[v][(t+1)&1][x+b], dp2[v][t&1][x] + w);
            if (x+w <= MAX_X) dp2[v][(t+1)&1][x+w] = min(dp2[v][(t+1)&1][x+w], dp2[v][t&1][x] + b);
        }
        t++;
    }

    dp[v] = INF;
    for (int x=0; x<=X[v]; x++) {
        dp[v] = min(dp[v], dp2[v][M&1][x]);
    }

#ifdef DEBUG
    DUMP(dp[v]);
#endif
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> N;
    G.resize(N);
    X.resize(N);

    for (int i=1; i<N; i++) {
        int P; cin >> P;
        P--;
        G[P].push_back(i);
    }

    rep(i, N) cin >> X[i];
    dfs(0);

    cout << (dp[0] < INF ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

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


Measured memory_bytes: 3652
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int N;
cin >> N;
int A, B;
cin >> A >> B;
int sum = 0;
for(int i = 1; i <= N; i++){
    int rest = 0, tmp = i; 
   for(int j = 0; j < 5; j++){ 
        rest += tmp % 10;
        tmp /= 10;
   }
        if(A <= rest && rest <= B) sum += i;
}
print(sum);

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 *1000 + 7;
const LL LINF = INF * (LL)INF;


int main()
{
	//freopen("in.txt","r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	string s;
	cin>>s;

	bool c1 = 0, c2 = 0, c3 = 0, c4 = 0;

	FOR (i, 0, SZ(s))
	{
		if (s[i] == 'N') c1 = 1;
		if (s[i] == 'E') c2 = 1;
		if (s[i] == 'W') c3 = 1;
		if (s[i] == 'S') c4 = 1;
	}

	if (c1 && c2 && c3 && c4)
	{
		cout<<"Yes"<<endl;
		return 0;
	}

	if (c1 && c4 && !c2 && !c3)
	{
		cout<<"Yes"<<endl;
		return 0;
	}

	if (c2 && c3 && !c1 && !c4)
	{
		cout<<"Yes"<<endl;
		return 0;
	}

	cout<<"No"<<endl;


}


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

std::string solve(int n, const std::vector<int>& array)
{
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (array[i] != i + 1) {
      ++count;
      if (count >= 3) break;
    }
  }
  return count == 0 || count == 2 ? "YES" : "NO";
}

int main()
{
  int n;
  std::cin >> n;

  std::vector<int> array(n);
  for (auto& a : array) {
    std::cin >> a;
  }

  std::cout << solve(n, array) << std::endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;

int fie[28][28];
int dx[4]={1,1,-1,-1};
int dy[4]={1,-1,1,-1};
int lane[1000];
int m,n,d;

bool check(const vec& x){
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(x[lane[i*m+j]]==1){
				fie[i][j]^=1;
				for(int k=-d;k<=d;k++){
					for(int l=0;l<2;l++){
						if(abs(k)==d && l==1)continue;
						int nx=j+k,ny=i+(d-abs(k))*dy[l];
						if(nx>=0 && nx<m && ny>=0 && ny<n){
							fie[ny][nx]^=1;
						}
					}
				}
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(fie[i][j]==1)return false;
		}
	}
	return true;
}

bool solve(){
	mat A(m*n,vec(m*n));
	int N=A.size();
	mat B(N,vec(N+1));
	vec b(N);
	for(int i=0;i<N;i++){
		lane[i]=i;
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			A[i][j]=0;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(fie[i][j]==0){
				b[i*m+j]=0;
			}else{
				b[i*m+j]=1;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			A[i*m+j][i*m+j]=1;
			for(int k=-d;k<=d;k++){
				for(int l=0;l<2;l++){
					if(abs(k)==d && l==1)continue;
					int nx=j+k,ny=i+(d-abs(k))*dy[l];
					if(nx>=0 && nx<m && ny>=0 && ny<n){
						A[i*m+j][ny*m+nx]=1;
					}
				}
			}
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			B[i][j]=A[i][j];
		}
	}
	for(int i=0;i<N;i++){
		B[i][N]=b[i];
	}
	for(int i=0;i<N;i++){
		int pivot=i;
		for(int j=i;j<N;j++){
			if(B[j][i]>B[pivot][i])pivot=j;
		}
		swap(B[i],B[pivot]);
		if(B[i][i]==0)B[i][i]=1;
		for(int j=0;j<N;j++){
			if(i!=j){
				for(int k=i+1;k<=N;k++){
					B[j][k]^=B[j][i]*B[i][k];
				}
			}
		}
	}
	vec x(N);
	for(int i=0;i<N;i++){
		x[i]=B[i][N];
	}
	return check(x);
}

int main(void){
	while(1){
		scanf("%d%d%d",&m,&n,&d);
		if(m+n+d==0)break;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				scanf("%d",&fie[i][j]);
			}
		}
		printf("%d\n",solve()?1:0);
	}
	return 0;
}

Measured memory_bytes: 5928
#include <iostream>
using namespace std;
int main(){
    int n;
    double data;
    int num[6];
    for (int i = 0; i < 6; i++) {
        num[i] = 0;
    }
    cin >> n;
    while(n--) {
        cin >> data;
        for (int i = 0; i < 6; i++) {
            if (data < (165.0+(i*5))) {
                ++num[i];
                break;
            }
        }
    }
    for(int i = 0; i < 6; ++i) {
        cout << i+1 << ":";
        for(int j = 0; j < num[i]; ++j) {
            cout << "*";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1232
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	long long n,ans = 0;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
			cin >> a[i];
			ans += a[i];
	}
	cout << ans-n << endl;
	return 0;
}

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

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

    vector<int> a(n + 1);
    for (auto& x : a) cin >> x;

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == i + 1) {
            swap(a[i], a[i + 1]);
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int x[1001];
int y[1001];
int main() {
    int c, d;
    char s[10];
    for(;fgets(s, 10, stdin), s[0] != '\n';) {
        sscanf(s, "%d,%d", &c, &d);
        x[c]++;
    }
    while(~scanf("%d,%d", &c, &d))
        if (x[c] != 0) y[c] = ++x[c];
    for (int i=1; i<1001; i++)
        if (y[i] != 0) printf("%d %d\n", i, y[i]);
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, count;
    count = 0;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i);
    }
    for(int i = 1; i < n - 1; i++){
        if(p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1)){
            count++;
        }
        else if(p.at(i - 1) > p.at(i) && p.at(i) > p.at(i + 1)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
def is_circular(n):
    s = str(n)
    l = len(s)
    for i in range(l//2):
        if s[i] != s[l-i-1]:
            return False
    else:
        return True

A, B = (int(x) for x in input().split())
print(sum(1 for i in range(A, B+1) if is_circular(i)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<map<int, bool>> check(50, map<int, bool>());
    for (int i = 0; i < S.length(); i++) {
        int num = S[i] - 'a';
        check[num][i] = true;
    }
    vector<int> ans;
    for (int i = 0; i < Q; i++) {
        int select;
        cin >> select;
        if (select == 1) {
            int l;
            char c;
            cin >> l >> c;
            --l;
            if (S[l] == c) continue;
            // del
            int num = S[l] - 'a';
            check[num].erase(l);
            // input
            num = c - 'a';
            // cout << i << endl;
            // cout << num << endl;
            check[num].insert(make_pair(l, true));
            S[l] = c;
        } else {
            int l ,r;
            cin >> l >> r;
            --l;
            --r;
            int count = 0;
            for (int j = 0; j <= 'z' - 'a'; j++) {
                auto itr = check[j].lower_bound(l);
                if (itr == check[j].end()) continue;
                int key = itr->first;
                if (l <= key && key <= r) {
                    ++count;
                }
            }
            ans.push_back(count);
        }
    }
    for (auto temp : ans) {
        cout << temp << endl;
    }
}

Measured memory_bytes: 32516
S=int(input())
mod = 10**9 + 7
N = 2*S

factorial=[1 for i in range(N+1)]
for i in range(1,N+1):
    if i==1:factorial[i]=1
    else:factorial[i] = factorial[i-1]*i % mod
      
def comb(n,k):
    return (factorial[n]*pow(factorial[n-k]*factorial[k], -1, mod))%mod

ans = 0
for i in range(S//3):
  s = S - (i+1)*3
  ans += comb(s+i,i)
  ans %= mod
  
print(ans)

Measured memory_bytes: 9268
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var vSize = inputs[0];
        var eSize = inputs[1];

        // 0, ... , vSize - 1のラベルがついた頂点
        var graph = new Graph<int>(Enumerable.Range(0, vSize));
        
        for(int  i = 0; i < eSize; i++)
        {
            var edge = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            graph.AddEdges(edge[0], edge[1]);
        }

        foreach (var item in TopologicalSort<int>.Excute(graph))
            Console.WriteLine(item);
    }
}

public static class TopologicalSort<T>
{
    // 入力されたノード
    private static Dictionary<T, List<T>> _nodes;

    // 既に訪問したかどうかを記録しておく
    private static Dictionary<T, bool> _seenVertexes;

    // トポロジカルソートされた結果を格納する
    private static Stack<T> _sortedNodes;

    public static IEnumerable<T> Excute(Graph<T> graph)
    {
        _seenVertexes = new Dictionary<T, bool>();
        _nodes = graph.Nodes;
        _sortedNodes = new Stack<T>(_nodes.Count);

        foreach (var node in _nodes)
            Visit(node.Key);

        _nodes = null;
        _seenVertexes = null;

        foreach (var node in _sortedNodes)
            yield return node;

        _sortedNodes = null;
    }

    private static void Visit(T node)
    {
        if (!_seenVertexes.ContainsKey(node))
        {
            _seenVertexes[node] = true;
            foreach (var to in _nodes[node])
                Visit(to);
            _sortedNodes.Push(node);
        }
    }
}

public class Graph<T>
{
    // <頂点, 接続先の頂点>
    public Dictionary<T, List<T>> Nodes { get; private set; }

    /// <summary>
    /// グラフ作成
    /// </summary>
    /// <param name="nodes">頂点のラベルのコレクション</param>
    public Graph(IEnumerable<T> nodes)
    {
        Nodes = new Dictionary<T, List<T>>();
        foreach (var node in nodes)
            Nodes[node] = new List<T>();
    }

    /// <summary>
    /// 頂点を追加する
    /// </summary>
    /// <param name="node">追加する頂点のラベル</param>
    /// <returns>追加できたか</returns>
    public bool AddVertex(T node)
    {
        if (Nodes.ContainsKey(node)) return false;

        Nodes[node] = new List<T>();
        return true;
    }

    /// <summary>
    /// 辺を追加する
    /// </summary>
    /// <param name="from">接続元の頂点</param>
    /// <param name="to">接続先の頂点</param>
    /// <returns>追加できたか</returns>
    public bool AddEdges(T from, T to)
    {
        if (!Nodes.ContainsKey(from) || !Nodes.ContainsKey(to)) return false;

        Nodes[from].Add(to);
        return true;
    }
}



Measured memory_bytes: 25128
#include <stdio.h>
int main(void)
{
	int n,a[100001],c[100001]={0},x=0,i;
	scanf("%d", &n);
	for(i=1; i<=n; i++)
	scanf("%d", &a[i]);
	i=1;
	while(i!=2&&c[i]==0)
	{
		x++;
		c[i]++;
		i=a[i];
	}
	if(c[i]>0)
	printf("-1\n");
	else
	printf("%d\n", x);
	
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define endl "\n"
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
string s,t;
ll i,c=0;
cin>>s>>t;
rep(i,0,3)
{
    if(s[i]==t[i])
        c++;
}
cout<<c;
return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from fractions import gcd
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,K = inputIL()
R,S,P = inputIL()
T = list(inputS())

t = []
for i in range(K):
  t.append(T[i::K])
  
  
def get(s):
  if s=="r": return P
  if s=="s": return R
  if s=="p": return S
ans = 0

for l in t:
  skipped = 0
  for i in range(len(l)):
    if i == 0:
      ans += get(l[i])
    else:
      if l[i]!=l[i-1] or skipped == 1:
        ans += get(l[i])
        skipped = 0
      else:
        skipped = 1 

print(ans)

Measured memory_bytes: 81160
def mink(X,Y,p):
    a =0
    for x,y in zip(X,Y):
        a+=abs(x-y)**p
    print(a**(1/p))

n = int(input())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))

for p in range(1,4):
    mink(X,Y,p)
    
print(max(abs(x-y) for x,y in zip(X,Y)))
    
    
            


Measured memory_bytes: 5648
#include<stdio.h>
#include<stdlib.h>

void printans(int N, int M, int *a, int *b){
	int *ans, i;

	ans = (int *)malloc(sizeof(int)*N);
	if(ans == NULL) exit(1);

	for(i = 0; i < N; i++){
		ans[i] = 0;
	}
	
	for(i = 0; i < M; i++){
		ans[a[i]-1]++;
		ans[b[i]-1]++;
	}

	for(i = 0; i< N; i++){
		printf("%d\n", ans[i]);
	}

	free(ans);
}

int main(){
	int N, M, *a, *b, i;
	char line[8];

	fgets(line, 8, stdin);
	sscanf(line, "%d %d", &N, &M);

	a = (int *)malloc(sizeof(int)*M);
	b = (int *)malloc(sizeof(int)*M);
	if((a == NULL) || (b == NULL)) exit(1);

	for(i = 0; i < M; i++){
		fgets(line, 8, stdin);
		sscanf(line, "%d %d", &a[i], &b[i]);
	}

	printans(N, M, a, b);

	free(a);
	free(b);
	return 0;
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if ((a == b && b != c) || (a == c && b != c) || (b == c && a != b)) {
    cout << "Yes" << endl;
  } else {
	cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 300000
main(){
  bool T[MAX+1];
  int N, Q, q, x, L[MAX+1];

  for ( int i = 0; i <= MAX; i++ ) {
    T[i] = false;
    L[i] = 0;
  }

  scanf("%d %d", &N, &Q);

  for ( int i = 0; i < N; i++ ) {
    scanf("%d", &x);
    T[x] = true;
  }

  int m = 0;
  for ( int i = 1; i <= MAX; i++ ){
    L[i] = m;
    if ( T[i] ) m = i;
  }

  for ( int i = 0; i < Q; i++ ){
    scanf("%d", &q);
    int maxv = 0;
    int cur = m;

    while(cur){
      int p = cur%q;
      maxv = max(maxv, p);
      if ( cur - p < 0 ) break;
      cur = L[cur - p];
    }

    printf("%d\n", maxv);
  }
}

Measured memory_bytes: 2652
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        String str = sc.nextLine();
        int cnt1 = 0, cnt2 = 0;
        int len = str.length();

        for(int i=0;i<len;i++) {
            if(str.charAt(i) == '0') cnt1++;
            else cnt2++;
        }

        pw.println(Math.min(cnt1, cnt2) * 2);
        pw.close();
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define ll long long
#define cases ll t;cin>>t;while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)


int main(){
    fast;
    ll i,j,n,k,x,y,ans=0,cnt=1;
    cin>>i>>j>>k;
    swap(i,j);swap(i,k);
    cout<<i<<" "<<j<<" "<<k;
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int n, x[100], y[100];


double minkowski_distance(double p)
{
	double sum = 0.0;
	for (int i = 0; i < n; i++)
		sum += pow(fabs(x[i] - y[i]), p);
	return pow(sum, 1.0 / p);
}
double minkowski_distance()
{
	double max = 0.0;
	for (int i = 0; i < n; i++) {
		if (fabs(x[i] - y[i]) > max)
			max = fabs(x[i] - y[i]);
	}
	return max;
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	cout << fixed
		<< setprecision(8)
		<< minkowski_distance(1.0) << endl
		<< minkowski_distance(2.0) << endl
		<< minkowski_distance(3.0) << endl
		<< minkowski_distance() << endl;
	return 0;
}

Measured memory_bytes: 1300
if __name__ == "__main__":
  S = input()
  
  maxLen = 0
  for start in range(len(S)):
    for end in range(start, len(S)+1):
      if set(S[start:end]) <= set("ATCG"):
        maxLen = max(end-start, maxLen)
        
  print(maxLen)


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
    return 0;
  }

  int A, B; cin >> A >> B;
  cout << A + B << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}
int divisible_count_2(ll n) {
  int ans = 0;
  while(n % 2 == 0) {
    ans++;
    n /= 2;
  }
  return ans;
}
bool check_divisible_count(vector<ll>& A) {
  int n = divisible_count_2(A[0]);
  rep(i, A.size()) if(divisible_count_2(A[i]) != n) return false;
  return true;
}
int main() {
  int N;
  ll M;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  if(!check_divisible_count(A)) {
    cout << 0 << endl;
    return 0;
  }
  ll LCM = 1;
  rep(i, N) {
    LCM = lcm(LCM, A[i]);
    if(LCM/2 > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << (M-LCM/2)/LCM+1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <assert.h>
int e,i,n,q,a,v,aa,vv,f[1000000],prev[100000],next[100000],aaa[100000],vvv[100000],head=0;
int main(void){
	scanf("%d %d",&n,&q);
	for(i=0;i<n;i++)f[i]=0; prev[0]=-1;

	for(e=0;e<q;e++){
		scanf("%d %d",&a,&v);a--;
		f[a]+=v;
		prev[e+1]=e;
		next[e]=e+1;
		aaa[e]=a;
		vvv[e]=f[a];

		if(v>0){if(f[a]>vv || (f[a]==vv && a<aa)){vv=f[a];aa=a;}}
		else if(a==aa){
			i=head;aa=0;vv=0;
			while(i<=e){
				if(vvv[i]!=f[aaa[i]]){
					if(prev[i]<0)head=next[i]; else next[prev[i]]=next[i];
					prev[next[i]]=prev[i];
				}
				else{
					if(vvv[i]>vv || (vvv[i]==vv && aaa[i]<aa)){vv=vvv[i];aa=aaa[i];}
				}
				i=next[i];
			}
		}

		printf("%d %d\n",aa+1,vv);
		
		/*
		{
			int aw=0,vw=0;
			for(i=0;i<n;i++){
				if(f[i]>vw || (f[i]==vw && a<aw)){vw=f[i];aw=i;}
			}
			if(aa!=aw || vw!=vv){
			for(i=0;i<=e;i++){fprintf(stderr,"%d %d %d %d %d %d %d %d %d\n",aaa[i],vvv[i],aa,aw,vv,vw,a,v,e);}
			assert(0);
			}
		}
		*/
		/*
		printf("head:%d\n",head);
		for(i=0;i<q;i++)printf("%3d",aaa[i]);printf("\n");
		for(i=0;i<q;i++)printf("%3d",vvv[i]);printf("\n");
		for(i=0;i<q;i++)printf("%3d",prev[i]);printf("\n");
		for(i=0;i<q;i++)printf("%3d",next[i]);printf("\n");
		for(i=0;i<n;i++)printf("%3d",f[i]);printf("\n\n");
		*/
	}
	return 0;
}

Measured memory_bytes: 6064
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
#    bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

N, M = map( int, input().split())
E = [ list( map( int, input().split())) for _ in range(M)]
ans = N*(N-1)//2
V = [1]*N
ANS = [0]*M
ANS[M-1] = ans
A = [ i for i in range(N)]
for i in range(M-1, 0,-1):
    a, b = E[i]
    a, b = find(A,a-1), find(A,b-1)
    if not a == b:
        ans -= V[a]*V[b]
        V[a] = V[b] = V[a]+V[b]
        union(A,a,b)
    ANS[i-1] = ans
    if ans == 0:
        break
for i in range(M):
    print(ANS[i])


Measured memory_bytes: 37348