akhauriyash/Code-Regression huggingface dataset:
#include <unistd.h>

char ibuf[2000010];
char *ibufe = ibuf-1;

extern inline void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[40];
char *bufe = buf;

void write_uintln(long long int x){
  int i;
  static char tmp[23];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

extern inline void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}


int n;
int A[200000];

inline void swap(int *a, int *b){
  int z;
  z = *a;
  *a = *b;
  *b = z;
}

int median(int *A, int n){
  int ll = 0;
  int rr = n;
  const int k = n/2;
  while(1){
    int i, l, r, pivot;
    swap(A+ll, A+(ll+rr)/2);
    pivot = A[ll];
    l = ll;
    r = rr;
    i = ll+1;
    while(i < r){
      if(A[i] < pivot) swap(A+l++, A+i++);
      else if(A[i] > pivot) swap(A+--r, A+i);
      else i++;
    } 
    if(k < l) rr = l;
    else if(k >= r) ll = r;
    else return pivot;
  }
}

int main(){
  int i, m;
  long long int r;
  readall();
  n = read_uint();
  for(i=0;i<n;i++){
    A[i] = read_uint()-(i+1);
  }
  m = median(A, n);
  r = 0;
  for(i=0;A[i] < m;i++) r += m - A[i];
  for(;i<n;i++) r += A[i] - m;
  write_uintln(r);
  writeall();
  return 0;
}


Measured memory_bytes: 2944
a,b,C = gets.split.map{|e|e.to_i}
rad = C * Math::PI / 180.0
S=a*b/2*Math.sin(rad)
c=Math.sqrt(a**2+b**2-2*a*b*Math.cos(rad))
L = a+b+c
h = 2*S/a

puts S
puts L
puts h

Measured memory_bytes: 6192
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

	int n;
	scanf("%d", &n);
	int ar[n + 1];

	for(int i=0; i<n + 1; i++)
		scanf("%d", &ar[i]);
	
	LL cnt = 0;
	int b, mn;

	for(int i=0; i<n; i++){
		scanf("%d", &b);
		
		mn = min(ar[i], b);
		cnt += mn;
		b -= mn;
		ar[i] -= mn;
		
		mn = min(ar[i + 1] , b);
		cnt += mn;
		b -= mn;
		ar[i + 1] -= mn;
	}

	cout<< cnt<< endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    int n = s.size();
    vector <int> cnt(26);
    for(auto &i : s) cnt[i - 'a']++;
    ll ans = 1LL * n * (n - 1) / 2;
    for(auto &i : cnt){
        ans -= 1LL * i * (i - 1) / 2;
    }
    cout << ans + 1 << endl;
}


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

int main(){
    int n, A[100], B[100];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    for(int i = n-1; i >= 0; i--){
        cin >> B[i];
        if(i != n-1){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{ 
    static void Main(string[] args)
    {
        var nm = Input.ar;
        var ar = Input.ar;
        var dic = new Dictionary<long, int>();
        var sum = new long[nm[0] + 1];
        for (var i = 0; i < nm[0]; i++)
            sum[i + 1] += sum[i] + ar[i];
        for (var i = 0; i <= nm[0]; i++)
            if (dic.ContainsKey(sum[i] % nm[1]))
                dic[sum[i] % nm[1]]++;
            else dic[sum[i] % nm[1]] = 1;
        var res = 0L;
        foreach (var val in dic.Values)
            res += (long)val * (val - 1) / 2;
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

long f(long n, long x){
	if(n == -1) return 0;
	else return n/x+1;
}

int main(){
	long a, b, x;
	cin >> a >> b >> x;
	cout << f(b, x) - f(a - 1, x);
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> P;
typedef tuple<ll,ll,ll> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int N; cin >> N;
    VL A(N), B(N);
    REP(i,N){
        cin >> A[i];
        B[i] = i - A[i];
    }

    ll ans = 0;
    map<ll,ll> m;
    RREP(i,N){
        ll x = i + A[i];
        if(m.find(x) != m.end()){
            ans += m[x];
        }
        if(m.find(B[i]) != m.end()) m[B[i]]++;
        else m[B[i]] = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
string s[200005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    int k=1;
    int m=0;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            k++;
        }else{
            m=max(m,k);
            k=1;
        }
    }
    m=max(m,k);
    k=1;
    if(m==1){
        cout<<s[0]<<endl;
    }
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            k++;
        }else{
            k=1;
        }
        if(k==m){
            cout<<s[i]<<endl;
        }
    }
    
    
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<P> train(M);
  int stop[N];
  int res[N][N];
  for (int i = 0; i < N; i++) stop[i] = 0;
  for (int i = 0; i < M; i++) {
    cin >> train[i].first >> train[i].second;
    train[i].first--;
    train[i].second--;
  }
  sort(train.begin(),train.end());
  for (int i = 0; i < M; i++) {
    stop[train[i].second]++;
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j == 0) {
        res[i][j] = stop[j];
      } else {
        res[i][j] = res[i][j-1] + stop[j];
      }
    }
    while (cnt != M && train[cnt].first == i) {
      stop[train[cnt].second]--;
      cnt++;
    }
  }

  for (int i = 0; i < Q; i++) {
    int p,q;
    cin >> p >> q;
    p--; q--;
    cout << res[p][q] << endl;
  }
  return 0;
}

Measured memory_bytes: 3456
n = int(input())
words = []
for i in range(n):
  s = input()
  a = [s[i] for i in range (len(s))]
  a.sort()
  words.append(a)
words.sort()

s = 0 #合計
v = 0 #種類中の数

old = False
for i in range(1,n):
  if words[i]==words[i-1] and (not old):
    s += 1
    v = 2
    old = True
  elif words[i]==words[i-1] and old:
    s += v
    v += 1
  else:
    old = False

print(s)

Measured memory_bytes: 24624
#include<stdio.h>
const int N = 305;
const int M = 305;

int main()
{
	int x , y;
	
	while(scanf("%d %d" , &x , &y))
	{
		if(x == 0 && y == 0)
		{
			break;
		}
		for(int i = 0 ; i < x ; i++)
		{
			for(int j = 0 ; j < y ; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  int a,b,c;cin>>a>>b>>c;
  cout<<min(b/a, c)<<endl;

  return 0;
}


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

ll f_max(ll p, ll q, ll r, ll s){
    ll x,y;
    x = max(p,q);
    y = max(r,s);
    return max(x,y);
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout<< f_max(a*c, a*d, b*c, b*d) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

string func(string s){
    int base = 0;
    int s2n[26];
    rep(i, 26)s2n[i] = -1;

    rep(i, s.size()){
        if(s2n[s[i]-'a'] < 0){
            s2n[s[i]-'a'] = base;
            s[i] = char('0' + base);
            base++;
        }
        else s[i] =  char('0' + s2n[s[i]-'a']);
    }

    return s;
}

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

    s = func(s);
    t = func(t);

    if(s == t)cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int) (a).size()
#define pb push_back
using ll = int64_t;
using ld = long double;
using vint = vector<int>;
using str = string;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    int dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        dp[i] = 1000000000000000000;
        for (int j = i - 1; j >= 0 && j + k >= i; --j)
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 1920
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return a
}

type vert struct {
	a   int
	num int
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := scanInt(), scanInt()
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		u, v := scanInt()-1, scanInt()-1
		g[u] = append(g[u], v)
	}
	s, t := scanInt()-1, scanInt()-1
	q := make([]vert, 0)
	q = append(q, vert{s, 0})
	g3 := make([][]int, n)
	for i := 0; i < n; i++ {
		g3[i] = append(g3[i], []int{-1, -1, -1}...)
	}
	g3[s][0] = 0
	for len(q) > 0 {
		a, num := q[0].a, q[0].num
		for _, e := range g[a] {
			if g3[e][(num+1)%3] != -1 {
				continue
			}
			g3[e][(num+1)%3] = g3[a][num] + 1
			q = append(q, vert{e, (num + 1) % 3})
		}
		q = q[1:]
	}
	if g3[t][0] == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(g3[t][0] / 3)
	}
}


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

using namespace std;

int main() {
	string a;
	cin >> a;
	if(a.at(0)=='A') {
		int ac = 0, cc=0;
		ac++;
		for(int i = 2; i < a.size()-1; i++) {
			if(a.at(i)=='A') ac++;
			else if(a.at(i)=='C') cc++;
			else if(a.at(i)<'A') {
				cout << a.at(i) << "WA" << endl;
				return 0;
			}
		}
		if(ac==1&&cc==1) {
			if(a.at(1)>'Z' && a.at(a.size()-1)>'Z') {
				cout << "AC" << endl;
				return 0;
			}
		}
	}
	cout << "WA" << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
    long a,b,c;
    Scanner s = new Scanner(System.in);
    a = s.nextLong();
    b = s.nextLong();
    c = s.nextLong();
    if(c-a-b<=0){
      System.out.println("No"); 
    }else{
      if(4*a*b<(c-a-b)*(c-a-b)){
        System.out.println("Yes"); 
      }else{
        System.out.println("No"); 
      }
    }
  }
}

Measured memory_bytes: 21844
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int a;
    cin>>a;
    int count=0;
    int ret=0;
   rep(i,a){
       count=0;
       if((i+1)%2!=0){
           rep(j,a){
               if((i+1)%(j+1)==0){
                   count++;
               }
           }
           if(count==8){
               ret++;
           }

       }
   }
   cout<<ret<<endl;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C&lang=ja

int d[105];
vector<vector<int>> vv;

int main() {
    int n; cin >> n;
    REP(i, n) d[i] = -1;
    vv.resize(n);
    REP(i, n) {
        int u, k; cin >> u >> k;
        u--;
        REP(j, k) {
            int v; cin >> v;
            v--;
            vv[u].push_back(v);
        }
    }

    queue<int> q;
    q.push(0);
    d[0] = 0;

    while (!q.empty()) {
        int f = q.front(); q.pop();

        for (int t : vv[f]) {
            if (d[t] == -1 || d[t] > d[f] + 1) {
                d[t] = d[f] + 1;
                q.push(t);
            }
        }
    }

    REP(i, n) {
        cout << i+1 << " "<< d[i] << "\n";
    }
       

    return 0;
}


Measured memory_bytes: 3164
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;

	rep(i, 1000) {
		if (1000 * i >= N) {
			cout << 1000 * i - N << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;

using namespace std;

int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        string s,t; cin >> s; cin >> t;
        auto n = s.size();
        int ans = 0;
        rep(i,n){
                if(s[i] != t[i]) ans++;
        }
        cout << ans << endl;
        
        return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<ll> A(M);
    vector<ll> B(M);

    REP(i, M){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        
        A[i] = a;
        B[i] = b;
    }

    ll ans = 0;
    REP(i, M){
         // グラフ入力受取
        Graph G(N);
        for (ll j = 0; j < M; ++j) {
            if(j == i) continue;
            G[A[j]].push_back(B[j]);
            G[B[j]].push_back(A[j]);
        }
        // cout << 2 << endl;
        // 頂点 s をスタートとした探索
        vector<ll> dist(N, -1);
        queue<ll> que;
        ll count = 0;
        for (ll v = 0; v < N; ++v) {
            if (dist[v] != -1) continue; // v が探索済みならスルー
            dist[v] = 0;
            que.push(v);
            while (!que.empty()) {
                int v = que.front(); que.pop();
                for (auto nv : G[v]) {
                    if (dist[nv] == -1) {
                        dist[nv] = dist[v] + 1;
                        que.push(nv);
                    }
                }
                // cout << v << endl;
            }
            ++count;
        }
        if(count > 1) ans++;
    }
   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n,t,a;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    double min_diff = fabs(a-(t-h[0]*0.006));
    int best_idx = 1;
    rep(i,n)
    {
        double tmp_diff = fabs(a-(t-h[i]*0.006));
        if(tmp_diff < min_diff)
        {
            min_diff = tmp_diff;
            best_idx = i + 1;
        }
    }
    cout << best_idx << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (true) {
            if (ok(n)) {
                System.out.println(n);
                return;
            }
            n++;
        }
    }
    public static boolean ok(int x) {
        String s = String.valueOf(x);
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i) != s.charAt(0)) return false;
        }
        return true;
    }
}

Measured memory_bytes: 21844
n = int(input())

v = list(map(int,input().split()))
c = list(map(int,input().split()))

t = []
for i in range(n):
    tmp = v[i] - c[i]
    t.append(tmp)

cnt = 0
for i in range(n):
    if t[i] > 0:
        cnt += t[i]

print(cnt)



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
class UnionFind{
    public:
        UnionFind(int N) : parent(N, -1) {}
        bool unite(int x, int y){
            x = find(x);
            y = find(y);
            if (x == y){return false;}
            if (parent[x] > parent[y]){swap(x, y);}
            parent[x] += parent[y];
            parent[y] = x;
            return true;
        }
        int find(int x) {
            if (parent[x] < 0){return x;}
            return parent[x] = find(parent[x]);
        }
        int size(int x) {
            return -parent[find(x)];
        }
        private:
            vector<int> parent;
};
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> x(n),y(n);
    vector<pair<ll,ll>> xs,ys;
    // ll lim = 1000000001;
    // xs.insert(-1);xs.insert(lim);
    // ys.insert(-1);ys.insert(lim);
    rep(i,n){
        cin>>x[i]>>y[i];
        xs.push_back(make_pair(x[i],i));
        ys.push_back(make_pair(y[i],i));
    }
    sort(begin(xs),end(xs));
    sort(begin(ys),end(ys));
    priority_queue<tuple<ll,ll,ll>, vector<tuple<ll,ll,ll>>, greater<tuple<ll,ll,ll>>> pq;

    rep(i,n-1){
        pq.push(make_tuple(xs[i+1].first-xs[i].first,xs[i].second, xs[i+1].second));
        pq.push(make_tuple(ys[i+1].first-ys[i].first,ys[i].second, ys[i+1].second));
    }
    UnionFind uf(n);
    ll res = 0;
    while(!pq.empty()){
        auto tp = pq.top();
        pq.pop();
        ll dist = get<0>(tp), n1=get<1>(tp), n2=get<2>(tp);
        DEBUG{
            printf("dist: %lld, n1: %lld, n2: %lld\n",dist,n1,n2);
        }
        if(uf.unite(n1,n2)){
            res += dist;
        }
        if(uf.size(n1)==n){
            break;
        }
    }
    cout << res << endl;
    return 0;
}


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

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

    for (int j = n - 1; j >= 0; j--) {
        cout << a[j];
        if (j != 0) {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<pair<pair<pair<pair<ll,ll>,string>,ll>,string>> p(n);
  r(i,n){
    string s1,s2; ll a,b,c;
    cin >> a >> b >> s1 >> c >> s2;
    p.at(i)=make_pair(make_pair(make_pair(make_pair(a,b),s1),c),s2);
  }
  sort(p.begin(),p.end());
  r(i,n){
    cout << p.at(i).first.first.first.first<< " " << p.at(i).first.first.first.second<<" "<< p.at(i).first.first.second << " " << p.at(i).first.second << " " <<p.at(i).second<<endl;
  }
}



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

using namespace std;

int main() {
    string s;
    long int len;
    long int ans = 0;

    cin >> s;
    len = s.length();
    for (int i = 0; i < len; i++){
        cout << "x";
    }
    cout << "\n";
    

    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
Ka = sum(B)-sum(A)
Kb = Ka
for a,b in zip(A,B):
    if a > b:
        Kb -= a-b
    else:
        if (b-a)%2:
            Ka -= (b-a+1)//2
            Kb -= 1
        else:
            Ka -= (b-a)//2
print('Yes' if Ka*2 == Kb and Ka >= 0 and Kb >= 0 else 'No')




Measured memory_bytes: 4596
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  getline(cin,s);
  
  rep(i,s.size()){
    if(s[i]>='a' && s[i]<='z'){
      s[i]+='A'-'a';
    }
  }
  
  cout<<s<<endl;
    
  return 0;
}


Measured memory_bytes: 3176
import sys

abc = 'abcdefghijklmnopqrstuvwxyz'
lines = sys.stdin.readlines()
for line in lines:
    for i in range(26):
        abcshift = abc[i:]+abc[:i]
        decode = line.translate(str.maketrans(abc, abcshift))
        if 'the' in decode or 'this' in decode or 'that' in decode:
            print(decode, end = '')
            break
        
    

Measured memory_bytes: 7352
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n,a,q,b,c;
vector<ll> sum(100010);
vector<ll> list(100010);
sum[0]=0;
cin >> n;
  
for(ll i=1;i<=n;i++){
cin >> a;
sum[0]+=a;
list[a]++;
}
cin >>q;

for(ll i=1;i<=q;i++){
cin >>b >> c;
sum[i]=sum[i-1];


sum[i]+=list[b]*(c-b);


list[c]+=list[b];
list[b]=0;


}
for(ll i=1;i<=q;i++)cout <<sum[i]<<endl;



return 0;
}


Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

const ll mod=1e9+7;

template<typename T>inline bool chmax(T &a,const T &b){if(a>=b){return false;}a=b;return true;}
template<typename T>inline bool chmin(T &a,const T &b){if(a<=b){return false;}a=b;return true;}

/*-------------------------------------------*/

vector<ll> fact,fact_inv;

template<typename T>T mpow(T x,T n){
    T ret=1;
    while(n>0){
        if(n&1)(ret*=x)%=mod;
        (x*=x)%=mod;
        n=n>>1;
    }
    return ret;
}

void COMinit(ll MAX){
    fact.resize(MAX+1);
    fact_inv.resize(MAX+1);
    fact[0]=fact_inv[0]=1;
    rep(i,MAX){
        fact[i+1]=fact[i]*(i+1)%mod;
        fact_inv[i+1]=mpow(fact[i+1],mod-2);
    }
}

ll COM(ll n,ll k){
    if(n<k||k<0)return 0;
    return (fact[n]*fact_inv[k]%mod)*fact_inv[n-k]%mod;
}

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

    ll n;
    cin>>n;
    
    vector<ll>c(n);
    rep(i,n)cin>>c[i];
    ll ans=0;

    sort(c.begin(),c.end(),greater<ll>());
    rep(i,n){
        // cout<<((i+2)%mod*mpow(2ll,n*2-2))%mod<<endl;
        (ans+=((i+2)*c[i])%mod*mpow(2ll,n*2-2))%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
int a[10];
int main()
{
  int i,n,j,k;
  for(i=0; i<10; i++){
    scanf("%d", &n);
    for(j=0; j<9; j++){
      if(n>a[j]){
	for(k=9;k>j;k--){
	  a[k] = a[k-1];
	}
	a[j] = n;
	break;
      }
    }
    if(j==9) a[j] = n;
  }
  printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
    ll m,n;cin>>m>>n;
    ll res=1;
    while(n>0){
        if(n&1) res=res*m%mod;
        m=m*m%mod;
        n>>=1;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3116
n,t1 = map(int,input().split())
list1 = []
for i in range(n):
  c,t = map(int,input().split())
  if t <= t1:
    list1.append(c)
  else:
    None
if list1 == []: 
  print("TLE")
else:
  print(min(list1))


Measured memory_bytes: 2940
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

MOD = 10**9+7

n,x = li()
s = list(li())
s.sort(reverse=True)

dd = defaultdict(int)

dd[x] = 1

for i in range(n):
    nexdd = defaultdict(int)
    
    for k, v in dd.items():
        nexdd[k] += dd[k] * (n-i-1)
        nexdd[k] %= MOD
        
        nexdd[k%s[i]] += dd[k]
        nexdd[k%s[i]] %= MOD
        
    dd = nexdd
    
ans = 0
for k,v in dd.items():
    ans += k*v
    ans %= MOD
    
print(ans)

Measured memory_bytes: 5520
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    const INF: i64 = 1e15 as i64;
    let N = S.len() + 1;
    let mut R = S
        .iter()
        .rev()
        .scan(0, |state, &s| {
            *state = if s == '>' { *state + 1 } else { 0 };
            Some(*state)
        })
        .collect::<Vec<_>>();
    R.reverse();
    let mut res = vec![0; N];
    res[0] = R[0];
    for i in 0..(N - 2) {
        res[i + 1] = match (S[i], S[i + 1]) {
            ('<', '<') => res[i] + 1,
            ('<', '>') => std::cmp::max(res[i] + 1, R[i + 1]),
            ('>', '<') => 0,
            _ => R[i + 1],
        };
    }
    res[N - 1] = if S[N - 2] == '>' { 0 } else { res[N - 2] + 1 };
    let ans = res.iter().sum::<i64>();

    println!("{}", ans);
}


Measured memory_bytes: 15088
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
char ss[maxn];
char trans[maxn];
/**int num[maxn],n,cnt,judge[maxn];
void shai()
{
    for(int i=2;i<=maxn;i++)
    {
        if(!judge[i])
            num[++cnt]=i;
        for(int j=1;j<=cnt&&num[j]*i<=maxn;j++)
        {
            judge[i*num[j]]=1;
            if(i%num[j]==0)
                break;
        }
    }
}**/
/**bool cmp(ll a,ll b) {
    return a>b;
}
ll zuhe[1010][1010];
void yanghui()
{
    for ( ll i = 0; i < 1005; i++)
        zuhe[i][0] = zuhe[i][i] = 1;
    for ( ll i = 2; i < 1005; i++)
        for ( ll j = 1; j < i; j++)
            zuhe[i][j] = (zuhe[i-1][j]%mod + zuhe[i-1][j-1]%mod) % mod;
}**/
const int M=108;
double sum=0.0,cnt=1;
ll num[M][2]={0};
double dis(ll x1,ll y1,ll x2,ll y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
start{
    ll n=read;
    for(int i=1;i<=n;i++)
    {
        cnt*=i;
        num[i][0]=read;
        num[i][1]=read;
    }
    int temp=0;
    for(ll i=1;i<=n;i++)
        for(ll j=i+1;j<=n;j++)
            sum+=2*dis(num[i][0],num[i][1],num[j][0],num[j][1])/n;
	printf("%.10f",sum);
	end;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3596
def f1():
    t = 0
    for y, line in enumerate(M):
        for x, cell in enumerate(line):
            if M[y][x] == '1':
                f2(x, y)
                t += 1
    return t


def f2(x, y):
    if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
        return
    if M[y][x] == '1':
        M[y][x] = '0'
        f2(x, y-1)
        f2(x, y+1)
        f2(x+1, y)
        f2(x-1, y)


M = []
while True:
    try:
        line = input()
        if line == '':
            print(f1())
            M = []
        else:
            M.append(list(line))
    except EOFError:
        print(f1())
        break

Measured memory_bytes: 7472
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
/*#include <ext/pb_ds/assoc_container.hpp> // Общий файл.
#include <ext/pb_ds/tree_policy.hpp> // Содержит класс tree_order_statistics_node_update

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rep0(i, n) for(int i = (0); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
#define iter(el, arr) for(auto& el : arr)
#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)

#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()

#define ld long double
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plli pair<pll,int>
#define mp make_pair
#define MP make_pair
#define sz(a) int((a).size())
#define X first
#define Y second

#define endl '\n'
#define pb push_back
#define has(i, m) (m.find(i) != m.end())

#define vi vector<int>
#define vll vector<ll>
#define vch vector<char>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vb vector<bool>
#define vvb vector<vb>
#define pdd pair<long double, long double>
#define vpll vector<pll>
#define vpdd vector<pair<long double, long double> >
#define pq priority_queue
#define mod 1000000007
using namespace std;

#define lsb(i) ((-i) & i)


int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	vi arr(n);
	vi dp(n + 1, 1e9);
	dp[0] = 0;
	
	rep0(i, n) {
		cin >> arr[i];
	}
	if (arr[0] != 1) {
		dp[1] = 0;
	}

	for (int i = 2; i < dp.size(); ++i) {
		if (arr[i - 1] == i) {
			dp[i] = dp[i - 2] + 1;
			dp[i] = min(dp[i - 1] + 1, dp[i]);
		}
		else {
			dp[i] = dp[i - 1];
			if (i - 1 == arr[i - 2]) {
				dp[i] = min(dp[i - 2] + 1, dp[i]);
			}
		}
	}

	cout << dp.back() << endl;
}

Measured memory_bytes: 1024
# B - Good Distance

import numpy as np
from itertools import combinations

N, D = map(int, input().split())
X = np.array([list(map(int, input().split())) for i in range(N)])
cnt = 0
# for p1, p2 in combinations(X, 2):
#     d = sum((p1-p2)**2)**.5
#     if d.is_integer():
#         cnt+= 1
for p1, p2 in combinations(X, 2):
    cnt+= (sum((p1-p2)**2)**.5).is_integer()
print(cnt)

Measured memory_bytes: 12500
#include <cstdio>
#include <cstring>
using namespace std;

#define L 3194304
bool HA[L];
int T[256] = {0};

inline int get( unsigned char c ) {
    return T[c];
}

int main() {
    int n, sum, t, c;
    T['A'] = 1, T['C'] = 2, T['G'] = 3, T['T'] = 4;
    scanf("%d", &n);
    memset(HA,false,L);
    while ( getchar() != '\n' );
    for ( register int i = 0; i++ < n; ) {
        sum = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            sum += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[sum] = true;
        } else {
            puts( HA[sum] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
const int N=2e3+5;
int n,f[N][12],p[N][12];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=0;j<10;j++)
			cin>>f[i][j];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=10;j++)
			cin>>p[i][j];
	int ans=-1e9;
	for(int i=1;i<(1<<10);i++)
	{
		int res=0;
		for(int j=1;j<=n;j++)
		{
			int cnt=0;
			for(int k=0;k<10;k++)
			{
				if(f[j][k]==0)
					continue;
				if(i&(1<<k))
					cnt++;	
			}	
			res+=p[j][cnt];
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;	
} 

Measured memory_bytes: 256
//=================================
// Created on: 2018/09/21 23:10:47
//=================================
#include <bits/stdc++.h>
using ll = long long;
constexpr ll MOD = 1000000007;
int main()
{
    std::string s;
    std::cin >> s;
    const int N = s.size();
    std::vector<ll> pow(N + 1, 1);
    for (int i = 1; i <= N; i++) { pow[i] = pow[i - 1] * 3 % MOD; }
    std::vector<int> a(N, 0), b(N, 0), c(N, 0), d(N, 0);
    for (int i = 0; i < N; i++) {
        if (s[i] == '?') {
            d[i]++;
        } else {
            (s[i] == 'A' ? a : s[i] == 'B' ? b : c)[i]++;
        }
    }
    for (int i = 1; i < N; i++) {
        a[i] += a[i - 1], b[i] += b[i - 1], c[i] += c[i - 1], d[i] += d[i - 1];
    }
    ll ans = 0;
    for (int i = 1; i < N - 1; i++) {
        if (s[i] == 'B' or s[i] == '?') {
            const int A = a[i - 1], D1 = d[i - 1];
            const int C = c[N - 1] - c[i], D2 = d[N - 1] - d[i];
            const ll X = D1 == 0 ? A : (3 * A + D1) * pow[D1 - 1] % MOD;
            const ll Y = D2 == 0 ? C : (3 * C + D2) * pow[D2 - 1] % MOD;
            (ans += X * Y % MOD) %= MOD;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

struct Tree{
	int V;
	vector<int> G[100010];
	int dp[100010];
	int dfs(int v,int p){
		dp[v] = 0;
		for(int u: G[v]){
			if(u == p)continue;
			dp[v] ^= dfs(u,v);
		}
		return dp[v]+1;
	}
}tree;

int main(){
	static int n;
	static int x[100010],y[100010];
	scanf("%d",&n);
	rep1(i,n-1)scanf("%d%d",&x[i],&y[i]);
	
	tree.V = n;
	rep1(i,n-1){
		tree.G[x[i]].pb(y[i]);
		tree.G[y[i]].pb(x[i]);
	}
	tree.dfs(1,0);
	if(tree.dp[1] == 0)puts("Bob");
	else puts("Alice");
}



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

namespace _1_8_d
{
    class Program
    {
        static void Main(string[] args)
        {
            string r = Console.ReadLine();
            string rr = r + r;
            string ring = rr;
            string word = Console.ReadLine();
            int Count = 0;
            
            for (int i = 0; i < ring.Length/2; i++)
            {
                string Answer = ring.Substring(i,word.Length);
                if (Answer == word)
                {
                    Count += 1;
                }
            }
            if (Count == 0)
            {
                Console.WriteLine("No");
            }
            else 
            {
                Console.WriteLine("Yes");
            }
            Console.ReadKey();
        }
    }
}



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

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

    if (S.size() == 2){
        cout << S;
    }else{
        for (int i = 0; i < 3; i++){
            cout << S.at(2 - i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def f(n):
    if n == 0:
        return 0
    pc = 0
    k = n
    while k:
        pc += k & 1
        k >>= 1
    
    return 1 + f(n % pc)

def solve():
    N = int(readline())
    X = readline().rstrip()
    X = list(map(int, X))

    N1 = sum(X) - 1
    N0 = N1 + 2

#    if N1 == 0:
#        a = 0
#        for i in range(N):
#            a = (a * 2) % N0
#        
#        anses = [0] * N
#        b = 1
#        for i in range(N):
#
#        exit(0)

    a0 = 0
    a1 = 0
    for i in range(N):
        a0 = (a0 * 2 + X[i]) % N0
        a1 = (a1 * 2 + X[i]) % N1 if N1 != 0 else 0
    
    anses = [0] * N
    b0 = 1
    b1 = 1
    for i in range(N):
        if X[N - 1 - i] == 0:
            k = (a0 + b0) % N0
        else:
            k = (a1 - b1) % N1 if N1 != 0 else 0
        
        if N1 == 0 and X[N - 1 - i] == 1:
            anses[N - 1 - i] = 0
        else:
            anses[N - 1 - i] = 1 + f(k)

        b0 = b0 * 2 % N0
        b1 = b1 * 2 % N1 if N1 != 0 else 0

    for a in anses:
        print(a)

solve()

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

using i64 = int64_t;

struct Query{
    i64 q, x, s, t;
};

void update(int idx, vector<i64> &v, deque<bool> &updated, const vector<Query> &query){
    if(updated[idx])return;
    for(auto q: query){
        if(q.q == 1){
            if(v[idx] < q.x)continue;
            v[idx] += q.s;
            v[idx] *= q.t;
        }else{
            if(v[idx] > q.x)continue;
            v[idx] -= q.s;
            v[idx] /= q.t;
        }
    }
    updated[idx] = true;
}

int main(){
    i64 n, q, l, r;
    cin >> n >> q >> l >> r;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    deque<bool> updated(n, false);

    vector<Query> query;
    for(int i=0;i<q;++i){
        i64 q, x, s, t;
        cin >> q >> x >> s >> t;
        query.push_back({q, x, s, t});
    }

    int ri = n, li = -1;
    while(ri-li > 1){
        int mi = (ri + li) / 2;
        update(mi, v, updated, query);
        if(v[mi] > r)ri = mi;
        else li = mi;
    }
    int R = ri;
    ri = n; li = -1;
    while(ri-li > 1){
        int mi = (ri + li) / 2;
        update(mi, v, updated, query);
        if(v[mi] < l)li = mi;
        else ri = mi;
    }
    int L = li + 1;

    cout << R - L << endl;

    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int x) { return (x > 0) - (x < 0); }
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T> T sq(T x) { return x * x; }
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    string S;
    cin >> S;
    if (S.back() == 's') { cout << S << "es" << endl; }
    else { cout << S << "s" << endl; }
}



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int left, int right)
{
  if (left >= right)
  {
    return;
  }

  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(), in.end(), root));
  rec(left, m);
  rec(m + 1, right);
  post.push_back(root);
}

void solve()
{
  pos = 0;
  rec(0, pre.size());
  for (int i = 0; i < n; i++)
  {
    if (i)
    {
      cout << " ";
    }
    cout << post[i];
  }
  cout << endl;
}

int main()
{
  int c;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> c;
    pre.push_back(c);
  }
  for (int i = 0; i < n; i++)
  {
    cin >> c;
    in.push_back(c);
  }

  solve();

  return 0;
}


Measured memory_bytes: 3172