akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#include <numeric>
#include<string_view>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
void a(){
    ll N,X,T; cin >> N >> X >> T;
    cout << N/X*T+(N%X!=0?T:0) << endl;
}

void b(){

}

void c(){

}


void d(){

}

int main(void){
    a();
    return 0;
 }

Measured memory_bytes: 3620
import math
N,K = map(int,input().split())
suma = 0
if N >= K:
    suma += (N-K+1)/N
    for i in range(1,K):
        n = math.ceil(math.log2(K/i))
        suma += (1/N)*((0.5)**n)
else:
    for i in range(1,N+1):
        n = math.ceil(math.log2(K/i))
        suma += (1/N)*((0.5)**n)
print(suma)

Measured memory_bytes: 3060
import java.util.*;


public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		AdjacencyMatrices am = new AdjacencyMatrices(scan.nextInt());
		am.readList(scan);
		Graph graph = new Graph(am.getMatrix());
		graph.walk();
		graph.print();
	}

}
class Graph{
	ArrayList<Node> vertices;
	public Graph(int[][] matrix){
		vertices = new ArrayList<Node>();
		for(int i=0; i<matrix.length;i++)
			vertices.add(new Node(i+1));
		for(int i=0; i<matrix.length;i++)
			for(int j=0; j<matrix.length; j++)
				if(matrix[i][j]!=0)
					vertices.get(i).addNext(vertices.get(j));
	}
	void walk(){
		int time = 0;
		for(int i=0; i<vertices.size();i++){
			time = vertices.get(i).walk(time);
		}
	}
	void print(){
		for(int i=0; i<vertices.size();i++)
			vertices.get(i).result();
	}
}

class Node{
	int id;
	int startTime;
	int endTime;
	boolean steped = false;
	ArrayList<Boolean> stepedNext = new ArrayList<Boolean>(); 
	ArrayList<Node> nextNode = new ArrayList<Node>();
	public Node(int id){
		this.id = id;
	}
	public void addNext(Node n){
		nextNode.add(n);
		stepedNext.add(false);
	}
	public int walk(int time){
		if(this.steped)
			return time;
		time++;//
		this.startTime = time;
		this.steped = true;
		int end = time;
		for(int i=0; i<stepedNext.size(); i++){
			time = nextNode.get(i).walk(time);
		}
		time++;//
		this.endTime = time;
		return endTime;
	}
	boolean remainNext(){
		return stepedNext.contains(false);
	}
	void result(){
		System.out.println(this.id + " " + startTime + " " + endTime);
	}
}
class AdjacencyMatrices{
	int pointNum;
	int[][] matrix;
	public AdjacencyMatrices(int n){
		pointNum = n;
		matrix = new int[n][];
		for(int i=0; i<n; i++)
			matrix[i] = new int[n];
	}
	public void readList(Scanner scan){
		for(int i=0; i<pointNum; i++){
			int index = scan.nextInt()-1;
			int dim = scan.nextInt();
			for(int j=0; j< dim; j++)
				matrix[index][scan.nextInt()-1] = 1;
		}
	}
	public int[][] getMatrix(){
		return matrix;
	}
	public void printMatrix(){
		StringBuilder temp = new StringBuilder();
		for(int i=0; i<pointNum; i++){
			for(int j=0; j<pointNum; j++){
				temp.append(matrix[i][j]);
				if(j!=pointNum-1)
					temp.append(" ");
			}
			temp.append("\n");
		}
		System.out.print(new String(temp));
	}

}

Measured memory_bytes: 20832
#include<stdio.h>
   
#define MAX 10000
   
typedef struct{
   
  int parent;
  int left;
  int right;
 
}Node;
   
Node A[MAX];
int B[MAX], C[MAX], n;
   
void setDepth(int,int);
int setHeight(int);
int getSibling(int);
void output(int);
int main(){
 
  int i, v, l, r, root;
  root = 0;
   
  scanf("%d",&n);
    
  for(i = 0; i < n; i++){
 
    A[i].parent = -1;
  }
 
  for(i = 0 ;i < n; i++){
    scanf("%d %d %d",&v,&l,&r);
    A[v].left = l;
    A[v].right = r;
    if(l != -1)A[l].parent = v;
    if(r != -1)A[r].parent = v;
  }
   
  for(i = 0 ; i < n; i++){
    if(A[i].parent == -1)
      root = i;
 
  }
    
  setDepth(root,0);
  setHeight(root);
   
  for(i = 0; i < n; i++){
 
    output(i);
 
  }
  return 0;
}
   
void setDepth(int u, int d){
   
  if(u == -1)
    return;
  B[u] = d;
  setDepth(A[u].left, d+1);
  setDepth(A[u].right,d+1);
}
   
int setHeight(int u){
  int h1,h2;
  h1 = h2 = 0;
  if(A[u].left != -1)h1 = setHeight(A[u].left) + 1;
  if(A[u].right != -1)h2 = setHeight(A[u].right) + 1;
  return C[u] = (h1 > h2 ? h1 : h2); 
}
   
int getSibling(int u){
  if(A[u].parent == -1)return -1;
  if(A[A[u].parent].left != u && A[A[u].parent].left != -1)
    return A[A[u].parent].left;
 
  if(A[A[u].parent].right != u && A[A[u].parent].right != -1)
    return A[A[u].parent].right;
 
  return -1;
}
   
void output(int u){
  int count;
  printf("node %d: parent = %d, sibling = %d, ",u,A[u].parent,getSibling(u));
  count = 0;
   
  if(A[u].left != -1)
    count++;
  if(A[u].right != -1)
    count++;
   
  printf("degree = %d, depth = %d, height = %d, ",count,B[u],C[u]);
   
  if(A[u].parent == -1)
    printf("root\n");
 
  else if(A[u].left == -1 && A[u].right == -1)
    printf("leaf\n");
 
  else
    printf("internal node\n");
 
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define el cout<<endl
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint n, c;
    cin >> n >> c;
    vector<lint> x(n+1), v(n+1), y(n+1), w(n+1);
    x[0] = v[0] = y[0] = w[0] = 0;
    repeat_from_to (i, 1, n) {
        cin >> x[i] >> v[i];
        y[n+1-i] = c - x[i];
        w[n+1-i] = v[i];
    }
    
    vector<lint> s(n+1), t(n+1);
    s[0] = t[0] = 0;
    repeat_from_to (i, 1, n) {
        s[i] = s[i-1] + v[i];
        t[i] = t[i-1] + w[i];
    }
    
    lint ans = 0;
    vector<lint> r(n+1);
    r[0] = 0;
    repeat_from_to (i, 1, n) {
        r[i] = max(r[i-1], s[i] - x[i]);
    }
    repeat_from_to (i, 0, n) {
        lint ls = t[i] - y[i] * 2;
        lint rs = r[n-i];
        ans = max(ans, ls + rs);
    }

    ///////////////////////////
    
    vector<lint> l(n+1);
    l[0] = 0;
    repeat_from_to (i, 1, n) {
        l[i] = max(l[i-1], t[i] - y[i]);
    }
    repeat_from_to (i, 0, n) {
        lint rs = s[i] - x[i] * 2;
        lint ls = l[n-i];
        ans = max(ans, ls + rs);
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	bool poss[F+1];
	bool poss2[F+1];
	poss[0] = true;
	poss2[0] = true;
	double ans = -1.0;
	int as, bs;
	for (int i = 1; i <= F; i++) {
		poss[i] = false;
		if (i - 100*B >= 0) {
			poss[i] = poss[i] || poss[i-100*B];
		}
		if (i - 100*A >= 0) {
			poss[i] = poss[i] || poss[i-100*A];
		}
		poss2[i] = false;
		if (i- C >= 0) {
			poss2[i] = poss2[i] || poss2[i-C];
		}
		if (i - D >= 0) {
			poss2[i] = poss2[i] || poss2[i-D];
		}
	}
	for (int i = 1; i <= F; i++) {
		for (int j = 0; j <= (i/100.0)*E; j++) {
			if (poss[i] && poss2[j] && i + j <= F) {
				double rat = (j-0.0)/(i + j + 0.0);
				if (rat > ans) {
					ans = rat;
					as = i; bs = j;
				}
			}
		}
	}
	cout << as+bs << " " << bs << endl;
	// cin >> A;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, m;
    vector<pair<ll, ll>> A;
    cin >> n >> m;
    repi(i, n, 0)
    {
        ll a;
        cin >> a;
        A.push_back({a, 1});
    }
    repi(i, m, 0)
    {
        ll b, c;
        cin >> b >> c;
        A.push_back({c, b});
    }
    sort(A.begin(), A.end(), greater<pair<ll, ll>>());

    ll ans = 0, cnt = 0;
    repi(i, A.size(), 0)
    {
        if (n - cnt - A[i].second > 0)
        {
            ans += A[i].first * A[i].second;
            cnt += A[i].second;
        }
        else
        {
            ans += A[i].first * (n - cnt);
            cnt += (n - cnt);
        }
        if (cnt == n)
        {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6512
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    T = "CODEFESTIVAL2016"
    ans = 0
    for s,t in zip(S,T):
        ans += s!=t
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 5372
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

typedef long long ll;
void coun(ll n) 
{ 
  
    // Array to store the count 
    // of divisors 
    ll div[n + 1]; 
    ll sum=0;
    memset(div, 0, sizeof div); 
  
    // For every number from 1 to n 
    for (ll i = 1; i <= n; i++) { 
  
        // Increase divisors count for 
        // every number divisible by i 
        for (ll j = 1; j * i <= n; j++) 
            div[i * j]++; 
    } 
  
    // Print the divisors 
    for (ll i = 1; i <= n; i++) 
        sum+=div[i]*i;
        
    cout<<sum;
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    
    //ll sum=0;
    
    coun(n);
    

    return 0;
}


Measured memory_bytes: 81760
package main

import (
	"fmt"
	"sort"
)

func main() {
	a := make([]int, 3)
	fmt.Scan(&a[0], &a[1], &a[2])
	sort.Ints(a)
	fmt.Println(a[2] * 10 + a[1] + a[0])
}

Measured memory_bytes: 512
using System;

namespace soundhound2018_summer_qual_b
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < s.Length; i += n)
			{
				Console.Write(s[i]);
			}
		}
	}
}

Measured memory_bytes: 11092
Program main
  implicit none
  integer :: N
  character(len=10),allocatable :: S(:)
  integer :: i,j
  character(len=10), allocatable :: list(:)
  type testt
     character(len=10) :: name
  end type testt
  read(*,*) N
  allocate(S(N))
  do i = 1,N
     read(*,*) S(i)
  end do
  list = deduplicate(S)
  write(*,'(i0)') size(list)
contains
  recursive function deduplicate(texts) result(res) ! skew-quicksort
    character(len=10), intent(in) :: texts(:)
    character(len=10), allocatable :: res(:)
    integer :: m
    
    m = size(texts) / 2
    
    if (m < 1) then
       res = texts
    else
       res = [ deduplicate(pack(texts, texts < texts(m))), &
            texts(m), &
            deduplicate(pack(texts, texts > texts(m)))  ]
    end if
  end function deduplicate
end program main

Measured memory_bytes: 13520
i=lambda:map(int,input().split())
N,Q=i()
adj=[[] for _ in range(N)]
for _ in range(N-1):
  a,b=i()
  adj[a-1].append(b-1)
  adj[b-1].append(a-1)
V = [0 for _ in range(N)]
for _ in range(Q):
  p,x=i()
  V[p-1]+=x
par = [-1 for _ in range(N)]
q = [0]
for cur in q:
  if par[cur] != -1: V[cur] += V[par[cur]]
  for nxt in adj[cur]:
    if nxt == par[cur]: continue
    par[nxt] = cur
    q.append(nxt)
print(' '.join(map(str, V)))

Measured memory_bytes: 134708
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = n / 100
    val q = n % 100

    if (q > 5 * p) {
        println(0)
    } else {
        if (q % 5 == 0) {
            println(1)
        } else if (q % 5 == 1) {
            if (q - 1 <= 5 * (p-1)) {
                println(1)
            } else {
                println(0)
            }
        } else if (q % 5 == 2) {
            if (q - 2 <= 5 * (p-1)) {
                println(1)
            } else {
                println(0)
            }
        } else if (q % 5 == 3) {
            if (q - 3 <= 5 * (p-1)) {
                println(1)
            } else {
                println(0)
            }
        } else if (q % 5 == 4) {
            if (q - 4 <= 5 * (p-1)) {
                println(1)
            } else {
                println(0)
            }
        }
    }
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr <<"at line "<< __LINE__<<": [" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type,
		less_equal<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
		
typedef tree<int, null_type,
		less<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	string a,b;
	cin>>a>>b;
	b.pop_back();
	if(a==b) cout<<"Yes";
	else cout<<"No";
}
		
	
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
void a(int i,int j,int k){
    cout<<"< "<<i<<" "<<j<<" "<<k<<"\n";
}
void b(int i,int j,int k){
    cout<<"+ "<<i<<" "<<j<<" "<<k<<"\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<"29944\n";
    b(0,1,10);
    a(5,10,100);
    b(0,100,0);
    b(1,100,1);
    rep(i,30) b(100+i,100+i,101+i);
    per(i,30){
        b(200,100+i,201);
        a(201,0,1000+i);
        b(8,1000+i,7);
        rep(j,i) b(7,7,7);
        b(7,200,200);
    }
    per(i,30){
        b(300,100+i,301);
        a(301,1,2000+i);
        b(8,2000+i,7);
        rep(j,i) b(7,7,7);
        b(7,300,300);
    }
    rep(i,30)rep(j,30){
        b(1000+i,2000+j,7);
        a(100,7,7);
        rep(k,i+j) b(7,7,7);
        b(2,7,2);
    }
}

Measured memory_bytes: 3588
#include<stdio.h>

int main(void){
    int time[3],tmp,ans;

    scanf("%d %d %d",&time[0],&time[1],&time[2]);

    for(int i=0;i<3;i++){
        for(int j=i+1;j<3;j++){
            if(time[i]>time[j]){
                tmp=time[i];
                time[i]=time[j];
                time[j]=tmp;
            }
        }
    }   

    ans=time[0]+time[1];

    printf("%d\n",ans);

    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}
int bfs(int s,vector<vector<int>> &g,int &n){
	vector<int> dist(n,-1);
	queue<int> que;
	dist[s]=0;
	que.push(s);

	while(!que.empty()){
		int p=que.front();que.pop();
		for(auto x:g[p]){
			if(dist[x]>=0)continue;
			dist[x]=dist[p]+1;
			que.push(x);
		}
	}
	return *max_element(all(dist))+1;
}

bool Bipartite(vector<vector<int>> &g,int &n){
	vector<int> color(n,0);
	color[0]=1;
	queue<int> que;
	que.push(0);
	while(!que.empty()){
		int p=que.front();que.pop();
		for(auto x:g[p]){
			if(color[x]==0){
				color[x]=color[p]*-1;
				que.push(x);
			}else if(color[x]==color[p]) return false;
		}
	}
	return true;
}

int main()
{
	int n;
	cin>>n;
	vector<vector<int>> g(n);
	vector<string> s(n);
	rep(i,n)cin>>s[i];
	rep(i,n){
		rep(j,n){
			if(s[i][j]=='1')g[i].push_back(j);
		}
	}

	int ans=0;
	rep(i,n){
		ans=max(ans,bfs(i,g,n));
	}

	cout<<(Bipartite(g,n)?ans:-1)<<endl;

	return 0;
}

Measured memory_bytes: 512
q = int(input())
data_list = list()
for i in range(q):
    data = input()
    data_list.append(data)

a = list()
for data in data_list:
    if data[0] == "0":
        a.append(data.split()[1])
    elif data[0] == "1":
        print(a[int(data.split()[1])])
    else:
        a.pop(-1)



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

void testcase() {

}

int main()
{
	int n;
	cin >> n;
	vector<int> num(n,0);
	for (int i = 0; i < n-1; i++) {
		int cur;
		cin >> cur;
		num[cur-1]++;
	}
	for (int i : num) {
		cout << i << endl;
	}
	



	return 0;
}


Measured memory_bytes: 4048
import sys
sys.setrecursionlimit(10 ** 6)

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

graph = [[] for _ in range(n + 1)]

for i in range(m):
    f, t = map(int, input().split())
    graph[t].append(f)

dp = [None] * (n + 1)
def dfs(now):
    if dp[now] is not None:
        return dp[now]

    if not graph[now]:
        return 0

    r = max(dfs(parent) for parent in graph[now]) + 1
    dp[now] = r
    return r

print(max(dfs(i) for i in range(1, n + 1)))


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


 int main(){
     int a, b, c, d;
     cin >> a >> b >> c >> d;

     const int lower = max(a, c);
     const int upper = min(b, d);

     cout << max(0, upper-lower) << endl;

     return 0;
 }

Measured memory_bytes: 256
def main():
    from copy import deepcopy
    from itertools import permutations
    import sys
    input=sys.stdin.readline

    k=int(input())
    stage=[[0]*8 for _ in range(8)]
    ans=[['.']*8 for _ in range(8)]
    ablex=[0,1,2,3,4,5,6,7]
    abley=[0,1,2,3,4,5,6,7]

    def q(x,y,stage):
        i,j=x,y
        while i>=0 and j>=0:
            stage[i][j]=1
            i-=1
            j-=1
        i,j=x,y
        while i<8 and j<8:
            stage[i][j]=1
            i+=1
            j+=1
        i,j=x,y
        while i>=0 and j<8:
            stage[i][j]=1
            i-=1
            j+=1
        i,j=x,y
        while i<8 and j>=0:
            stage[i][j]=1
            i+=1
            j-=1
        
    for i in range(k):
        x,y=map(int,input().split())
        q(x,y,stage)
        ans[x][y]='Q'
        ablex.remove(x)
        abley.remove(y)
    
    for ptr in permutations(abley):
        s=deepcopy(stage)
        flag=True
        for x,y in zip(ablex,ptr):
            if s[x][y]==1:
                flag=False
                break
            else:
                q(x,y,s)
        if flag:
            for x,y in zip(ablex,ptr):
                ans[x][y]='Q'
            for i in range(8):
                print(''.join(ans[i]))
            exit()
    
if __name__=='__main__':
    main()


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

typedef struct _set{
    int *element;
    int eCnt;
    struct _set *next;
}SET;

SET* initSet(int n){
    int i;
    SET *p,*head;
    for(i=0;i<n;i++){
        if(i==0){
            head=(SET*)malloc(sizeof(SET));
            p=head;
        }else{
            p->next=(SET*)malloc(sizeof(SET));
            p=p->next;
        }
        p->element=(int*)malloc(sizeof(int));
        p->element[0]=i;
        p->eCnt=1;
    }
    p->next=NULL;
    
    return head;
}
void printSet(SET *head){
    int i;
    SET *p=head;
    printf("-----printSet-----\n");
    while(p!=NULL){
        for(i=0;i<p->eCnt;i++)printf("%d ",p->element[i]);
        printf("\n");
        p=p->next;
    }
    printf("------end------\n");
}
SET* getTarget(SET *head,int target){
    int i;
    SET *p=head;
    while(p!=NULL){
        for(i=0;i<p->eCnt;i++){
            if(p->element[i]==target)return p;
        }
        p=p->next;
    }
    return NULL;
}
SET* del(SET *head,SET *target){
    SET *p=head;
    
    if(head==target){
        head=head->next;
        free(p->element);
        free(p);
        return head;
    }
    
    while(p!=NULL&&p->next!=target)p=p->next;
    if(p==NULL)return head;
    
    p->next=target->next;
    
    free(target->element);
    free(target);
    
    return head;
}
SET* unite(SET *head,int x,int y){
    SET *xp,*yp;
    xp=getTarget(head,x);
    yp=getTarget(head,y);
    
    if(xp==NULL||yp==NULL||xp==yp)return head;

    xp->element=(int*)realloc(xp->element,sizeof(int)*(xp->eCnt+yp->eCnt));
    int i,j;
    for(i=xp->eCnt,j=0;j<yp->eCnt;i++,j++)xp->element[i]=yp->element[j];
    xp->eCnt+=yp->eCnt;
    
    return head=del(head,yp);
}
void same(SET *head,int x,int y){
    SET *xp,*yp;
    xp=getTarget(head,x);
    yp=getTarget(head,y);
    if(xp==yp)printf("1\n");
    else printf("0\n");
}
void delAll(SET *head){
    SET *p=head;
    while(p!=NULL){
        head=head->next;
        free(p->element);
        free(p);
        p=head;
    }
}
int main(void){
    int i;
    
    int n;
    scanf("%d ",&n);
    
    SET *head;
    head=initSet(n);

    int q;
    scanf("%d\n",&q);
    
    int com,x,y;
    for(i=0;i<q;i++){
        scanf("%d %d %d\n",&com,&x,&y);
        switch(com){
            case 0:
                head=unite(head,x,y);
                break;
            case 1:
                same(head,x,y);
                break;
        }
    }

    delAll(head);
    
    return 0;
}



Measured memory_bytes: 2436
from sys import stdin
from numpy import array
from numpy import dot
import itertools


def main():
     n,m = [int(x) for x in stdin.readline().split()]
     A = array([[0]*n for _ in range(m)])
     for i in range(m):
          tmp = [int(x) for x in stdin.readline().split()]
          for j in tmp[1:]:
               A[i][j-1] = 1
     k = array([int(x) for x in stdin.readline().split()])
     swt = [0,1]
     
     ans = 0
     for i in itertools.product(swt, repeat=n):
          i = array(i)
          Ai = dot(A,i)
          if (Ai%2 == k).all():
               ans += 1
     print(ans)
          
     
if __name__ == '__main__':
     main()

Measured memory_bytes: 12504
#include<stdio.h>
#include<string.h>

int main(){
	int i,joi,ioi,l;
	char s[10001];
	while(scanf("%s",s)!=EOF){
		joi=ioi=0;
		l=strlen(s);
		for(i=0;i<l-2;i++){
			if(s[i+1]=='O'&&s[i+2]=='I'){
				if(s[i]=='J')joi++;
				else if(s[i]=='I')ioi++;
			}
		}
		printf("%d\n%d\n",joi,ioi);
	}
	return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <string>
#include <algorithm>

#define MAXLEN 4001

using namespace std;

string str[2];
int len[2],lng,sht;

int main(void)
{
	while(true)
	{
		cin >> str[0];
		if(cin.eof())
		{
			exit(0);
		}
		cin >> str[1];
		len[0] = str[0].length();
		len[1] = str[1].length();
		if(len[0] < len[1])
		{
			lng = 1;
			sht = 0;
		}
		else
		{
			lng = 0;
			sht = 1;
		}
		int count_len_max = 0;
		for(int offset = 0;offset < len[lng];offset++)
		{
			int count_len = 0;
			for(int count = 0;count < len[sht];count++)
			{
				if((count + offset) < len[lng])
				{
					if(str[lng][(count + offset)] == str[sht][count])
					{
						count_len++;
					}
					else
					{
						count_len = 0;
					}
					count_len_max = max(count_len_max,count_len);
				}
			}
		}
		for(int offset = 0;offset < len[sht];offset++)
		{
			int count_len = 0;
			for(int count = 0;count < len[lng];count++)
			{
				if((count + offset) < len[sht])
				{
					if(str[sht][(count + offset)] == str[lng][count])
					{
						count_len++;
					}
					else
					{
						count_len = 0;
					}
					count_len_max = max(count_len_max,count_len);
				}
			}
		}
		
		cout << count_len_max << endl;
	}
}

Measured memory_bytes: 3004
#include <stdio.h>
int main()
{
  int i, j, H, W;
  for(;;){
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0)break;
    for(i = 0; i < H; i++){
      for(j = 0; j < W; j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
s = input() + "{{{{{"
K = int(input())
L = []
t = 0
while t <= K:
    for k in range(len(s)-t):
        if "{" not in s[k:k+t+1]:
            L.append(s[k:k+t+1])
    t += 1
L = sorted(list(set(L)))
print(L[K-1])


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
typedef vector<int> vi;typedef vector<vi> vvi;typedef pair<int,int> pii;typedef vector<pii> vpii;
typedef long long ll;

vvi E;
vi D;
int N, K;

void dfs(int cur, int pre) {
  forr(nex, E[cur]) {
    if (nex != pre) {
      D[nex] = D[cur] + 1;
      dfs(nex, cur);
    }
  }
}

void Main() {
  scanf("%d%d", &N, &K);
  E.resize(N);
  rep(i, N-1) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--; v--;
    E[u].push_back(v);
    E[v].push_back(u);
  }

  if (K == 1) {
    _p("%d\n", N-2);
    return;
  }

  D.resize(N);

  int ans = 1e9;
  if (K % 2) {
    rep(i, N) forr(j, E[i]) if (i < j) {
      int cand = 0;
      fill(ALL(D), 0);
      dfs(i, j);
      sort(ALL(D));
      cand += N - distance(D.begin(), upper_bound(ALL(D), K/2));

      fill(ALL(D), 0);
      dfs(j, i);
      sort(ALL(D));
      cand += N - distance(D.begin(), upper_bound(ALL(D), K/2));
      ans = min(ans, cand);
    }
  }
  else {
    rep(i, N) {
      D[i] = 0;
      dfs(i, -1);
      sort(ALL(D));
      int cand = N - distance(D.begin(), upper_bound(ALL(D), K/2));
      ans = min(ans, cand);
    }
  }
  _p("%d\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


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

int countDivisor(int n){
  int divisor = 0;
  for(int i = 1; i <= n; i++){
    if(n%i == 0) divisor++;
  }
  return divisor;
}

int main(void){
  int n, count = 0;
  cin >> n;
  for(int i = 1; i <= n; i += 2){
    if(countDivisor(i) == 8) count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int x,SUM=0,min=10;
    for (int i=0; i<5; i++) {
        scanf("%d",&x);
        SUM+=x;
        if(x%10!=0){
            if(x%10<min){
                min=x%10;
            }
            SUM=SUM+(10-(x%10));
        }
    }
    SUM=SUM-(10-min);
    printf("%d\n",SUM);
    
    return 0;
}


Measured memory_bytes: 128
def main():
    nn, m = map(int, raw_input().split())
    ss = []
    for _ in xrange(m):
        n = 0
        for s in map(int, raw_input().split()[1:]):
            n |= 1 << (s - 1)
        ss.append(n)
    pp = map(int, raw_input().split())
    ans = 0
    for sw in xrange(2 ** nn):
        for s, p in zip(ss, pp):
            if bin((sw & s)).count('1') % 2 != p:
                break
        else:
            ans += 1
    print ans


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i=0; i<n; i++) cin >> x[i];

    int ans = 0;
    for (int i=0; i<n; i++) {
        ans += min(x[i]*2, abs(k - x[i])*2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
(let ((nm (mapcar (lambda (a) (parse-integer (string a))) (concatenate 'list (read-line)))))
  (cond ((= (nth 0 nm) (nth 1 nm) (nth 2 nm)) (princ "Yes"))
        ((= (nth 3 nm) (nth 1 nm) (nth 2 nm)) (princ "Yes"))
        (t (princ "No"))))

Measured memory_bytes: 4452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int N1 = Integer.parseInt(strArr[0]);
		int N2 = Integer.parseInt(strArr[1]);
		int N3 = Integer.parseInt(strArr[2]);
		int N4 = Integer.parseInt(strArr[3]);
		boolean ans = true;
		if (N1 != 1 && N2 != 1 && N3 != 1 && N4 != 1)
			ans = false;
		if (N1 != 9 && N2 != 9 && N3 != 9 && N4 != 9)
			ans = false;
		if (N1 != 7 && N2 != 7 && N3 != 7 && N4 != 7)
			ans = false;
		if (N1 != 4 && N2 != 4 && N3 != 4 && N4 != 4)
			ans = false;
		if (ans)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21332
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input) {
  input = input.split("\n");
  const [n, k] = input[0].split(" ").map((a) => parseInt(a, 10));
  const a = input[1].split(" ").map((a) => parseInt(a, 10));
  let l = 0, r = 1e9;
  while (r-l > 1) {
    const x = Math.ceil((l+r)/2);
    let now = 0;
    for(let i=0; i<n; i++) {
      now += Math.ceil((a[i])/x) -1;
    }
    if (now <= k) {
      r = x;
    } else {
      l = x;
    }
  }
  console.log(r);
  return;
}

Measured memory_bytes: 50208
a1,a2,a3= input().split(" ")
a1 = int(a1)
a2 = int(a2)
a3 = int(a3)
if ((a1>=1 and a1<=13) and (a2>=1 and a2<=13) and (a3>=1 and a3<=13)):
    if a1+a2+a3>=22:
        print('bust')
    else:
        print('win')

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int V,E,s,t;
long long d;
const long long inf=100000000000000;
long long K[100][100];

int main(){
	cin >> V >> E;

	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(i==j){
				K[i][j]=0;
			}else{
				K[i][j]=inf;
			}
		}
	}

	for(int i=0;i<E;i++){
		cin >> s >> t >> d;
		K[s][t]=d;
	}

	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				long long temp;
				if(K[i][k]==inf||K[k][j]==inf){
					temp=inf;
				}else{
					temp=K[i][k]+K[k][j];
				}
				if(temp<K[i][j]){
					K[i][j]=temp;
				}
			}
		}
	}
	
	bool ans=false;
	for(int i=0;i<V;i++){
		ans=ans||(K[i][i]<0);
	}
	if(ans){
		cout << "NEGATIVE CYCLE" << endl;
	}else{
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				if(K[i][j]==inf){
					cout << "INF";
				}else{
					cout << K[i][j];
				}
				if(j!=V-1){
					cout << " ";
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 1244
#pragma comment(linker, "/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= b; ++i)
const int max_number = 1000000;
const double pi = 3.14159265358979323846264338328;

//TODO: atoi  <math.h>定义了圆周率M_PI

// int main() //a/b problem
// {
//     int a, b;
//     scanf("%d%d", &a, &b);
//     int d, r;
//     double real;
//     d = a / b;
//     r = a % b;
//     real = (a+0.0) / b;
//     printf("%d %d %.5lf\n", d, r, real);
//     return 0;
// }

// int main()
// {
//     int a, b, result;
//     char op;

//     while (true) {
//         scanf("%d%c%d", &a, &op, &b);
//         if (op == '?')
//             break;
//         switch (op) {
//         case '+': //要加单引号，变成常量才可以
//             result = a + b;
//             printf("%d\n", result);
//             break;

//         case '-':
//             result = a - b;
//             printf("%d\n", result);
//             break;
//         case '*':
//             result = a * b;
//             printf("%d\n", result);
//             break;
//         case '/':
//             result = a / b;
//             printf("%d\n", result);
//             break;
//         }
//     }
// }

int main()
{
    int n;
    ll sum=0;
    scanf("%d", &n);
    vector<int> res(n); //vector 需要这样？？

    for (int i = 0; i < n; i++) {
        scanf("%d", &res[i]);
    }
    //for (int i; cin >> i;res.push_back(i)){}  //这个是没有指明数量时候的写法

    //sort swap max_element 的用法
    printf("%d ", *min_element(res.begin(), res.end()));
    printf("%d ", *max_element(res.begin(), res.end()));
for(auto it =res.begin(); it != res.end(); it++)
    sum += (*it);
//printf("%d\n", accumulate(res.begin(), res.end(), 0));
cout <<sum<< endl;
return 0;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
int maxx, n;
const int maxn = 100010;
int a[maxn], b[maxn], c[maxn], num = 0, max1, max2, x;

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", &x);
		b[x]++;
		b[x - 1]++;
		b[x + 1]++; 
	}
	max1 = b[1];
	for(int i = 2; i <= 100010; i++){
		if(b[i] > max1){
			max1 = b[i];
		}
	}
	printf("%d", max1);
	return 0;
}

Measured memory_bytes: 640
import heapq

N = int(input())
v = [int(x) for x in input().split()]

h = []
for i in v:
    heapq.heappush(h, i)

while len(h) != 1:
    min1 = heapq.heappop(h)
    min2 = heapq.heappop(h)
    heapq.heappush(h, (min1 + min2) / 2)

print(heapq.heappop(h))






Measured memory_bytes: 3060
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	ll n; cin >> n;
	ll g[n][n]; for ( int k = 0; k < n; k++ ){ parseArray(g[k], n - 1); }
	ll day[n][n];
	for ( int k = 0; k < n; k++ ){
		for ( int j = 0; j < n - 1; j++ ){
			g[k][j]--;
			day[k][g[k][j]] = j;
		}
	}
	ll ans = 0;
	ll cur[n]; memset(cur, 0, sizeof cur);
	while (1) {
		bool flag = true;
		bool played[n]; memset(played, 0, sizeof played);
		for ( int k = 0; k < n; k++ ){
			if (cur[k] == n - 1 || played[k] || played[g[k][cur[k]]]) continue;
			ll opponent = g[k][cur[k]];
			if (cur[k] >= cur[opponent] && g[opponent][cur[opponent]] == k) {
				played[k] = true;
				played[opponent] = true;
				cur[opponent]++;
				cur[k]++;
				flag = false;
			}
		}
		if (flag) break;
		ans++;
	}
	for ( int k = 0; k < n; k++ ){
		if (cur[k] != n - 1) return cout << -1 << endl, 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	cout << n*(n + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)

int cot ;
void permute(int index , int &n)
{
	if(index == 3)
	{
		++cot ; return ;
	}
	for(int i = 1 ; i <= n ; ++i)
	{
		permute(index + 1 , n);
	}	
	return ; 
}

int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n ; 
	cin >> n ; 
	int a[n+1] , b[n+1] , c[n];
	for(int i = 1 ; i <=n ; ++i)
		cin >> a[i] ; 
	for(int i = 1 ; i <=n ; ++i)
	cin >> b[i] ;
	for(int i = 1 ; i < n ; ++i)
	cin >> c[i] ;
	int ans = b[a[1]] ;
	for(int i = 2 ; i <=n ; ++i)
	{
		ans += b[a[i]] ;
		if(a[i] - a[i-1] == 1) ans += c[a[i-1]];
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl "\n"
#define mod 1000000007
#define INF 1e18
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define w(x) int x; cin >> x; while (x--)

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void rwf()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int xpowery(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x) % mod;
		x = (x * x) % mod;
		y = y / 2;
	}
	return ans;
}

int32_t main()
{
	IOS;
	//rwf();

	int n, m;
	cin >> n >> m;

	int cnt = 0, a[n], sum = 0;

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

	int x = sum / (4 * m);

	if (sum % (4 * m))
		x++;

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

	if (cnt >= m)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(is, 1<<h)rep(js, 1<<w) {
        int cnt = 0;
        rep(i,h)rep(j,w) {
            if (is>>i&1) continue;
            if (js>>j&1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    ll s[n];rep(i,0,n)cin>>s[i];
    ll ans=0;
    rep(i,1,n-1){
        if(n/2==i)break;
        ll x=0,y=0;
        ll nowx=0,nowy=n-1;
        
        for(;;){
            nowx+=i;
            nowy-=i;
            if(nowy<=i)break;
            if(nowx==nowy)break;
            if(nowx>=n-1)break;
            if(nowx>nowy&&nowx-nowy==i)break;
            x+=s[nowx];
            y+=s[nowy];
            ans=max(ans,x+y);
            
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

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

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

void rot(vector<pi> &v){
  int n=v.size();
  rep(i,n){
    int a=v[i].first,b=v[i].second;
    v[i].first=-b,v[i].second=a;
  }
}

int main()
{
  int n;
  while(cin>>n,n){
    vector<vector<pi> > line,base;
    rep(i,n+1){
      int m,px,py; cin>>m>>px>>py;
      vector<pi> v;
      rep(j,m-1){
	int x,y; cin>>x>>y;
	v.pb(mp(x-px,y-py));
	px=x,py=y;
      }
      if(i)line.pb(v);
      else base.pb(v);
    }
    
    vector<pi> v=base[0],u=v;
    int m=v.size();
    reverse(all(v));
    
    base.pb(v);
    v=base[0],u=base[1];
    /*
    rep(i,m)cerr<<u[i].first<<" "<<u[i].second<<endl;
    rep(i,m)cerr<<v[i].first<<" "<<v[i].second<<endl;
    */
    rep(i,3){
      rot(v); rot(u);
      base.pb(v); base.pb(u);
    }

    rep(i,n){
      bool ok=0;
      fr(j,base)if(line[i]==*j)ok=1;
      if(ok)cout<<i+1<<endl;
    }
    cout<<"+++++"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
while True:
    m,f,r = tuple(int(n) for n in input().split())
    if m == f == r == -1:
        break
    if (m == -1 or f == -1) or m + f < 30:
        print("F")
    elif m + f >= 80:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    else:
        if r >= 50:
            print("C")
        else:
            print("D")


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

int a[N], dp[N], cs;

int main()
{
	dp[0] = 1;
	int n; cin >> n;
	for (int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++){
		if (dp[a[i] - 1]){
			dp[a[i]] = 1;
			cs = max(cs, a[i]);
		}
	}
	if (cs == 0) cs = -1;
	else	cs = n - cs;
	cout << cs;
	return 0;
}

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

string S,T;
bool success;
int main(){
	cin >> S >> T;
	int num = S.length();
	for (int i = 0; i < num; i++) {
		bool success1 = true;
		for (int j = 0; j < num; j++) {
			int k = (i + j) % num;
			if (S[j] != T[k]) {
				success1 = false;
				break;
			}
		}
		if (success1) {
			success = true;
			break;
		}
	}
	if (success) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;
    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
    
}

void preOrder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preOrder(u->left);
    preOrder(u->right);
}

void inOrder(Node *u){
    if(u == NIL) return;
    inOrder(u->left);
    printf(" %d", u->key);
    inOrder(u->right);
}

int main(){
    int N;
    scanf("%d", &N);
    rep(i, N){
        char S[10];
        int k;
        scanf("%s%d", S, &k);
        if(S[0] == 'i') insert(k);
        else {
            inOrder(root);
            printf("\n");
            preOrder(root);
            printf("\n");
        }
    }
}


Measured memory_bytes: 26600