akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#define y1 y11
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define NAME ""

using namespace std;
	
typedef long long ll;
typedef long double ld;

const ld PI = acos(-1.0);

const int MAXN = 300000;

const ll INF = 2ll * (ll)MAXN * (ll)MAXN;

vector <pair <ll, ll> > ans[MAXN];
int l[MAXN], r[MAXN];
int c[MAXN];
vector <pair <ll, ll> > v1;
vector <pair <ll, ll> > v2;
vector <pair <ll, ll> > n1;
vector <pair <ll, ll> > n2;
pair <ll, ll> tmp[10 * MAXN];
int sz[MAXN];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		l[i]  = r[i] = -1;
	for (int i = 2; i <= n; i++)
	{
		int p;
		cin >> p >> c[i]; 
		if (l[p] != -1) r[p] = i;
		else l[p] = i;
	}
	ll lg = 0, rg = INF;
	while (lg < rg)
	{
		ll md = (lg + rg) / 2;
		bool fail = false;
		for (int i = n; i >= 1; i--)
		{
			if (fail) continue;
			ans[i].clear();
			if (l[i] == -1)
			{
				sz[i] = 1;
				ans[i].pb(mp(0, 0));
				continue;
			}
			v1 = ans[l[i]];
			v2 = ans[r[i]];
			sz[i] = sz[l[i]] + sz[r[i]];
			int c1 = v1.size(), c2 = v2.size();
			n1.clear();
			n2.clear();
			for (int j = 0; j < c1; j++) 
				v1[j].fs += c[l[i]], v1[j].sc += c[l[i]];
			for (int j = 0; j < c2; j++)
				v2[j].fs += c[r[i]], v2[j].sc += c[r[i]];
			int p =0;
			for (int j = 0; j < c1; j++)
			{
				while ((p < c2) && (v1[j].sc + v2[p].fs <= md)) p++;
				if (p == 0) continue;
				n1.pb(mp(v1[j].fs, v2[p - 1].sc));
			}
			p = 0;
			for (int j = 0; j < c2; j++)
			{
				while ((p < c1) && (v2[j].sc + v1[p].fs <= md)) p++;
				if (p == 0) continue;
				n2.pb(mp(v2[j].fs, v1[p - 1].sc));
			}
			c1 = n1.size(), c2 = n2.size();
			int tot = c1 + c2;
			int p1 = 0, p2 = 0;
			n1.pb(mp(INF, 0));
			n2.pb(mp(INF, 0));
			for (int j = 0; j < tot; j++)
			{
				if (n1[p1] < n2[p2]) tmp[j] = n1[p1++];
				else tmp[j] = n2[p2++];
			}
			for (int j = tot - 1; j > 0; j--)
			{
				if (tmp[j].fs == tmp[j - 1].fs) tmp[j - 1].sc = min(tmp[j - 1].sc, tmp[j].sc);
			}
			ll cp = INF;
			for (int j = 0; j < tot; j++)
			{
				if (tmp[j].sc < cp)
				{
					cp = tmp[j].sc;
					ans[i].pb(tmp[j]);
				}
			}
			if (ans[i].size() == 0) fail = true;
		}
		if (fail) lg = md + 1;
		else rg = md;
	}
	cout << lg << endl;
	return 0;
}






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

const int MAXN = 100010;
int h[MAXN][3], dp[2][3];
int main() {
	int n;
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>h[i][0]>>h[i][1]>>h[i][2];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = h[0][0];
	dp[0][1] = h[0][1];
	dp[0][2] = h[0][2];
	for (int i=0; i<n; i++) 
		for (int j=0; j<3; j++) {
			dp[i%2][j] = 0;
			for (int last=0; last<3; last++)
				if (j != last)
					dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][last] + h[i][j]);
		}
	cout<<max(max(dp[(n-1)%2][0], dp[(n-1)%2][1]), dp[(n-1)%2][2])<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

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

    vector<int> p(N);
    rep(i,N){
        cin >> p[i];
    }

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

    ll ans = 0;
    rep(i, K) {
        ans += p[i];
    }

    cout << ans << endl;
}


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

int main() {
	int sx,tx,sy,ty,i;
	cin>>sx>>sy>>tx>>ty;
	for(i=0;i<tx-sx;i++){
		cout<<"R";
	}
	for(i=0;i<ty-sy;i++){
		cout<<"U";
	}
	for(i=0;i<tx-sx;i++){
		cout<<"L";
	}
	for(i=0;i<ty-sy;i++){
		cout<<"D";
	}
	cout<<"D";
	for(i=0;i<tx-sx+1;i++){
		cout<<"R";
	}
	for(i=0;i<ty-sy+1;i++){
		cout<<"U";
	}
	cout<<"LU";
	for(i=0;i<tx-sx+1;i++){
		cout<<"L";
	}
	for(i=0;i<ty-sy+1;i++){
		cout<<"D";
	}
	cout<<"R";	
}

Measured memory_bytes: 256
const lines=readlines()
state=0
input()=lines[global state+=1]
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
floatSub(s::SubString{String})=parse(Float64,s)
intLine()=map(intSub,split(input()))
function main()
    n,m=intLine()
    c=zeros(Int32,m)
    for i=1:n;for j=intLine()[2:end];c[j]+=1;end;end
    println(sum((x->x==n).(c)))
end
main()

Measured memory_bytes: 181000
N, M = map( int, input().split())
ans = 1
for i in range(1, N):
    if M%i == 0 and M//i >= N:
        ans = max( ans, i)
for i in range(N,int(M**(0.5))+2):
    if M%i == 0:
        ans = max( max( ans, i), M//i)
        break
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<pair<int,int> > adj[1000000];
int col[1000000];
int mx=0;
void dfs(int v,int p,int cant){
    int cur = 1;
    for (auto u:adj[v]){
        if (u.first==p)continue;
        while(cur==cant)cur++;
        mx=max(mx,cur);
        col[u.second]=cur++;
        dfs(u.first, v, cur-1);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back({b,i});
        adj[b].push_back({a,i});
    }
    dfs(1,0,0);
    cout<<mx<<endl;
    for (int i=1;i<n;i++)cout<<col[i]<<endl;
}

Measured memory_bytes: 32256
#include <iostream>

using namespace std;

int main()
{
    char s1[6];
    cin >> s1;
    
    if(s1[2] == s1[3] && s1[4] == s1[5]){
        cout << "Yes" << endl;
    }else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>

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

using namespace std;

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

int main(){
	static int isqrt[1000001]; // isqrt[a] := ceil(sqrt(a))
	rep(a,1001) isqrt[a*a]=a;
	for(int a=999999;a>0;a--) if(isqrt[a]==0) isqrt[a]=isqrt[a+1];

	for(int n;scanf("%d",&n),n;){
		int n2=(int)ceil(sqrt(n));

		// 上から見た面
		const int O=n2; // offset
		static int h[2000][2000];
		rep(x,n2) rep(y,n2) {
			int z2=n-(x*x+y*y);
			if(z2<=0) h[x+O][y+O]=-1;
			else      h[x+O][y+O]=isqrt[z2];
		}
		// 左上 1/4 だけ高さを決めれば、残りは対称性からわかる
		rep(x,n2) rep(y,n2) h[O-x-1][y+O]=h[O-x-1][O-y-1]=h[x+O][O-y-1]=h[x+O][y+O];

		// painting
		int cnt=0;
		static bool vis[2000][2000];
		for(int x=-n2;x<n2;x++) for(int y=-n2;y<n2;y++) vis[x+O][y+O]=false;
		for(int x=-n2;x<n2;x++) for(int y=-n2;y<n2;y++) {
			if(vis[x+O][y+O] || h[x+O][y+O]==-1) continue;
			vis[x+O][y+O]=true;

			static queue< pair<int,int> > Q;
			Q.push(make_pair(x,y));
			while(!Q.empty()){
				int xx=Q.front().first,yy=Q.front().second; Q.pop();
				rep(k,4){
					int xxx=xx+dx[k],yyy=yy+dy[k];
					if(-n2<=xxx && xxx<n2 && -n2<=yyy && yyy<n2
					&& !vis[xxx+O][yyy+O] && h[xxx+O][yyy+O]==h[x+O][y+O]){
						vis[xxx+O][yyy+O]=true;
						Q.push(make_pair(xxx,yyy));
					}
				}
			}

			cnt++;
		}

		printf("%d\n",6*cnt);
	}

	return 0;
}

Measured memory_bytes: 23000
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	ans = {}
	ans["AC"] = 0
	ans["WA"] = 0
	ans["TLE"] = 0
	ans["RE"] = 0

	for i in range(N):
		s = inputStr()
		ans[s] += 1

	print("AC x {}".format(ans["AC"]))
	print("WA x {}".format(ans["WA"]))
	print("TLE x {}".format(ans["TLE"]))
	print("RE x {}".format(ans["RE"]))

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 78568
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200000 + 100;
int Begin[Maxn], To[Maxn], Next[Maxn], e;
int N, Dp[Maxn], Tmp[Maxn];

inline void add_edge (int x, int y)
{
	To[++e] = y;
	Next[e] = Begin[x];
	Begin[x] = e;
}

inline void dfs (int x)
{
	int Cnt = 0;
	for (int i = Begin[x]; i; i = Next[i])
		dfs(To[i]);	
	for (int i = Begin[x]; i; i = Next[i])
		Tmp[++Cnt] = Dp[To[i]];
	if (!Cnt) return ;
	sort(Tmp + 1, Tmp + Cnt + 1);
	for (int i = 2; i <= Cnt; ++i)
		if (Tmp[i] <= Tmp[i - 1])
			Tmp[i] = Tmp[i - 1] + 1;
	Dp[x] = Tmp[Cnt] + 1;
}

int main()
{
#ifdef hk_cnyali
	freopen("B.in", "r", stdin);
	freopen("B.out", "w", stdout);
#endif
	scanf("%d", &N);
	for (int i = 2; i <= N; ++i)
	{
		int x;
		scanf("%d", &x);
		add_edge(x, i);
	}
	dfs(1);
	cout<<Dp[1]<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 3000;
const int MAXNUM = 3e5;
const ll MOD = 1e9+7;

struct Point{ int x, y; };

int h, w, n;
Point arr[MAXN+10];

ll fact[MAXNUM+10], invfact[MAXNUM+10];

ll mypow(ll x, ll y)
{
    if(y==0) return 1;
    if(y%2) return mypow(x, y-1)*x%MOD;
    ll t=mypow(x, y/2);
    return t*t%MOD;
}

ll comb(int n, int r)
{
    if(n<r) return 0;
    return fact[n]*invfact[r]%MOD*invfact[n-r]%MOD;
}

ll dp[MAXN+10];

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll i, j;

    fact[0]=1;
    for(i=1; i<=MAXNUM; i++) fact[i]=fact[i-1]*i%MOD;
    invfact[MAXNUM]=mypow(fact[MAXNUM], MOD-2);
    for(i=MAXNUM-1; i>=0; i--) invfact[i]=invfact[i+1]*(i+1)%MOD;

    scanf("%d%d%d", &h, &w, &n);
    for(i=0; i<n; i++) scanf("%d%d", &arr[i].x, &arr[i].y);

    sort(arr, arr+n, [](const Point& p, const Point& q)
         {
             if(p.x==q.x) return p.y<q.y;
             else return p.x<q.x;
         });

    arr[n]={h, w};
    for(i=0; i<=n; i++)
    {
        dp[i]=comb(arr[i].x+arr[i].y-2, arr[i].x-1);
        for(j=0; j<i; j++) if(arr[j].x<=arr[i].x && arr[j].y<=arr[i].y) dp[i]=(dp[i]-dp[j]*comb(arr[i].x-arr[j].x+arr[i].y-arr[j].y, arr[i].x-arr[j].x)%MOD+MOD)%MOD;
    }
    printf("%lld", dp[n]);
    return 0;
}


Measured memory_bytes: 5120
def masucnt(masu,i,j):
  if i<0 or j<0:
    return 0
  s="."
  try:
    s=masu[i][j]
  except:
    s=""
  return 1 if s=="#" else 0

h,w=map(int,input().split())
masu=[""]*h

for i in range(h):
  masu[i]=input().strip()

for i in range(h):
  for j in range(len(masu[i])):
    n=0
    s=masu[i][j]
    if s=="#":
      if j==(len(masu[i])-1):
        print("#")
      else:
        print("#",end="")
    else:
      n+=masucnt(masu,i-1,j-1)
      n+=masucnt(masu,i-1,j)
      n+=masucnt(masu,i-1,j+1)
      n+=masucnt(masu,i,j-1)
      n+=masucnt(masu,i,j+1)
      n+=masucnt(masu,i+1,j-1)
      n+=masucnt(masu,i+1,j)
      n+=masucnt(masu,i+1,j+1)
      if j==(len(masu[i])-1):
        print(n)
      else:
        print(n,end="")



Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int C = sc.nextInt();
        String S = sc.next();
    	int[] maxWorkDaysL = new int[N + 2];
    	int[] maxWorkDaysR = new int[N + 2];
    	for (int i = 0; i <= N + 1; i++) {
    		maxWorkDaysL[i] = 0;
    		maxWorkDaysR[i] = 0;
    	}
    	int prev = - C;
    	int totalWorkDays = 0;
    	for (int i = 1; i <= N; i++) {
    		if (S.charAt(i - 1) == 'o' && i > prev + C) {
    			totalWorkDays += 1;
    			prev = i;
    		}
    		maxWorkDaysL[i] = totalWorkDays;
    	}
    	prev = - C;
    	totalWorkDays = 0;
    	for (int i = 1; i <= N; i++) {
    		if (S.charAt(N - i) == 'o' && i > prev + C) {
    			totalWorkDays += 1;
    			prev = i;
    		}
    		maxWorkDaysR[N + 1 - i] = totalWorkDays;
    	}
    	for (int i = 1; i <= N; i++) {
    		if (maxWorkDaysL[i - 1] + maxWorkDaysR[i + 1] < K) {
    			System.out.println(i);
    		}
    	}
	}
}


Measured memory_bytes: 46644
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=2e5+5;

int a[mxn];
ll dp[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	a[0]=0; dp[0]=0;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		dp[i] = dp[i-1]+a[i];
	}
	for(int i=0; i<=n; i++){
		dp[i]-=i;
		dp[i] %= k;
		while(dp[i]<0)dp[i]+=k;
	}
	ll ans=0;
	int ptr=0;
	map<ll,int>mp;
	while(ptr<=n){
		if(ptr-k>=0)mp[dp[ptr-k]]--;
		ans += mp[dp[ptr]];
		mp[dp[ptr]]++;
		ptr++;
	}
	cout << ans << endl;
}	


Measured memory_bytes: 15104
N, K = gets.split.map(&:to_i)
d = []
a = []
K.times do |i|
  d[i] = gets.to_i
  a[i] = []
  a[i] = gets.split.map(&:to_i)
end

have = []
have = have.fill(0,0..N-1)

a.each do |item|
  item.each do |j|
    have[j-1] += 1
  end
end

puts have.count(0)

Measured memory_bytes: 14368
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long t,n,i;
	cin>>n;
	long long a[n],b[n]; 
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++)
	{
		if(b[n/2]<=a[i])
			cout<<b[(n/2)-1];
		else
			cout<<b[n/2];
		if(i!=n-1)
			cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5376
a,b,c=map(int,input().split())
if a == 1 and b == 0 and c == 0:
    print("Close")
elif a == 0 and b == 1 and c == 0:
    print("Close")
elif a == 0 and b == 0 and c == 0:
    print("Close")
elif a == 0 and b == 0 and c == 1:
    print("Open")
elif a == 1 and b == 1 and c == 0:
    print("Open")


Measured memory_bytes: 5596
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AtCoder.ABC066
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine(Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).OrderBy(elem => elem).Where((elem, idx) => idx < 2).Sum());
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int d,t,s;
    cin>>d>>t>>s;
    YN(d<=s*t);
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N;
vector<ll> A;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  cin >> N;
  ll ans = 0;
  rep(i, N+1){
    if (i == 0) continue;
    if (i % 5 == 0 || i % 3 == 0) continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n,k;
ll tojo[11];
ll isshu;
int main()
{
	cin>>n>>k;
	if(n<=2) {
		puts("0");
		return 0;
	}
	n-=2;
	ll s=4;
	for(ll i=0;i<11;i++){
		ll b=s;
		for(ll j=0;j<5;j++){
			if(b==k) tojo[i]++;
			b=(b+9)%11;
		}
		isshu+=tojo[i];
		s=(s+8)%11;
	}
	ll ans = (n/11)*isshu;
	for(ll i=0;i<n%11;i++){
		ans+=tojo[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
open Batteries
 
let () =
  let n = Scanf.scanf " %d %d\n" (fun n _ -> n) in
  List.init n (fun _ -> Scanf.scanf "%s\n" (fun x -> x))
  |> List.sort compare
  |> List.fold_left (fun x y -> x ^ y) ""
  |> print_endline


Measured memory_bytes: 3456
#include<iostream>
#include<string>
using namespace std;
int main(){
    string S; int K;cin>>S>>K;
    int ichinum=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='1')++ichinum;
        else break;
    }
    if(ichinum>=K)cout<<1<<endl;
    else cout<<S[ichinum]<<endl;
}

Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:break
    for i in range(h):
        if i % 2 == 0:
            print('#.'*(w // 2) + '#'*(w % 2))
        else:
            print('.#'*(w // 2) + '.'*(w % 2))
    print()


Measured memory_bytes: 5616
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		ArrayList<String> ary = new ArrayList<String>();
		int a,b,c;
		int cnt = 0;
		Scanner sc = new Scanner(System.in);
//		sc.useDelimiter("\\r\\n");

		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();

		for(int i=a;i<=b;i++){
			if(c%i==0){
				cnt++;
			}
		}
		System.out.println(cnt);

		sc.close();
	}

}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n, t;
    int m = 1001;
    cin >> n >> t;
    rep(i, n){
        int c, tt;
        cin >> c >> tt;
        if(tt <= t){
            m = min(c, m);

        }
    }
    if(m == 1001){
        cout << "TLE" << endl;
    }else{
        cout << m << endl;
    }
	//cout << "test" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, p;
    cin >> n >> m >> p;
    vector<int> a(m), b(m), c(m);
    REP(i, 0, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        c[i] = -c[i];
    }
    const ll inf = 1LL << 60;
    auto Cost = make_v(5 * n + 1, n, inf);
    Cost[0][0] = 0;
    ll ans = -inf;
    ll tmp = -inf;
    REP(i, 0, 5 * n) {
        REP(j, 0, m) {
            if (Cost[i][a[j]] == inf) continue;
            chmin(Cost[i + 1][b[j]], Cost[i][a[j]] + c[j]);
            if (b[j] == n - 1) {
                dump(Cost[i + 1][b[j]], i);
            }

            if (i < 3 * n && b[j] == n - 1) {
                chmax(ans, -Cost[i + 1][n - 1] - 1LL * (i + 1) * p);
            } else if (i >= 3 * n && b[j] == n - 1) {
                chmax(tmp, -Cost[i + 1][n - 1] - 1LL * (i + 1) * p);
            }
        }
    }
    dump(ans, tmp);
    if (ans < tmp) {
        cout << -1 << endl;
    } else {
        cout << max(ans, 0LL) << endl;
    }

    return 0;
}


Measured memory_bytes: 247040
def mi():
    return map(int, input().split())

def main():
    S = input()
    K = int(input())
    N = len(S)
    if len(set(S)) == 1:
        print(N*K//2)
    else:
        SS = S+S
        t = ''
        tt = ''
        flg = 0
        for i in range(N):
            if i and t[i-1] == S[i]:
                t += '#'
            else:
                t += S[i]

        for i in range(2*N):
            if i and tt[i-1] == SS[i]:
                tt += '#'
            else:
                tt += SS[i]

        d = tt.count('#')-t.count('#')
        print(t.count('#')+(K-1)*d)

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  vector<ll> lucas (87);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for(int i=2; i<n+1; i++){
    lucas.at(i) = lucas.at(i-2) + lucas.at(i-1);
  }
  cout << lucas.at(n) << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int t[N],x[N],y[N];
  for(int i = 0;i < N;i++)cin >> t[i] >> x[i] >> y[i];
  for(int i = 0;i < N;i++){
    if(i){
      if(t[i] - t[i - 1] >= abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])){
        if((t[i] - t[i - 1] - (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]))) % 2){
          cout << "No" << endl;
          return 0;
        }else continue;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(t[i] >= x[i] + y[i]){
        if((t[i] - x[i] - y[i]) % 2){
          cout << "No" << endl;
          return 0;
        }else continue;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int h,w;
    cin>>h>>w;
    if(h>w) swap(h,w);
    if(h==1)
    {
        print(1);
        return 0;
    }
    ll tot=1LL*h*w;
    print((tot+1)/2);
}

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

using namespace std;

int main()
{
	char input[100000];
	string str;

	int n;

	scanf("%d", &n);

	scanf("%s", input);

	str = input;

	for (int i = 0; i < str.size(); i++)
	{
		int val;
		val = str[i] - 'A';

		val = (val + n) % 26;

		str[i] = 'A' + val;
	}

	printf("%s\n", str.c_str());

	return 0;
}

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

int mod = 1000000007;

int main()
{
    int N, most = 0;
    cin >> N;
    map<string, int> list;
    for (int i = 0; i < N; i++)
    {
        string tmp;
        cin >> tmp;
        list[tmp]++;
        most = max(most, list[tmp]);
    }
    for (auto entry : list)
    {
        if (entry.second == most)
            cout << entry.first << endl;
    }
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A;
    for(int i=0; i<M; i++)
    {
    	int a;
    	cin >> a;
    	A.push_back(a);
    }

    int cost1 = 0, cost2 = 0;
    for(int i=X-1; i>0; i--)
    {
       for(int j=0; j<M; j++)
       {
       	  if(i==A[j]) cost1++;
       }
    }    

    for(int i=X+1; i<N; i++)
    {
        for(int j=0; j<M; j++)
        {
        	if(i==A[j]) cost2++;
        }
    }

    cout << min(cost1, cost2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>


bool isPalyndrome(std::string str)
{
	int p = 0, q = str.size() - 1;

	while (p < q) {
		if (str[p] != str[q]) {
			return false;
		}
		++p;
		--q;
	}

	return true;
}

std::string isStrongPalyndrome(std::string S)
{
	return (isPalyndrome(S.substr(0, (S.size() - 1) / 2)) && isPalyndrome(S.substr((S.size() + 3) / 2 - 1, S.size() - 1)) && isPalyndrome(S)) ? "Yes" : "No";
}


int main()
{
	std::string S;
	std::getline(std::cin, S);
	
	std::cout << isStrongPalyndrome(S);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    char s[100001];
    cin >> s;

    char marker = s[0];
    Int sum = 1;
    for(Int i=1; i<strlen(s); i++){
        if(s[i] == marker){
            sum++;
        }
    }
    
    if(strlen(s)-sum < sum){
        sum = strlen(s)-sum;
    }
    cout << sum*2 << endl;
    return 0;
}

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

int main() {
    int q, lcs[1100][1100], n, m;
    string X, Y;
    cin >> q;
    while(q--) {
        cin >> X >> Y;
        memset(lcs, 0, sizeof(lcs));
        n = X.size(), m = Y.size();
        X = ' ' + X, Y = ' ' + Y;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (X[i + 1] == Y[j + 1]) lcs[i + 1][j + 1] = lcs[i][j] + 1;
                else lcs[i + 1][j + 1] = max(lcs[i + 1][j], lcs[i][j + 1]);
            }
        }
        cout << lcs[n][m] << endl;
    }
    
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e5+5;
const int mxM = 1e5+5;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    int b[n][2];
    for(int i=0;i<n;i++){
        cin>>b[i][0]>>b[i][1];
    }
    string ans = "No";
    for(int i=0;i+2<n;i++){
        if(b[i][0]==b[i][1]&&b[i+1][0]==b[i+1][1]&&b[i+2][0]==b[i+2][1]){
            ans = "Yes";
            break;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    char msg[n + 1];
    scanf("\n%s", msg);

    if (n % 2 != 0)
    {
        printf("No\n");
        return 0;
    }

    char part1[n / 2 + 1];
    char part2[n / 2 + 1];
    
    for (int i = 0; i < n / 2; i++)
    {
        part1[i] = msg[i];
    }
    part1[n / 2] = '\0';
    int index = 0;
    for (int i = n / 2; i < n; i++)
    {
        part2[index] = msg[i];
        index++;
    }
    part2[n / 2] = '\0';

    if (strcmp(part1, part2))
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

double Manh(int *vx, int *vy, int n)
{
	int i;
	double d = 0;
	for (i = 0; i < n; i++)
		d += fabs(vx[i] - vy[i]);
	return d;
}
double Eucl(int *vx, int *vy, int n)
{
	int i;
	double d = 0;
	for (i = 0; i < n; i++)
		d += pow(fabs(vx[i] - vy[i]), 2);
	return sqrt(d);
}
double Mink(int *vx, int *vy, int n)
{
	int i;
	double d = 0;
	for (i = 0; i < n; i++)
		d += pow(fabs(vx[i] - vy[i]), 3);
	return pow(d, 1.0/3.0);
}
double Cheb(int *vx, int *vy, int n)
{
	int max = 0;
	int i;
	for (i = 0; i < n; i++)
		if (max == 0 ||  max < fabs(vx[i]-vy[i]))
			max = fabs(vx[i]-vy[i]);
	return max;
}

int main()
{
	int n, i;
	int vx[100] = {0};
	int vy[100] = {0};
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		vx[i] = x;
	}
	for (i = 0; i < n; i++)
	{
		int y;
		scanf("%d", &y);
		vy[i] = y;
	}
	
	printf("%f\n%f\n%f\n%f\n", 
		Manh(vx, vy, n),
		Eucl(vx, vy, n),
		Mink(vx, vy, n),
		Cheb(vx, vy, n));
	
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<pair<int, int>> d(a + b + c);
	for (int i = 0; i < a; i++) {
		cin >> d[i].first;
		d[i].second = 1;
	}
		
	for (int i = a; i < a + b; i++) {
		cin >> d[i].first;
		d[i].second = 2;
	}

	for (int i = a + b; i < a + b + c; i++) {
		cin >> d[i].first;
		d[i].second = 3;
	}
	sort(d.begin(), d.end());
	ll res = 0;
	int ac = 0;
	int bc = 0;
	int cc = 0;
	for (int i = d.size() - 1; i >= 0 && ac + bc + cc < x + y; i--) {
	        if (d[i].second == 1 && ac < x) {
			ac++;
	          	res += d[i].first;
		} else if (d[i].second == 2 && bc < y) {
			bc++;
	          	res += d[i].first;
		} else if (d[i].second == 3) {
			cc++;
	          	res += d[i].first;
		}
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

long long n, a[100005], b[100005], c[100005], cur, ans;

int main() {
	cin >> n;
	for (int i = 0; i <= n; i++) {
		cin >> a[i];
	}
	if (a[0] != 0 && n != 0 || n == 0 && a[0] >= 2) {
		cout << -1;
		return 0;
	}
	cur = 1;
	b[0] = 1;
	for (int i = 1; i <= n; i++) {
		cur = cur * 2 - a[i];
		if (cur < 0) {
			cout << -1;
			return 0;
		}
		if (cur > 1e18) cur = 1e18;
		b[i] = cur + a[i];
	}
	c[n] = a[n];
	cur = a[n];
	for (long long i = n - 1; i >= 0; i--) {
		cur += a[i];
		c[i] = cur;
	}
	for (int i = 0; i <= n; i++) {
		ans += min(b[i], c[i]);
	}
	cout << ans;
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  double n; cin>>n;
  int ans=(double)n/1.08;
  if((int)((double)ans*1.08)==n){
    cout<<ans<<endl;
  }else{
    ans++;
    if((int)((double)ans*1.08)==n){
      cout<<ans<<endl;
    }else{
      cout<<":("<<endl;
    }
  }
  
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)
	y /= 1000
	for i := 0; i <= n; i++ {
		if i*10 > y {
			break
		}
		for j := 0; j <= n-i; j++ {
			k := n - i - j
			if i*10+j*5+k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Red_or_Not(void) {

	int a; string s; cin >> a >> s;

	cout << (a >= 3200 ? s : "red") << flush;
	return;
}

void B_Resistors_in_Parallel(void) {

	int N; cin >> N;
	double denominator = 0;
	rep(loop, N) {
		int A; cin >> A;
		denominator += (1.0 / A);
	}

	cout << setprecision(20) << 1.0 / denominator << flush;
	return;
}

void C_Alchemist(void) {

	int N; cin >> N;
	vector<double> v(N); for (double& it : v)cin >> it;
	sort(v.begin(), v.end());
	double value = v[0] / pow(2, N - 1);
	for (int loop = 1; loop < N; loop++) {
		if (N - loop < 20) value += v[loop] / pow(2, N - loop);
	}

	cout << setprecision(20) << value << flush;
	return;
}

int main(void) {
	
	//A_Red_or_Not();
	//B_Resistors_in_Parallel();
	C_Alchemist();
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A,B;
	while(cin>>N>>A>>B) {
		cout<<min(A, B)<<" "<<max(0LL, A+B-N)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, M, X = map(int, input().split())
books = []
for i in range(N):
    books.append(list(map(int, input().split())))

min_total = -1
for i in range(2 ** N):
    sub = 0
    skills = [0] * M

    for j in range(N):
        if (i >> j & 0b1) == 1:
            sub += books[j][0]
            for k in range(M):
                skills[k] += books[j][k + 1]

    for k in range(M):
        if skills[k] < X:
            break
    else:
        min_total = sub if min_total == -1 else min(min_total, sub)

print(min_total)


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



int main(void)
{
    int a,b;
    cin >> a >> b;

    if (a >=13){
        cout << b << endl;
    } else if (a >= 6) {
        cout << b/2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 764
def solve(N, W):
    left, right = 0, sum(W)
    ans = [abs(right-left)]
    for w in W:
        left += w
        right -= w
        ans.append(abs(right-left))
    return min(ans)


N = int(input())
W = [int(w) for w in input().split()]
ans = solve(N, W)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;

int n, res, u, mx, y, t;

int main(){
	cin>>n;
	vector<int> vec(n, 0);
	map<int,int> m;
	map<int, bool> flag;
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
		m[vec[i]]++;
		mx = max(mx, vec[i]);
		flag[vec[i]] = false;
	}
	res = 0;
	for(auto x : m){
		if(x.second > 1)flag[x.first] = true;
		t = x.first;
		for(int r = 2; x.first * r <= mx; r+=4){
			t = x.first * r;
			if(m.count(t)){
				flag[t] = true;
			}
			t = x.first * (r + 1);
			if(m.count(t)){
				flag[t] = true;
			}
			t = x.first * (r + 2);
			if(m.count(t)){
				flag[t] = true;
			}
			t = x.first * (r + 3);
			if(m.count(t)){
				flag[t] = true;
			}
		}
	}
	for(auto x : flag)if(!x.second)res++;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 22744
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e16;

template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

char c;
map<char, char> mp;
int main() {
	cin >> c;
	mp['C'] = 'G';
	mp['G'] = 'C';
	mp['A'] = 'T';
	mp['T'] = 'A';
	cout << mp[c] << endl;
}


Measured memory_bytes: 3536
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if (a>b){
        cout << "a > b" << endl;
    }else if(a<b){
        cout << "a < b" << endl;
    }else if(a==b){
        cout << "a == b" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf")]*N
dp[0] = 0
for i in range(N - 1):
	dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
	if i < N - 2:
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print(dp[N - 1])

Measured memory_bytes: 13928
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
using namespace std;

int flag[100];

int main(){
	int n,all = 0,ans = 0,m;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> m;
		if(m >= 3200) ans++;
		else if(m >= 1 && m <= 399 && flag[1] == 0){
			all++;
			flag[1] = 1;
		}
		else if(m >= 400 && m <= 799 && flag[2] == 0){
			all++;
			flag[2] = 1;
		}
		else if(m >= 800 && m <= 1199 && flag[3] == 0){
			all++;
			flag[3] = 1;
		}
		else if(m >= 1200 && m <= 1599 && flag[4] == 0){
			all++;
			flag[4] = 1;
		}
		else if(m >= 1600 && m <= 1999 && flag[5] == 0){
			all++;
			flag[5] = 1;
		}
		else if(m >= 2000 && m <= 2399 && flag[6] == 0){
			all++;
			flag[6] = 1;
		}
		else if(m >= 2400 && m <= 2799 && flag[7] == 0){
			all++;
			flag[7] = 1;
		}
		else if(m >= 2800 && m <= 3199 && flag[8] == 0){
			all++;
			flag[8] = 1;
		}
	}
	if(ans >= 1){
		if(all == 0) cout << 1 << ' ' << ans;
		else cout << all << ' ' << all + ans;
	}
	else if(ans == 0){
		cout << all << ' ' << all;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_N 2002
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r-1);
}

int N,A,B,C,D;
ll dp[1001][1001];

ll coef[1001];

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

void mul(ll &a,ll b){
    a=a*b%MOD;
}

ll rec(int ma,int rest){
    if(rest==0) return 1;
    if(ma<A) return 0;
    if(dp[ma][rest]>=0) return dp[ma][rest];

    ll res=0;
    add(res,rec(ma-1,rest));

    ll c=coef[ma];
    for(int i=C;i<=D;i++){
        if(i*ma>rest) break;
        
        if(i>C) mul(c,comb(i*ma,ma));
        ll cost=c;
        mul(cost,comb(rest,i*ma));
        mul(cost,ifac[i]);

        ll tmp=rec(ma-1,rest-(i*ma));
        mul(tmp,cost);
        add(res,tmp);
    }
    return dp[ma][rest]=res;
}

int main(){
  cin>>N>>A>>B>>C>>D;

  for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) dp[i][j]=-1;

  setComb();
  for(int i=A;i<=B;i++){
      coef[i]=1;
      if(i*C>N) break;
      for(int j=0;j<C;j++){
          mul(coef[i],comb(i*C-i*j,i));
      }
  }

  cout<<rec(B,N)<<endl;

  return 0;
}


Measured memory_bytes: 8192
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

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

	int* table = new int[N+1];
	table[0] = -1;

	int index = 0;

	int tmp,left,right,m,replace_index;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);

		if(tmp > table[index]){
			index++;
			table[index] = tmp;
			continue;
		}

		left = 1,right = index,m = (left+right)/2;

		while(left <= right){
			if(table[m] == tmp){
				replace_index = -1;
				break;
			}else if(table[m] > tmp){
				replace_index = m;
				right = m-1;
			}else{
				left = m+1;
			}
			m = (left+right)/2;
		}

		if(replace_index != -1){
			table[replace_index] = tmp;
		}
	}

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

	return 0;
}

Measured memory_bytes: 3584