akhauriyash/Code-Regression huggingface dataset:
from heapq import *
import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class BitSum:
    def __init__(self, n):
        self.n = n + 1
        self.table = [0] * self.n

    def add(self, i, x):
        i += 1
        while i < self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

    # 数列を度数分布とみたときに、x番目がどのインデックスにあるかを返す
    def rank(self, x):
        idx = 0
        for lv in range((self.n - 1).bit_length() - 1, -1, -1):
            mid = idx + (1 << lv)
            if mid >= self.n: continue
            if self.table[mid] < x:
                x -= self.table[mid]
                idx += 1 << lv
        return idx

def solve():
    bit = BitSum(w + 1)
    for j in range(w): bit.add(j + 1, 1)
    cost = [0] * (w + 1)
    hp = [0] * w
    heapify(hp)
    rem = []

    for i in range(h):
        l, r = MI()
        r += 1
        # cost[r]の更新
        if r <= w:
            cnt = bit.sum(r)
            if cnt:
                j = bit.rank(cnt)
                if l <= j < r:
                    bit.add(r, 1)
                    cost[r] = cost[j] + r - j
                    heappush(hp, cost[r])
        # 区間[l,r)を無効にする
        cnt = bit.sum(l - 1)
        while 1:
            j = bit.rank(cnt + 1)
            if j >= r: break
            heappush(rem, cost[j])
            bit.add(j, -1)
        # ヒープからの削除
        while hp and rem and hp[0] == rem[0]:
            heappop(hp)
            heappop(rem)
        # 出力
        if hp: print(hp[0] + i + 1)
        else: print(-1)

h,w=MI()
solve()


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

	typedef long long ll;
	using namespace std;

	int main(){
		string s;
		cin >> s;
		string tmp = "";
		vector <int >a;
		for(int i=0; i < s.size(); i++){
			if(s[i] == '/'){
				a.push_back(atoi(tmp.c_str()));
				tmp = "";
			}else{
				tmp += s[i];
			}
		}

		if(a[0] == 2019 ){
			if(a[1] < 4){
				cout << "Heisei";
			}else if(a[1] == 4){
				if(a[2] <31){
					cout << "Heisei";
				}else{
					cout << "TBD";
				}
			}else{
				cout << "TBD";
			}
		}else{
			cout << "TBD"<<endl;
		}



		return 0;
	}

Measured memory_bytes: 764
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import itertools as it
import collections as cl
import math
from functools import reduce

def li():
    return [int(x) for x in input().split()]

L, R, d = li()

cnt = 0
for i in range(L, R+1):
    if i % d == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 67540
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int main(){
    vector<int> p(3);
    for (int i=0;i<3;++i) cin >> p[i];
    sort(p.begin(), p.end());
    
    bool ans = false;
    if (p[0] == 5 && p[1] == 5 && p[2] == 7) ans = true;
    
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
//v.erase(unique(v.begin(),v.end()),v.end());

using namespace std;
 
typedef long double ld;
typedef long long ll;
typedef  pair <ll, ll> pii;
 
const ll N = 200500;
const ll mod = 1e9 + 7;
const ld PI = 3.141592654;

vector <int> xd[200500];

int main() {


	ll n, k;
	cin >> n >> k;

	ll sum = 0;
	for(int i = k; i <= n + 1; i++){
		sum += ((n - i + 1) * (ll)(i) + 1);
		sum %= mod;
	}

	if(sum < 0) sum += mod;

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 7860
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int n, loop_cnt = 1, cnt1 = 0, cnt2 = 0, j = 0, cnt = 0;
    cin >> n;
    vector<int> p(n), q(n), v(n), ans(2);
    rep(i, n)cin >> p[i];
    rep(i, n)cin >> q[i];
    rep(i, n)v[i] = i+1;
    for(int i = 0; i < n; i++){
        if(p[i] == q[i]){
            cnt++;
        }
    }
    if(cnt == n){
        cout << 0 << endl;
        return 0;
    }
    do{
        cnt1 = cnt2 = 0;
        for(int i = 0; i < n; i++){    
            if(v[i] == p[i]){
                cnt1++;
            }
            if(v[i] == q[i]){
                cnt2++;
            }
        }
        if(cnt1 == n || cnt2 == n){
            ans[j] = loop_cnt;
            j++;
        }
        loop_cnt++;
    }while(next_permutation(v.begin(), v.end()));
    cout << abs(ans[0]-ans[1]) << endl;
}

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

int main(){
  string S;
  cin>>S;
  if(S[0]==S[1]){
    cout<<"Bad"<<endl;
  }
  else if(S[1]==S[2]){
    cout<<"Bad"<<endl;
  }
  else if(S[2]==S[3]){
    cout<<"Bad"<<endl;
  }
  
  else{
    cout<<"Good"<<endl;
  }
}
  
  
  

Measured memory_bytes: 256
_,*s=open(0);t='.';b=t*101;q=range(101)
for i,s in enumerate(s):
 a=[i]
 for x,y,z,c in zip(b,t+s,s,q):a+=min(c+(x==t>z),a[-1]+(y==t>z)),
 b,q=s,a[1:]
print(a[-2])

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
typedef vector<int> int_vector;
typedef vector< vector<int> > int_matrix;
typedef vector<string> string_vector;
typedef vector< vector<string> > string_matrix;

int main(){
    int h, a, n;
    cin >> h >> a;
    n = h%a == 0 ? h/a : h/a+1;
    cout << n  << endl;
}

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

int selectionSort(int N, int *series){
    int swapNum=0;
    for(int i=0; i<N; i++){
        int minj=i;
        for(int j=i; j<N; j++){
            if(series[minj]>series[j])minj=j;
        }
        swap(series[i], series[minj]);
        if(i!=minj)swapNum++;
    
    }
    return swapNum;
}

int main(){

    int N, swapNum;
    int series[100];
    cin >> N;

    for(int i=0; i!=N; i++){cin >> series[i];}
    
    swapNum=selectionSort(N, series);

    for(int i=0; i!=N; i++){
        cout << series[i];
        if(i!=N-1)cout << " ";
    }
    cout << endl;
    
    cout << swapNum << endl;

    return 0;
}


Measured memory_bytes: 3096
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m = readline() |> split |> parseMap
    e = Tuple{Int,Int,Int}[(0,0,0) for i in 1:m]
    for i in 1:m
        a,b,c = readline() |> split |> parseMap
        e[i] = (a,b,c)
    end
    d = 10^13*ones(Int,n)
    d[1] = 0
    f = 0
    for i in 1:n-1
        for j in e
            d[j[2]]=min(d[j[2]],d[j[1]]-j[3])
        end
    end
    neg = zeros(Int,n)
    for j in e
        if d[j[2]]>d[j[1]]-j[3] || neg[j[1]]==1
            neg[j[2]] = 1
        end
        d[j[2]]=min(d[j[2]],d[j[1]]-j[3])
    end
    println(neg[n]==0?-d[n]:"inf")
end

main()

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

int main(){
    int n;
    cin>>n;
    vector<int> x(n);

    for(int i=0; i<n; i++){
        cin>>x.at(i);
    }

    int sum=0,sum_min=0;

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

    for(int i=x.at(0); i<x.at(n-1)+1; i++){
        for(int j=0; j<n; j++){
            sum+=(x.at(j)-i)*(x.at(j)-i);
        }
        if(sum_min==0 || sum<sum_min){
            sum_min=sum;
        }
        sum=0;
    }

    cout<<sum_min<<endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	long long a, b, x;
	cin >> a >> b >> x;
	if (a != 0)cout << b / x - (a - 1) / x << endl;
	else cout << b / x + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        cnt += (p[i] - p[i-1]) * (p[i] - p[i+1]) < 0;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
N = int(input())
S = input()
Sl = list(S[:N])
Sr = list(reversed(S[N:]))
d_l = defaultdict(int)
d_r = defaultdict(int)
for s in range(1<<N):
    sl1 = ''
    sl2 = ''
    sr1 = ''
    sr2 = ''
    for i in range(N):
        if s&(1<<i):
            sl1+=Sl[i]
            sr1+=Sr[i]
        else:
            sl2+=Sl[i]
            sr2+=Sr[i]
    d_l[sl1+' '+sl2]+=1
    d_r[sr1+' '+sr2]+=1
ans = 0
for k, v in d_l.items():
    ans += d_r[k]*v
print(ans)






Measured memory_bytes: 144380
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
ll C[32];
ll S[366][32];
ll T[366];
ll P[32];
set<int> H[32];

ll calcSum(int D) {
  ll ret = 0;
  for (int i=1; i<=D; i++) {
    ret += S[i][T[i]];
  }
  return ret;
}
ll calcPenalty(int con, int D) {
  ll ret = 0;
  ll prev = 0;
  for (auto& it: H[con]) {
    ll dif = it - prev;
    ret += (dif - 1) * dif / 2;
    prev = it;
  }
  ll dif = D + 1 - prev;
  ret += (dif - 1) * dif / 2;
  ret *= C[con];
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  for (int i=1; i<=26; i++) {
    cin >> C[i];
  }
  for (int i=1; i<=D; i++) {
    for (int j=1; j<=26; j++) {
      cin >> S[i][j];
    }
  }
  for (int i=1; i<=D; i++) {
    cin >> T[i];
    H[T[i]].insert(i);
  }
  ll ret = calcSum(D);
  for (int i=1; i<=26; i++) {
    P[i] = calcPenalty(i, D);
    ret -= P[i];
  }
  int M;
  cin >> M;
  for (int query=0; query<M; query++) {
    int day, ncon;
    cin >> day >> ncon;
    int pcon = T[day];
    ll pen = -P[pcon] - P[ncon];
    H[pcon].erase(day);
    H[ncon].insert(day);
    T[day] = ncon;
    P[pcon] = calcPenalty(pcon, D);
    P[ncon] = calcPenalty(ncon, D);
    pen += P[pcon] + P[ncon];
    ret -= pen;
    ret -= S[day][pcon];
    ret += S[day][ncon];
    cout << ret << endl;
  }
}

Measured memory_bytes: 3732
h,w=map(int,input().split())
l=list()
l.append(['.']*(w+2))
for i in range(h):
    l.append(['.']+list(input())+['.'])
l.append(['.']*(w+2))
p,pp=0,0
for i in range(1,h+1):
    for j in range(1,w+1):
        if l[i][j]=='#':
            p+=1
            pp+=int(l[i-1][j]=='#' or l[i+1][j]=='#' or l[i][j-1]=='#' or l[i][j+1]=='#')
print('NYoe s'[p==pp::2])

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

void vector_setter(const int order, const int &N, const int &M, const int &Q, std::vector<int> &Arr,
                   std::vector<int> &a, std::vector<int> &b, std::vector<int> &c, std::vector<int64_t> &d,
                   int64_t &d_max)
{
    if (order == N)
    {
        int64_t sum = 0;

        for (int i = 0; i < Q; ++i)
        {
            if (Arr[b[i] - 1] - Arr[a[i] - 1] == c[i])
                sum += d[i];
        }

        if (d_max < sum)
            d_max = sum;
    }
    else
    {
        for (int i = Arr[order - 1]; i <= M; ++i)
        {
            Arr[order] = i;
            vector_setter(order + 1, N, M, Q, Arr, a, b, c, d, d_max);
        }
    }
}

int main()
{
    int N, M, Q;
    std::cin >> N >> M >> Q;

    std::vector<int> a(Q);
    std::vector<int> b(Q);
    std::vector<int> c(Q);
    std::vector<int64_t> d(Q);
    for (int i = 0; i < Q; ++i)
    {
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    std::vector<int> Arr(N);

    int64_t d_max = 0;
    for (int i = 1; i <= M; ++i)
    {
        Arr[0] = i;
        vector_setter(1, N, M, Q, Arr, a, b, c, d, d_max);
    }

    std::cout << d_max;
}

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

class Program
{
    const int MOD = 1000000007;
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int x = cin.NextInt();
        int[] l = new int[n];

        for (int i = 0; i < n; i++)
        {
            l[i] = cin.NextInt();
        }

        List<int> d = new List<int>();
        d.Add(0);

        foreach (var len in l)
        {
            d.Add(d.Last() + len);
        }

        var less = d.Where(e => e <= x);
        int res = less.Count();

        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        Console.WriteLine(res);

        Console.Out.Flush();
        
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

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

using namespace std;

 


typedef long long  ll;
typedef vector<ll> VL;
typedef pair<ll,ll> PLL;
#define pb push_back
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;



void solve()
{
	ll s,p,x,y;
	cin>>s>>p>>x>>y;
	string ans="";
	fr(i,s,x)
	{
		ans+='R';
	}
	fr(i,p,y)
	{
		ans+='U';
	}
	fr(i,s,x)
	{
		ans+='L';
	}
	fr(i,p,y)
	{
		ans+='D';
	}
	ans+='D';
	fr(i,s,x+1)
	{
		ans+='R';
	}
	fr(i,p,y+1)
	{
		ans+='U';
	}
	ans+='L';
	ans+='U';
	fr(i,s,x+1)
	{
		ans+='L';
	}
	fr(i,p,y+1)
	{
		ans+='D';
	}	
	ans+='R';
	cout<<ans<<endl;
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    ll t=1;
    //cin>>t;
   	// cout<<"ok\n";
    while(t--)
    {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b; cin>>a>>b;
    if(a>b) cout<<a-1<<endl;
    else cout<<a<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int N=s.size();
    vl dp(4,0);
    dp[0]=1;
    rep(i,N){
        vl nowdp(4,0);
        rep(j,4){
            if(s[i]=='?'){
                nowdp[j]=3*dp[j];
                if(j>0)nowdp[j]+=dp[j-1];
            }
            else if(s[i]-'A'+1==j) nowdp[j]=dp[j]+dp[j-1];
            else nowdp[j]=dp[j];
            nowdp[j]%=MOD;
        }
        swap(nowdp,dp);
        rep(j,4){
            //cout << i << ' ' << dp[j] << endl;
        }
    }
    cout << dp[3] << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 3652
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = [LIST() for _ in range(N)]

match = defaultdict(int)
cnt = 0
for i, j in combinations(range(N), 2):
	match[(i, j)] = cnt
	match[(j, i)] = cnt
	cnt += 1

V = N*(N-1)//2
graph = [[] for _ in range(V)]
dag = [0]*V

for i in range(N):
	for j in range(N-2):
		graph[match[(i, A[i][j]-1)]].append(match[(i, A[i][j+1]-1)])
		dag[match[(i, A[i][j+1]-1)]] += 1

q = deque([i for i in range(V) if dag[i] == 0])
day = [1]*V
while q:
	p = q.popleft()
	for v in graph[p]:
		dag[v] -= 1
		if dag[v] == 0:
			day[v] = day[p]+1
			q.append(v)
			
if any(dag):
	print(-1)
else:
	print(max(day))




Measured memory_bytes: 281704
import sys
sys.setrecursionlimit(10**6)
n = int(input())
a = list(map(int,input().split()))
g = [[]for i in range(n)]
for i in range(n-1):
  x,y = map(int,input().split())
  x-=1;y-=1
  g[x].append(y)
  g[y].append(x)
used = [0]*n
ue = [0]*n
for i in range(n):
  if len(g[i])== 1:
    ne = i
    break
huka = [0]*n
def dfs(x,y,z):
  if used[x]:
    return 0
  used[x] = 1
  huka[x] = y
  ue[x] = z
  for ix in g[x]:
    dfs(ix,y+1,x)
dfs(ne,0,-1)
for i in range(n):
  huka[i] = [huka[i],i]
huka.sort(key=lambda x:-x[0])
hen = [0]*(n)
for i in range(n-1):
  x = huka[i][1]
  if len(g[x]) == 1:
    hen[x] = a[x]
    hen[ue[x]] += hen[x]
    if hen[x] > a[ue[x]]:
      print("NO")
      exit()
    continue
  hen[x] = a[x]*2-hen[x]
  hen[ue[x]] += hen[x]
  if hen[x] > a[ue[x]] or hen[x]>a[x]:
    print("NO")
    exit()
  if hen[x] <0:
    print("NO")
    exit()
if hen[ne] != a[ne]:
  print("NO")
else:
  print("YES")

Measured memory_bytes: 123784
n=int(input())
a=list(map(int,input().split()))

total = sum(a)
oneTri = n*(n+1)//2
if total%oneTri!=0:
    print("NO")
    exit()

trial = total//oneTri

cnt=0
for i in range(n):
    sa = a[i-1] + trial - a[i]
    if sa == 0:
        continue
    if sa % n != 0 or sa < 0:
        print("NO")
        exit()
    cnt += sa//n

if cnt != trial:
    print("NO")
else:
    print("YES")


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

int main() {
    string S, T;
    cin >> S >> T;
    int a = S.size();
    for (int i = 0; i < a; i++) {
        for (int j = i; j < a - 1 + i; j++) {
            if (S.at(j) != T.at(j - i)) {
                break;
            }
            if (j == a - 2 + i) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        S += S.at(i);
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll d = a - b;
    if(d >= c) cout << 0 << endl;
    else cout << c - d << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int a;
            cin >> a;
            mp[a]++;
        }
    }
    int ans = 0;
    rep(i,m+1){
        if(mp[i]==n) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
import numpy as np

H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

ans = np.zeros((H*W), dtype=np.int)

idx = 0
for i in range(1, N+1):
    ans[idx:idx+1+a[i-1]] = i
    idx += a[i-1]

ans = np.reshape(ans, (H, W))

x = [1, -1]

for i in range(H):
    print(' '.join(map(str, list(ans[i])[::x[i%2]])))

Measured memory_bytes: 12636
use std::io::*;
use std::str::FromStr;

//*
fn abc(mut ab: Vec<(i32, i32)>) -> i32 {
    ab.sort_by(|a, b| a.1.cmp(&b.1));
    let mut cnt = 0;
    let mut last = 0;

    for &(a, b) in ab.iter() {
        if a > last {
            last = b-1;
            cnt += 1;
        }
    }
    return cnt;
}
//*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    /*
    assert_eq!(abc(), "Yes");
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */
    let _n: i32 = read();
    let m: i32 = read();


    let ab: Vec<(i32, i32)> = (0..m).map(|_| (read(), read())).collect();

    let result = abc(ab);
    
    println!("{}", result);
}




Measured memory_bytes: 4352
x = input()
taka_hp = int(x.split()[0])
taka_attack = int(x.split()[1])
ao_hp = int(x.split()[2])
ao_attack = int(x.split()[3])

while (taka_hp > 0 and ao_hp > 0):
    ao_hp = ao_hp - taka_attack
    taka_hp = taka_hp - ao_attack
else:
    if ao_hp <= 0:
      print("Yes")
    elif taka_hp <= 0:
      print("No")



Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sote(vll &a) {sort(a.begin(), a.end());}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  sote(a);
  vector<vll> aa(1, vll(0));
  aa[aa.size() - 1].push_back(a[0]);
  for (ll i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      vll x(0);
      aa.push_back(x);
    }
    aa[aa.size() - 1].push_back(a[i]);
  }
  ll ans = 0;
  for (ll i = 0; i < aa.size(); i++) {
    if (aa[i][0] < aa[i].size()) ans += aa[i].size() - aa[i][0];
    else if (aa[i][0] > aa[i].size()) ans += aa[i].size();
  }
  cout << ans << endl;
}

Measured memory_bytes: 7348
n = int(input())
A = list(map(int, input().split()))
x = 0
y = 0
z = 0
ans = 1
for i in range(n):
  a = A[i]
  ans *= int(a==x) + int(a==y) + int(a==z)
  if a == x:
    x += 1
  elif a == y:
    y += 1
  elif a == z:
    z += 1
  else:
    print(0)
    exit()
print(ans%(10**9+7))

Measured memory_bytes: 53132
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    int l = 200000;
    int r = l + s.size() - 1;
    vector<char> sf(500000);
    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        sf[l + i] = s[i];
    }

    bool rev = false;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;

        if (t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;

            if ((f == 1 && !rev) || (f == 2 && rev)) {
                l--;
                sf[l] = c;
            } else {
                r++;
                sf[r] = c;
            }
        }
    }

    if (rev) {
        for (int i = r; i >= l; i--) {
            cout << sf[i];
        }
    } else {
        for (int i = l; i <= r; i++) {
            cout << sf[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 1280
N = int(input())
A = list(map(int, input().split()))
money = 0
A0 = [0] + A + [0]
for i in range(1, N + 2):
    money += abs(A0[i] - A0[i - 1])
for j in range(1, N + 1):
    if abs(A0[j + 1] -
           A0[j - 1]) == abs(A0[j + 1] - A0[j]) + abs(A0[j] - A0[j - 1]):
        print(money)
    else:
        print(money - (abs(A0[j + 1] - A0[j]) + abs(A0[j] - A0[j - 1])) +
              abs(A0[j + 1] - A0[j - 1]))

Measured memory_bytes: 14172
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int cnt = 0;
        
        if(!(a>=1 && a<=12)) {
        	cnt = 0;
        }else {
        	if(!(b>=1 && b<=31)) {
        		cnt=0;
        	}else {
        		for(int i=1;i<a+1;i++) {
        			cnt++;
        			if(i==a) {
        				if(!(b-i>=0)) {
        					cnt--;
        				}
        			}
        		}System.out.println(cnt);
        	}
        }
    }
}

Measured memory_bytes: 18900
import math
a,b,x = map(int,input().split())
x = x/a
if x == a*b/2:
    print(45)
    exit()
elif x < a*b/2:
    a = 2*x/b
    print(math.degrees(math.atan2(b,a)))
else:
    x = a*b - x
    b = 2*x/a
    print(math.degrees(math.atan2(b,a)))


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[100005];
int dp[100005];
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[0]=0;
	int ans=0;
	for(int i=1;i<n;i++){
		dp[i]=(a[i]<=a[i-1]?dp[i-1]+1:0);
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
s=input()
x,y=map(int,input().split())

l=[0]
for i in s:
    if i=="F":
        l[-1]+=1
    else:
        l.append(0)
lx=[0]
ly=[0]
for i in range(len(l)):
    if i==0:
        continue
    if i%2==0:
        lx.append(l[i])
    else:
        ly.append(l[i])

q=[l[0]]
for i in lx:
    ll=set()
    for j in q:
        ll.add(j+i)
        ll.add(j-i)
    q=list(ll)
if x not in set(q):
    print("No")
    exit()

q=[0]
for i in ly:
    ll=set()
    for j in q:
        ll.add(j+i)
        ll.add(j-i)
    q=list(ll)
if y in set(q):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3700
#include<stdio.h>
int H;
int A[500002];
void maxHeapify(int i){
  int l = i*2;
  int r = l+1;
  int largest;
  int tmp;
  if(l<=H && A[l]>A[i]){
    largest = l;
  }
  else largest = i;
  if(r<=H && A[r]>A[largest]){
    largest = r;
  }

  if(largest !=i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(void){
  int i;
  for(i=H/2;i>0;i--) maxHeapify(i);
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    vector<unsigned long> v(K + 1);
    unsigned long ans{0};
    for(unsigned long i{K}; i > 0; ){
        auto t = K / i;
        v[t] = modpow(t, N);
        for(unsigned long j{2 * i}; j <= K; j += i)v[t] += MOD - v[K / j];
        v[t] %= MOD;
        auto j = K / (t + 1);
        ans += (i - j) * (i + j + 1) / 2 % MOD * v[t] % MOD;
        i = j;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 4048
ai, ao, at, aj, al, as_, az = map(int, input().split())
gattai = min(ai, aj, al)
ans = gattai * 3
ai -= gattai
aj -= gattai
al -= gattai
ans += (ai // 2) * 2 + ao + (aj // 2) * 2 + (al // 2) * 2
if gattai and ((aj & al & 1) or (ai & aj & 1) or (ai & al & 1)):
    ans += 1
print(ans)


Measured memory_bytes: 3064
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    double q, x;
    for(;;out.println(x)){
      q = sc.nextDouble();
      if(q == -1)break;
      x = q / 2.0;
      for(;x * x * x - q >= 0.00001 * q || x * x * x - q <= -0.00001 * q;)
        x -= (x * x * x - q) / (3 * x * x);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b, c;
set<int> s;

int main() {
	cin >> a >> b >> c;
	
	s.insert(a);
	s.insert(b);
	s.insert(c);
	
	cout << s.size() << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int x,tmax=-999999;
	cin >> x;
	if(x==1||x==2||x==3)
	{
		cout << "1" << endl;
		return 0;
	} 
	for(int i=2;i<=sqrt(x);i++)
	{
		int ii=i;
		while(ii*i<=x) ii*=i;
		tmax=max(ii,tmax);
	}
	cout << tmax << endl;
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> x(n), y(n), c(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    c[i] = i;
  }
  int count = 0;
  auto dist = [&](int i, int j) {
    return sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2));
  };
  double sum = 0;
  do {
    rep(i, n-1) sum += dist(c[i], c[i+1]);
    ++count;
  } while(next_permutation(ALL(c)));
  sum /= count;
  printf("%0.12f\n", sum);
}

Measured memory_bytes: 3804
N, M = map(int, input().split())

L = 1
R = N

for i in range(0, M):
    l, r = map(int, input().split())
    if L < l:
        L = l
    if R > r:
        R = r

L = R - L + 1
if L < 0:
    L = 0

print(L)


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




//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e5 + 1;//                                                             |
//----------------------------------------------------------------------------------





//main func
void solve()
{
    
    ll a,b,c;cin>>a>>b>>c;
    vl n(a),m(b);
    for(auto &i:n) cin>>i;
    for(auto &i:m) cin>>i;
    ll sums=0,i=0,j=0;
    ll ans=0;
    while(i<a){
        if(sums+n[i]<=c) {
            sums+=n[i];
            i++;
            ans++;
        }
        else break;
    }
    i--;
    ll k=ans;
    while(j<b){
        while(i>=0 && sums+m[j]>c){
            sums-=n[i];
            i--;
            k--;
        }
        if(sums+m[j]<=c){
            sums+=m[j];
            j++;
            k++;
        }
        else break;
        ans=max(k,ans);
    }
    cout<<ans<<"\n";
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}


Measured memory_bytes: 6364
def rank(X):
    if X >= 1800:
        return 1
    if X >= 1600:
        return 2
    if X >= 1400:
        return 3
    if X >= 1200:
        return 4
    if X >= 1000:
        return 5
    if X >= 800:
        return 6
    if X >= 600:
        return 7
    if X >= 400:
        return 8


X = int(input())
ans = rank(X)
print(ans)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

// x^n in mod
ll modpow(ll x, ll n, ll mod){
  if(n==0) return 1;

  if(n%2==0){
    return modpow(x*x%mod, n/2, mod) % mod;
  }else{
    return x * modpow(x, (n-1), mod) % mod;
  }
}

ll facs[1000001];

// n! in mod
ll fac(ll n){
  return facs[n];
}

// nCr in mod
ll comb(ll n, ll r){
  if(n<0 || n<r || r<0)return 0;
  ll fn = fac(n);
  ll fr = fac(r);
  ll fn_r = fac(n-r);
  
  ll d = (modpow(fr, MOD-2, MOD) * modpow(fn_r, MOD-2, MOD)) % MOD;
  ll u = fn%MOD;
  
  ll result = u * d % MOD;
 
  return result;
}

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

  facs[0]=1;
  rep(i, 1000000)facs[i+1] = (facs[i]*(i+1))%MOD;

  ll s = (2*x-y)/3;
  ll t = (2*y-x)/3;
  cout<<comb(s+t, t);

  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int N, M, Q;
VEC<VEC<int>> G;
LL ans = 0;
int calc(VEC<int> &col) {
  LL ret = 0;
  REP(q, 0, Q) {
    int a = G[q][0] - 1;
    int b = G[q][1] - 1;
    int c = G[q][2];
    int d = G[q][3];
    if (col[b] - col[a] == c) ret += d;
  }
  return ret;
}
void dfs(int x, int nth, VEC<int> &col) {
  col[nth] = x;
  // DUMP(x, nth, col);
  if (nth == N - 1) {
    LL tmp = calc(col);
    ans = max(ans, tmp);
    // DUMP(x, nth, col, tmp, ans);
  } else {
    REP(y, x , M + 1) { dfs(y, nth + 1, col); }
  }
  col[nth] = 0;
}

int main() {
  cin >> N >> M >> Q;
  int num = 4;

  G = VEC<VEC<int>>(Q, VEC<int>(num, 0));
  REP(i, 0, Q) { REP(j, 0, num) cin >> G[i][j]; }
  VEC<int> A(N, 0);
  REP(i, 1, M+1) { dfs(i, 0, A); }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, x;
vector<ll> a(51);
vector<ll> p(51);
ll f(ll c, ll d)
{
    if(d == 1)
    {
      if(c == 0) return 1;
      else return 0;
    }
    else if(1 < d && d <= a[c-1]+1)
    {
        return f(c-1, d-1);
    }
    else if(d == a[c-1] + 2)
    {
        return p[c-1]+1;
    }
    else if(a[c-1]+2 < d && d <= 2 * a[c-1] + 2)
    {
        return p[c-1] + 1 + f(c-1, d-2-a[c-1]);
    }
    else if(d == 2 * a[c-1] + 3)
    {
        return 2 * p[c-1] + 1;
    }
    return 0;
}
int main()
{
    cin >> n >> x;
    
    a[0] = 1;
    p[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        a[i] = 2 * a[i-1] + 3;
        p[i] = 2 * p[i-1] + 1;
    }

    cout << f(n, x) << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int euclidean_gcd(int a, int b) {
  if(a < b) return euclidean_gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x>>y>>z;
w=euclidean_gcd(x,y);
while(1){
  if(x%w==0&&y%w==0){
    n++;
  }
  if(n==z){
    std::cout << w << '\n';
    return 0;
  }
  w--;
}
}


Measured memory_bytes: 256
# 方針: N本のそれぞれを抜いた時全ての頂点を探索することができるか判定し、カウントを行う。
import copy
N , M = map(int,input().split())

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

def dfs(now):
    stack = [work_graph[now]]
    while stack:
        next_nodes = stack.pop()
        for next_node in next_nodes:
            if not visited[next_node]:
                visited[next_node] = True
                stack.append(work_graph[next_node])


cnt = 0
for i in range(M):
    work_graph = [[] for _ in range(N)]
    for j in range(M):
        if j == i:
            continue
        work_graph[tmp_list[j][0]].append(tmp_list[j][1])
        work_graph[tmp_list[j][1]].append(tmp_list[j][0])
    visited = [False] * N
    dfs(0)
    if not all(visited):
        cnt += 1
print(cnt)

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

int main()
{
    int n, x; cin >> n >> x;
    vector<int> m(n);
    for (int i = 0; i < n; i++) {cin >> m[i]; x -= m[i];}
    sort(m.begin(), m.end());
    cout << n + (x / m[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

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

typedef long long ll;

const int N_prime  = 10000001;

int main()
{
	vector<char> used(N_prime, '1');
	int n;

	for(int i = 2; i < sqrt(N_prime); i++)
	{
		if(used[i] == '0')
		{
			continue;
		}
		for(int j = i*2; j < N_prime; j += i)
		{
			used[j] ='0';
		}
	}
	
	while(cin >> n, n)
	{
		int res;
		for(int i = n; i >= 13; i--)
		{
			if(used[i] == '1' && used[i-2] == '1')
			{
				if(used[i-2] == '1'&& used[i-6] == '1')
				{
					if(used[i-6] == '1'&& used[i-8] == '1')
					{
						res = i;
						break;
					}	
				}
			}
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 10768
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,k;
    cin >> n >> k;
    if (n < 2 * k - 1) {
        cout << -1 << endl;
        return;
    }
    if (k == 1) {
        REP(i,0,n) {
            cout << k + i << " " << k + n + i << " " << k + 2 * n + i << endl;
        }
        return;
    }
    REP(i,0,(n+1)/2) {
        cout << k + 2 * n - 1 - 2 * i << " ";
        cout << k + n / 2 + i << " ";
        cout << k + 3 * n - 1 - i << endl;
    }
    REP(i,0,n/2) {
        cout << k + 2 * n - 2 - i * 2 << " ";
        cout << k + i << " ";
        cout << k + 3 * n - 1 - (n + 1) / 2 - i << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 2304
N,W = [int(s) for s in input().split()]
dp = [[10**10]*(1000*100+1) for _ in range(N+1)]#外側から内側のイメージ

dp[0][0] = 0
for i in range(N):
    w, v = [int(s) for s in input().split()]
    for sum_v in range(1000*100+1):
        if sum_v - v >= 0:
            dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v-v] + w)
        else:
            dp[i+1][sum_v] = dp[i][sum_v]

ans = 0
for sum_v in range(1000*100+1):
    if dp[N][sum_v] <= W:
        ans = sum_v

print(ans)

Measured memory_bytes: 119788