akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<"\n";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	map<string,int>m;
	string s;
	int mx=0;
	for(int i=0;i<n;i++){
		cin>>s;m[s]+=1;
		mx=max(mx,m[s]);
	}
	set<string>se;
	for(auto i:m){
		if(i.ss==mx){se.insert(i.ff);}
	}
	ps(se);
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 34884
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let ab: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            let a = input();
            let b = input();
            (a, b)
        })
        .collect();
    let cd: Vec<(i64, i64)> = (0..m)
        .map(|_| {
            let c = input();
            let d = input();
            (c, d)
        })
        .collect();

    for (a, b) in ab {
        let mut nearest = i64::max_value();
        let mut cp = 0;
        for j in 0..m {
            let (x, y) = cd[j];
            let d = (x - a).abs() + (y - b).abs();
            if d < nearest {
                nearest = d;
                cp = j;
            }
        }
        println!("{}", cp + 1);
    }
}


Measured memory_bytes: 4352
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
 
l = [[] for i in range(n+1)]
for a, b in ab:  
    l[a].append(b)

value = [0 for i in range(n+1)]
for p, x in px:
    value[p] += x

stack = [1]
while stack:
    label = stack.pop()
    for i in l[label]:
        value[i] += value[label]
    stack += l[label]
        
print(*value[1:])


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

int main(){
  int a, b;
  cin >> a >> b;
  if ((a+b)%2 == 0){
    cout << (a+b)/2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, k;
  in2(n, k);
  vector<double> s(n), t(n);
  rep(i, n){
    in(s[i]);
    s[i] = (1 + s[i]) / 2;
  }
  t[0] = s[0];
  rep2(i, 1, n)
    t[i] = t[i - 1] + s[i];
  double a = t[k - 1];
  rep(i, n - k + 1)
    a = max(a, t[i + k] - t[i]);
  kono(7);
  out(a);
  memi;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define X first
#define Y second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

const ll mod=1e9+7;
const ll MAXN=5e5+5;
const ll inf=1e18;



int main()
{
    fastio;
    ll n,a,mi=inf;
    cin>>n;
    ll cnt=0;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<=mi){
            mi=a;
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                                                                              
using namespace std;                                                                                  
using ll = long long;                                                                                 
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }               
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }               
                                                                                                      
int main() {                                                                                          
  double r;                                                                                           
  cin >> r;                                                                                           
  printf("%.10lf\n", 2.0*M_PI*r);                                                                     
  return 0;                                                                                           
}                                                                                                     
                                                                                                      
               

Measured memory_bytes: 3784
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int x1, x2, x3, x4, x5;

    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1==0) {
        cout << 1 << endl;
    } else if(x2==0) {
        cout << 2 << endl;
    } else if(x3==0) {
        cout << 3 << endl;
    } else if(x4==0) {
        cout << 4 << endl;
    } else if(x5==0) {
        cout << 5 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 3632
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [h, w] <- getIntList
  [ch, cw] <- getIntList
  [dh, dw] <- getIntList

  s <- replicateM h $ BS.getLine
  let s' = VB.fromList s

  arr <- IO.newArray ((1,1),(h,w)) inf :: IO (IO.IOUArray (Int,Int) Int)

  let getC y x | y < 1 || y > h || x < 1 || x > w = '#'
               | otherwise = (s' VB.! (y-1)) `BS.index` (x-1)

  let bfs :: Seq.Seq (Int, Int, Int) -> IO ()
      bfs q
        | Seq.null q = return ()
        | otherwise = do
            let (ct,y,x) Seq.:< q' = Seq.viewl q
                c = getC y x
            if c == '#'
              then bfs q'
              else do v <- IO.readArray arr (y, x)
                      if v <= ct
                        then bfs q'
                        else do IO.writeArray arr (y, x) ct
                                if (y == dh && x == dw)
                                  then bfs q'
                                  else do
                                  let walkable = [(ct, y',x') |
                                                  (y',x') <- [(y-1, x),(y+1, x), (y, x-1), (y, x+1)],
                                                  getC y' x' /= '#']
                                      warpable = [(ct+1, y+dy,x+dx) |
                                                  dy <- [(-2)..2], dx <- [(-2)..2],
                                                  getC (y+dy) (x+dx) /= '#']
                                      q1 = (Seq.fromList walkable) Seq.>< q'
                                      q2 = q1 Seq.>< (Seq.fromList warpable)
                                  bfs $ q2

  bfs $ Seq.fromList [(0,ch,cw)]
  ans <- IO.readArray arr (dh, dw)
  print $ if ans >= inf then (-1) else ans


Measured memory_bytes: 56036
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


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

c = collections.Counter(a)
cM = c.most_common()
n_sel = 0
for i in range(len(c)):
  if cM[i][1] > 1:
    n_sel += cmb(cM[i][1], 2)
  else:
    break;
    
for k in range(n):
  k_sel = c[a[k]] - 1
  print(n_sel - k_sel)

Measured memory_bytes: 30124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>

#define MAX_N (10000)
#define MAX_LEN (10)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N;
  int lens[MAX_N];
  char css[MAX_N][MAX_LEN + 1];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%s", css[i]);
    lens[i] = strlen(css[i]);
  }

  // solve
  int ans = 0;
  int num_end_a = 0, num_begin_b = 0, num_end_a_begin_b = 0;
  for (int i = 0; i < N; i++) {
    const int len = lens[i];
    int is_prev_a = 0;
    if (css[i][len - 1] == 'A' && css[i][0] == 'B') {
      num_end_a_begin_b++;
    } else if (css[i][len - 1] == 'A') {
      num_end_a++;
    } else if (css[i][0] == 'B') {
      num_begin_b++;
    }
    for (int j = 0; j < len; j++) {
      const char c = css[i][j];
      if (c == 'A') {
        is_prev_a = 1;
      } else {
        if (is_prev_a && c == 'B') {
          ans++;
        }
        is_prev_a = 0;
      }
    }
  }
  // connect all that start with B and end with A
  if (num_end_a_begin_b > 0) {
    ans += num_end_a_begin_b - 1;
    if (num_begin_b > 0) {
      ans++;
      num_begin_b--;
    }
    if (num_end_a > 0) {
      ans++;
      num_end_a--;
    }
  }
  ans += min(num_end_a, num_begin_b);
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];

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

  int cnt=0;
  while(x > 0 && cnt < n){
    x -= a[cnt];
    cnt++;
  }
  cout << (!x + cnt - 1) << endl;
  //cout << ( x == 0 ? i : max(i-1, 0)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, a[100];

signed main(){
    cin >> N;
    ll M = 0, m = 0, pos = 0, neg = 0;
    REP(i, N){
        cin >> a[i];
        if(a[i] > a[M]) M = i;
        if(a[i] < a[m]) m = i;
        if(a[i] > 0) pos++;
        if(a[i] < 0) neg++;
    }
    if(abs(a[m]) <= abs(a[M])){
        PRINT(neg + N - 1);
        REP(i, N){
            if(a[i] < 0){
                cout << M + 1 << " " << i + 1 << endl;
            }
        }
        REP(i, N - 1){
            cout << i + 1 << " " << i + 2 << endl;
        }
    }else{
        PRINT(pos + N - 1);
        REP(i, N){
            if(a[i] > 0){
                cout << m + 1 << " " << i + 1 << endl;
            }
        }
        for(ll i = N - 1; i >= 1; i--){
            cout << i + 1 << " " << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Typical Stairs
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MOD = 1000000007;

/* typedef */

/* global variables */

bool ngs[MAX_N + 1];
int dp[MAX_N + 1];

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int ai;
    scanf("%d", &ai);
    ngs[ai] = true;
  }

  dp[0] = 1;
  for (int i = 0; i < n; i++)
    if (! ngs[i]) {
      addmod(dp[i + 1], dp[i]);
      if (i + 2 <= n) addmod(dp[i + 2], dp[i]);
    }

  printf("%d\n", dp[n]);
  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main() {
	char a[3];
	scanf("%s", a);
	int x = 700;
	int i;
	for (i = 0; i < 3; i++) {
		if (a[i] == 'o') {
			x = x + 100;
		}
	}
		printf("%d", x);
	return 0;
}

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

int main(){
	int n,k;
	cin >> n >> k;
	ll x;
	vector<ll> p,m;
	rep(i,n){
		cin >> x;
		if(x == 0) k--;
		if(x > 0) p.push_back(x);
		else m.push_back(-x);
	}
	sort(p.begin(),p.end());
	sort(m.begin(),m.end());

	ll ans(pow(10,15));
	for(int i(k);i>=0;--i){
		if(p.size() < i) continue;
		ll p_cost, m_cost;
		if(i == 0){
			p_cost = 0;
		}else{
			p_cost = p[i-1];
		}

		if(k == i){
			m_cost = 0;
		}else{
			if(k-i > m.size()) continue;
			m_cost = m[k-i-1];
		}
		if(ans > 2*p_cost + m_cost) ans = 2*p_cost + m_cost;
		if(ans > 2*m_cost + p_cost) ans = 2*m_cost + p_cost;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1656
#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<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


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(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	ll N, M, P;
	cin >> N >> M >> P;
	vector<ll> node(N);
	vector<pair<ll, ll>> edge(M);
	vector<ll> score(M);
	vector<bool> loop;
	loop.resize(N, false);
	ll inf = (ll)1e18;
	REP(i, 0, N)node[i] = inf;
	node[0] = 0;
	REP(i, 0, M) {
		ll a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		edge[i].first = a;
		edge[i].second = b;
		score[i] = -(c-P);
	}
	REP(j,0,N) {
		REP(i, 0, M) {
			if (node[edge[i].first] != inf && node[edge[i].second] > node[edge[i].first] + score[i]) {
				node[edge[i].second] = node[edge[i].first] + score[i];
				if (j == N - 1) {
					loop[edge[i].second] = true;
				}
			}
		}
	}
	REP(j, 0, N+1) {
		REP(i, 0, M) {
			if (loop[edge[i].first]) loop[edge[i].second] = true;
		}
	}
	if (node[N - 1] == inf || loop[N - 1])PRI(-1);
	else PRI(max(0LL,-node[N - 1]));
	return 0;
}




Measured memory_bytes: 3752
#!usr/bin/env python3

import sys


def string_to_list_spliter():
    h, w = [int(i) for i in sys.stdin.readline().split()]
    return h, w


def generate_frame(h, w):
    frame = ''
    for i in range(h):
        for j in range(w):
            if i == 0 or i == h-1:
                frame += '#'
            else:
                if j == 0 or j == w-1:
                    frame += '#'
                else:
                    frame += '.'
        frame += '\n'
    return frame


def print_frame():
    while True:
        h, w = string_to_list_spliter()
        if h == 0 and w == 0:
            break
        print(generate_frame(h, w))


def main():
    print_frame()


if __name__ == '__main__':
    main()

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

int main() {
  int X;
  cin >> X;
  
  int ans = 0;
  for (int b = 1; b < 1000; b++) {
    int beki = b;
    for (int p = 1; p < 1000; p++) {
      beki *= b;
      if(ans < beki && beki <= X) {
        ans = beki;
      }
    }
  }
  
  cout << ans << endl;
    
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pp pair< ll, pair<ll,ll> >

int main()
{
    ll n; cin>>n;
    ll a = -INT_MAX, b = INT_MAX, c = -INT_MAX, d = INT_MAX;
    for(ll i = 0; i < n; i++){
        ll x, y; cin>>x>>y;
        a = max(x+y, a);
        b = min(b, x+y);
        c = max(x-y, c);
        d = min(x-y, d);
    }
    cout << max( a-b, c-d ) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！

#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！
const double pi = 3.14159265359;

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

  if(isupper(s)){
      cout << "A" << endl;
  }
  else{
      cout << "a" << endl;
  }
}


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

typedef long long int in;

in dp[3][100005];

int main() 
{
	in n;
	cin>>n;
	
	in a[3][n+1],i,j;
	
	for(i=1;i<=n;++i)
	{
	    cin>>a[0][i]>>a[1][i]>>a[2][i];
	}
	
	
	for(i=1;i<=n;++i)
	{
	    dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[0][i];
	    dp[1][i]=max(dp[0][i-1],dp[2][i-1])+a[1][i];
	    dp[2][i]=max(dp[0][i-1],dp[1][i-1])+a[2][i];
	}
	
	cout<<max({dp[0][n],dp[1][n],dp[2][n]});
	
	return 0;
}

Measured memory_bytes: 4992
import math
all = input()
A = int(all.split(' ')[0])
B = int(all.split(' ')[1])
H = int(all.split(' ')[2])
M = int(all.split(' ')[3])
delta_ = H/12+(1/12)*(M/60)-M/60
c = (A**2+B**2-2*A*B*math.cos(2*delta_*math.pi))**0.5
print(c)

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

int main()
{
    int N,dt,dx,dy,ta,tb,xa,xb,ya,yb,i;
    int flag = 1;

    scanf("%d",&N);
    xa=0;
    ya=0;
    ta=0;

    for(i=0;i<N;i++){
        scanf("%d %d %d",&tb,&xb,&yb);
        dt = tb - ta;
        dx = abs(xb - xa);
        dy = abs(yb - ya);
        if(dt<dx+dy||(dt-(dx+dy))%2 == 1){
            flag = 0;
            printf("No\n");
            break;
        }
        ta = tb;
        xa = xb;
        ya = yb;
    }

    if(flag == 1){
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> result(n, 0);

  int a;
  rep(i, q){
    cin >> a;
    result[a-1]++;
  }

  rep(i, n){
    if(k + result[i] - q > 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,an;
double a[110];
double s,t;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	t=s;
	s/=n;
	for(int i=0;i<n;i++)
	{
		if(abs(a[i]-s)<t)
		{
			t=abs(a[i]-s);
			an=i;
		}
	}
	cout<<an;
	return 0;
} 


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

int main() {
    int N;              // 2N個のマスのうちN個当たりだとok
    int M;              // M - 1個以上のあたりが欲しい
    int A_lt_N[1000];   // 当たりがNより少ない時
    int keihin = 0;     // もらえる景品の数
    int yen = 0;        // 払うお金

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int A;         // 当たりの数
        int B;         // はずれの数
        cin >> A >> B;
        if (A < N) {
            A_lt_N[i - keihin] = A;
        } else {
            keihin++;
        }
    }

    int num_array = M - keihin + 1;
    while (keihin < M - 1) {
        int maxi = 0;
        int max_index = -1;
        for (int i = 0; i < num_array - 1; i++) {
            if (A_lt_N[i] >= maxi) {
                maxi = A_lt_N[i];
                max_index = i;
            }
        }
        yen += N - maxi;
        keihin++;
        swap(A_lt_N[max_index], A_lt_N[num_array-2]);
        num_array--;

    }
    cout << yen << '\n';
    return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m2%12==(m1+1)%12&&d2==1) cout<<1;
    else cout<<0;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)

    out.println(n * (n - 1) / 2 + m * (m - 1) / 2)
    out.flush()
  }
}


Measured memory_bytes: 27328
d,g = map(int,input().split(' '))
pc = []
for _ in range(d):
    p,c = map(int,input().split(' '))
    pc.append((p,c))

ans = 10000000

for i in range(2**d):
    cnt = 0
    score = 0
    max_flg = 0
    for j in range(d):
        #print(str(i) + ' ' + str(j))
        if((i>>j)&1 == 1):
            score += pc[j][0]*(j+1)*100+pc[j][1]
            cnt += pc[j][0]
        else:
            max_flg = j
    
    #print(str(score) + ' '+ str(cnt))
    if(score >= g):
        ans = min(ans,cnt)
    elif(score + (pc[max_flg][0]-1)*(max_flg+1)*100 < g):
        continue
    else:
        for k in range(pc[max_flg][0]):
            if(score + k*(max_flg+1)*100 >= g):
                ans = min(ans,cnt+k)
            else:
                continue

print(str(ans))

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

vector<pair<int, ll>> tree[100010];
ll depth[100010];

void dfs(int v, int p, ll d) {
    depth[v] = d;
    for (auto &e: tree[v]) {
        if (e.first == p) continue;
        dfs(e.first, v, d + e.second);
    }
}

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

    rep(i, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int q, k;
    cin >> q >> k;
    k--;

    dfs(k, -1, 0);
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << depth[x] + depth[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

struct edge{
	int to;
	int money;
	int enemy;
	edge(int t, int m, int e):to(t),money(m),enemy(e){}
	bool operator<(const edge &r) const{
		return enemy > r.enemy;
	}
};

int main(){
	int n, m, l;
	while(cin >> n >> m >> l, n|m|l){
		vector<vector<edge> > G(n);
		rep(i, m){
			int a, b, d, e;
			cin >> a >> b >> d >> e;
			a--, b--;
			G[a].push_back(edge(b, d, e));
			G[b].push_back(edge(a, d, e));
		}

		priority_queue<edge> q;
		q.push(edge(0, l, 0));

		vector<vi> visit(n, vi(l+1, 0)); // visit[pos][money]

		while(!q.empty()){
			edge s = q.top();
			q.pop();

			//cout << "pos=" << s.to << ", money=" << s.money << ", enemy=" << s.enemy << endl;

			if(visit[s.to][s.money]) continue;
			visit[s.to][s.money] = 1;

			if(s.to == n-1){
				cout << s.enemy << endl;
				break;
			}

			rep(i, G[s.to].size()){
				if(G[s.to][i].money <= s.money){
					edge next = s;
					next.money -= G[s.to][i].money;
					next.to = G[s.to][i].to;
					if(!visit[next.to][next.money]){
						q.push(next);
					}
				}
				edge next = s;
				next.enemy += G[s.to][i].enemy;
				next.to = G[s.to][i].to;
				q.push(next);
			}
		}

	}

	return 0;
}

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

using namespace std;

int a[2222];
int main()
{
	int n, k, q;
	cin >> n >> k >> q;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int m = 2e9;
	for (int i = 0; i < n; i++) {
		vector<int> b;
		for (int s = 0, t; s < n; s = t + 1) {
			for (t = s; t < n&&a[t] >= a[i]; t++);
			if (t - s < k) continue;
			b.insert(b.end(), a + s, a + t);
			sort(b.end() - (t - s), b.end());
			b.erase(b.end() - (k - 1), b.end());
		}
		sort(b.begin(), b.end());
		if (b.size() >= q)
			m = min(m, b[q - 1] - b[0]);
	}
	cout << m << endl;
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int N; cin >> N;
    vector<int> X(N); REP(i, N) cin >> X[i];
    int res = pow(10, 8);
    int max_n = *max_element(all(X));
    REP(i, max_n) {
        int tmp = 0;
        REP(k, N) {
            tmp += pow((X[k] - (i + 1)), 2);
        }
        if(tmp < res) res = tmp;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A_XorBattle solver = new A_XorBattle();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_XorBattle {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int numTests = in.nextInt();
            for (int test = 0; test < numTests; test++) {
                int n = in.nextInt();
                long[] a = new long[n];
                for (int i = 0; i < n; i++) {
                    a[i] = in.nextLong();
                }
                char[] s = in.next().toCharArray();
                long[] basis = new long[64];
                int[] bit = new int[64];
                int k = 0;
                boolean z = true;
                for (int i = n - 1; i >= 0; i--) {
                    long x = a[i];
                    for (int j = 0; j < k; j++) {
                        if (((x >> bit[j]) & 1) != 0) {
                            x ^= basis[j];
                        }
                    }
                    if (x != 0) {
                        if (s[i] == '0') {
                            // Add a[i] to basis.
                            basis[k] = x;
                            bit[k] = Long.numberOfTrailingZeros(x);
                            ++k;
                        } else {
                            // a[i] must lie in the subspace spanned by basis.
                            z = false;
                        }
                    }
                }
                out.println(z ? 0 : 1);
            }
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 40888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll a,p;
int main(void){
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    
}


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

int main(){
	string s;
	cin >> s;
	long ans = 0, cnt = 0;
	int n = s.size();
	for(int i = 0; i < n; i++) {
		if(s[i] == 'A') cnt++;
		else if(s[i] == 'B') {
			if(i + 1 < n && s[i+1] == 'C') {
				i++;
				ans += cnt;
			} else cnt = 0;
		} else cnt = 0;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

void initialize(){
    int i;
    for(i=0;i<N;i++) {
        row[i] = FREE;
        col[i] = FREE;
    }
    for(i=0;i<N;i++){
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard(){
    int i,j;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(X[i][j] == 1){
                if(row[i] != j) return;
            }
        }
    }
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(row[i] == j) printf("Q"); 
            else printf(".");
        }
        printf("\n");
    }
}

void recursive(int i){
    int j;
    if(i == N){
        printBoard();
        return;
    }
    
    for(j=0;j<N;j++){
        if(NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
        row[i] = j;
        col[j] = dpos[i+j] = dneg[i - j + N - 1] = NOT_FREE;
        recursive(i+1);
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
}
int main(void){
    initialize();
    int i,j;
    int r,c;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++) X[i][j] = false;
    }
    int k;
    scanf("%d",&k);
    for(i=0;i<N;i++){
        scanf("%d %d",&r,&c);
        X[r][c] = true;
    }
    recursive(0);
    return 0;
}




Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int n = 0, heap[2000001];

void maxHeapify(int i) {
    int l = i * 2;
    int r = i * 2 + 1;
    int maxi = i;
    if (l <= n && heap[l] > heap[maxi])
        maxi = l;
    if (r <= n && heap[r] > heap[maxi])
        maxi = r;
    if (i != maxi) {
        swap(heap[i], heap[maxi]);
        maxHeapify(maxi);
    }
}

void insert(int v) {
    int i = ++n;
    heap[i] = v;
    while (i > 1 && heap[i] > heap[i / 2]) {
        swap(heap[i], heap[i / 2]);
        i /= 2;
    }
}

int extract() {
    int ret = heap[1];
    swap(heap[1], heap[n--]);
    maxHeapify(1);
    return ret;
}

int main() {
    int v;
    string s;
    while (1) {
        cin >> s;
        if (s == "insert") {
            cin >> v;
            insert(v);
        }
        if (s == "extract") {
            cout << extract() << endl;
        }
        if (s == "end") {
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 7052
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)
var sc2 = bufio.NewScanner(os.Stdin)

func main() {
	list := getStdinIntArr()
	N := list[0]
	M := list[1]
	H := getStdinIntArr()
	flag := make([]bool, N)
	for i := 0; i < M; i++ {
		list2 := getStdinIntArr()
		A := list2[0] - 1
		B := list2[1] - 1
		if H[A] <= H[B] {
			flag[A] = true
		}
		if H[B] <= H[A] {
			flag[B] = true
		}
	}

	ans := 0
	for _, val := range flag {
		if !val {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

func getStdin() string {
	return readLine()
}
func getStdin2() string {
	sc2.Scan()
	return sc2.Text()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr2() []int {
	str := getStdin2()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main() {
    int n,m;
    cin>>n>>m;
    char arr[n][m];
    for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
            cin>>arr[i][j];
        }
    }
    ll dp[n][m];
    dp[0][0] = 0;
    bool f1=true,f2=true;
    for(int i=1;i<n;i++) {
        if(arr[i][0] == '#' || !f1) {
            f1 = false;
            dp[i][0] = 0;
        }
        else
            dp[i][0] = 1;
    }
    for(int i=1;i<m;i++) {
        if(arr[0][i] == '#' || !f2) {
            f2 = false;
            dp[0][i] = 0;
        }
        else
            dp[0][i] = 1;
    }
    
    for(int i=1;i<n;i++) {
        for(int j=1;j<m;j++) {
            if(arr[i][j] == '.')
                dp[i][j] = (dp[i-1][j]%1000000007+dp[i][j-1]%1000000007)%1000000007;
            else
                dp[i][j] = 0;
        }
    }
    cout<<dp[n-1][m-1]%1000000007;
    return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


ll cnt[100005];
ll plnty[100005];

int main()
{
    FASTIO;

    ll n, m;

    cin >> n >> m;

    int count = 0, count1 = 0;





    ll num;

    string st;

    for(int i=0; i<m; i++)
    {
        cin >> num >> st;

        if(cnt[num])
        {
            continue;
        }

        else if(st=="AC")
        {
            cnt[num]++;

            count++;

            count1 += plnty[num];

        }
        else if(st=="WA")
        {
            plnty[num]++;
        }
    }

    cout << count << " " << count1 << endl;

//
//    for(int i=1; i<=n; i++)
//    {
//        if(cnt[i]>0)
//        {
//            count++;
//        }
//
//    }
//
//    for(int i=1; i<=n; i++)
//    {
//        if(plnty[i]>0)
//        {
//            count1+=plnty[i];
//        }
//    }
//
//    cout << count << " " << count1 << endl;
//
//
//



    return 0;
}



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

using namespace std;

int main(int argc, char const *argv[]) {
  char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  vector<char> alphabets;
  for (size_t i = 0; i < 26; i++) alphabets.push_back(alphabet[i]);

  string s;
  cin >> s;
  int ln = s.size();
  if (ln < 26) {
    for (size_t i = 0; i < ln; i++) {
      alphabets.erase(remove(alphabets.begin(), alphabets.end(), s[i]), alphabets.end());
    }
    cout << s + alphabets[0] << endl;
  } else {
    int it=0;
    for (int i = ln-1; i > 0; i--) {
      if (s[i] < s[i-1]) ;
      else {
        it = i;
        break;
      }
    }
    if (it == 0) cout << -1 << endl;
    else {
      vector<char> svec;
      for (size_t i = it; i < s.size(); i++) svec.push_back(s[i]);
      sort(svec.begin(), svec.end());
      decltype(svec)::iterator iter = std::upper_bound(svec.begin(), svec.end(), s[it-1]);

      s.erase(s.begin() + it-1, s.end());

      cout << s + *iter << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

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



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
vector<vector<int> > v(111111);
ll dp[111111][2];
ll mod=1e9+7;

ll f(int node,bool ok,int p=-1){
    ll res=1;bool yay=1;
    if(dp[node][ok]!=-1)return dp[node][ok];
    for(auto u:v[node]){
        if(u==p)continue;
        yay=0;
       if(ok)res*=f(u,0,node);
       else res*=(f(u,1,node)+f(u,0,node))%mod;
       res%=mod;
    }
    if(yay)return dp[node][ok]=1;
    return dp[node][ok]=res;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
   for(int i=0;i<111111;i++)for(int j=0;j<2;j++)dp[i][j]=-1;
    cout<<(f(0,1)+f(0,0))%mod;
    
}

Measured memory_bytes: 16128
as = gets.chomp!.split('')
bs = gets.chomp!.split('')
cs = gets.chomp!.split('')

turn = as.shift

winner = ""
flag = true
while flag
  if turn == "a" then
    if as.size == 0 then
      flag = false
      winner = "A"
    end
    turn = as.shift
  elsif turn == "b" then
    if bs.size == 0 then
      flag = false
      winner = "B"
    end
    turn = bs.shift
  elsif turn == "c" then
    if cs.size == 0 then
      flag = false
      winner = "C"
    end
    turn = cs.shift
  end
end

puts winner


Measured memory_bytes: 1788
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy";
    else if(s=="Cloudy") cout << "Rainy";
    else cout << "Sunny";

    return 0;
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

int main()
{
	string s;
  int ret = 0;
  int sum = 0;

	cin >> s;
  rep(i,s.size()){
    if(s[i] == 'S') sum++;
    else{
      if(sum > 0){
        sum--;
        ret+=2;
      }
    }
  }
  cout << s.size() - ret << endl;

	return 0;
}


Measured memory_bytes: 640
import sys

s = input()
left = s[: len(s) // 2]
right = s[len(s) // 2 + 1 :]
if left != right[::-1]:
    print("No")
    sys.exit()
for i in range(len(left) // 2):
    if left[i] != left[-i - 1]:
        print("No")
        sys.exit()
print("Yes")


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main() {
    ll n,k;cin >>n>>k;
    k--;
    vector<ll>h(n);
    for (int i = 0; i < n; ++i) {
        cin >>h[i];
    }
    sort(all(h));
    ll ans=INF;
    for (int i = 0; i < n; ++i) {
        if(i+k>=n)break;
        ll tmp=h[i+k]-h[i];
        ans=min(ans,tmp);
    }
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, A, B;
	cin >> N >> A >> B;

	if (A + B > N + 1
		|| A == 1 && B != N
		|| B == 1 && A != N) {
		cout << -1 << endl;
		return 0;
	}

	bool swapped = false;
	if (A < B) {
		swapped = true;
		swap(A, B);
	}

	vector<int> ret;
	REP(i, N - A + 1, N) ret.push_back(i);
	int len = B - 1;
	if (len > 0) {
		if (N - A + 1 < B) {
			cout << -1 << endl;
			return 0;
		}

		int round = 1;
		int maxV = N - A;
		while (true) {
			int pt = round * len;
			rep(j, len) {
				if (pt <= maxV) ret.push_back(pt);
				pt--;
			}
			if (round * len + 1 > maxV) break;
			round++;
		}
		if (round > A) {
			cout << -1 << endl;
			return 0;
		}
	}

	if (swapped) {
		reverse(all(ret));
	}

	rep(i, N - 1) printf("%d ", ret[i]);
	cout << ret.back() << endl;

    return 0;
}


Measured memory_bytes: 6000
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    int s = n % 60;
    n /= 60;
    int m = n % 60;
    n /= 60;
    cout << n << ':' << m << ':' << s << endl;
}



Measured memory_bytes: 3108