akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (int)(1e9+7)
#define MOD (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//manip
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; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power_mod(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define outaa(a, m, n) rep(i, m) {rep(j, n) cout << a[i][j] << " "; cout << endl;} cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl

//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always
//product of minimum 9 prime numbers is above 1e9

struct mint { int n; mint(int n) : n(n){ } }; //n = n;
mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
ostream &operator<<(ostream &s, mint a) { return s << a.n; }

int main() {
    int h, w; cin >> h >> w;
    char c[h][w]; rep(i, h) rep(j, w) cin >> c[i][j];
    
    //mint dp[h][w]; fill_n(*dp, h * w, 0);
    vector<vector<mint> > dp(h, vector<mint>(w, 0));
    dp[0][0] = 1;
    rep(i, h) rep(j, w) {
        if (i == 0 && j == 0) continue;
        if (c[i][j] == '#') continue;
        if (j) dp[i][j] += dp[i][j - 1];
        if (i) dp[i][j] += dp[i - 1][j];
    }
    out(dp[h - 1][w - 1]);
}

/*
 あるマスに関して下、右がすでに訪問済みだったらいい
 
 
 
 */



Measured memory_bytes: 5120
def main():
    n, c = map(int, input().split())
    d = [list(map(int, input().split())) for i in range(c)]
    grid = [list(map(int, input().split())) for i in range(n)]

    group = [[0 for i in range(c)], [0 for i in range(c)], [0 for i in range(c)]]
    for i in range(n):
        for j in range(n):
            group[(i+j) % 3][grid[i][j]-1] += 1

    min_cost = 1 << 30
    for i in range(c):
        for j in range(c):
            if i != j:
                for k in range(c):
                    if j != k and k != i:
                        cost = 0
                        for color in range(c):
                            cost += group[0][color] * d[color][i]
                            cost += group[1][color] * d[color][j]
                            cost += group[2][color] * d[color][k]

                        min_cost = min(cost, min_cost)

    print(min_cost)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll modmul(ll a,ll b,ll mod){
    return a%mod * (b%mod) %mod;
}

ll modpow(ll a,ll b,ll mod){
    if(b==0) return 1;
    else if(b%2==0) return modpow(modmul(a,a,mod),b/2,mod);
    else return modmul(modpow(a,b-1,mod),a,mod);
}

ll moddiv(ll a,ll b,ll mod){
    return a%mod * modpow(b,mod-2,mod) %mod;
}

int main(void)
{
    ll n; cin >> n;
    string ans;
    while(n>0){
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int a=scn.nextInt();
		int b=scn.nextInt();
		int c=scn.nextInt();
		int x=c-a+b;
		if(x<0)
			x=0;
		System.out.println(x);
	}

}


Measured memory_bytes: 21972
def f(h, w):
    l = []
    for i in range(w):
        m = [(w-i)*h, i*(h//2), i*(h-h//2)]
        l.append(max(m)-min(m))
    # print(l)
    return min(l)

H, W = map(int, input().split(" "))

if 0 in [H%3, W%3]:
    print(0)
else:
    # T字分割縦, T字分割横、3列分割縦、3列分割横
    print(min(f(H, W), f(W, H), H, W))


Measured memory_bytes: 7016
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	string s = rstring, t = rstring;

	foreach(i; 0 .. n){
		s[i].write;
		t[i].write;
	}
	"".writeln;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N = ini()
adj = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = [x - 1 for x in inm()]
    adj[a].append(b)
    adj[b].append(a)

depth = [(0, 0) for _ in range(N)]


def solve():
    stk = [(0, -1, False)]
    while stk:
        node, p, agg = stk.pop()
        if not agg:
            stk.append((node, p, True))
        md1, md2 = 0, 0
        for x in adj[node]:
            if x == p:
                continue
            if agg:
                dx, _ = depth[x]
                dx += 1
                if md1 < dx:
                    md2 = md1
                    md1 = dx
                elif md2 < dx:
                    md2 = dx
            else:
                stk.append((x, node, False))
        if agg:
            depth[node] = (md1, md2)

    stk = [(0, -1)]
    max_len = 0
    while stk:
        node, p = stk.pop()
        d1, d2 = depth[node]
        if p >= 0:
            pd1, pd2 = depth[p]
            if pd1 == 1 + d1:
                pd1 = pd2
            if d2 < pd1 + 1:
                d2 = pd1 + 1
        if max_len < d1 + d2 + 1:
            max_len = d1 + d2 + 1
        for x in adj[node]:
            if x != p:
                stk.append((x, node))

    if max_len == 1:
        return True
    if max_len == 2:
        return False
    return (max_len + 1) % 3 != 0


print("First" if solve() else "Second")


Measured memory_bytes: 121932
# -*- coding: utf-8 -*-
n = int(input())
S = []
for i in range(n):
    s = input()
    S.append(s)
print("AC x "+str(S.count("AC")))
print("WA x "+str(S.count("WA")))
print("TLE x "+str(S.count("TLE")))
print("RE x "+str(S.count("RE")))

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    string S;
    cin >> S;
    REP(i,0,S.length()) cout << "x";
    cout << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int N,data[301];
	bool** table = new bool*[301]; //table[left][right] = left???????§?????????????2*right??????????????¨?¶??????§??????????????????
	int** maximum = new int*[301]; //?????????????????????????????§?¶????????????°
	for(int i = 0; i <= 300; i++){
		table[i] = new bool[151];
		maximum[i] = new int[301];
	}

	bool FLG;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		if(N <= 1){
			printf("0\n");
			continue;
		}

		//?¶??????????????????????????????????
		for(int i = 1; i <= N; i++){
			for(int k = 0; k <= N/2; k++)table[i][k] = false;
			for(int k = 1; k <= N; k++)maximum[i][k] = 0;
		}

		for(int i = 1; i <= N; i++)scanf("%d",&data[i]);

		//????????????2???????¨?
		for(int i = 1; i <= N-1; i++){
			if(abs(data[i+1]-data[i]) <= 1){
				table[i][1] = true;
				maximum[i][i+1] = 2;
			}
		}

		//?¶??????????????????????????¨????
		for(int length = 4; length <= N; length += 2){ //??????????????????
			for(int left = 1; left+length -1 <= N; left++){ //??????????????????
				FLG = false;

				if(table[left+1][(length-2)/2] == true && abs(data[left] - data[left+length-1]) <= 1)FLG = true;//??????????????£?????????length-2??????????¶????????????????????????¨??????+length-1?????´???????????????????¶?????????´???

				if(!FLG){
					for(int i = 2; i <= length-2; i += 2){
						if(table[left][i/2] == true && table[left+i][(length-i)/2] == true){
							FLG = true;
							break;
						}
					}
				}
				if(FLG){
					table[left][length/2] = true;
					maximum[left][left+length-1] = length; //????¨?????????§??????OK????????§?????¶????????§???????¨????
				}else{
					//maximum[left][left+length-1]?????´??°????????°????????????
					for(int div = 0; left+div <= left+length-2;div++){ //????´¢?§????????????????
						for(int i = 2; left+div+i-1 <= left+length-1; i+= 2){ //????´¢?§?????????????????????´?????????????????§????????¢?????????
							maximum[left][left+length-1] = max(maximum[left][left+length-1],maximum[left+div][left+div+i-1]+maximum[min(left+length-1,left+div+i)][left+length-1]);
						}
					}
					//printf("maximum[%d][%d]:%d\n",left,left+length-1,maximum[left][left+length-1]);
				}
			}
		}

		if(N%2 == 0)printf("%d\n",maximum[1][N]);
		else{
			printf("%d\n",max(maximum[1][N-1],maximum[2][N]));
		}

	}

	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL maxn=1e18;
int main(){
	LL a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0)cout<<a-b<<endl;
	else cout<<b-a<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  Scanner sc;

  void run() {
    for ( ;; ) {
      int n = ni();
      int r = ni();

      if ( ( n | r ) == 0 )
        break;

      ArrayList<Integer> list = new ArrayList<Integer>();
      for ( int i = 0; i < n; ++i ) {
        list.add( n - i );
      }

      for ( int i = 0; i < r; ++i ) {
        int p = ni();
        int c = ni();

        List<Integer> subl = new ArrayList<Integer>( list.subList( p - 1, p + c
            - 1 ) );
        for ( int j = 0; j < c; ++j ) {
          list.remove( p - 1 );
        }
        list.addAll( 0, subl );

        // debug( list );
      }

      System.out.println( list.get( 0 ) );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 28696
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <cstdio>

typedef long long ll;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char s[100001], t[100001];
  cin >> s >> t;
  int s_len = strlen(s);
  //cout << s_len << "\n";
  int t_len = strlen(t);
  map<char, vector<int> > m;
  for(int i = 0; i < s_len; i++) {
    m[s[i]].push_back(i);
  }
  ll loop = 0;
  ll cur = -1;
  for(int i = 0; i < t_len; i++) {
    int glen = m[t[i]].size();
    //cout << glen << "\n";
    if(glen == 0) {
      cout << -1 << "\n";
      return 0;
    }
    int l = 0, r = glen;
    while(l < r) {
      int mid = (l + r) / 2;
      if(m[t[i]][mid] > cur) r = mid;
      else l = mid + 1;
    }
    if(l == glen) {
      loop += 1LL;
      cur = m[t[i]][0];
    } else {
      cur = m[t[i]][l];
    }
  }
  cout << loop * ((ll) s_len) + cur + 1LL << "\n";
  return 0;
}



Measured memory_bytes: 1148
#include<iostream>

#define MAXN 100000
#define MAXQ 50000

using namespace std;

int n,q;
int S[MAXN+1],T[MAXQ+1];
int cnt=0;

bool binarySearch( int num )
{
	int mi;
	int lo=0;
	int hi=n;	
	while( lo <= hi ) {
		mi=(lo+hi)/2;
		if( num < S[mi] ) {
			hi=mi-1;
		} else if( S[mi] < num ) {
			lo=mi+1;
		} else {
			return true;
		}
	}
	

	return false;
}

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

	cin>>q;
	for( int i=0; i<q; i++ ) {
		cin>>T[i];
		cnt += binarySearch( T[i] );
	}
	cout<<cnt<<endl;
	
    return 0;
}

Measured memory_bytes: 1744
M,K=map(int,input().split())
if M==0 and K==0:
  ans=[0,0]
elif M==1:
  if K==0:
    ans=[0,0,1,1]
  else:
    ans=[-1]
elif K>=2**M:
  ans=[-1]
else:
  ans=[]
  for i in range(2**M):
    if i!=K:
      ans.append(i)
  ans.append(K)
  for j in range(2**M-1,-1,-1):
    if j!=K:
      ans.append(j)
  ans.append(K)
for i in ans:
  print(i,end=' ')

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){	
	ll n, i, ans = 0, cur = 1;
	string s;
	cin >> n >> s;
	rep(i,1,n){
		if(s[i] != s[i - 1]){
			ans++;
		}
	}
	cout << ans + 1 << nl;
}

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


Measured memory_bytes: 3764
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  char s[1001];
  scanf("%s", s);
  int len;
  for(len=0; s[len]!='\0'; ++len);
  if (s[0] != 'A') {
    printf("WA\n");
    return 0;
  }
  if (!((s[1]>= 'a') && (s[1]<='z'))) {
    printf("WA\n");
    return 0;
  }
  bool flag = false;
  for (int i=2; i<len-1; i++) {
    if (s[i] == 'C') {
      if (!flag) {
        flag = true;
      } else {
        printf("WA\n");
        return 0;
      }
    } else if (!((s[1]>= 'a') && (s[1]<='z'))) {
      printf("WA\n");
      return 0;
    }
  }
  if (!((s[len-1]>= 'a') && (s[len-1]<='z'))) {
    printf("WA\n");
    return 0;
  }
  if (flag) {
    printf("AC\n");
    return 0;
  } else {
    printf("WA\n");
    return 0;
  }

  return 0;
}


Measured memory_bytes: 128
import sys

def solve():
    input = sys.stdin.readline
    S = input()
    if "RRR" in S:
        print(3)
    elif "RR" in S:
        print(2)
    elif "R" in S:
        print(1)
    else:
        print(0)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9040
#include <bits/stdc++.h>
#if LOCAL
#include "../cout.hpp"
#endif
using namespace std;

#define forn(i,n) for (unsigned i = 0; i < n; ++i)
#define fors(i,n,s) for (unsigned i = 0; i < n; i += 2) 

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

    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)) {
	cout << "A";
    } else {
	cout << "B";
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=200005;
int n,p[N],val[N];

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%d",p+i);
    }
    int mx=0;
    for (int i=1;i<=n;i++) {
        val[p[i]]=val[p[i]-1]+1;
        mx=max(mx,val[p[i]]);
    }
    printf("%d\n",n-mx);
}

Measured memory_bytes: 1792
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,X = map(int, input().split())
    LS = list(map(int, input().split()))
    res = [0]*(N+1)
    for i in range(N):
        res[i+1] = res[i]+LS[i]
    res.sort()
    print(bisect_right(res,X))

if __name__ == '__main__':
    main()

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

using lint = long long;

vector<vector<int>> edges;
array<int, 100015> depth, deg, seen;
int result;

void dfs(int v) {
    seen[v] = 1;
    for (int u : edges[v]) {
        depth[u] = max(depth[u], 1 + depth[v]);
        deg[u]--;
        if (deg[u] == 0) dfs(u);
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    edges.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        deg[b]++;
    }
    for (int i = 0; i < n; ++i) if (!deg[i] && !seen[i]) dfs(i);
    for (int i = 0; i < n; ++i) result = max(result, depth[i]);
    cout << result << '\n';
}

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

int main() {
  int A, B, C ;
  cin >> A >> B >> C ;

  if ( A<C && C<B ) {
    cout << "Yes" << endl;
  }

 else if ( B<C && C<A ) {
    cout << "Yes" << endl;
  }

 else {
     cout << "No" << endl;
}
}


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int d[10][10];
int n, m;
int h = 10;
void warshall_floyd() {
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < h; j++) {
			for (int k = 0; k < h; k++) {
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
}

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

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> d[i][j];
		}
	}
	warshall_floyd();

	// for (int i = 0; i < 10; i++) {
	// 	for (int j = 0; j < 10; j++) {
	// 		cout << d[i][j] << " ";
	// 	}
	// 	cout << "\n";
	// }


	int ans = 0;
	int tmp;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> tmp;
			if (tmp==-1) {
				continue;
			}
			if (tmp == 1) {
				continue;
			}
			ans += d[tmp][1];
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
int m[N][N],color[N],d[N],n;



void bfs(int s){
	
	queue<int> q;
	q.push(s);
	for(int i=0;i<N;i++){
		color[i] = WHITE;
		d[i] = (1<<21);
	}
	d[s] = 0;
	color[s] = GRAY;
	int u;
	while(!q.empty()){
		u = q.front();
		q.pop();
		
		for(int v=0;v<n;v++){
			if(m[u][v]&&color[v]==WHITE){
				color[v] = GRAY;
				d[v] = d[u]+1;
				q.push(v);
			}
		}
	}
	for(int i=0;i<n;i++){
			cout<<i+1<<" "<<((d[i]==(1<<21))?(-1):(d[i]))<<endl; 
		}
}
	
	int main(){
		int u,v,k;
		
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>u>>k;
			u--;
			for(int j=0;j<k;j++){
				cin>>v;
				v--;
				m[u][v]=1;
			}
		}
		bfs(0);
		
		return 0;
}

Measured memory_bytes: 3120
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, q = LI()
    v = [n] * n
    h = [n] * n
    c = n
    r = n
    ans = 0
    for _ in range(q):
        q, x = LI()
        if q == 1:
            if c < x:
                ans += v[x] - 2
            else:
                ans += r - 2
                for i in range(x, c):
                    v[i] = r
                c = x
        else:
            if r < x:
                ans += h[x] - 2
            else:
                ans += c - 2
                for i in range(x, r):
                    h[i] = c
                r = x
    print((n - 2) ** 2 - ans)
    return


#main
if __name__ == '__main__':
    solve()


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int d[333333];

bool f(){
    int r=0;
    rep(i,N){
        if(i*10>r)return false;
        chmax(r,i*10+d[i]);
    }
    return true;
}

signed main(){
    cin>>N;
    rep(i,N)cin>>d[i];

    bool ok=true;
    ok&=f();
    reverse(d,d+N);
    ok&=f();
    if(ok)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}

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

int main(void)
{
  int a;
  int b;
  cin >> a >> b;
  int flag = 0;
  if(a+b ==15)
  {
    flag = 1;
  }
  if(a*b == 15)
  {
    flag =2;
  }

  if(flag ==0)
  {
    cout <<"x";
  }
  else if(flag == 1)
  {
    cout << "+";
  }
  else if(flag == 2)
  {
    cout << "*";
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

cnt = [0]*n
ans = 1

for i in a:
    if i>0: ans *= max(0,cnt[i-1] - cnt[i])
    cnt[i] += 1
    if cnt[i]>3:ans = 0
    ans %= mod

ans *= 3 if cnt[0]==1 else 6

print(ans%mod)


Measured memory_bytes: 84152
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

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

	auto result = 0.0;
	for (auto i = 1; i <= N; ++i)
	{
		auto temp = 1 / (double)N;
		for (auto j = i; j < K; j *= 2)
		{
			temp /= 2.0;
		}
		result += temp;
	}

	cout << setprecision(11) << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define ll long long
using namespace std;

const int N = 4007;

void solve() {
    int n;
    ll r = 0, g = 0, b = 0;
    string s;
    cin >> n;
    cin >> s;
    s = '#' + s;
    for (int i = 1; i <= n; ++i) {
        r += s[i] == 'R';
        g += s[i] == 'G';
        b += s[i] == 'B';
    }
    ll bad = 0;
    for (int i = 1; i <= n; ++i) {
         for (int j = i + 1; j <= n; ++j) {
             int d = j - i;
             int k = j + d;
             if (k > n)
                 continue;
             if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
                 ++bad;
             }
         }
     }
    cout << r * g * b - bad << endl;
    return;
}

int main() {
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3196
S = list(input())

if S[0] == "B":
    flg = True
else:
    flg = False

ans = 0
for i in range(1, len(S)):
    s = S[i]
    if s == "B":
        tmp = True
    else:
        tmp = False

    if flg != tmp:
        ans += 1
        flg = not flg

print(ans)


Measured memory_bytes: 9812
#include <iostream>

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

using namespace std;

bool check[300001];

int main() {
	rep(i, 300001) {
		if((i%7==1) || (i%7==6)) check[i] = true;
	}
	check[1] = false;
	rep(i, 300001) {
		if(check[i]) {
			for(int j = i * 2; j < 300001; j+=i) {
				check[j] = false;
			}
		}
	}
	int n;
	while(cin >> n) {
		if(n == 1) break;
		cout << n << ":";
		rep(i, n+1) {
			if(check[i] && n % i == 0) {
				cout << " " << i;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1452
#include <iostream>
using namespace std;
int main(){
    int n;cin>>n;
    int l,r,ans;ans=0;
    for(int i=0;i<n;++i){
        cin>>l>>r;
        if(l==r){
            ans+=1;
        }else{
            ans+=abs(l-r)+1;
        }
    } 
    cout<<ans<<endl;
}

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

#define rep(i, s, n) for(int i = (s); i < (int)(n); i++)
#define INF INT_MAX/2

using namespace std;

int N, K;

int main() {
    cin >> N >> K;
 
    queue<int> que1;
    que1.push(1);
 
    rep(i, 0, N) {
        queue<int> que0;
 
        while (!que1.empty()) {
            int x = que1.front(); que1.pop();
            que0.push(x * 2);
            que0.push(x + K);
        }
 
        swap(que1, que0);
    }
 
    int ans = INF;
    while (!que1.empty()) {
        int x = que1.front(); que1.pop();
        ans = min(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";

#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 125

template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

//FILE* outFile;

inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}
inline int gcd(int a, int b){if(b == 0)return a; return gcd(b, a%b);}
int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

pii a[55];
int main(){
    int j,k,i,T,ca=0, m, K = 0, n;
    scanf("%d", &n);
    rep(i, 0, n)scanf("%d%d", &a[i].x, &a[i].y);
    map<pii, int>cnt;
    rep(i, 0, n)rep(j, 0, n)if(i!=j){
        int x = a[i].x - a[j].x;
        int y = a[i].y - a[j].y;
        cnt[mp(x, y)]++;
    }
    int ans = 0;
    for(auto &o : cnt)Max(ans, o.y);
    printf("%d\n", n - ans);
}



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

int main(){
  string s;
  int K;
  cin>>K>>s;
  
  if(s.size()<=K){
    cout<<s;
  }else{
    for(int i=0;i<K;i++){
      cout<<s.at(i);
    }
    cout<<"..."<<endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define pll pair<ll,ll>
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
#define PI 3.141592653589
const ll INF = 1e18l+10,N = 1e5+10,MAX = 2e5+10;

int main()
{
    SPEED
    ll n,i,j;
    cin>>n;
    ld p[n];
    ld dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] =1.0;
    f(n) {
        cin>>p[i];
        dp[0][i+1] = (1-p[i])*dp[0][i];
        for(j=1;j<=i+1;j++)
        dp[j][i+1] = p[i]*dp[j-1][i] + (1-p[i])*dp[j][i];
    }

    ld ans = 0;
    for(i=n/2+1;i<=n;i++)ans+=dp[i][n];
    cout<<fixed<<setprecision(10)<<ans<<'\n';

}

Measured memory_bytes: 140928
import sys
N, M = map(int, input().split())
d = {}
for _ in range(M):
  s, c = input().split()
  if s in d and d[s] != c:
    print("-1")
    sys.exit()
  else:
    d[s] = c
    
if N == 3:
  if "1" in d and d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" not in d:
      a = "1"
    else:
      a = d["1"]
    if "2" in d:
      b = d["2"]
    else:
      b = "0"
    if "3" in d:
      c = d["3"]
    else:
      c = "0"
  print(a + b + c)
  sys.exit()
  
if N == 2:
  if "1" in d and d["1"] == "0":
    print("-1")
    sys.exit()
  else:
    if "1" in d:
      b = d["1"]
    else:
      b = "1"
    if "2" in d:
      c = d["2"]
    else:
      c = "0"
  print(b + c)
  sys.exit()
  
if N == 1:
  if "1" in d and d["1"] == "0":
    print("0")
    sys.exit()
  else:
    if "1" in d:
      c = d["1"]
    else:
      c = "0"
  print(c)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

const int INF = 1e9;
#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)

using namespace std;

int main(){
    int n, m;
    while(cin >> n >> m, n || m){
        int w[128][128][2];
        rep(i,m+1)rep(j,m+1)rep(k,2) w[i][j][k] = INF;

        rep(i,n){
            int a, b, c, t;
            cin >> a >> b >> c >> t;
            w[a][b][0] = c;
            w[b][a][0] = c;
            w[a][b][1] = t;
            w[b][a][1] = t;
        }
        rep(l,2) repi(k, 1, m+1) repi(i, 1, m+1) repi(j, 1, m+1)
            w[i][j][l] = min(w[i][j][l], w[i][k][l] + w[k][j][l]);

        int k;
        cin >> k;

        rep(i,k){
            int p, q, r;
            cin >> p >> q >> r;
            cout << w[p][q][r] << endl;
        }
    }
}

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

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

    ll k;
    cin >> k;
    
    int len = s.length();

    ll ans = 0;
    int cou = 0;
    for(int i = 0; i < len - 1; i++){
        if(s[i] == s[i + 1]){
            cou++;
        }
    }

    if(cou == len - 1){
        ans = len * k;
        ans /= 2;
    }else{
        if(s[0] == s[len - 1]){
            int a = 1;
            for(int i = 0; i < len - 1; i++){
                if(s[i] == s[i + 1]){
                    a++;
                }else{
                    break;
                }
            }
            int b = 1;
            for(int i = len - 1; i > 0; i--){
                if(s[i] == s[i - 1]){
                    b++;
                }else{
                    break;
                }
            }

            for(int i = 0; i < len - 1; i++){
                if(s[i] == s[i + 1]){
                    s[i + 1] = '?';
                    ans++;
                }
            }
        
            ans *= k;
            ll t = a / 2;
            t += b / 2;
            t -= (a + b) / 2;
            t *= (k - 1);
            ans -= t;

        }else{
            for(int i = 0; i < len - 1; i++){
                if(s[i] == s[i + 1]){
                    s[i + 1] = '?';
                    ans++;
                }
            }
            ans *= k;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
s = input()
n = len(s) - 1

ans_list = []
for i in range(2 ** n):
    ans = s[0]
    for j in range(n):
        if ((i >> j) & 1):
            ans += "+" + s[j + 1]
        else:
            ans += s[j + 1]
    ans_list.append(ans)

sum_ = 0
for enume in ans_list:
    sum_ += eval(enume)
print(sum_)

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(a*n, b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
from queue import Queue
def bfs(field, sy, sx, wall, dir):
    h = len(field)
    w = len(field[0])
    dp = [[-1 for _j in range(w)] for _i in range(h)]
    q = Queue()

    dp[sy][sx] = 0
    q.put((sy, sx))
    
    dy = [1, -1, 0, 0, 1, 1, -1, -1]
    dx = [0, 0, 1, -1, 1, -1, 1, -1]
    def isin(x,y): return 0 <= y and y < h and 0 <= x and x < w
    
    while not q.empty():
        y, x = q.get()
        for k in range(dir):
            ny,nx = y+dy[k],x+dx[k]
            if not isin(nx, ny) or field[ny][nx] == wall:
                continue
            elif dp[ny][nx] != -1:
                continue
            dp[ny][nx] = dp[y][x] + 1
            q.put((ny,nx))
        
    return dp
    
# END CUT HERE

def ABC088_D():
    h, w = mi()
    s = [['' for _j in range(w)] for _i in range(h)]
    for i in range(h):
        s[i] = li()
    dp = bfs(s, 0, 0, '#', 4)
    if dp[h - 1][w - 1] < 0:
        print(-1)
    else:
        cnt = 0
        for i in range(h):
            for j in range(w):
                cnt += s[i][j] == '.'
        print(cnt - (dp[h - 1][w - 1] + 1)) # 0-indexed
# verified on 2019/06/13
# Python3:29ms https://atcoder.jp/contests/abc088/submissions/5898220
# Pypy3:239ms https://atcoder.jp/contests/abc088/submissions/5898207
# https://atcoder.jp/contests/abc088/tasks/abc088_d

def ATC002_A():
    R, C = mi()
    sy, sx = mi()
    gy, gx = mi()
    s = [['' for _j in range(C)] for _i in range(R)]
    for i in range(R):
        s[i] = li()
    dp = bfs(s, sy-1, sx-1, '#', 4) # 0-indexed
    print(dp[gy-1][gx-1]) # 0-indexed

# グリッドでないbfs
def ABC126_D():
    N= ii()
    G = [[] for i in range(N)]
    for i in range(N-1):
        a, b, w = mi()
        a -= 1
        b -= 1
        G[a].append((b,w))
        G[b].append((a,w))
    is_bipartite = True
    dist = [-1 for _ in range(N)]
    que = Queue()
    for v in range(N):
        if dist[v] != -1:
            # v が探索済ならスルー
            continue
        dist[v] = 0
        que.put(v)
        while not que.empty():
            v = que.get()
            for nv,nw in G[v]:
                if dist[nv] == -1:
                    dist[nv] = dist[v] + nw
                    que.put(nv)

    for i in dist:
        if i % 2 == 0:
            print(0)
        else:
            print(1)


if __name__ == '__main__':
    # ABC088_D()
    # ATC002_A()
    ABC126_D()

Measured memory_bytes: 43708
import numpy as np

n,m = map(int,input().split())

#接続道が存在するかを確認するための配列
#数値が0なら、接続道が無い
no_path = np.zeros(n)

#道がある場合、標高を格納する配列
path = [[] for i in range(n)]

#標高
higher = list(map(int,input().split()))

ans = 0

for _ in range(m):
    a,b = map(int,input().split())
    no_path[a-1] = 1
    no_path[b-1] = 1

    path[a-1].append(higher[b-1])
    path[b-1].append(higher[a-1])

ans = ans + n-np.count_nonzero(no_path)

for idx,_path in enumerate(path):
    if len(_path)>0 and higher[idx] > max(_path):
        ans += 1

print(ans)

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

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint facctorialMethod(int k) {
  mint sum = 1;
  int cnt = 0;
  mint i = 1;
  while (cnt < k) {
    sum *= i;
    cnt += 1;
    i += 1;
  }
  return sum;
}

int main() {
  int x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  if (x * 2 < y || y * 2 < x) {
    cout << 0 << endl;
    return 0;
  }

  if (x * 2 == y || y * 2 == x) {
    cout << 1 << endl;
    return 0;
  }

  if (x == y) {
    int a0 = (x + y) / 3;
    mint a1 = facctorialMethod(a0);
    mint a2 = facctorialMethod(a0 / 2);
    mint ans = a1 / (a2 * a2);
    cout << ans.x << endl;
    return 0;
  }

  int sub = abs(x - y);
  int b0 = (x + y) / 3;
  int b4 = (b0 + sub) / 2;
  mint b1 = facctorialMethod(b0);
  mint b2 = facctorialMethod(b4);
  mint b3 = facctorialMethod(b0 - b4);
  mint ans = b1 / (b2 * b3);
  cout << ans.x << endl;

  return 0;
}

Measured memory_bytes: 3612
// 5/28
// 過去問ガリガリ
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

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

    cout << 6 - A - B << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll H,ans=0,cnt=1;
  cin>>H;
  while(H>0){
    ans+=cnt;
    H/=2;
    cnt*=2;
  }  
  co(ans);
  return 0;
}

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

int main(){
    ll x, y;
    cin >> x >> y;
    int n = 1;
    ll a = x;
    while(a <= y){
        a *= 2;
        n++;
    }
    cout << n-1 << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<double> x(N),y(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i);
    cin >> y.at(i);
  }
  double sum=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i!=j){
        sum+=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
      }
    }
  }
  int p=1;
  for(int i=1;i<=N;i++){
   p*=i;
  }
  printf("%.16f",sum*(p/N)/p);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;
typedef long long  ll;
int vztd[5000000];
int main()
{
    ll k;
    cin >> k;
    ll tem = 7;
    ll ans = 1;
    while (tem < k)
        tem = tem * 10 + 7,ans++;
    for (;;)
    {
        if (tem % k == 0)
        {
            cout << ans << endl;
            return 0;
        }
        ans++;
        tem = tem * 10 + 7;
        tem %= k;
        if (vztd[tem] == 1)
            break;
        else
            vztd[tem] = 1;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 7428
#include<stdio.h>

int main(){
		int n,m,i,ab[30][2],ans=0,ttyk[10][10]={0},j;
		scanf("%d%d",&n,&m);
		for(i=0;i<m;i++){
				scanf("%d%d",&ab[i][0],&ab[i][1]);
				ttyk[ab[i][0]][ab[i][1]]=1;
				ttyk[ab[i][1]][ab[i][0]]=1;
		}
		int dfs[100000][10]={0},st=0,fn=1;
		dfs[0][0]=1;
		dfs[0][1]=1;
		while(fn>st){
				int f=0;
				for(j=1;j<=n;j++){
						if(ttyk[dfs[st][0]][j]==1&&dfs[st][j]!=1){
								dfs[fn][0]=j;
								for(i=1;i<=n;i++)dfs[fn][i]=dfs[st][i];
								dfs[fn][j]=1;
								fn++;
								f=1;
						}
				}
				if(f==0){
						for(j=1;j<=n;j++){
								if(dfs[st][j]==0)break;
						}
						if(j==n+1)ans++;
				}
				st++;
		}
		printf("%d\n",ans);
		return 0;
}


Measured memory_bytes: 4096
//
//  AGC3C.cpp
//  CF
//
//  Created by Mohammadreza Raddanipour on 8/8/19.
//  Copyright © 2019 Mohammadreza Raddanipour. All rights reserved.
//

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

const int MXN = 1e5 + 10;

int n, ans;
pair <int, int> a[MXN];

void npt() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
}

void slv() {
    sort(a, a + n) ;
    for (int i = 0; i < n; i++)
        if (a[i].second % 2 != i % 2)
            ans++;
}

void tpt() {
    cout << ans / 2 << endl;
}

int main() {
    npt();
    slv();
    tpt();
    return 0;
}


Measured memory_bytes: 1024
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll maxm=0;ll sum=0;bool abc=1;
    for(ll i=0;i<n;i++){
        if(a[i]%2!=0)abc=0;
    }
    if(abc)
        cout<<"second"<<endl;
    else
        cout<<"first"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	string s;
	cin >>s;
	cout <<s.substr(0, 3)<<endl;
	return 0;
}

Measured memory_bytes: 3600