akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
string a,b; 
int x,y;
string t;
int main(){
    cin>>a>>b>>x>>y>>t;
    if(t==a)x--;
    else y--;
    cout<<x<<" "<<y;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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;}
 


 int main(){
  string s, t ;cin>>s>>t ;
  ll k = s.size() ;
  vector<ll> A(26,-1) ,B(26,-1) ;
  
  bool ok=1 ;
  rep(i,k){
    ll p= s[i]-'a' ;
    ll q= t[i]-'a' ;
    if(A[p]!=B[q]){
      ok=0 ;
      break ;
    }
    A[p]= i ; B[q]= i ;
  }
  if(ok) cout<<"Yes"<<endl ;
  else cout<<"No"<<endl ;
   return 0 ;
 }



Measured memory_bytes: 3876
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n;
    cin>>n;
    ll k=1;
    while(k*(k+1)/2<n) k++;
    ll m=-n+k*(k+1)/2;
    for(int i=1;i<=k;i++){
        if(i!=m) cout<<i<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using p = pair<int,int>;

void dfs(int node, int cor, vector<vector<int>> &edge, map<p, int> &ans, vector<bool> &used){
    used[node] = true;
    int c = (cor == 1?2:1);
    for(auto e: edge[node]){
        if(used[e]) continue;
        ans[{node, e}] = c;
        ans[{e, node}] = c;
        dfs(e, c, edge, ans, used);
        c = (c+1 != cor? c+1: c+2);
    }

}

int main(){
    int n;
    cin >> n;
    vector<p> e(n);
    vector<vector<int>> edge(n, vector<int>());
    for(int i=0;i<n-1;i++){
        cin >> e[i].first >> e[i].second;
        e[i].first--; e[i].second--;
        edge[e[i].first].push_back(e[i].second);
        edge[e[i].second].push_back(e[i].first);
    }
    int k = 0;
    for(int i=0;i<n;i++){
        k = max((int)edge[i].size(), k);
    }
    map<p, int> ans;
    vector<bool> used(n, false);
    dfs(0, 0, edge, ans, used);

    cout << k << endl;
    for(int i=0;i<n-1;i++){
        cout << ans[e[i]] << endl;
    }
}

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

void fnInput(int &rnLodC, int &rnTrkC, vector<int> &rvnLod)
{
  cin >> rnLodC >> rnTrkC;

  rvnLod.resize(rnLodC);
  for (int i = 0; i < rnLodC; i++)
    cin >> rvnLod[i];
}

int fnSimuAlloc(const vector<int> &cnrvnLod, int nTrkC, int nLod)
{
  int iCurLod;
  int iCntTrk = 0;

  for (int i = 0; i < cnrvnLod.size();    )
  {
    if (cnrvnLod[i] > nLod)  return 0;

    iCntTrk++;
    iCurLod = 0;
    while (i < cnrvnLod.size())
    {
      iCurLod += cnrvnLod[i];
      if (iCurLod > nLod)  break;

      i++;
    }
  }
  return (iCntTrk <= nTrkC);
}

void fnAlloc(const vector<int> &cnrvnLod, int nTrkC, int &rnMinLod)
{
  const int cnnMinLod = 0;
  const int cnnMaxLod = 1000000000;

  int nLow  = cnnMinLod;
  int nHigh = cnnMaxLod;
  rnMinLod = cnnMaxLod;

  while (nLow < nHigh)
  {
    int nMind = (nLow + nHigh) / 2;
    if (fnSimuAlloc(cnrvnLod, nTrkC, nMind))
    {
      rnMinLod = min(rnMinLod, nMind);
      nHigh = nMind;
    }
    else
      nLow = nMind + 1;
  }
}

void fnReSult(int nMinLod)
{
  cout << nMinLod << endl;
}

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

  int nLodC, nTrkC;
  vector<int> vnLod;
  int nMinLod = 0;

  fnInput(nLodC, nTrkC, vnLod);
  fnAlloc(vnLod, nTrkC, nMinLod);
  fnReSult(nMinLod);

  return 0;
}

Measured memory_bytes: 1528
#include <iostream>

using namespace std;

int main()
{
    int x,y,r,w,h;
    cin >> w >> h >> x >> y >> r;
    if((w-r)>=x && x>=r && (h-r)>=y && y>=r){
            cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		int point;
		double kakuritu = 1.0000000000;
		double ans = 0.0000000000;
		for(int i=1;i<=N;i++){
			kakuritu = 1.0000000000/N;
			point = i;
			while(point<K){
				kakuritu *= 0.5;
				point *= 2;
			}
			ans += kakuritu;
		}
		sc.close();
		System.out.println(ans);
	}
};


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main(){
  fast;
  long long w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans_area = (double)(w) / 2.0 * h;
  bool multi = (w == x * 2) && (h == y * 2);
  cout << ans_area << ' ' << (int)(multi) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t, n, x, y, c, d;
    cin >> t >> d;
    vector<pair<long long int,long long int>> st;
    c = 0;
    while (t--)
    {
        cin >> x >> y;
        st.push_back(make_pair(x, y));
    }
    for (auto i = st.begin(); i != st.end(); i++)
        {
            if (sqrt((i->first * i->first) + (i->second * i->second)) <= d)
                c++;
        }
    cout << c;
}

Measured memory_bytes: 7520
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

long long inv(int a, int p) { return a==1 ? 1 : (1-p*inv(p%a,a))/a+p; }
static const int MODVAL = 1000000007;
struct mint {
  int val;
  mint():val(0){}
  mint(int x):val(x%MODVAL) { if(val<0) val+= MODVAL; }
  mint(size_t x):val(x%MODVAL) {}
  mint(long long x):val(x%MODVAL) { if(val<0) val+= MODVAL; }
  mint& operator+=(mint y) { val+=y.val; if(val>=MODVAL) val-=MODVAL; return *this; }
  mint& operator-=(mint y) { val-=y.val; if(val<0) val+= MODVAL; return *this; }
  mint& operator*=(mint y) { val=(val*(long long)y.val)%MODVAL; return *this; }
  mint& operator/=(mint y) { val=(val*inv(y.val,MODVAL))%MODVAL; return *this; }
};
inline mint operator+(mint x, mint y) { return x+=y; }
inline mint operator-(mint x, mint y) { return x-=y; }
inline mint operator*(mint x, mint y) { return x*=y; }
inline mint operator/(mint x, mint y) { return x/=y; }
mint POW(mint x, long long n) { mint r(1); for(;n;x*=x,n>>=1) if(n&1) r*=x; return r; }
mint FAC(int n) { static vector<mint> FAC_(1,1);
  while(int(FAC_.size())<=n) FAC_.push_back(FAC_.back()*FAC_.size()); return FAC_[n]; }
inline mint CMB(int n, int k) { return k<0||n<k ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); }
inline ostream& operator<<(ostream& os, mint a) { return os << a.val; }

int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  mint res = 0;
  for(int i = k; i <= n+1; ++i) {
    res += mint(n + (n-i+1))*i/2 - mint(0 + i-1)*i/2 + 1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3268
#[allow(unused_imports)]
use std::io;

#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

#[allow(unused_macros)]
macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

trait Monoid {
    type Elem;
    fn id(&self) -> Self::Elem;
    fn ops(&self, lhs: &Self::Elem, rhs: &Self::Elem) -> Self::Elem;
}

struct SegmentTree<T: Monoid> {
    v: Vec<T::Elem>,
    n: usize,
    t: T,
}

impl<T: Monoid> SegmentTree<T>
where
    T::Elem: std::clone::Clone,
{
    fn new(n: usize, t: T) -> SegmentTree<T> {
        let mut st = SegmentTree {
            n: 1,
            t: t,
            v: Vec::new(),
        };
        while st.n < n {
            st.n *= 2;
        }
        st.v.resize(st.n * 2 - 1, st.t.id());
        if n >= 2 {
            for i in 0..st.n - 2 + 1 {
                let i = st.n - 2 - i;
                st.v[i] = st.t.ops(&st.v[i * 2 + 1], &st.v[i * 2 + 2]);
            }
        }
        st
    }
    #[allow(dead_code)]
    fn set(&mut self, i: usize, x: T::Elem) {
        let mut i = i + self.n - 1;
        self.v[i] = x;
        while i > 0 {
            i = (i - 1) / 2;
            self.v[i] = self.t.ops(&self.v[i * 2 + 1], &self.v[i * 2 + 2]);
        }
    }
    #[allow(dead_code)]
    fn get(&self, a: usize, b: usize) -> T::Elem {
        fn q<U: Monoid>(
            st: &SegmentTree<U>,
            a: usize,
            b: usize,
            k: usize,
            l: usize,
            r: usize,
        ) -> U::Elem
        where
            U::Elem: std::clone::Clone,
        {
            if r <= a || b <= l {
                st.t.id()
            } else if a <= l && r <= b {
                st.v[k].clone()
            } else {
                let c = (l + r) / 2;
                st.t
                    .ops(&q(st, a, b, k * 2 + 1, l, c), &q(st, a, b, k * 2 + 2, c, r))
            }
        }
        q(self, a, b, 0, 0, self.n)
    }
}

impl<T: Monoid> std::ops::Index<usize> for SegmentTree<T> {
    type Output = T::Elem;
    #[allow(dead_code)]
    fn index(&self, i: usize) -> &Self::Output { &self.v[i] }
}

struct MinMonoid {}
impl Monoid for MinMonoid {
    type Elem = u64;
    fn id(&self) -> Self::Elem { (1u64 << 31) - 1 }
    fn ops(&self, lhs: &Self::Elem, rhs: &Self::Elem) -> Self::Elem { std::cmp::min(*lhs, *rhs) }
}

fn main() {
    from_line!(n: usize, q: usize);
    let mut st = SegmentTree::new(n, MinMonoid {});
    for _ in 0..q {
        from_line!(comp: usize, x: usize, y: usize);
        match comp {
            0 => st.set(x, y as u64),
            1 => println!("{}", st.get(x, y + 1)),
            _ => unreachable!(),
        };
    }
}



Measured memory_bytes: 7096
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define Rep(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n,k;cin>>n>>k;
  int max=(n-1)*(n-2)/2;
  int ans=max-k;
  if(ans<0)cout<<-1<<endl;
  else{
    cout<<n-1+ans<<endl;
    rep(i,n-1)cout<<n<<' '<<i+1<<endl;
    bool b=false;
    rep(i,n-1){
      Rep(j,i+1,n-1){
        if(ans==0){
          b=true;
          break;
        }
        cout<<i+1<<' '<<j+1<<endl;
        ans--;
      }
      if(b)break;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rRep(i,a,b) for(int i = a; i >= b; i--)
#define rrep(i,a) rRep(i,a,0)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9+7;
const ll infll = (1 << 60);
const ll mod = 1e9 + 7;

// 型による変数のオーバーフローに気をつけろ！！
// 悩んだら図やグラフを書け！！悩む前から書け！！

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

	// ?をABCのいずれかに置き換えることで得られるすべてのABCのかず
	// 難しくね？

	ll sum = 1;

	vector<vector<ll>>dp;
	dp = vector<vector<ll>>(s.size() + 1, vector<ll>(4));

	for (int i = s.size(); i >= 0; i--) {
		for (int j = 3; j >= 0; j--) {
			if (i == s.size()) {
				dp[i][j] = (j == 3 ? 1 : 0);
			}
			else {
				dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3LL : 1LL);
				if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j])) { // こんな書き方あるんだ
					dp[i][j] += dp[i + 1][j + 1];
				}
				dp[i][j] %= mod;
			}
		}
	}


	cout << dp[0][0] << endl;


	return 0;
}

Measured memory_bytes: 7424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	static int N;
	static String S;
	static int[] sum;

	public static void main(String[] args) {
		//入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			N = Integer.parseInt(br.readLine());
			S = br.readLine();
			sum = new int[N+1];
		} catch(IOException e) {
			e.printStackTrace();
		}

		for(int i=0; i<N; i++) {
			if(S.charAt(i)=='.') sum[0]++;
		}

		for(int i=1; i<N+1; i++) {
			if(S.charAt(i-1)=='#') {
				sum[i] = sum[i-1] + 1;
			} else {
				sum[i] = sum[i-1] - 1;
			}
		}

		Arrays.sort(sum);
		System.out.println(sum[0]);
	}
}

Measured memory_bytes: 27476
N= int(input())
M=0
A=0
R=0
C=0
H=0
for i in range (N):
    a=(input())
    a_split=list(a)
    if a_split[0]=='M':
        M=M+1
    elif a_split[0]=='A':
        A=A+1
    elif a_split[0]=='R':
        R=R+1
    elif a_split[0]=='C':
        C=C+1
    elif a_split[0]=='H':
        H=H+1

count=0
#M
count=count+M*A*R
count=count+M*A*C
count=count+M*A*H

#A
count=count+M*R*C
count=count+M*R*H
count=count+M*C*H

count=count+A*R*C
count=count+A*R*H
count=count+A*C*H

count=count+R*C*H

print (count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long int
#define pb push_back
#define mp make_pair
#define ip pair<int, int>
#define it pair<int, pair<int, int>>
#define F first
#define S second
#define fori(p, n) for(int i = p; i < n; i++)
#define forj(q, m) for(int j = q; j < m; j++)
#define fork(r, l) for(int k = r; k < l; k++)
#define revi(h) for(int i = h; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define PI 3.14159265358
#define debug(x) cout<<"DEBUGGING --- "<<x<<endl;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file freopen("output.txt", "w", stdout);
//vector<bool>vis(1005);
signed main(){
    fastio;
    //input_from_file; 
    //output_to_file;
    string s, t;
    getline(cin, s);
    getline(cin, t);
    //cout<<s<<" "<<t<<endl;
    int ss = s.size(), tt = t.size();
    vector<vector<int>>dp(ss + 1, vector<int>(tt + 1, 0));
    fori(1, ss + 1)
        forj(1, tt + 1)
            if(s[i - 1] == t[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
            else dp[i][j] = max(dp[i- 1][j], dp[i][j - 1]);
    // fori(0, ss + 1){
    //     forj(0, tt + 1) cout<<dp[i][j]<<" ";
    //     cout<<endl;         
    // }
    vector<char>res(dp[ss][tt] + 1);
    int idx = dp[ss][tt];
    //cout<<idx<<endl;
    int i = ss, j = tt;
    while(i > 0 && j > 0){
        if(s[i - 1] == t[j - 1]) res[--idx] = s[i - 1], i--, j--;
        else
            if(dp[i - 1][j] > dp[i][j - 1]) i--;
            else j--;
        //cout<<idx<<endl;
        }        
    fori(0, dp[ss][tt]) cout<<res[i];                   
}

Measured memory_bytes: 70784
N = int(input())
A = list(map(int,input().split()))
 
four = 0
two = 0
odd = 0
for i in A:
    if i%4 == 0:
        four += 1
    elif i%2 == 0:
        two += 1
    else:
        odd += 1
 
if two >= 1:
    odd += 1
 
if odd <= four+1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N = scanner.nextInt();
		    int P = scanner.nextInt();
		    int[] array = new int[N];
		    int count0 = 0;
		    int count1 = 0; 
		    
		    for( int i = 0; i < N; i++ ) 
		    {
		    	array[i] = scanner.nextInt() % 2;
		    	if( array[i] == 1 ) 
		    	{
		    		count1 = count1 + 1;
		    	}
		    	else 
		    	{
		    		count0 = count0 + 1;
		    	}
		    }
		    if( count1 == 0 ) 
		    {
		    	if( P == 1 ) 
		    	{
		    		System.out.println(0);
		    	}
		    	else 
		    	{
		    		System.out.println((long)Math.pow( 2, N ));
		    	}
		    }
		    else
		    {
		    	System.out.println( (long)Math.pow( 2,N-1 ) );
		    }
		    scanner.close(); }
		  }

Measured memory_bytes: 21332
// 5/8 p121

#include<cstdio>

int search(int A[], int n, int key){
	int i = 0;
	A[n] = key;
	while(A[i] != key)i++;
	return i != n;
}

int main(){
	int i, n, A[10000+1], q, key, sum = 0;
	scanf("%d", &n);
	for(i = 0; i < n; ++i)scanf("%d", &A[i]);//&A[i]??¨A+i?????????
	scanf("%d", &q);
	for(i = 0; i < q; ++i){
		scanf("%d", &key);
		if(search(A, n, key))sum++;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
    std::fill((T *)array, (T *)(array + N), val);
}

int main()
{
    int n, m;
    cin >> n >> m;
    int h[n];
    repi(i,n,0){
        cin >> h[i];
    }
    vector<int> vec[n];
    repi(i, m, 0)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    int ans = 0;
    repi(i, n, 0)
    {
        bool state = true;
        repi(j, vec[i].size(), 0)
        {
            if (h[i] <= h[vec[i][j]]){
                state = false;
                break;
            }
        }
        if(state)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9120
open Printf
open Scanf

module Uftree =
  struct
    type t = int array
    let create n : t = Array.make n (-1)
    let rec find (uft : t) x =
      let p = uft.(x) in
      if p < 0 then x
      else
        let rt = find uft p in
        uft.(x) <- rt; rt
    let unite (uft : t) x y =
      let rx = find uft x in
      let ry = find uft y in
      if rx = ry then ()
      else
        if uft.(rx) < uft.(ry) then
          begin
            uft.(rx) <- uft.(rx) + uft.(ry);
            uft.(ry) <- rx
          end
        else
          begin
            uft.(ry) <- uft.(rx) + uft.(ry);
            uft.(rx) <- ry
          end
    let same (uft : t) x y =
      let rx = find uft x in
      let ry = find uft y in
      rx = ry
    let size (uft : t) x =
      let rx = find uft x in -uft.(rx)
  end

let tuple x y = (x, y)
                  
let () =
  let n, q = scanf "%d %d " tuple in
  let uft = Uftree.create n in
  let rec loop x =
    if x = 0 then ()
    else
      let com, a, b = scanf "%d %d %d " (fun i j k -> (i, j, k)) in
      if com = 0 then
        Uftree.unite uft a b
      else
        (if Uftree.same uft a b then 1 else 0) |> printf "%d\n";
      loop (x-1)
  in loop q

Measured memory_bytes: 4688
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

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

    void run() {
        int n  = sc.nextInt();
        int m  = sc.nextInt();

        int ans = n*(n-1)/2 + m*(m-1)/2;

        out.print(ans);
        out.flush();
    }

}


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

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		ans = gcd(ans, a);
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
    int N; long long L; cin >> N >> L;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    int pl = -1;
    for (int i = 0; i+1 < N; ++i) if (A[i] + A[i+1] >= L) pl = i;

    if (pl == -1) { cout << "Impossible" << endl; return 0; }

    cout << "Possible" << endl;
    for (int i = 0; i < pl; ++i) cout << i+1 << endl;
    for (int i = N-2; i > pl; --i) cout << i+1 << endl;
    cout << pl+1 << endl;
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(6000)

n_node, n_path = [int(x) for x in input().split()]

A = [[0]*2 for x in range(n_path)]

for i in range(n_path):
	A[i][0], A[i][1] = [int(x) for x in input().split()]



def serch(A, cur_node, old, n_node):
	
	ans = 0
		
	if len(old) == (n_node-1):
		return 1
	
	for i in range(len(A)):
		
		if cur_node == A[i][0] and not(A[i][1] in old):
			A_copy = A.copy()
			A_copy.pop(i)
			old_copy = old.copy()
			old_copy.append(cur_node)
			ans += serch(A_copy, A[i][1], old_copy, n_node)
		
		elif cur_node == A[i][1] and not(A[i][0] in old):
			A_copy = A.copy()
			A_copy.pop(i)
			old_copy = old.copy()
			old_copy.append(cur_node)
			ans += serch(A_copy, A[i][0], old_copy, n_node)
	return ans

print(serch(A, 1, [], n_node))



Measured memory_bytes: 3064
#include<string>
#include<iostream>
using namespace std;
int main() {
	string a;
	int l = 0;
	while (cin >> a) {
		if(l==1)cout << endl;
		l = 1;
		int b[5], c[5],e[5];
		fill(b, b + 5, 0);
		fill(c, c + 5, 0);
		fill(e, e + 5, 4);
		for (int i = a.length() - 1; i >= 0; i--) {
			int d = (int)a[i] - '0';
			if (d >= 5) {
				b[5 - a.length() + i]++;
				d -= 5;
			}
			c[5 - a.length() + i] += d;
			e[5 - a.length() + i] -= d;
		}
		for (int i = 0; i < 5; i++) {
			if (b[i] != 0)
				cout << " ";
			else
				cout << "*";
		}
		cout << endl;
		for (int i = 0; i < 5; i++) {
			if (b[i] != 0)
				cout << "*";
			else
				cout << " ";
		}
		cout << endl;
		for (int i = 0; i < 5; i++)
			cout << "=";
		cout << endl;
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 5; j++) {
				if (c[j] != 0) {
					cout << "*";
					c[j]--;
				}
				else if (i >= 5 - e[j]) {
					cout << "*";
				}
				else
					cout << " ";
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3132
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <bitset>

using namespace std;

typedef long long ll;

bitset<2000 * 2000 + 2> b;

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

  b[0] = 1;
  for (int i = 0; i < n; ++i) {
    b = b | (b << a[i]);
  }

  int i = (sum + 1) / 2;
  while (!b[i]) i++;

  cout << i << endl;

  return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define RSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))
#define PREC(n) setprecision(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

vi a;

void sosu(){
    ll i,j;
    SIZE(a,pow(10,5)+5);
    repj(i,2,a.size()){
        if(a[i]==0){
            a[i]=1;
            for(j=i*2;j<a.size();j+=i){
                a[j]=-1;
            }
        }
    }
}

int main() {
	ll x,i,j;

    cin>>x;

    sosu();

    repj(i,x,a.size()){
        if(a[i]==1){
            cout<<i;
            return 0;
        }
    }

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int main() {
    vi a(3);
    cin >> a[0]>>a[1]>>a[2];
    Sort(a);
    cout << 10*a[2]+a[1]+a[0] << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")



int main() {
	ll mod = 1000000007;
	int N;
	cin >> N;
	vector<ll> A(N+1);
	vector<ll> B(N+1);
	REP(i, 1, N + 1) cin >> A[i];
	B[N] = 0;
	for (int i = N - 1; i >= 1; --i) B[i] = (B[i + 1] + A[i + 1]) % mod;
	ll ans = 0;
	REP(i, 1, N) {
		ans += A[i] * B[i];
		ans %= mod;
	}
	PRI(ans);
	return 0;
}




Measured memory_bytes: 6404
def main():
    from bisect import bisect_left

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

    # cumulative sum
    # cs[i] = sum(a[:i+1])
    cs = [0] * n
    for i in range(n):
        cs[i] = cs[i-1] + a[i]

    # search all possible indexes of middle split
    ans = 10**15
    for middle in range(2, n-1):
        # first_half = a[:middle]
        first = bisect_left(cs, cs[middle-1]//2, lo=1, hi=middle)
        if abs((cs[middle-1] - cs[first-1]) - cs[first-1]) < abs((cs[middle-1] - cs[first]) - cs[first]):
            p = cs[first-1]
            q = cs[middle-1] - cs[first-1]
        else:
            p = cs[first]
            q = cs[middle-1] - cs[first]

        # latter_half = a[middle:]
        last = bisect_left(cs, (cs[-1] + cs[middle-1])//2, lo=middle+1, hi=n)
        if abs((cs[-1] - cs[last-1]) - (cs[last-1] - cs[middle-1])) < abs((cs[-1] - cs[last]) - (cs[last] - cs[middle-1])):
            r = cs[last-1] - cs[middle-1]
            s = cs[-1] - cs[last-1]
        else:
            r = cs[last] - cs[middle-1]
            s = cs[-1] - cs[last]
        
        diff = max(p, q, r, s) - min(p, q, r, s)
        if diff < ans:
            ans = diff
    
    print(ans)

main()

Measured memory_bytes: 103284
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;

int main(void) {
	string s, t;
	cin >> s >> t;
	reverse(t.begin(), t.end());
	if (s == t)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

public class Ans
{
    public int step { get; set; }
    public int gcd { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            if (a == 0 && b == 0) break;
            var ret = Gcd(a, b);
            Console.WriteLine("{0} {1}",ret.gcd,ret.step);
        }
    }
    public static Ans Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        var count = 0;
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
            count++;
        }
        return new Ans { step = count, gcd = a };
    }
}



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

#define int long long
#define mod 1000000007
#define p pair<int,int>
#define MAX 1000010

using namespace std;

int a[MAX],b[MAX];
bool vis[MAX];

vector <int> v;
vector <p> vp;
set <int> s;
set <p> sp;
map <int,int> m;
unordered_map <int,int> um;
queue <int> bq;

int32_t main()
{
    um.reserve(1<<15);
    um.max_load_factor(0.25);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,t;
    cin >> n >> t;

    int ans = 1e9;

    while(n--)
    {
        int x,y;
        cin >> x >> y;

        if(y <= t)
            ans = min(ans,x);
    }

    if(ans == 1e9)
        cout << "TLE\n";
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var sc=bufio.NewScanner(os.Stdin)
func nextInt()int{
	sc.Scan()
	i,e:=strconv.Atoi(sc.Text())
	if e!=nil{
		panic(e)
	}
	return i
}
func main(){
	 sc.Split(bufio.ScanWords)
	 n:=nextInt()
	 count:=0
	 max:=0
	 a:=make([]int, n)
	 for i:=0;i<n;i++{
		 a[i]=nextInt()
		 if max<=a[i]{
			 max=a[i]
			 count++
		 }
	 }
	 fmt.Println(count)
}


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

typedef struct
{
    int count;
    int no;
} info_t;

int cmp( const void *p, const void *q ) {
    return ((info_t*)p)->count- ((info_t*)q)->count;
}

int main()
{
    int N;
    scanf("%d", &N);
    int i;
    info_t* list = (info_t*)malloc(N * sizeof(info_t));

    for (i = 0; i < N; i++)
    {
        scanf("%d", &list[i].count);
        list[i].no = i+1;
    }

    qsort(list, N, sizeof(info_t), cmp);
    for(i=0; i<N; i++) {
        printf("%d\n", list[i].no);
    }
    free(list);
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll   = long long;
const ll mod = 1e9+7;

void solve(){
    int n,w, max_val=0;cin>>n>>w;
    vector<vector<ll>> a(n, vector<ll>(2));
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
        max_val += a[i][1];
    }
    vector<vector<ll>> dp(n+1, vector<ll>(max_val+1, mod));
    for(int i=0;i<=n;i++)dp[i][0]=0;
    for(int i=1;i<=n;i++){
        for(int val=1;val<=max_val;val++){
            if(a[i-1][1] <= val){
                dp[i][val] = min(dp[i-1][val], dp[i-1][val-a[i-1][1]] + a[i-1][0]);
            }else dp[i][val] = dp[i-1][val];
        }
    }
    ll ans=0;
    for(int i=1;i<=max_val;i++){
        if(dp[n][i]<=w)ans = max(ans, (ll)i);
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    int t;
    t=1;
    // cin>>t;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 83188
#include<iostream>
#include<cmath>

using namespace std;

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

  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    int o1=dp[i-1]+abs(h[i]-h[i-1]);
    int o2=dp[i-2]+abs(h[i]-h[i-2]);
    dp[i]=min(o1,o2);
  }

  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 3908
#include <iostream>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    if (x == 4 || x == 6 || x == 9 || x == 11) {
        if (y == 4 || y == 6 || y == 9 || y == 11) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (x == 2) {
        cout << "No" << endl;
    } else {
        if (y != 2 && y != 4 && y != 9 && y != 11) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)
ans = [0 for _ in range(n)]

r = []
l = []
bdr = []
cnt = 1
for i in range(n):
    if i == n - 1 or s[i] != s[i + 1]:
        if s[i] == 'L':
            l.append(cnt)
        else:
            r.append(cnt)
            bdr.append(i)
        cnt = 1
    else:
        cnt += 1
for i in range(len(bdr)):
    ans[bdr[i]] += (r[i] + 1) // 2 + l[i] // 2
    ans[bdr[i] + 1] += r[i] // 2 + (l[i] + 1) // 2
print(' '.join(map(str, ans)))

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

ll up(ll a, ll b) {
  return (a + b - 1) / b;
}

ll down(ll a, ll b) {
  return a / b;
}

ll getak(ll a, ll b) {
  return up(a, b + 1);
}

ll getbk(ll a, ll b) {
  return up(b, a + 1);
}

ll getk(ll a, ll b) {
  return max(getak(a, b), getbk(a, b));
}

void solve() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll k = getk(a, b);
  //cerr << "k: " << k << '\n';

  ll l = 0, r = 1e9;
  while (l + 1 < r) {
    ll c = (l + r) / 2;

    ll na = a - c * k - 1;
    ll nb = b - c;
    if (na < 0 || nb < 0) {
      r = c;
      continue;
    }
    ll nk = getbk(na, nb);
    if (nk > k) {
      r = c;
    } else {
      l = c;
    }
  }
  ll x = l;

  l = 0, r = 1e9;
  while (l + 1 < r) {
    ll c = (l + r) / 2;

    ll nb = b - c * k - 1;
    ll na = a - c;
    if (na < 0 || nb < 0) {
      r = c;
      continue;
    }
    ll nk = getak(na, nb);
    if (nk > k) {
      r = c;
    } else {
      l = c;
    }
  }
  ll y = l;

  ll p = a - x * k - y;
  ll q = b - y * k - x;

  //cerr << x << ' ' << y << ' ' << p << ' ' << q << '\n';

  l = c - 1;
  ll rem = d - l;
  string res;

  ll skip = min(x, l / (k + 1));
  x -= skip;
  l -= skip * (k + 1);

  while (x > 0 && rem > 0) {
    ll len = min(k - l, rem);
    res += string(len, 'A');
    rem -= len;
    l = max(0ll, l - k);
    if (rem > 0) {
      res += "B";
      --rem;
    }
    --x;
  }

  skip = min(l, p);
  p -= skip;
  l -= skip;

  ll len = min(p, rem);
  res += string(len, 'A');
  rem -= len;

  skip = min(l, q);
  q -= skip;
  l -= skip;

  len = min(q, rem);
  res += string(len, 'B');
  rem -= len;

  skip = min(y, l / (k + 1));
  y -= skip;
  l -= skip * (k + 1);

  while (y > 0 && rem > 0) {
    if (rem > 0 && l == 0) {
      res += "A";
      --rem;
    } else {
      --l;
    }
    ll len = min(k - l, rem);
    res += string(len, 'B');
    rem -= len;
    l = max(0ll, l - k);
    --y;
  }

  assert(rem == 0);
  cout << res << '\n';
}

signed main() {
#ifdef LOCAL
  assert(freopen("d.in", "r", stdin));
#endif
  int tn;
  cin >> tn;
  for (int i = 0; i < tn; ++i) {
    solve();
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner bui = new Scanner(System.in);
		
		int N = bui.nextInt();
		float sum = 0;
		for(int i=0;i<N;i++) {
			String f = bui.next();
			String s = bui.next();
			if(s.equals("JPY")) {
				sum += Integer.parseInt(f);
			}else {
				sum += Float.parseFloat(f)*380000.0f;
			}
		}
		
		System.out.println(sum);
		
		
	}
}

Measured memory_bytes: 25172
# from math import gcd
from fractions import gcd
from functools import reduce
 
n = int(input())
a = [int(x) for x in input().split()]
 
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
lcm = lcm_list(a)
ans = 0
for i in range(len(a)):
    ans += lcm // a[i]
print(ans % 1000000007)

Measured memory_bytes: 6100
N, K = map(int, input().split())
hlist = list(map(int, input().split())) + [0] * (K + 2)
inf = float("inf")
dp = [inf] * (N * K + 2)


def abs_sbn(a, b):
    return abs(hlist[b] - hlist[a])


dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        dp[i + j] = min(dp[i + j], dp[i] + abs_sbn(i, i + j))

print(dp[N - 1])


Measured memory_bytes: 416460
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define mp make_pair
    #define mod 1e9+7
    #define sz 100000
    #define f(i,n) for(ll i=0;i<n;i++)
    #define fab(i,a,b) for(ll i=a;i<b;i++)
    #define fr(i,n) for(ll i=n-1;i>=0;i--)
    #define fba(i,b,a) for(ll i=b-1;i>=a;i--)
    #define tc(t) ll t;cin>>t;while(t--)
     
    ll pw(ll x,unsigned ll y) 
    { 
        if (y==0) 
            return 1; 
        else if (y%2==0) 
            return pw(x,y/2)*pw(x,y/2); 
        else
            return x*pw(x,y/2)*pw(x,y/2);
    }
     
    int main() 
    {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll a,b;
        cin>>a>>b;
        for(int i=0;i<max(a,b);i++)
            cout<<min(a,b);
        return 0;
    }

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;

#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair


template <typename T>
using vv = vector<vector<T>>;

void solve() {
    ll n, k; cin >> n >> k;
    vi p(n);
    vi c(n);
    for (auto &i : p) cin >> i, i--;
    for (auto &i : c) cin >> i;

    vi used(n);

    vi maxes(n + 1);

    ll res = *max_element(all(c));
    if (res <= 0) {
        cout << res;
        return;
    }

    for (int f = 0; f < n; f++) {
        ll len = 0;
        ll tmp = 0;
        ll mx = 0;
        maxes[0] = 0;
        int v = f;
        while (used[v] == 0) {
            len++;
            tmp += c[v];
            mx = max(mx, tmp);
            used[v] = 1;
            maxes[len] = mx;
            v = p[v];
        }
        fill(all(used), 0);
        if (k < len) {
            res = max(res, maxes[k]);
        } else {
            if (tmp > 0) {
                ll cycles = k / len;
                // all cycles use
                res = max(res, cycles * tmp + maxes[k % len]);
                // without one
                res = max(res, (cycles - 1) * tmp + maxes[len]);
            } else {
                res = max(res, maxes[len]);
            }
        }
    } 
    cout << res;
}



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


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

int main() {
	int N , M;
  	cin >> N >> M;
  	vector<int>  tosi(N); // int型配列は初期値は全ての要素が「 0 」となる。
  	int a , b; // 都市 a から 都市 b へ道路が双方向へ結んでいる
  	for(int i = 0; i < M; i++){
		cin >> a >> b;
		tosi.at(a - 1) += 1; // 都市 a の要素番号（a - 1）のカウントを1つ増やす
		tosi.at(b - 1) += 1; // 都市 b の要素番号（b - 1）のカウントを1つ増やす
	}
  	for(int i = 0; i < N; i++){
    	cout << tosi.at(i) << endl; //それぞれの都市ごとのカウント数を出力する
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
#define INF 0x3f3f3f3f
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)


int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    string s,t;
    cin>>s>>t;
    cout<<t<<s;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

int main() {
  int H,W;
  scanf("%d%d",&H,&W);
  getchar();
   
  string a[H];
  rep(i,H){
    string line;
    getline(cin,line);
    a[i] = line;
  }

  rep(i, W + 2) printf("#");
  puts("");
  rep(i, H) printf("#%s#\n",a[i].c_str());
  rep(i, W + 2) printf("#");
  puts("");
  return 0;
}

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

int main() {
  long A, V;
  long B, W;
  long T;
  
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  
  if (A<B) {
    if ((A+V*T) >= (B+W*T)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    if ((A-V*T) <= (B-W*T)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  
  return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    if(n==1)
    {
        cout << "Hello World" << endl;
    } else {
        ll a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
    Min, Max, and Sum: ITP1_4_D
*/

#include <stdio.h>

int main(void)
{
    int n = 0;
    long nnum[10000] = {0};
    long min = 1000000;
    long max = -1000000;
    long sum = 0;
    int i = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%ld", &nnum[i]);

        if (nnum[i] > max)
            max = nnum[i];
        if (nnum[i] < min)
            min = nnum[i];
        sum += nnum[i];
    }
    printf("%ld %ld %ld\n", min, max, sum);
    return (0);
}



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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    vector<ll> s;
    vector<ll> ord(n+1,-1);
    int c = 1, l = 0;
    {
        int v = 1;
        while(ord[v] == -1){
            ord[v] = s.size();
            s.push_back(v);
            v=a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }
    
    if(k<l) cout << s[k] << "\n";
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << "\n";
    }
    return 0;
}

Measured memory_bytes: 8492
#ABC-B_not debuged
H, W = map(int, input().split())
a, ans = [], []
for i in range(H):
    temp = input()
    if temp == '.'*W:
        continue
    a.append(temp)
    ans.append([])

for i in range(W):
    for j in a:
        if j[i] == '#':
            break
    else:
        continue
    for j,k in zip(a,ans):
        k.append(j[i])
for i in ans:
    print(''.join(i))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll MOD=1e9+7,MAXN=2048;
inline ll fpow(ll a,ll x) { ll ans=1; for(;x;x>>=1,a=a*a%MOD) if(x&1) ans=ans*a%MOD; return ans; }
ll Fac[MAXN],InF[MAXN];
inline void pre(){
    Fac[0]=1;
    for(int i=1;i<=2000;i++) Fac[i]=Fac[i-1]*i%MOD;
    InF[2000]=fpow(Fac[2000],MOD-2);
    for(int i=2000;i>=1;i--) InF[i-1]=InF[i]*i%MOD;
}
inline ll C(ll N,ll M) { return Fac[N]*InF[M]%MOD*InF[N-M]%MOD; }
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    pre();
    int S,Ans=0;
    cin>>S;
    for(int t=1,i=3;i<=S;i+=3,t++)
        Ans=(Ans+C(S-t-t-1,t-1))%MOD;
    cout<<Ans<<endl;
    return 0;
}

Measured memory_bytes: 3688
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

const int INF  = 1 << 30;
const int MINF = -1 * (1 << 30);

int main()
{
    int n;
    int a;
    int maxv;
    int minv;
    int sum;

    while (scanf("%d", &n), n != 0) {
        sum  = 0;
        maxv = MINF;
        minv = INF;

        for (int i = 0; i < n; i++) {
            scanf("%d", &a);

            sum += a;

            maxv = max(maxv, a);
            minv = min(minv, a);
        }

        sum -= maxv;
        sum -= minv;

        printf("%d\n", sum / (n - 2));
    }

    return 0;
}



Measured memory_bytes: 1980
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

int main() {
	int N = 0;
	std::cin >> N;
	std::map<std::pair<int, int>, int> inputs;
	auto itr = inputs.begin();
	{
		int x, y;
		for (int i = 0; i < N; ++i) {
			std::cin >> x >> y;
			std::cin >> inputs[std::make_pair(x, y)];
			if (inputs[std::make_pair(x, y)] >= 1)itr = inputs.find(std::make_pair(x, y));
		}
	}
	int x = 0;
	int y = 0;
	int height = 0;
	for (x = 0; x <= 100; ++x) {
		for (y = 0; y <= 100; ++y) {
			bool flag = false;
			height = itr->second + abs(itr->first.first - x) + abs(itr->first.second - y);
			if (std::all_of(inputs.begin(), inputs.end(), [&](const auto& arg) {
				return std::max(height - abs(arg.first.first - x) - abs(arg.first.second - y), 0) == arg.second;
			})) {
				flag = true;
			}
			if (flag) {
				printf("%d %d %d", x, y, height);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;

fn main() {
    solve_b();
}

fn solve_b() {
    let mut x = String::new();

    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<i32> = x.trim()
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap())
        .collect();

    let a = v[0];
    let b = v[1];
    let c = v[2];
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <memory.h>
#include <algorithm>
#define case        printf("Case %d: ",++tc);
#define read        freopen("tst.txt","r",stdin)
#define write       freopen("out.txt","w",stdout)
typedef long long ll;
using namespace std;
#define pi acos(-1)




main(){
int t,tc = 0;


int n,k;
cin>>n>>k;
string s;
cin>>s;
int x = 1;
for(int i = 1; i<n; i++){
    if(s[i]!=s[i-1])    x++;
}
int ans = x-2*k;

if(ans<=0)  ans = 1;


ans = n-ans;
cout<<ans<<endl;



return 0;
}


Measured memory_bytes: 512
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  200007
ll expo(ll base, ll exponent, ll mod) {                                //return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
int main()
{
    
    io
    
    ll n,k;
    cin>>n>>k;
    ll res=0;
    rep(i,k,n+2)
    {
        ll mn=((i-1)*(i))/2;
        ll m1=(n-i);
        ll tot=(n*(n+1))/2;
        ll mx=tot-((m1*(m1+1))/2);
        ll tc=(mx-mn+1);
        // cout<<i<<" "<<mn<<" "<<mx<<endl;
        res=(res+tc)%hell;
    }
    cout<<res;
}

Measured memory_bytes: 3648