akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Pos[] ss = new Pos[N];
		Pos[] ps = new Pos[M];
		for(int i=0; i<N; i++){
			ss[i] = new Pos();
			ss[i].x = sc.nextInt();
			ss[i].y = sc.nextInt();
		}
		for(int i=0; i<M; i++){
			ps[i] = new Pos();
			ps[i].x = sc.nextInt();
			ps[i].y = sc.nextInt();
		}
		sc.close();
		
		int[] ans = new int[N];
		for(int n=0; n<N; n++){
			Pos s = ss[n];
			long min = Long.MAX_VALUE;
			for(int i=0; i<M; i++){
				Pos p = ps[i];
				long d = (long) (Math.abs(s.x - p.x) + Math.abs(s.y - p.y));
				if(d<min){
					min = d;
					ans[n] = i+1;
				}
			}
		}
		
	
		for(int a: ans){
			System.out.println(a);
		}

	}
	
	private static class Pos {
		long x;
		long y;
	}

}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numberOfDocuments = scanner.nextInt();

        String answer = "APPROVED";
        for (int i = 0; i < numberOfDocuments; i++) {
            int nextInput = scanner.nextInt();
            if (nextInput % 2 == 0) {
                if (nextInput % 3 != 0 && nextInput % 5 != 0) {
                    answer = "DENIED";
                    break;
                }
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21716
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll x;
    cin>>x;
    ll a[100010];
    rep2(i,1,100010){
        a[i]=(i+1)*i/2;
    }
    rep(i,100010){
        if(x<=a[i]){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
ARG_N, ARG_W = gets.split.map(&:to_i)
ARG_w = Array.new(ARG_N)
ARG_v = Array.new(ARG_N)
ARG_N.times do |i|
  ARG_w[i], ARG_v[i] = gets.split.map(&:to_i)
end

def max a,b
  a > b ? a : b
end

def min a,b
  a > b ? b : a
end

MAX_V = ARG_N*(10**3)
dp = Hash.new(Float::INFINITY)
dp[0] = 0
ARG_N.times do |i|
  w, v = ARG_w[i], ARG_v[i]
  dv = MAX_V
  while v <= dv do
    dw = dp[dv-v]+w
    if dw <= ARG_W
      dp[dv] = min(dw, dp[dv])
    end
    dv-=1
  end
end
puts dp.keys.max

Measured memory_bytes: 6652
#include<bits/stdc++.h>
using namespace std;
#define ld long double
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ld a,b,c;
	cin>>a>>b>>c;
	if(a+b+2*sqrtl(a*b)<c)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 1e9;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int sq_N = sqrt(N_MAX);
  vector<int> v(sq_N);
  repp(i,1,sq_N+1){
    v[i-1] = i*i;
  }
  int N;cin >> N;
  auto it = lower_bound(all(v),N);
  if(*it != N)--it;
  cout << *it << endl;
  return 0;
}


Measured memory_bytes: 384
def isPrime(num):
    if num == 2: return 1
    if num < 2 or num&1 == 0: return 0
    if pow(2, num-1, num) == 1: return 1
    return 0

n = input()
s = 0
for i in xrange(n):
    s += isPrime(input())

print s

Measured memory_bytes: 6420
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var c = Convert.ToInt32(input[0]);
        var people = Convert.ToInt32(input[1]);
        if (c % people == 0) Console.WriteLine(0);
        else Console.WriteLine(1);
    }
}

Measured memory_bytes: 11220
from collections import deque

N, M = map(int, input().split())

adjList = [[] for i in range(N)]
for i in range(M):
    L, R, D = map(int, input().split())
    adjList[L - 1].append((R - 1, D))
    adjList[R - 1].append((L - 1, -D))

def bfs(vSt):
    xs[vSt] = 0
    Q = deque()
    Q.append(vSt)
    while Q:
        vNow = Q.popleft()

        for v2, d in adjList[vNow]:
            x2 = xs[vNow] + d
            if xs[v2] == None:
                xs[v2] = x2
                Q.append(v2)
            elif xs[v2] != x2:
                return False

    return True


xs = [None] * N
for vSt in range(N):
    if xs[vSt] == None:
        if not bfs(vSt):
            print('No')
            exit()

print('Yes')


Measured memory_bytes: 66220
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

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

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, x;
int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> x;
  REP(i, n) {
    cin >> a[i];
  }

  ll ans = 0;
  FOR(i, 1, n) {
    if((a[i - 1] + a[i]) > x) {
      int ca = (a[i] + a[i - 1]) - x;
      if(ca > a[i]) {
        a[i - 1] -= ca - a[i];
        a[i] = 0;
      } else {
        a[i] -= ca;
      }
      ans += ca;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,ans[MAXN],m[MAXN];
vector<int> G[MAXN];
map<int,int> mp[MAXN];
int find(int v,int p,int val)
{
    if(mp[v].find(val)!=mp[v].end()) return mp[v][val];
    for(auto to:G[v])
    {
        if(to==p) continue;
        if(to>=val) continue;
        mp[v][val]+=1+find(to,v,val);
    }
    return mp[v][val];
}
void dfs(int v,int p)
{
    for(auto to:G[v])
    {
        if(to==p) continue;
        ans[to]=ans[v];
        m[to]=max(m[v],v);
        if(to>m[v]) ans[to]+=find(to,v,m[to])+1; 
        else ans[to]+=find(to,v,m[to])-find(to,v,m[v]);
        dfs(to,v);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);G[v].push_back(u);
    }
    ans[1]=0;m[1]=-1;
    dfs(1,0);
    for(int i=2;i<=n;i++) printf("%d%c",ans[i],i==n?'\n':' ');
    return 0;
}



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

namespace ConsoleApplication18 {//b54
    class Program {
        static void Main(string[] args) {

   
            int x = int.Parse(Console.ReadLine());

            var result = Method(x);
            Console.WriteLine(result);
        }
        private static string Method(int x) {

            string result = "";
            if (x <1200) {
                result = "ABC";
            } else {
                
                result = "ARC";
            }

            return result; 

        }
    }
}

Measured memory_bytes: 13140
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	var n int
	fmt.Sscanf(scanner.Text(), "%d", &n)

	as := make([]int, n/2)
	bs := make([]int, n/2)
	for i := 0; i < n; i++ {
		scanner.Scan()
		if i%2 == 0 {
			fmt.Sscanf(scanner.Text(), "%d", &as[i/2])
		} else {
			fmt.Sscanf(scanner.Text(), "%d", &bs[i/2])
		}
	}

	mpA := make(map[int]int)
	for _, val := range as {
		mpA[val]++
	}
	mpB := make(map[int]int)
	for _, val := range bs {
		mpB[val]++
	}

	// find 1st/2dn mode
	fstA := -1
	fstCntA, sndCntA := 0, 0
	for num, count := range mpA {
		if count > fstCntA {
			fstA = num
			fstCntA, sndCntA = count, fstCntA
		} else if count > sndCntA {
			sndCntA = count
		}
	}

	fstB := -1
	fstCntB, sndCntB := 0, 0
	for num, count := range mpB {
		if count > fstCntB {
			fstB = num
			fstCntB, sndCntB = count, fstCntB
		} else if count > sndCntB {
			sndCntB = count
		}
	}

	var ans int
	if fstA != fstB {
		ans = (n/2 - fstCntA) + (n/2 - fstCntB)
	} else {
		ans = min((n/2-fstCntA)+(n/2-sndCntB), (n/2-sndCntA)+(n/2-fstCntB))
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        ans += y - x + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b; cin>>a>>b;
  if(a==b) cout<<"Draw"<<endl;
  else if(a!=1 && b!=1){
    if(a>b) cout<<"Alice"<<endl;
    if(a<b) cout<<"Bob"<<endl;
  }
    else if(a==1) cout<<"Alice"<<endl;
    else if(b==1) cout<<"Bob"<<endl;

}

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

typedef long long ll;
const int maxn=1000;
ll n,stk[maxn],top;
struct point{
	ll x,y,id,on;
	bool operator< (point o)const{
		return x<o.x||x==o.x&&y<o.y;
	}
}p[maxn];
vector<int> vec;
double ans[maxn];

void work(int l,int mid,int r){
	double a=atan2(p[l].y-p[mid].y,p[l].x-p[mid].x),b=atan2(p[r].y-p[mid].y,p[r].x-p[mid].x);
	a-=b;
	a-=acos(-1);
	while(a<0)
		a+=acos(-1)*2;
	ans[p[mid].id]=a/acos(-1)/2;
}

int main(){
	cin>>n;
	if(n==2){
		puts("0.5");
		puts("0.5");
		return 0;
	}
	for(int i=1;i<=n;++i){
		cin>>p[i].x>>p[i].y;
		p[i].id=i;
	}
	sort(p+1,p+n+1);
	stk[1]=1;stk[2]=2;top=2;
	for(int i=3;i<=n;++i){
		while(top>=2&&
		(p[i].y-p[stk[top]].y)*(p[stk[top]].x-p[stk[top-1]].x)
		>(p[i].x-p[stk[top]].x)*(p[stk[top]].y-p[stk[top-1]].y))
			--top;
		stk[++top]=i;
	}
	for(int i=1;i<=top;++i)
		vec.push_back(stk[i]);
	stk[1]=n;stk[2]=n-1;top=2;
	for(int i=n-2;i;--i){
		while(top>=2&&
		(p[i].y-p[stk[top]].y)*(p[stk[top]].x-p[stk[top-1]].x)
		>(p[i].x-p[stk[top]].x)*(p[stk[top]].y-p[stk[top-1]].y))
			--top;
		stk[++top]=i;
	}
	for(int i=2;i<top;++i)
		vec.push_back(stk[i]);
	work(vec[vec.size()-1],vec[0],vec[1]);
	for(int i=1;i+1<vec.size();++i)
		work(vec[i-1],vec[i],vec[i+1]);
	work(vec[vec.size()-2],vec[vec.size()-1],vec[0]);
	for(int i=1;i<=n;++i)
		printf("%.5f\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int n;
    cin>>n;
    vector<ll> a(n);
    deque<ll> b;
    rep(i,n) cin>>a[i];

    rep(i,n){
        if(i%2==0){
            b.push_back(a[i]);
        }else{
            b.push_front(a[i]);
        }
    }

    if(n%2==0){
        for(int i=0;i<n;i++){
            cout<<b[i]<<" ";
        }
    }
    else{
        for(int i=n-1;i>=0;i--){
            cout<<b[i]<<" ";
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>
int array[512345];
int a[212345];
int main(void){
  int n;
  scanf("%d",&n);
  for(int loop=0;loop<n;++loop){
    scanf("%d",&a[loop]);
  }
  int left=212345;
  int right=left+1;
  for(int loop=0;loop<n;++loop){
    if(loop%2==(n-1)%2){
      array[left--]=a[loop];
    }else{
      array[right++]=a[loop];
    }
  }
  for(int loop=left+1;loop<right;++loop){
    printf("%d ",array[loop]);
  }
  return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;
ll N, a[100000]; bool flag = true; ll ans = 1;
int main(void)
{
	cin >> N;
	FOR(i, 0, N)cin >> a[i];
	sort(a, a + N);
	if (N % 2 == 1) {
		if (a[0] != 0)flag = false;
		else {
			FOR(i, 1, (N - 1) / 2+1) {
				if (a[2 * i - 1] != i * 2 || a[2 * i] != i * 2)flag = false;
				ans = (ans*2)%MOD;
			}
		}
	}
	else {
		FOR(i, 0, N / 2) {
			if (a[2 * i] != 2 * i + 1 || a[2 * i + 1] != 2 * i + 1)flag = false;
			ans = (ans*2)%MOD;
		}
	}
	if(flag)cout << ans << endl;
	else cout << 0 << endl;
	return 0;
}


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

const int MN = 100010;

int N;
vector<int> adj[MN];
int C[MN], deg[MN], leaf[MN], del[MN], dp1[MN], dp2[MN];

bool dfs0(int u, int p) {
    bool ret = false;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        ret |= dfs0(v, u);
    }
    if(!ret) leaf[u] = 1;
    ret |= !C[u];
    if(!ret) del[u] = 1;
    return ret;
}

void dfs1(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        if(del[v]) continue;
        dfs1(v, u);
        deg[u]++;
        deg[v]++;
    }
}

void dfs2(int u, int p) {
    int mx = -1e9;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        if(del[v]) continue;
        dfs2(v, u);
        dp1[u] = max(dp1[u], 1 + dp1[v]);
        dp2[v] = max(dp2[v], 2 + mx);
        mx = max(mx, dp1[v]);
    }
    mx = -1e9;
    for(int i = (int)adj[u].size() - 1; i >= 0; i--) {
        int v = adj[u][i];
        if(v == p) continue;
        if(del[v]) continue;
        dp2[v] = max(dp2[v], 2 + mx);
        mx = max(mx, dp1[v]);
    }
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        if(del[v]) continue;
        if(!leaf[v]) dp2[v] += ((deg[v] % 2) ^ C[v])? -1 : 1;
        if(!leaf[u]) dp2[v] += ((deg[u] % 2) ^ C[u])? -1 : 1;
    }

    if(!leaf[u]) dp1[u] += ((deg[u] % 2) ^ C[u])? -1 : 1;
}

void dfs3(int u, int p) {
    if(p != -1) {
        int tmp = 1 + dp2[p];
        if(!leaf[u]) tmp += ((deg[u] % 2) ^ C[u])? -1 : 1;
        dp2[u] = max(dp2[u], tmp);
    }
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        if(del[v]) continue;
        dfs3(v, u);
    }
}

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

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int wcnt = 0;

    scanf("\n");
    for(int i = 0; i < N; i++) {
        char c; scanf("%c", &c);
        C[i] = c == 'B';
        if(!C[i]) wcnt++;
    }

    if(!wcnt) {
        printf("0");
        return 0;
    }
    if(wcnt == 1) {
        printf("1");
        return 0;
    }

    int root;
    for(int i = 0; i < N; i++) if(!C[i]) {
        root = i;
        break;
    }

    dfs0(root, -1);
    dfs1(root, -1);
    dfs2(root, -1);
    dfs3(root, -1);

    int x = 0, y = 0, ans = 1e9;
    for(int i = 0; i < N; i++) if(!del[i]) x++;
    for(int i = 0; i < N; i++) if(!del[i] && !((deg[i] % 2) ^ C[i])) y++;

    for(int i = 0; i < N; i++) if(!del[i]) {
        int tmp = 2 * (x - 1) + y;
        tmp -= max(dp1[i], dp2[i]);
        if(leaf[i]) tmp -= ((deg[i] % 2) ^ C[i])? -1 : 1;
        ans = min(ans, tmp);
    }
    printf("%d", ans);
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define MOD 1000000007
template <typename Type>
istream &operator>>(istream &in, vector<Type> &vec) {
    ll n = vec.size();
    for (ll i = 0; i < n; i++)
        in >> vec[i];
    return in;
}
template <typename Type>
ostream &operator<<(ostream &out, vector<Type> &vec) {
    for (auto val : vec)
        out << val << " ";
    return out;
}
#define PI 3.14159265

int main()
{
   string s;
   string t;
   cin>>s>>t;
   ll m = s.size();
   ll n = t.size();
   ll l[m+1][n+1];
   for(ll i=0;i<=m;i++)
   {
       for(ll j=0;j<=n;j++)
       {
           if(i==0||j==0)
            l[i][j]=0;
           else if(s[i-1]==t[j-1])
            l[i][j] = l[i-1][j-1]+1;
            else
            {
                l[i][j] = max(l[i][j-1],l[i-1][j]);
            }
            
       }
   }
   ll lt = l[m][n];
   ll x = lt;
   vector<char>lcs(lt+1);
   ll i=m,j=n;
   while(i>0&&j>0)
   {
       if(s[i-1]==t[j-1])
       {
           lcs[lt--] = s[i-1];
           i--;
           j--; 
       }
       else if(l[i-1][j]>l[i][j-1])
       {
           i--;
       }
       else
       j--;
   }
   for(ll i=1;i<=x;i++)
   cout<<lcs[i];
   cout<<endl;
   return 0;
}
    


Measured memory_bytes: 70656
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template <class T>
inline void read(T &x)
{
    x=0; char c=getchar();  int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
    while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
int mp[5][5];
bool dfs(int u,int last,int dep)
{
	if(dep==4) return 1;
	for(int i=1;i<=4;++i)
		if(i!=last&&mp[u][i]) return dfs(i,u,dep+1);
	return 0;
}
int main()
{
	int x,y;
	for(int i=1;i<=3;++i) read(x),read(y),mp[x][y]=mp[y][x]=1;
	for(int i=1;i<=4;++i)
	{
		if(dfs(i,0,1))
		{
			printf("YES");
			return 0;
		}
	}
	printf("NO");
	return 0;
}

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

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


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    double a, b;
    cin >> a >> b;
    double minA, maxA, minB, maxB;
    minA = 12.5 * a; maxA = minA + 12.5;
    minB = 10 * b; maxB = minB + 10;
    double ans;
    ans = max(minA, minB);
    if (ans < maxA and ans < maxB){
        cout << ceil(ans)<< endl;
    }else{
        cout << -1 << endl;
    }
}



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

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin>>n>>k;
  if(k>(n-1)*(n-2)/2)
    {cout<<-1;return 0;}
  vector<pair<ll,ll>> ans;
  for(ll i=2;i<=n;i++)
    ans.push_back({1,i});
  ll cur = (n-1)*(n-2)/2 ;
  ll i=2,j=3;
  while(cur!=k){
      ans.push_back({i,j});
      j++;
      if(j==n+1)
        {i++;j=i+1;}
      cur--;
  }
  cout<<ans.size()<<endl;
  for(auto p:ans)
    cout<<p.first<<" "<<p.second<<endl;
    
  return 0;
}

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




void solve(long long N, std::vector<long long> A){
    vector<vector<ll>> graph(N+1);
    for (ll i = 1; i<N;i++ ){
        graph[A[i-1]].push_back(i+1);
    }
    for (ll i=1;i<=N;i++){
        printf("%d\n",graph[i].size());
    }
    


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-2+1);
    for(int i = 0 ; i < N-2+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 15588
use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::cmp::{max, min};

fn main() {
    input! {
        k: i8,
    }
    let mut ans = String::new();
    for _ in 0..k {
        ans = format!("{}{}", ans, "ACL");
    }
    println!("{}", ans);
}


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

int main()
{
	long long N;
	cin >> N;

	long long ans = 0;
	for( long long A = 1; A < N; A++ ) {
		long long B = N / A;
		long long C = N % A;
		if( C > 0 ) {
			ans += B;
		}
		else ans += B - 1;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
  long K, X;
  cin >> K >> X;
  
  cout << X - K + 1;
  for (long l = X - K + 2; l < X + K; ++l) {
    cout << " " << l;
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php
[$N, $A, $B, $C] = array_map('intval',explode(' ',trim(fgets(STDIN))));;
for($i = 0; $i < $N; $i++){
    $S[] = trim(fgets(STDIN));
}
$path = [];
dfs(0, $path, $A, $B, $C);
echo "No\n";
function dfs($d, &$path, $A, $B, $C){
    global $S, $N;
    if($d == $N){
        echo "Yes\n";
        echo implode("\n", $path);
        exit;
    }
    $s = $S[$d];
    for($i = 0; $i < 2; $i++){
        if(${$s[$i]}>0){
            $path[] = $s[1-$i];
            ${$s[$i]}--;
            ${$s[1-$i]}++;
            dfs($d+1, $path, $A, $B, $C);
            ${$s[$i]}++;
            ${$s[1-$i]}--;
            array_pop($path);
        }
    }
}



Measured memory_bytes: 164256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll h,w;
    cin >> h >> w;
    for (ll i=0;i<w+2;++i){
        cout << "#";
    }
    cout << endl;
    for (ll i=0;i<h;++i){
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    for (ll i=0;i<w+2;++i){
        cout << "#";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
int main()
{
	cin >> n;
	int l = 1, r = 1e6, m, res = n;
	r = min(r, n);
	while (l <= r) {
		m = (l + r) / 2;
		int cur = n;
		for (int i = m; i > 0; --i) {
			if (cur >= i)
				cur -= i;
		}
		if (cur == 0) {
			res = m;
			r = m - 1;
		}
		else
			l = m + 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <cstring>
#include <cmath>

constexpr int MAX = 200;
constexpr int MAX_C = 100;

int D, N, T[MAX], A[MAX], B[MAX], C[MAX];
int memo[MAX_C + 1][MAX + 1];

int solve(int tmp, int n = 1);

int main(){
	std::ios::sync_with_stdio(false);
	
	memset(memo, -1, sizeof(memo));

	std::cin >> D >> N;

	for(int i = 0; i < D; ++i){
		std::cin >> T[i];
	}

	for(int i = 0; i < N; ++i){
		std::cin >> A[i] >> B[i] >> C[i];
	}

	int ans = 0;
	for(int i = 0; i < N; ++i){
		if(A[i] <= T[0] && T[0] <= B[i]){
			ans = std::max(ans, solve(C[i]));
		}
	}

	std::cout << ans << std::endl;
	return 0;
}

int solve(int tmp, int n){
	if(n == D){
		return 0;
	}
	if(memo[tmp][n] != -1){
		return memo[tmp][n];
	}

	int res = 0;
	for(int i = 0; i < N; ++i){
		if(A[i] <= T[n] && T[n] <= B[i]){
			res = std::max(res, solve(C[i], n + 1) + abs(tmp - C[i]));
		}
	}
	//std::cout << "memo[" << tmp << "][" << n << "] = " << res << std::endl;
	return memo[tmp][n] = res;
}

Measured memory_bytes: 3280
n = int(input())
a = list(map(int,input().split()))
for i in a :
    if i == 0 :
        print(0)
        exit()
ans = 1
for i in range(len(a)) :
    ans *= a[i]
    if ans > 10**18 :
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 21636
let rec calc r i n k =
	if i==n then r else (calc ((r+k) mod i) (i+1) n k);;

while true do
	Scanf.sscanf (read_line ()) "%d %d %d" (fun n k m ->
		if n==0 then exit(0) else (print_int ((((calc 0 1 n k)+m) mod n)+1); print_string "\n")
	) done;;

Measured memory_bytes: 2344
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <vector>
#include <set>
#include <map>

#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DV_NUM (100000007)

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main()
{
    int X,Y,Z;
    cin >> X >> Y >> Z;

    cout << Z << " " << X << " " << Y << endl;    
 
    return 0;
 
}

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

int n,ans,mx;
int a[6005],curdp[2005][2005],dp[2005][2005],f[2005];
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		f[i]=-n*10;
		for(j=i;j<=n;j++)
			dp[i][j]=curdp[i][j]=-n*10;
	}
	for(i=1;i<=n*3;i++)
		scanf("%d",&a[i]);
	dp[min(a[1],a[2])][max(a[1],a[2])]=0;
	f[a[1]]=f[a[2]]=0;
	for(i=5;i<=3*n;i+=3)
	{
		int tt=0;
		if(a[i]==a[i-1]&&a[i-1]==a[i-2])
		{
			ans++;
			tt=1;
		}
		int b[3];
		for(k=0;k<3;k++)
			b[k]=a[i-k];
		sort(b,b+3);
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			curdp[b[1]][b[2]]=max(curdp[b[1]][b[2]],max(dp[t][t]+1,mx));
			b[0]=t;
			sort(b,b+3);
		}
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			if(b[1]==b[2])
			{
				for(j=1;j<=n;j++)
					curdp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)],dp[min(b[1],j)][max(b[1],j)]+1);
			}
			for(j=1;j<=n;j++)
				curdp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)],f[j]);
			b[0]=t;
			sort(b,b+3);
		}
		for(k=0;k<3;k++)
		{
			int t=b[k];
			b[k]=-10;
			sort(b,b+3);
			dp[b[1]][b[2]]=max(dp[b[1]][b[2]],curdp[b[1]][b[2]]-tt);
			mx=max(mx,dp[b[1]][b[2]]);
			f[b[1]]=max(f[b[1]],dp[b[1]][b[2]]);
			f[b[2]]=max(f[b[2]],dp[b[1]][b[2]]);
			curdp[b[1]][b[2]]=-n*10;
			for(j=1;j<=n;j++)
			{
				dp[min(t,j)][max(t,j)]=max(curdp[min(t,j)][max(t,j)]-tt,dp[min(t,j)][max(t,j)]);
				mx=max(mx,dp[min(t,j)][max(t,j)]);
				f[t]=max(f[t],dp[min(t,j)][max(t,j)]);
				f[j]=max(f[j],dp[min(t,j)][max(t,j)]);
				curdp[min(t,j)][max(t,j)]=-n*10;
			}
			b[0]=t;
			sort(b,b+3);
		}
	}
	printf("%d\n",ans+max(mx,dp[a[n*3]][a[n*3]]+1));
	return 0;
}

Measured memory_bytes: 31440
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    string s;
    cin>>s;
    ll c=0,d=0;
    for(int i=0;i<s.length();i++)
    {
        if(i%2==0)
        {
            if(s[i]!='0')
            c++;
        }
        else
        {
            if(s[i]!='1')
            c++;
        }
    }
     for(int i=0;i<s.length();i++)
    {
        if(i%2==0)
        {
            if(s[i]!='1')
            d++;
        }
        else
        {
            if(s[i]!='0')
            d++;
        }
    }
    cout<<min(c,d);}
    

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

int main(){

  int x,y,z,wide=0,ans=0;

  cin>>x>>y>>z;

  for(int i=1; i<100000; i++){

    wide = i * y + (i+1) * z ;

    if(wide > x ) break;

    ans++;
    
  }

  cout<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int A[200];

int main() {
    int n, m; cin >> n >> m;
    int mx = 0;
    
    for(int i = 0; i < n; ++i) {
        mx += i + m;
    }
    
    int nx = 500;
    
    for(int i = 0; i < n; ++i)
        if(abs(i + m) < abs(nx)) nx = i + m;
    
    cout << mx - nx;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;

int main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  rep(l, k+1) {
    rep(r, k-l+1) {
      if(l+r > n) continue;
      int d = k - l - r;
      int now = 0;
      vector<int> s;
      rep(i, l) {
        now += v[i];
        s.push_back(v[i]);
      }
      for(int i = n-r; i < n; i++) {
        now += v[i];
        s.push_back(v[i]);
      }
      sort(s.begin(), s.end());
      rep(i, d) {
        if(i >= s.size()) break;
        if(s[i] > 0) break;
        now -= s[i];
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))


a.sort()
c.sort()

ans = 0
for i in b:
    p1 = bisect_left(a, i)
    p2 = bisect_right(c, i)

    ans += p1*(n-p2)

print(ans)


Measured memory_bytes: 105396
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];/*depth*/
int H[MAX];/*height*/
int n;

int sibling(int u){
 if(T[u].p == NIL) return NIL;
 if(T[T[u].p].l != u && T[T[u].p].l != NIL) return  T[T[u].p].l;
 if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
 return NIL;
}

void print(int u){
 int i, c;
 int degree=0;

 if(T[u].l != NIL) degree=degree+1;
 if(T[u].r != NIL) degree=degree+1;

 printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p,sibling(u),degree, D[u],H[u]);

 if(T[u].p == NIL) printf("root");
 else if(T[u].l == NIL && T[u].r == NIL) printf("leaf");
 else printf("internal node");

 printf("\n");

}

void calcDepth(int u, int p){
//if(u==NILL) return;
 D[u] = p;
 if(T[u].r != NIL) calcDepth(T[u].r,p+1);
 if(T[u].l != NIL) calcDepth(T[u].l,p+1);
}


int calcHeight(int u){
 int h1=0,h2=0;
 if(T[u].r != NIL) h1=calcHeight(T[u].r)+1;
 if(T[u].l != NIL) h2=calcHeight(T[u].l)+1;

 if(h1 > h2) return H[u]=h1;
 else return H[u]=h2;
}

int main(){
 int i, j, k;
 int n;
 int id, left, right;
 int root = NIL;

 scanf("%d", &n);
 for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

 for(i=0; i<n; i++){
   scanf("%d", &id);
   scanf("%d %d", &left, &right);
   T[id].r = right;
   T[id].l = left;
   if(right != NIL) T[right].p = id;
    if(left != NIL) T[left].p = id;
 }

 //根を求める (find the root)
 for(i=0; i<n; i++){
   if(T[i].p == NIL) root = i;
 }

 //それぞれのノードの深さを求める (find depth of each node)
 calcDepth(root, 0);
 calcHeight(root);

 //出力 (output)
 for(i=0; i<n; i++) print(i);

 return 0;
}


Measured memory_bytes: 2104
//
//  main.cpp
//  Nikkei09Qual
//
//  Created by 原大曜 on 2019/01/27.
//  Copyright © 2019年 原大曜. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;

void probA()
{
    int N,A,B;
    cin >> N >> A >> B;
    cout << std::min(A,B) << " " << std::max(0,(A + B - N)) << endl;
}

int main(int argc, const char * argv[]) {
    probA();
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B1, B2;
    scanf("%lld %lld.%lld", &A, &B1, &B2);
    cout << A * (B1 * 100 + B2) / 100 << endl;
    return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005;

int n, q;
long long m;
int a[N], b[N], c[N];

struct DSU {
	int fa[N];

	void init() {
		for (int i = 0; i < n; ++i) {
			fa[i] = i;
		}
	}

	int find(int x) {
		return fa[x] == x ? x : (fa[x] = find(fa[x]));
	}

	bool merge(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) {
			return false;
		}
		fa[y] = x;
		return true;
	}
} D;

int main() {
	read(n), read(m), read(q);
	D.init();
	int C = n;
	for (int i = 0; i < q; ++i) {
		read(a[i]), read(b[i]), read(c[i]);
		if (!c[i]) {
			C -= D.merge(a[i], b[i]);
		}
	}
	bool flag = 0;
	for (int i = 0; i < q; ++i) {
		if (c[i]) {
			flag = 1;
			if (D.find(a[i]) == D.find(b[i])) {
				printStr("No");
				return 0;
			}
		}
	}
	if (m == n - 1) {
		printStr(flag ? "No": "Yes");
		return 0;
	}
	if (C <= 2) {
		printStr("No");
		return 0;
	}
	if (n <= m && m <= n - C + 1ll * C * (C - 1) / 2) {
		printStr("Yes");
	} else {
		printStr("No");
	}
}


Measured memory_bytes: 6552
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
	int a1,a2,b1,b2;
	int t1,t2;
	cin >> t1 >> t2;
	cin >> a1 >> a2;
	cin >> b1 >> b2;
	int s1 = a1-b1;
	int s2 = a2-b2;
	int d1 = s1 * t1;
	int d2 = s2 * t2;
	if(d1<0){
		d1*=-1;
		d2*=-1;
	}
	// int mode = d1<0 ? -1 : 1;
	if((d1+d2) < 0){
		// 有限回
		// cerr << mode << endl;
		int dd = (d1+d2)*-1;
		int dm = d1;
		// cerr << dd << "*" << dm << endl;
		int ans = (dm/dd) * 2;
		if(dm%dd){
			ans += 1;
		}
		cout << ans << endl;
	}else if((d1+d2) == 0){
		cout << "infinity" << endl;
	}else{
		cout << "0" << endl;
	}
	// cerr << "*" << d1+d2 << endl;
}


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

using namespace std;

const int MAXN = 1E5;
int h[MAXN];

bool check(int k, int a, int b, int n)
{
    long long spells = 0;
    int over = a - b;
    for (int i = 0; i < n; i++)
    {
        spells += (max((long long) 0, (h[i] - (long long) b * k)) + over - 1)  / (over);
    }
    return spells <= k;
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    int ans = 0;
    for (int jump = 1E9; jump > 0; jump /= 2)
    {
        while ((long long) ans + jump <= 1E9 && !check(ans + jump, a, b, n))
            ans += jump;
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

struct MaxFlow{
	using D = int;
	const D inf = 1e9;
	struct edge{
		int to;
		D cap;
		int rev;
		edge(int to,D cap,int rev):to(to),cap(cap),rev(rev){}
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level,iter;

	MaxFlow(int V):V(V){
		G = vector<vector<edge>>(V);
		level = vector<int>(V);
		iter = vector<int>(V);
	}

	void add_edge(int from, int to, D cap){
		edge e1(to,cap,(int)G[to].size());
		edge e2(from,0,(int)G[from].size());
		G[from].push_back(e1);
		G[to].push_back(e2);
	}
	void bfs(int s){
		level = vector<int>(V,-1);

		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<(int)G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0 && level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	D dfs(int v,int t,D f){
		if(v==t) return f;
		for(int &i=iter[v];i<(int)G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0 && level[v]<level[e.to]){
				D d = dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	D max_flow(int s,int t){
		D flow=0;
		while(true){
			bfs(s);
			if(level[t]<0) return flow;
			iter = vector<int>(V,0);
			D f;
			while( (f=dfs(s,t,inf))>0 ) flow+=f;
		}
	}
};


int main(){
	int N;
	cin>>N;
	VV<int> A(N-1);
	VV<int> v2as(N);
	rep(i,N-1){
		int K;
		cin>>K;
		rep(j,K){
			int x;
			cin>>x;
			x--;
			A[i].pb(x);
			v2as[x].pb(i);
		}
	}
	MaxFlow MF(N-1+N+2);
	rep(i,N-1){
		for(int v:A[i]) MF.add_edge(i,v+N-1,1);
	}
	int S = N-1+N;
	int T = S+1;
	rep(i,N-1) MF.add_edge(S,i,1);
	rep(i,N) MF.add_edge(i+N-1,T,1);
	int f = MF.max_flow(S,T);
	if(f != N-1){
		puts("-1");
		return 0;
	}
	V<int> match(N-1);
	rep(i,N-1){
		for(auto e: MF.G[i]) if(N-1 <= e.to && e.to < N-1+N && e.cap == 0){
			match[i] = e.to - (N-1);
		}
	}

	
	VV<int> ans(N-1,V<int>(2,-1));
	rep(i,N-1) ans[i][0] = match[i];

	int r = 0;
	rep(i,N) r ^= i;
	rep(i,N-1) r ^= match[i];
	queue<int> que;
	que.push(r);
	
	while(!que.empty()){
		int v = que.front();
		que.pop();
		for(int i: v2as[v]) if(ans[i][0] != v && ans[i][1] == -1){
			ans[i][1] = v;
			que.push(ans[i][0]);
		}
	}
	rep(i,N-1) if(ans[i][1] == -1){
		puts("-1");
		return 0;
	}
	rep(i,N-1) cout<<ans[i][0]+1<<" "<<ans[i][1]+1<<endl;
}

Measured memory_bytes: 39300
S = input()
K = int(input())

if S[0] != S[-1]:
    ans = 0
    for i in range(len(S) - 1):
        if S[i] == S[i + 1]:
            S = S[:i + 1] + '*' + S[i + 2:]
            ans += 1
    print(ans * K)
else:
    # S -> s_1 s_2 ... s_k + A + t_l t_l-1 ... t_1 (s_i = t_j)と分解
    k, l = 0, len(S) - 1
    while k < len(S) and S[k] == S[-1]:
        k += 1
    while l > -1 and S[l] == S[0]:
        l -= 1

    # 連結に関係ない部分のカウント
    A = S[k:l + 1]
    ans = 0
    for i in range(len(A) - 1):
        if A[i + 1] == A[i]:
            A = A[:i + 1] + '*' + A[i + 2:]
            ans += 1
    ans *= K

    # 連結に関係ある部分のカウント
    if l == -1 and k == len(S):
        # 全部同じ
        print((len(S) * K) // 2)
    else:
        ans += (len(S) - l + k - 1) // 2 * (K - 1)
        ans += (len(S) - l - 1) // 2 + k // 2
        print(ans)


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

ll GCD(ll a, ll b) {
    if (a <= 0 || b <= 0) {
        return -1;
    }
    if (a > b) {
        if (a % b == 0) {
            return b;
        } else {
            GCD(b, a % b);
        }
    } else if (a < b) {
        if (b % a == 0) {
            return a;
        } else {
            GCD(a, b % a);
        }
    } else {
        return a;
    }
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> x(N+1);
    rep (i, N+1) {
        cin >> x[i];
    }

    sort(x.rbegin(), x.rend());

    vector<ll> diff(N);

    ll ans = 0;
    if (N == 1) {
        ans = x[0]-x[1];
    } else {
        ans = GCD(x[0]-x[1], x[1]-x[2]);
        for (ll i = 2; i < N; i++) {
            ans = GCD(x[i]-x[i+1], ans);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
"use strict";
const Main = input => {
    const array = input.split("");

    let result = "Good";
    for(let i = 0; i < array.length - 1; i++) {
        if(array[i] === array[i+1]) result = "Bad";
    }
    console.log(result);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int dp[45][410][410];

//
int main(){
	int N,Ma,Mb;cin>>N>>Ma>>Mb;
	vector<int> a(N),b(N),c(N);
	REP(i,N)cin>>a[i]>>b[i]>>c[i];

	fill(dp[0][0],dp[45][0],INF);

	dp[0][0][0] = 0;

	REP(i,N){
		REP(ca,401){
			REP(cb,401){
				if(dp[i][ca][cb]==INF)continue;
				dp[i+1][ca][cb] = min(dp[i+1][ca][cb],dp[i][ca][cb]);
				dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]] , dp[i][ca][cb]+c[i]);
			}
		}
	}

	int ans = INF;
	/*REPS(i,1,40){
		REP(n,N)
			ans = min(ans,dp[n][Ma*i][Mb*i]);
	}*/
	REPS(ca,1,401)
		REPS(cb,1,401)
			if(ca*Mb == cb*Ma)ans = min(ans,dp[N][ca][cb]);

	cout << (ans!=INF?ans:-1) << endl;

	return 0;
}




Measured memory_bytes: 29824
h,w,K=map(int,input().split())
data=[[0 for i in range(w+1)]]
for i in range(h):
    x=list(input())
    x.insert(0,0)
    for j in range(w+1):
        x[j]=int(x[j])
    data.append(x)
    
for i in range(h+1):
    for j in range(1,w+1):
        data[i][j]+=data[i][j-1]
        
for i in range(w+1):
    for j in range(1,h+1):
        data[j][i]+=data[j-1][i]
        


ans=10**10
for _ in range(2**(h-1)):
    st=choice=format(_,"0%ib"%(h-1))
    div=[0]
    sub=0
    for j in range(h-1):
        if st[j]=="1":
            div.append(j+1)
            sub+=1
    div.append(h)
    cnt=0
    nowindex=0
    for j in range(1,w+1):
        flag=True
        if nowindex==0:
            for k in range(1,len(div)):
                if data[div[k]][j]-data[div[k-1]][j]>K:
                    flag=False
                    break
            if flag is False:
                nowindex=j-1
                cnt+=1
                 
        else:
            for k in range(1,len(div)):
                if (data[div[k]][j]-data[div[k]][nowindex])-(data[div[k-1]][j]-data[div[k-1]][nowindex])>K:
                    flag=False
                    break
            if flag is False:
                nowindex=j-1
                cnt+=1
    subflag=True
    for k in range(1,len(div)):
        if (data[div[k]][w]-data[div[k]][nowindex])-(data[div[k-1]][w]-data[div[k-1]][nowindex])>K:
            subflag=False
    if subflag is True:
        ans=min(ans,sub+cnt)
print(ans)
                    
    

    
        
    
    


Measured memory_bytes: 46684