akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<climits>
using namespace std;

template<typename T, T identity, function<T(T, T)>& op>
class SegTree{
private:
  vector<T> data;
  int size;
  int height; // the number of edges between the root and leaves

  T query_util(int bidx, int eidx, int data_idx, int dbi, int dei){
    if((bidx <= dbi) && (dei <= eidx)){
      return data[data_idx];
    }

    if((eidx <= dbi) || (dei <= bidx)){
      return identity;
    }

    int dmi = (dbi + dei) / 2;
    return op(
              query_util(bidx, eidx, 2 * data_idx + 1, dbi, dmi),
              query_util(bidx, eidx, 2 * data_idx + 2, dmi, dei)
              );
  }
public:
  SegTree(int size):
    size(size){
      height = 0;
      while((1 << height) < size){
        height++;
      }
      for(height = 0; (1 << height) < size; height++){
      }
      data = vector<T>((1 << (height + 1)) - 1, identity);
  }
  SegTree& update(int idx, T val){
    int leaf_idx = (1 << height) - 1 + idx;
    data[leaf_idx] = val;

    for(int node_idx = (leaf_idx - 1) / 2; node_idx > 0; node_idx = (node_idx - 1) / 2){
      data[node_idx] = op(data[2 * node_idx + 1], data[2 * node_idx + 2]);
    }
    data[0] = op(data[1], data[2]);
    return *this;
  }
  T query(int begin, int end){
    return query_util(begin, end, 0, 0, 1 << height);
  }
};

function<long long(long long, long long)> rangeMaximumQueryTreeOp = [](long long a, long long b){return max(a, b);};
using RangeMaximumQueryTree = SegTree<long long, LLONG_MIN, rangeMaximumQueryTreeOp>;
function<long long(long long, long long)> rangeMinimumQueryTreeOp = [](long long a, long long b){return min(a, b);};
using RangeMinimumQueryTree = SegTree<long long, LLONG_MAX, rangeMinimumQueryTreeOp>;
function<long long(long long, long long)> rangeSumTreeOp = [](long long a, long long b){return a + b;};
using RangeSumTree = SegTree<long long, 0LL, rangeSumTreeOp>;

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

  vector<int> h(N);
  for(auto& hh: h){
    cin >> hh;
  }

  vector<long long> a(N);
  for(auto& aa: a){
    cin >> aa;
  }

  vector<long long> dp(N);
  auto tree = RangeMaximumQueryTree(N + 1);
  dp[0] = a[0];
  tree.update(h[0], dp[0]);
  for(int i = 1; i < N; i++){
    dp[i] = max(0LL, tree.query(0, h[i])) + a[i];
    tree.update(h[i], dp[i]);
    dp[i] = max(dp[i - 1], dp[i]);
  }

  cout << dp[N - 1] << endl;
}



Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> h(n), dp(n, INT_MAX);
  
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  dp[0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 1; j <= 2; j++){
       if(i >= j){
          dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
       }
    }
  }
  
  cout << dp[n - 1];
  return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  long long n,m;
  cin>>n>>m;
  long long ans;
  if(n>m) swap(n,m);
  if(n==1){
    if(m==1) ans=1;
    else ans=m-2;
  }
  else if(n==2) ans=0;
  else ans=(n-2)*(m-2);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int main(){
    string a;   
	bool vis[2]={0};
    cin>>a;
    for(i,0,a.size()-1){
        if(a[i]=='C') vis[0]=1;
        if(a[i]=='F'&&vis[0]) vis[1]=1;
    }
    if(vis[1]) puts("Yes");
    else puts("No");
    exit(0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(int tc=1; ; ++tc){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<vector<vector<int> > > grid(7, vector<vector<int> >(7, vector<int>(7, 0)));
        for(int x=1; x<=5; ++x){
            for(int y=1; y<=5; ++y){
                for(int z=1; z<=5; ++z){
                    char c;
                    cin >> c;
                    grid[x][y][z] = c - '0';
                }
            }
        }

        vector<vector<int> > alive(2, vector<int>(27, 0));
        for(int i=0; i<2; ++i){
            int m;
            cin >> m;
            for(int j=0; j<m; ++j){
                int a;
                cin >> a;
                alive[i][a] = 1;
            }
        }

        while(--n >= 0){
            vector<vector<vector<int> > > nextGrid(7, vector<vector<int> >(7, vector<int>(7, 0)));
            for(int x=1; x<=5; ++x){
                for(int y=1; y<=5; ++y){
                    for(int z=1; z<=5; ++z){
                        int neighbor = -grid[x][y][z];
                        for(int i=0; i<27; ++i){
                            int x2 = x - 1 + i%3;
                            int y2 = y - 1 + i/3%3;
                            int z2 = z - 1 + i/3/3;
                            neighbor += grid[x2][y2][z2];
                        }
                        nextGrid[x][y][z] = alive[grid[x][y][z]][neighbor];
                    }
                }
            }
            grid.swap(nextGrid);
        }
        
        if(tc > 1)
            cout << endl;
        cout << "Case " << tc << ':' << endl;

        for(int x=1; x<=5; ++x){
            for(int y=1; y<=5; ++y){
                for(int z=1; z<=5; ++z){
                    cout << grid[x][y][z];
                }
                cout << endl;
            }
            if(x < 5)
                cout << endl;
        }
    }
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	float a,b,c,d,e,f,x,y,i,n;
	while(cin >> a >> b >> c >> d >> e >> f){
		x=(c*e-b*f)/(a*e-b*d);
		y=(c*d-a*f)/(b*d-a*e);
		if(x==-0) x=0;
		if(y==-0) y=0;
		printf("%.3f %.3f\n",x ,y);
	}
	return 0;
}


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

namespace _0337
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] == 0)
            {
                if (a[1] <= 1911) { Console.WriteLine("M" + (a[1] - 1867).ToString()); }
                else if (a[1] <= 1925) { Console.WriteLine("T" + (a[1] - 1911)); }
          else      if (a[1] <= 1988) { Console.WriteLine("S" + (a[1] - 1925)); }
                else { Console.WriteLine("H" + (a[1] - 1988)); }

            }
            else if (a[0] == 1) { Console.WriteLine(1867+a[1]); }
            else if (a[0] == 2) { Console.WriteLine(1911+a[1]); }
            else if (a[0] == 3) { Console.WriteLine(1925+a[1]); }
            else { Console.WriteLine(1988+a[1]); }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9552
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            String word = br.readLine();
            if ("-".equals(word)) {
                break;
            }

            int num = Integer.parseInt(br.readLine());
            String after_shuffle_word = word;
            for (int i = 0; i < num; i++) {
                int shuffle_num = Integer.parseInt(br.readLine());
                after_shuffle_word = shuffle(after_shuffle_word, shuffle_num);
            }
            
            System.out.println(after_shuffle_word);
        }
    }
    
    private static String shuffle(String word, int shuffle_num) {
        String pre_word = word.substring(0, shuffle_num);
        String post_word = word.substring(shuffle_num);
        return post_word + pre_word;
    }
}



Measured memory_bytes: 24444
"use strict";


const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    // 差が2以上あると交互に並べられない
    if(Math.abs(N - M) > 1) {
        console.log(0);
        return;
    }
    
    const MOD = 1e9 + 7;
    let answer = 1;
    
    for(let i=1; i<=N; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    for(let i=1; i<=M; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    // 差が1のときは、組み合わせが1通り 例：犬猿犬猿, 猿犬猿犬
    // 差が0のときは、組み合わせが2通り 例：犬猿犬猿犬
    // それによって答えを2倍にするかどうか分ける
    console.log(answer * ((N == M) + 1) % MOD);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main()
{
    int n, t, tt[200010];
    cin >> n >> t;
    for (int i = 0; i < n; i++) cin >> tt[i];

    long long ans = 0;
    for (int i = 1; i < n; i++) {
        if (tt[i] - tt[i - 1] >= t) ans += t;
        else ans += tt[i] - tt[i - 1];
    }
    ans += t;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

dp = Array.new(n)
dp[0] = 0
dp[1] = (h[0] - h[1]).abs

(2..(n - 1)).each do |i|
  dp[i] = [dp[i - 2] + (h[i - 2] - h[i]).abs, dp[i - 1] + (h[i - 1] - h[i]).abs].min
end

puts dp[n - 1]

Measured memory_bytes: 11780
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775808;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    if (N == 1) {
        if (A == B) {
            ans = 1;
        }
    }
    if (N > 1) {
        if (B >= A) {
            ans = ((B * (N - 1)) + A) - (B + A * (N - 1)) + 1;
        }
    }
    cout << ans << endl;
}


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

int main () {
  int n, p=0; cin >> n;
  vector<int> vec(n);
  for (int i=0;i<n;i++) 
    cin >> vec.at(i);
  for (int i=0;i<n;i++) {
    vector<int> a(n);
    a.at(i) = i+1;
    if (a.at(i) != vec.at(i))
      p++;
  }
  if (p == 0 || p == 2)
    cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 256
import math
import itertools

a, b = map(str, input().split())
C = a+b
c = int(C)

I=c
s=0
R=int(I)
L=[]
while s==0:
    for i in range(2,R+1):
        if I%i==0:
            I=I/i
            if I==1:
                s=1
            L.append(i)
            break
beforeC =""
count=0
index=0
flag=0
while index < len(L):
    if beforeC =="":
        beforeC = L[index]
        count+=1
    else:
        if L[index] == beforeC:
            count+=1
        else:
            if count%2==0:
                count =1
                beforeC = L[index]
            else:
                flag=1
                break
    index+=1
if count==1:
    flag=1

if flag ==1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000000000000
#define pi atan(1)*4
#define MOD 1000000000+7L
#define eps 0.0000006
#define MAX_V 10000
 
using namespace std;

vll a;
vll estado;

int k;

int solve(int i){
	if(i == 0) return 0;
	if(i == 1) return abs(a[0]-a[1]);

	if(estado[i] != INF) return estado[i]; 

	for (int j = i-1; j >= (i-k) && j >= 0; --j){
		estado[i] = min(solve(j)+abs(a[i]-a[j]),estado[i]);
	}

	return estado[i];
}

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

	cin >> n >> k;

	a.assign(n,0);
	estado.assign(n,INF);

	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}	

	estado[0] = 0;
	estado[1] = abs(a[1]-a[0]);

	for (int i = 2; i < n; ++i){
		for (int j = i-1; j >= (i-k) && j >= 0; j--){
			estado[i] = min(estado[j]+abs(a[i]-a[j]),estado[i]);
		}
	}

	cout << estado[n-1] << '\n';

	return 0;
}

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

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

    set<int> s;
    for (int i = a; i < a + k; ++i) {
        if (i <= b) {
            s.insert(i);
        }
    }
    for (int i = b; i > b - k; --i) {
        if (i >= a) {
            s.insert(i);
        }
    }

    set<int>::iterator it;
    for (it = s.begin(); it != s.end(); ++it) {
        cout << *it << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool F[10000][1440]; int n, K, a, b, s, t;
int main() {
	while (true) {
		cin >> n >> s >> t; if (n == 0)break;
		s = s / 100 * 60 + s % 100; t = t / 100 * 60 + t % 100;
		for (int i = 0; i < 14400000; i++)F[i / 1440][i % 1440] = false;
		for (int i = 0; i < n; i++) {
			cin >> K;
			for (int j = 0; j < K; j++) {
				cin >> a >> b; a = a / 100 * 60 + a % 100; b = b / 100 * 60 + b % 100;
				for (int k = a; k < b; k++)F[i][k] = true;
			}
		}
		int sum = 0, maxn = 0;
		for (int i = s; i < t; i++) {
			bool OK = false;
			for (int j = 0; j < n; j++) {
				if (F[j][i] == false)OK = true;
			}
			if (OK == true)sum++;
			else { sum = 0; }
			maxn = max(maxn, sum);
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 15220
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] a = new int[n];
        double sum=0;
        double sa = 0;
        int ans = 0;
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            sum+=a[i];
        }
        
        sa = sum/n;
      	double min = Math.abs(a[0]-sa);
      	
      	for(int i=1; i<n; i++){
      	    double diff = Math.abs(a[i]-sa);
      	    if(diff<min){
      	        min = diff;
      	        ans = i;
      	    }
        }
        
		System.out.println(ans);
    }
}


Measured memory_bytes: 36028
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MIN -10000000
#define MAX 10000000
#define debug printf("%d",__LINE__)
using namespace std;
int main()
{
	int n;
	int a, b;
	cin >> n >> a >> b;
	for(int i=a; i<=b; i++)
	{
		if(i % n == 0)
			cout << "OK", exit(0);
	}
	cout << "NG"; 
	return 0;
}


Measured memory_bytes: 3588
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(a[n-1])

Measured memory_bytes: 38384
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

void start() {
	#ifndef ONLINE_JUDGE 
		freopen("in", "r", stdin); 
		freopen("out", "w", stdout); 
	#endif
}

int n, m;
int arr[82][82][2];
int cache[81][81][81*162];

int dp(int i, int j, int diff) {
    if(i >= n || j >= m)
        return 1e18;

    if(i == n-1 && j == m-1) {
        return min(abs(diff - arr[i][j][0] + arr[i][j][1]), 
                    abs(diff + arr[i][j][0] - arr[i][j][1]));
    }

    int &ans = cache[i][j][diff];
    if(ans !=-1)
        return ans;

    int ans1 = min(dp(i+1, j, abs(diff - arr[i][j][0] + arr[i][j][1])),
                dp(i+1, j, abs(diff + arr[i][j][0] - arr[i][j][1])));
    int ans2 = min(dp(i, j+1, abs(diff - arr[i][j][0] + arr[i][j][1])),
                dp(i, j+1, abs(diff + arr[i][j][0] - arr[i][j][1])));
    ans = min(ans2, ans1);
    return ans;
}
int32_t main() {
    IOS;
    start();

    cin >> n >> m;
    for(int i = 0 ; i < n ; i++) {
        for(int j = 0 ; j < m ; j++) {
            cin >> arr[i][j][0];
        }
    }
    for(int i = 0 ; i < n ; i++) {
        for(int j = 0 ; j < m ; j++) {
            cin >> arr[i][j][1];
        }
    }

    memset(cache, -1, sizeof(cache));
    cout << dp(0, 0, 0) << endl;
}   

Measured memory_bytes: 676292
fn main() {
    let ab = read_vec::<String>();
    let a: u64 = ab[0].parse().ok().unwrap();
    let b: u64 = ab[1].split('.').collect::<Vec<_>>().concat().parse().ok().unwrap();
    println!("{}", (a * b) / 100);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 2144
import itertools

def warshall_floyd(d,n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

N,M,R = [int(x) for x in input().split()]
graph = [[float('inf')]*(N+1) for _ in range(N+1)]
r = [int(x) for x in input().split()]

for _ in range(M):
    s,d,w = [int(x) for x in input().split()]
    graph[s][d] = w
    graph[d][s] = w

warshall_floyd(graph,N+1)
ans = float('inf')
for _r in itertools.permutations(r):
    di = 0
    for ind,j in enumerate(_r[:-1]):
        di+=graph[j][_r[ind+1]]
    ans = min(ans,di)

print(ans)


Measured memory_bytes: 59352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto& e : v) cin >> e;
    map<int,int>cnt; for(auto e : v) cnt[e]++;
    bool flag = false;
    if(cnt.size() == 2){
        flag = cnt[0] == N/3;
    } else if(cnt.size() == 3){
        int temp = cnt.begin() -> first;
        for(auto itr = cnt.begin(); itr != cnt.end(); ++itr){
            if(itr != cnt.begin())
                temp  = temp xor itr-> first;
            if (itr->second  != N/3) return puts("No") *0;
        }
        flag = temp ==  0;
    }
    cout <<
    (accumulate(v.begin(), v.end(),true,[](bool res,int a){
        return res and a == 0LL;
    }) or flag ? "Yes\n" : "No\n");
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
#include<math.h>
const double PI = acos(-1);
using namespace std;
int main()
{

     long int t,i,b,n;
     
     double m,p,k,l; 
    cin>>n>>m;
    long int a[n];
     for(i=0;i<n;i++)
     cin>>a[i];
     b=0;
     k=0;
     for(i=0;i<n;i++)
     {
     k=k+a[i];
         
     }
     for(i=0;i<n;i++)
     {
         if(a[i]>=(k/(4*m)))
           b++;
     }
    if(b>=m)
    cout<<"Yes";
    else
    cout<<"No";
    
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
/////////////////////////



//Answer


int main() {

    int N,Answer;
    cin>>N;
    if(N>=30){
            cout<<"Yes"<<endl;
    }else{
            cout<<"No"<<endl;
    }







}

Measured memory_bytes: 3620
import math

input()

vx = [int(i) for i in input().split()]
vy = [int(i) for i in input().split()]

Dxy = []
for p in range(1, 4):
    Dxy.append(sum([abs(vx[i] - vy[i]) ** p for i in range(len(vx))]) ** (1 / p))

Dxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))]))

for res in Dxy:
    print('{0:5f}'.format(res))

Measured memory_bytes: 6848
using System;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];

            var cities = new int[n];

            for(int i = 0; i < m; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var a = ab[0];
                var b = ab[1];

                cities[a - 1]++;
                cities[b - 1]++;
            }

            for(int i = 0; i < n; i++)
            {
                Console.WriteLine(cities[i]);
            }
        }
    }
}

Measured memory_bytes: 28116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    char ch = getchar(); ll x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}
const ll N=1e5+7;
struct node{
	ll x,y,v;}a[N];
bool mmp(node a,node b){
	return a.x<b.x;}
bool mp(node a,node b){
	return a.y<b.y;}
ll dis[N],hang[N],lie[N],smi[N];
bool boo[N];
vector<ll> now,si[N],v[N];
ll mi=1e9+7;
void dfs(ll x){
	mi=min(mi,dis[x]);
	boo[x]=1;
	now.push_back(x);
	for (ll j=0;j<si[x].size();++j)
	{
		ll p=si[x][j];
		if (!boo[p])
		{
			dis[p]=dis[x]+v[x][j];
			dfs(p);
		}
	}
}
void add(ll x,ll y,ll vv){
	si[x].push_back(y);
	v[x].push_back(vv);
}
int main(){
	ll T=1;
	while (T--)
	{
		bool flat=0;
		ll R=read(),C=read();
		ll n=read();
		for (ll i=1;i<=n;i++)
		{a[i].x=read();a[i].y=read();a[i].v=read();}
		sort(a+1,a+1+n,mmp);
		for (ll i=1;i<n;i++)
		{
			if (a[i].x==a[i+1].x)
			{
				add(a[i+1].y,a[i].y,a[i].v-a[i+1].v);
				add(a[i].y,a[i+1].y,a[i+1].v-a[i].v);
			}
		}
		for (ll i=1;i<=C;i++)
		if (!boo[i])
		{
			mi=1e9+7;
			dis[i]=0;
			dfs(i);
			for (ll j=0;j<now.size();++j)
				smi[now[j]]=mi;
			now.clear();
		}
		for (ll i=1;i<=C;i++)
			for (ll j=0;j<si[i].size();++j)
			if ((dis[si[i][j]]-dis[i])!=v[i][j])
			{flat=1;break;}
		for (ll i=1;i<=C;i++)
		{
		  lie[i]=dis[i]-smi[i];
		  boo[i]=0;
		  si[i].clear();
		  v[i].clear();
		}	
		
		
		sort(a+1,a+1+n,mp);
		for (ll i=1;i<n;i++)
		{
			if (a[i].x==a[i+1].x)
			{
				add(a[i+1].y,a[i].y,a[i].v-a[i+1].v);
				add(a[i].y,a[i+1].y,a[i+1].v-a[i].v);
			}
		}
		for (ll i=1;i<=R;i++)
		if (!boo[i])
		{
			mi=1e9+7;
			dis[i]=0;
			dfs(i);
			for (ll j=0;j<now.size();++j)
				smi[now[j]]=mi;
			now.clear();
		}
		for (ll i=1;i<=R;i++)
			for (ll j=0;j<si[i].size();++j)
			if ((dis[si[i][j]]-dis[i])!=v[i][j])
			{flat=1;break;}
		for (ll i=1;i<=R;i++)
		{
		  hang[i]=dis[i]-smi[i];
		  boo[i]=0;
		  si[i].clear();
		  v[i].clear();
		}
		for (ll i=1;i<=n;i++)
		if ((a[i].v-hang[a[i].x]-lie[a[i].y])<0)
			flat=1;
		if (flat) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
}
	

Measured memory_bytes: 15872
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;
ll ma;

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

  cin >> n >> h;
  rep(i, n) {
    cin >> a[i] >> b[i];
    ma = max(ma, a[i]);
  }
  sort(b, b + n);
  reverse(b, b + n);
  rep(i, n) {
    if (ma > b[i]) break;
    h -= b[i];
    ans++;
    if (h <= 0) break;
  }
  if (h > 0) ans += (h + ma - 1) / ma;
  Cout(ans);
  return 0;
}

Measured memory_bytes: 5120
import sys, itertools
f = sys.stdin

start = [line.split() for line in f]
start = tuple(int(x) for y in start for x in y)
end =(1, 2, 3, 4, 5, 6,7, 8, 0)

d = {start:0}

def next_board(b):
    brank = b.index(0)
    if brank % 3:
        yield b[:brank - 1] + (b[brank], b[brank - 1]) + b[brank + 1:]
    if brank // 3:
        yield b[:brank - 3] + (b[brank],)+ b[brank - 2:brank] +  (b[brank - 3],) + b[brank + 1:]
    if brank % 3 != 2:
        yield b[:brank] + (b[brank + 1], b[brank]) + b[brank + 2:]
    if brank // 3 != 2:
        yield b[:brank] + (b[brank + 3],)+ b[brank + 1:brank + 3] +  (b[brank],) + b[brank + 4:]

queue = set([start])
while len(queue):
    u = queue.pop()
    for b in next_board(u):
        if b not in d or d[b] > d[u] + 1:
            d[b] = d[u] + 1
            queue.update([b])
        
print(d[end])

Measured memory_bytes: 52548
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

const ll mod = 1000000007;

ll dp[1000][2010];

int main(){
  int S; cin >> S;
  dp[0][0]=1;
  // i, sumj
  for(int i=1;i<667;i++){
    ll tmp = 0;
    for(int j=0;j<=S;j++){
      if(j>=3) tmp+=dp[i-1][j-3];
      dp[i][j] = tmp;
      dp[i][j]%=mod;
    }
  }
  ll ans = 0;

  rep(i,1000) {
    ans+=dp[i][S];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14028
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

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

    vector<char> v(3); cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    
    cout << (v[0]=='a' && v[1]=='b' && v[2]=='c' ? "Yes":"No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long H,W;
	cin>>H>>W;
	if(H==1||W==1){
		cout<<1<<endl;
	}
	else{
		if(H*W%2==0)
			cout<<H*W/2<<endl;
		else
			cout<<H*W/2+1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
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();
      if (a < b)
         System.out.println("a < b");
      else if (a > b)
         System.out.println("a > b");
      else
         System.out.println("a == b");
   }
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'A'){
      if(s[i+1] == 'B' && s[i+2] == 'C'){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
subroutine heapsort(n,array)                                                                               
  implicit none
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)

  integer ::i,k,j,l
  double precision :: t

  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo

  return
end subroutine heapsort

program Beg3
  implicit none
  integer :: N, i, j
  integer, allocatable :: A(:)


  read(*,*) N
  allocate(A(N))
  read(*,*) (A(i), i=1,N)

  call heapsort(N,A)

  do i=1,N-1
     if(A(i).eq.A(i+1)) goto 500
  enddo


  print*, 'YES'
  stop

  500 print *, 'NO'



end program Beg3



Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

double Max(double a,double b){
	if(a>=b){
		return a;
	}
	else{
		return b;
	}
}

double Min(double a,double b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

int main(){

	double max=0,min=100000000;

	double tmp;

	while(cin>>tmp){
		if(tmp==0){
			break;
		}
		max = Max(max,tmp);
		min = Min(min,tmp);
	}

	cout<<(max-min)<<endl;
}

/*
Sample Input
3776.0
1819.0
645.2
2004.1
1208.6
Output for the Sample Input
3130.8
*/

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    int N,M,K;
    cin >> N >> M >> K;
    // 友達関係もブロック関係もまとめて管理する
    vector<set<int>> ForB(N);
    UnionFind uf(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--; b--;
        ForB[a].insert(b);
        ForB[b].insert(a);
        uf.merge(a,b); // 友人関係をUFに突っ込む
    }
    rep(i,K){
        int c,d;
        cin >> c >> d;
        c--; d--;
        if(uf.issame(c,d)==false){
            // 違う繋がりならブロック関係でも無視
            continue;
        }
        ForB[c].insert(d);
        ForB[d].insert(c);
        // ブロック関係はUFに突っ込む必要はない
    }
    rep(i,N){
        int num;
        num = uf.size(i) - 1; //自分自身を除く
        num -= ForB[i].size();
        cout << num << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 24704
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      // 取得
	  int N = sc.nextInt();
      int ans = 0;
      for(int i=0;i<N;i++){
        ans+=sc.nextInt()-1;
      }
      System.out.println(ans);
    }
}

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

using namespace std;

#define MOVEMAX 10000
#define NMAX 100
#define ARRAYSIZE NMAX+MOVEMAX+5
struct list{
	int next,prev;
	int n;
};


int main(){

	list l[ARRAYSIZE];
	int N,b;
	int cnt;
	int s,e;
	int ans;
	int tmp;
	bool f;

	while(1){

		cin>>N;
		if(N==0) break;

		l[0].n=-1;
		l[0].next=1;
		l[0].prev=-1;
		s=0;
		cnt=0;
		for(int i=1;i<=N;i++){
			cin>>b;
			l[i].n=b;
			l[i].prev=i-1;
			l[i].next=i+1;
			cnt+=b;
		}
		l[N+1].n=-1;
		l[N+1].next=-1;
		l[N+1].prev=N;
		e=N+1;
		for(int i=N+2;i<ARRAYSIZE;i++){
			l[i].n=-1;
			l[i].next=-1;
			l[i].prev=-1;
		}
		ans=0;
		f=false;
		for(int i=0;cnt>=i*(i+1)/2;i++){
			if(cnt==i*(i+1)/2){
				f=true;
				break;
			}
		}
		if(!f){
			cout<<"-1"<<endl;
			continue;
		}
		while(1){
			f=true;
			cnt=1;
			for(int i=l[s].next;l[i].next!=-1;i=l[i].next){
				if(cnt!=l[i].n){
					f=false;
					break;
				}
				cnt++;
			}
			if(f) break;
			ans++;
			if(ans>MOVEMAX) break;
			cnt=0;
			for(int i=l[s].next;l[i].next!=-1;i=l[i].next){
				cnt++;
				l[i].n--;
			}
			for(int i=l[s].next;l[i].next!=-1;i=l[i].next){
				if(l[i].n==0){
					l[l[i].prev].next=l[i].next;
					l[l[i].next].prev=l[i].prev;
					tmp=l[i].prev;
					l[i].n=-1;
					l[i].next=-1;
					l[i].prev=-1;
					i=tmp;
				}
			}
			l[l[e].prev].next=e+ans;
			l[e+ans].next=e;
			l[e+ans].prev=l[e].prev;
			l[e].prev=e+ans;
			l[e+ans].n=cnt;
		}
		if(ans>MOVEMAX) cout<<"-1"<<endl;
		else cout<<ans<<endl;
	}

}

Measured memory_bytes: 1280
n,a,b = map(int,input().split())
s = input()
p,o = 0,1

for i in range(len(s)):
    if s[i] == "a":
        if p < a+b:
            print("Yes")
            p += 1
            continue

    elif s[i] == "b":
        if p < a+b and o <= b:
            print("Yes")
            p += 1
            o += 1
            continue

    print("No")
        


Measured memory_bytes: 4024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

int main() {
	string s;
	cin >> s;
	int ans = 0;http://arc063.contest.atcoder.jp/submit?task_id=2146
	Loop1(i, s.length()-1) {
		if (s[i] != s[i - 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  if (s == "SUN") {
    cout << 7 << endl;
  } else if (s == "MON") {
    cout << 6 << endl;
  } else if (s == "TUE") {
    cout << 5 << endl;
  } else if (s == "WED") {
    cout << 4 << endl;
  } else if (s == "THU") {
    cout << 3 << endl;
  } else if (s == "FRI") {
    cout << 2 << endl;
  } else if (s == "SAT") {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
 
typedef long long int ll;
typedef string str;
 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}
 
ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}
 
void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	
	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    str st,s;
    m=0;
    cin >> st;
    for(i=0;i<st.size();i++)
    {
        m+=(st[i]-'0');
        m%=9;
    }
    if(m==0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3752
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,mi,ind,res=0;
  P r[101],b[101];
  bool ur[101],ub[101];
  REP(i,101){ur[i]= false;ub[i]=false;}
  cin >> N;
  REP(i,N)cin >> r[i].first >> r[i].second;
  REP(i,N)cin >> b[i].first >> b[i].second;
  sort(b,b+N);
  REP(j,N){
    mi = -1;
    REP(i,N){
      if(mi < r[i].second && !ur[i] && b[j].first > r[i].first && b[j].second > r[i].second){
        mi = r[i].second;
        ind = i;
      }
    }
    if(mi != -1){
      ur[ind] = true;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;

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

  ll a[n],sumArray[n],minScore = 1e15;
  rep(i,n){
    cin >> a[i];
    sumArray[i] = a[i];
  }
  rep(i,n-1) sumArray[i+1] += sumArray[i];

  FOR(i,0,n-1){
    minScore = min(minScore,abs(sumArray[i]-(sumArray[n-1]-sumArray[i])));
  }
  cout << minScore << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 11) * 2;
    x %= 11;
    ans += (x + 5) / 6;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	string s,t;
	cin >> s >> t;
	vector< vector<int> > spos(26), tpos(26);
	for(int i = 0; i < (int)t.size(); i++){
		int snum = s[i] - 'a';
		spos[snum].pb(i);
		int tnum = t[i] - 'a';
		tpos[tnum].pb(i);
	}

	sort(spos.begin(), spos.end());
	sort(tpos.begin(), tpos.end());
	if(spos == tpos)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

#define ll long long
#define ar array

int main() {

    ios::sync_with_stdio(false);
	
	int a, n, soma=0, numero;
	
	cin >> a;
	numero = a;

    while (numero != 0) {
        soma   += numero % 10;
        numero  = numero / 10;
    }
    
    if (a%soma == 0){
    	cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

    return 0;
}


Measured memory_bytes: 256
n, k =map(int, input().split())
h = list(map(int, input().split()))
dp = [10 ** 9 for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    for j in range(1, min(i+1, k+1)):
        x = dp[i-j] + abs(h[i]-h[i-j])
        #print([i, j, x])
        dp[i] = min(x, dp[i])
    #print(dp[i])
print(dp[n-1])

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int v = -150, w = MOD;

    rep(i, n){
        int tmp;
        cin >> tmp;
        v = max(v, tmp);
    }
    rep(i, m){
        int tmp;
        cin >> tmp;
        w = min(w, tmp);
    }
    v++;

    for (int i = v; i <= w; ++i) {
        if(x < i && i <= y){
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	vector<lli> a(n), b(n);
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
	}
	lli ans = 0;
	for(int i=n-1; i>=0; i--){
		ans += (b[i] -(a[i]+ans)%b[i])%b[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <iostream>
#include <string>

int main() {
	std::string input;
	std::getline(std::cin, input);

	input.replace(5, 1, " ");
	input.replace(13, 1, " ");

	std::cout << input << std::endl;

	return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int asc(const void *a,const void *b){return *(long long *)a-*(long long*)b;}
int main(){
    int n, k, i = 0;
    scanf("%d%d",&n,&k);
    ll h[n];
    for(; i < n; i++)
        scanf("%lld",&h[i]);
    qsort(h,n,sizeof(long long),asc);
    ll ans = 0;
    for(i = 0; i < n - k; i++)
        ans += h[i];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3324
def main():
    N, T = [int(e) for e in input().split()]

    c_t_pairs = []
    for _ in range(N):
        c, t = [int(e) for e in input().split()]
        c_t_pairs.append((c, t))
    # print(c_t_pairs)

    ok_c = []
    for pair in c_t_pairs:
        c, t = pair
        if t <= T:
            ok_c.append(c)
    if ok_c:
        print(min(ok_c))
    else:
        print("TLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    int a,b,c;
    cin>>a>>b>>c;
    int ans=max<int>({
    	10*a+b+c,
    	a+b*10+c,
    	a+b+c*10,

    });
    cout<<ans;
	return 0;
}

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;

int arr[4];
string s;

void print( int x ) {
  cout << arr[0];
  for( int i = 0; i < 3; ++i ) {
    if( x&(1<<i) ) cout << '+';
    else cout << '-';
    cout << arr[i+1];

  }
  cout << "=7\n";
}

bool check( int x ) {
  int sum = arr[0];
  for( int i = 0; i < 3; ++i ) {
    if( x&(1<<i) ) sum += arr[i+1];
    else sum -= arr[i+1];
  }
  return sum == 7;
}

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif
  while( cin >> s ) {
    for( int i = 0; i < 4; ++i ) {
      arr[i] = s[i]-'0';
    }
    for( int i = 0; i < (1<<3); ++i ) {
      if( check(i) ) {
        print(i);
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;
int L[2001];

int main(void){
    int N, ab, cIdx, ans=0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &L[i]);
    sort(L, L+N);
    for (int i = 0; i < N-2; i++) {
        for (int j = i + 1; j < N-1; j++) {
            ab = L[i] + L[j]-1;
            cIdx = int(upper_bound(L, L+N, ab)-L);
            for (int k = j + 1; k < cIdx; k++) {
                if (L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1700
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] abt = sc.nextLine().split(" ");
        int A = Integer.parseInt(abt[0]);
        int P = Integer.parseInt(abt[1]);

        int piece = A * 3 + P;
        int created = piece / 2;
        System.out.println(created);
    }

}


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

int main()
{
    
   
   
    int n;
    cin>>n;
    int a[n];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x%2!=0 and (i+1)%2!=0)
            ans+=1;
    }
    cout<<ans<<endl;
    

}


Measured memory_bytes: 3628