akhauriyash/Code-Regression huggingface dataset:
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define track  1;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

vector<pair<int, int>>v;
int n,capacity;

int dp[201][100001];

int sol(int item,int remain)
{
	d(item,remain);

	int left=0,right=0,mid=0;
	
	if(remain==0||item==(n+1))
	{
		return 0;
	}
	if(dp[item][remain]!=-1)
	{
		return dp[item][remain];
	}
	if(v[item].ff<=remain)
	{
		  left = v[item].ss+sol(item+1,remain-v[item].ff);
		  right = sol(item+1,remain); 
	}
	else
	{
		right = sol(item+1,remain);
	}
	return dp[item][remain]=max(left,right);
}






int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j,cnt=0;
	bool flag=0;
	cin>>n>>capacity;
	v.resize(n+1);

	for(i=1;i<=n;i++)
	{
		cin>>v[i].ff>>v[i].ss;
	}

	memset(dp,-1,sizeof(dp));

	d(v);

	int ans = sol(1,capacity);
	cout<<ans<<endl;


	

	

}

Measured memory_bytes: 157312
import math
while 1:
    n = int(input())
    if n == -1:
        break
    elif n == 0:
        print(0)
    else:
        p = int(math.log(n,4))

        l =[None for i in range(p)]
        x = n
        for i in range(p):
            l[i] = x // (4 ** (p - i))
            x = x % (4 ** (p - i))
        l.append(x)

        print(*l,sep="")



Measured memory_bytes: 5684
n, lw = gets.split.map(&:to_i)
w, v = Array.new(n) { gets.split.map(&:to_i) }.transpose
lv = v.sum
dp = Array.new(lv + 1) { Float::INFINITY }
dp[0] = cv = 0

n.times do |i|
  cv = [cv + v[i], lv].min

  cv.downto(v[i]) { |e| dp[e] = [dp[e], dp[e - v[i]] + w[i]].min }
end

puts dp.rindex { |e| e <= lw }


Measured memory_bytes: 15148
def main():
    n = int(input())
    arr = [int(x) for x in input().split()]
    if n == 1:
        return 0

    a, b = 0, abs(arr[0] - arr[1])
    for i in range(2, n):
        a, b = b, min(a + abs(arr[i - 2] - arr[i]),
                      b + abs(arr[i - 1] - arr[i]))
    return b


print(main())


Measured memory_bytes: 52208
#include<bits/stdc++.h>
#define N 1005
#define int long long
using namespace std;
int a[N][N],n,m,g[N][N],cnt[N];
struct data{
	int to,v;
}to[N][N];
struct data1{
	int x,t,v;
};
queue<data1>Q;
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<n;j++)scanf("%lld",&a[i][j]),g[i][a[i][j]]=j;
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++)to[i][j]=(data){a[i][j],g[a[i][j]][i]};
	}
	for(int i=1;i<=n;i++)
		if(to[i][1].v==1)Q.push((data1){i,1,1});
	int ans=0;
	while(!Q.empty()){
		data1 now=Q.front();Q.pop();
		int x=now.x,t=now.t,v=now.v;
		if(t<=cnt[x])continue;
		ans=max(ans,v);
		int y=to[x][t].to,t1=cnt[y]+1;
		cnt[x]++,cnt[y]++;
		if(to[x][cnt[x]+1].v==cnt[to[x][cnt[x]+1].to]+1)Q.push((data1){x,cnt[x]+1,v+1});
		if(to[y][cnt[y]+1].v==cnt[to[y][cnt[y]+1].to]+1)Q.push((data1){y,cnt[y]+1,v+1});
	}
	for(int i=1;i<=n;i++)
		if(cnt[i]!=n-1){puts("-1");return 0;}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31744
#include <stdio.h>

#define PRIME_MAX 1000000
int getprimes(int list[], int top){
	int i, j;
	int index = 0;
	char tmp[PRIME_MAX];

	for(i=0;i<top;i++) {
		tmp[i] = 1;
	}
	
	tmp[0] = tmp[1] = 0;
	for(i=2;i<top;i++) {
		if(tmp[i] == 1) {
			/* 素数 */
			list[index] = i;
			index ++;
			for(j=2;j*i<top;j++) {
				tmp[j*i] = 0;
			}
		}
	}

	list[index] = -1;
	return index;
}

int main(void) {
	int i, c;
	int n;
	int size;
	int primes[100000];
	size = getprimes(primes, PRIME_MAX);
	
	while(scanf("%d\n", &n) == 1) {
		c = 0;
		for(i=0;i<size;i++) {
			if(primes[i] > n) break;

			c++;
		}
		printf("%d\n", c);
	}
	
	return 0;
}

Measured memory_bytes: 1888
n = gets.to_i
nums = []
n.times { nums << gets.to_i }

sort_nums = nums.sort{|x,y| y<=>x}
max_unip = true if sort_nums[0] != sort_nums[1]

nums.each do |num|
  if num != sort_nums[0]
    puts sort_nums[0]
  elsif max_unip == true
    puts sort_nums[1]
  else
    puts sort_nums[0]
  end
end

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

using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	int n,a[100005];
	
	cin >> n;
	int ans = 1;
	bool yes = false;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
		if(a[i] == 0) yes = true;
	}
	if(yes) cout << 0 << endl;
	else
	{
		for(int i = 1;i <= n;i++)
		{
			ans*= a[i];
		}
		if(ans <= 0 || ans > 1000000000000000000) cout << -1 << endl;
		else cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
pair<string,int> a[100];
int main(){
	int t=0,g;
	string f;
	while(cin>>a[t].first>>a[t].second)t++;
	sort(a,a+t);
	cout<<a[0].first<<endl<<a[0].second;
	for(int i=1;i<t;i++){
		bool n=0;
		f=a[i].first,g=a[i].second;
		if(i)if(f==a[i-1].first)n=1;
		if(n)cout<<" "<<g;
		else cout<<endl<<f<<endl<<g;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1228
until (a = $<.gets.split.map(&:to_i)) == [0, 0]
  h, w = a
  field = Array.new(h) {$<.gets.chomp.chars}
  
  erase = ->(x, y, fruit) {
    stack = [[x, y]]
    while (a = stack.shift)
      x, y = a
      next if x < 0 or x >= w or y < 0 or y >= h
      f = field[y][x]
      next unless f == fruit
      field[y][x] = "."
      [[1, 0], [0, -1], [-1, 0], [0, 1]].each do |dx, dy|
        stack << [x + dx, y + dy]
      end
    end
  }
  
  num = 0
  i = 0
  loop do
    x, y = i % w, i / w
    i += 1
    unless field[y][x] == "."
      erase.(x, y, field[y][x])
      num += 1
    end
    break if i >= w * h
  end
  puts num
end


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
LL A[300005]={};
int main()
{
    int a;
    while(cin>>a){
        for(int i=0;i<a*3;i++){
            cin>>A[i];
        }
        sort(A,A+a*3);
        int k=0;
        LL ans=0;
        int l=0,r=a*3-1;
        while(1){
            LL t1=A[l],t2=A[r],t3=A[r-1];
            ans+=t3;
            k++;
            l++;
            r-=2;
            if(k==a)
                bk;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int N[5001]={};
int main(){

int n,x;

while(1){
scanf("%d",&n);if(n==0)break;


for(int i=0;i<n;i++)
scanf("%d",&N[i]);
int t=N[0],s=0;
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
s+=N[j];if(t<s)t=s;
}
s=0;
}
printf("%d\n",t);
}
return 0;
}

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

int n, s[100];
int sum[100];

int main(void){
  cin >> n;
  bool flag = true;
  for(int i = 0; i < n; i++){
    cin >> s[i];
    if(s[i] % 10 == 0){
      flag = flag & true;
    }
    else{
      flag = false;
    }
  }
  if(flag){
    cout << 0 << endl;
    return 0;
  }
  sort(s, s + n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    sum += s[i];
  }
  if(sum % 10 != 0){
    cout << sum << endl;
    return 0;
  }
  for(int i = 0; i < n; i++){
    if((sum - s[i]) % 10 != 0){
      cout << sum - s[i] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, z,sum, mn = 999999999, avg, pos, dif,k, mx, xi, yi;
const int MXN=2e5;
const ll mod=1e9+7;
ll pre[MXN];
bool prime[MXN];

bool PE ( ll x )
{
    for ( ll i = 2; i * i <= x; i+=1+(i&1))
    if ( x % i == 0 )
    return false;
    return true;
}
ll dist[MXN];
void sieve()
{
    memset(prime , 1 , sizeof prime);

    for ( ll i = 2; i * i <= MXN; i+=1+(i&1))
    if (prime[i])
    {
          for (ll j = i * i; j < MXN; j +=i)
         prime[j] = false;
    }
}

bool PR ( string s )
{
    int n = s.length();
    for ( ll i = 0; i < n / 2; i++ )
    if ( s[i] != s[n - i - 1] )
    return false;
    return true;
}

string s , o;
ll a[MXN];


bool is(string fs , string nd ) 
{ 
    int j = 0;
    int fn = fs.length();
     int nn = nd.length();

   for (int i=0; i<fn && j<nn; i++) 
      if (fs[i] == nd[j])
         j++; 
  
 
   return j==nn; 
}

ll fin (ll n)
{
        int tm = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                tm++; 
  
            else 
                tm += 2; 
        } 
    } 
    return tm; 
}

int main (void){
    
     SpeeD;
cin >> n;
c=  0;

for (int  i=   1 ;  i <= 1000000 ; i++)
for (int j=  1 ; j*i < n ; j++)
 c++;   


cout << c;

}

Measured memory_bytes: 3692
import java.io.BufferedReader
import java.util.*

fun main() = abc175a()

@OptIn(ExperimentalStdlibApi::class)
fun abc175a() = SimpleFastIOWithToken_abc175a().exec {
    val s = readString()

    val answer = (3 downTo 0).first { s.contains("R".repeat(it)) }

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc175a(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc175a.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 36176
aa,bb = map(int,input().split())
a = aa
b = bb
if aa>bb:
    a = bb
    b = aa
rx = a
ry = b

while 1:
    if rx == 0:
        break
    rx2 = ry%rx
    ry = rx
    rx = rx2

print(int(a*b/ry))

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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define V vector<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int N;  cin >> N;
    set<string>  st;
    REP(i, N){
      string s;  cin >> s;
      st.insert(s);
    }

    cout << st.size() << endl;
  	return 0;
}


Measured memory_bytes: 19248
import math

n = int(input())
s = list(map(int, input().split()))
s.sort()

cnt = 0
for i in range(n-2):
    for j in range(i, n-1):
        for k in range(j, n):
            if s[i] == s[j] or s[j] == s[k]:
                pass
            else:
                if s[i] + s[j] > s[k]:
                    cnt += 1

print(cnt)



Measured memory_bytes: 9164
#include<cstdio>
#include<cstring>
using namespace std;
int len;
char str1[100001],str2[100001];
int main()
{
    scanf("%s",str1);
    strcpy(str2,str1);
    len=strlen(str1);
    for(int i=0;i<len;i++)
        str2[len-i-1]=str1[i];
    if(strcmp(str1,str2)==0)
    {
        printf("Yes");
        return 0;
    }
    for(int i=0;i<len;i++)
        switch(str2[i])
        {
            case 'b':str2[i]='d';break;
            case 'd':str2[i]='b';break;
            case 'p':str2[i]='q';break;
            case 'q':str2[i]='p';break;
        }
    if(strcmp(str1,str2)==0)
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
typedef long long ll;

int main()
{
	int N, i;
	ll L[87];
	scanf("%d", &N);
	L[0] = 2;
	L[1] = 1;
	for (i = 2; i <= N; i++) {
		L[i] = L[i - 2] + L[i - 1];
	}
	printf("%lld\n", L[N]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 2000001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,cnt,lim;

int main()
{
    scanf("%lld",&n);
    if(n%10==3)printf("bon\n");
    else if(n%10==0||n%10==1||n%10==6||n%10==8){
        printf("pon\n");
    }
    else printf("hon\n");
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, m;
  cin >> n >> m;
  vector <size_t> a (n);
  rep (i, n) cin >> a[i];
  auto sum = accumulate (begin (a), end (a), typename iterator_traits <decltype (begin (a))>::value_type {});

  auto choosable = [&] (size_t i) { return not (a[i] * m * 4 < sum); };
  size_t cnt = 0;
  rep (i, n)
  {
    if (choosable (i)) ++ cnt;
  }
  auto ans = cnt >= m;
  cerr << cnt << endl;
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int year,month,date;
	while(1) {
		if(scanf("%d %d %d",&year,&month,&date)==-1)break;
		switch(year) {
			case 1868:
				if(month>9 || (month==9 && date>=8)) {
					printf("meiji 1 %d %d\n",month,date);
				} else {
					printf("pre-meiji\n");
				}
				break;
			case 1912:
				if(month>7 || (month==7 && date>=30)) {
					printf("taisho 1 %d %d\n",month,date);
				} else {
					printf("meiji %d %d %d\n",1912-1867,month,date);
				}
				break;
			case 1926:
				if(month>12 || (month==12 && date>=25)) {
					printf("showa 1 %d %d\n",month,date);
				} else {
					printf("taisho %d %d %d\n",1926-1911,month,date);
				}
				break;
			case 1989:
				if(month>1 || (month==1 && date>=8)) {
					printf("heisei 1 %d %d\n",month,date);
				} else {
					printf("showa %d %d %d\n",1989-1925,month,date);
				}
				break;
			default:
				if(year<1868) {
					printf("pre-meiji\n");
				} else if(year<1912) {
					printf("meiji %d %d %d\n",year-1867,month,date);
				} else if(year<1926) {
					printf("taisho %d %d %d\n",year-1911,month,date);
				} else if(year<1989) {
					printf("showa %d %d %d\n",year-1925,month,date);
				} else {
					printf("heisei %d %d %d\n",year-1988,month,date);
				}
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
int actionFunction(vector<int> &spots) {
    if(spots.size()<=1)return 0;
    vector<int> minCost(spots.size());
    for(int i=1;i<spots.size();i++) {
        minCost[i]=min({minCost[i-1]+abs(spots[i]-spots[i-1]),i-2>=0?(minCost[i-2]+abs(spots[i]-spots[i-2])):INT_MAX});
    }
    return minCost[spots.size()-1];
}
int main(void){
    vector<int> spots;
    int n,tmp;
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>tmp;
        spots.push_back(tmp);
    }
    cout<<actionFunction(spots)<<endl;
    
}


Measured memory_bytes: 1144
#include<stdio.h>
#include<string.h>
int main(){
	char p[202],s[101],a[101];
	scanf("%s%s",p,s);
	strcpy(a,p);
	if(strstr(strcat(p,a),s)==NULL){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    int i, num[n], check=0, count=0;
    for(i=0;i<n;i++){
        cin >> num[i];
    }
    while(check == 0){
        for(i=0;i<n;i++){
            if(num[i] % 2 != 0){
                check = 1;
                break;
            }
            else{
                num[i] /= 2;
            }
        }
        if(check == 0) count++;
    }
    cout << count << endl;
}

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

#define A

const int vmax=100010;

vector<int> graph[vmax],ord,low,scc,par;
stack<int>s;

void dfs(int v,int p,int &k){
	ord[v]=k++;
	low[v]=ord[v];
	par[v]=p;
	#ifdef S
		s.push(v);
	#endif
	for(auto &i:graph[v]){
		if(ord[i]==-1){
			dfs(i,v,k);
			low[v]=min(low[v],low[i]);

		#ifdef S
			}else if(scc[i]==-1){
		#else
			}else if(i!=p){
		#endif
			low[v]=min(low[v],ord[i]);
		}
	}
	#ifdef S
		if(ord[v]==low[v]){
			while(1){
				int u=s.top();s.pop();
				scc[u]=v;
				if(u==v) break;
			}
		}
	#endif
}

void lowlink(int n){
	int k=0;
	ord.assign(n,-1),low.resize(n);
	scc.assign(n,-1),par.resize(n);
	rep(i,n) if(ord[i]==-1) dfs(i,-1,k);
}

int main(void){
	int v,e;
	cin >> v >> e;
	rep(loop,e){
		int a,b;
		cin >> a >> b;
		graph[a].push_back(b);
		#ifdef S
		#else
			graph[b].push_back(a); // B,A
		#endif
	}
	lowlink(v);

/*	rep(i,v){
		cout << "ord[" << i << "]=" << ord[i]  << endl;
		cout << "low[" << i << "]=" << low[i]  << endl;
	}
*/

// Bridge
#ifdef B
	vector<pair<int,int>> bridge;
	rep(i,v){
		int j=par[i];
		if(j==-1)
			continue;
		if(ord[i] < low[j] || ord[j] < low[i] ){
			auto in=make_pair(i,j);
			if(in.second<=in.first) swap(in.first,in.second);
			bridge.push_back(in);
		}
	}
	sort(bridge.begin(),bridge.end());
	for(auto &i:bridge)
		cout << i.first << " " << i.second << endl;
#endif

// Articulation Points
#ifdef A
	vector<int> articulation_point;
	rep(i,v){
		if(i){
			bool ok=false;
			for(auto &j:graph[i]){
				if(i==par[j]&&ord[i]<=low[j])
					ok=true;
			}
			if(ok) articulation_point.push_back(i);
		}else{
			int d=0;
			rep(j,v) if(par[j]==0) d++;
			if(d>=2) articulation_point.push_back(i);
		}
	}
	sort(articulation_point.begin(),articulation_point.end());
	for(auto &i:articulation_point)
		cout << i << endl;
#endif
// Strongly Connected Components
#ifdef S
	int q;
	cin >> q;
	rep(loop,q){
		int a,b;
		cin >> a >> b;
		cout << (scc[a]==scc[b]) << endl;
	}
#endif
	return 0;
}

Measured memory_bytes: 4988
use std::cmp::min;
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn read_str_as_char_vec() -> Vec<char> {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().chars().collect()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let n = in_vec[0];
    let a = in_vec[1];
    let b = in_vec[2];

    let mut res = n / (a + b) * a;

    let margin = n % (a + b);
    res += min(margin, a);

    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 110000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;



struct warshall_floyd {
    vector<vector<ll>> d;
    int V;
    warshall_floyd(int v){
        V = v;
        d.assign(V,vector<ll>(V,infl));
        rep(i,V) d[i][i] = 0;
    }
    void solve_d(){
        rep(k,V) rep(i,V) rep(j,V) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    }
    ll dir(int a, int b){
        return d[a][b];
    }
};



int main()
{

    int N,M,L;
    cin >> N >> M >> L;
    warshall_floyd G(N);
    rep(i,M) {
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        G.d[a][b] = c;
        G.d[b][a] = c;
    }
    G.solve_d();
    
    
    int Q;
    cin >> Q;
    
    warshall_floyd Gr(N);
    rep(i,N) rep(j,N) {
        if(i==j) continue;
        if(G.d[i][j] <= L) Gr.d[i][j] = 1;
    }
    Gr.solve_d();

    vi s(Q),t(Q);
    rep(i,Q) cin >> s[i] >> t[i];
    
    rep(i,Q){
        if(Gr.dir(s[i]-1,t[i]-1) < infl) cout << Gr.dir(s[i]-1,t[i]-1)-1 << endl;
        else cout << -1 << endl;
    }
    
    

    return 0;
}


Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
namespace I_am_the_brown_coder{
    class ABC10000000{
        static void Main(){
            string[] n_m = Console.ReadLine().Split();
            int n = int.Parse(n_m[0]);
            int m = int.Parse(n_m[1]);
            List<int>[] sw = new List<int>[n];
            for(int i=0;i<n;i++){
                sw[i] = new List<int>();
            }
            for(int i=0;i<m;i++){
                string[] input = Console.ReadLine().Split();
                for(int j=0;j<int.Parse(input[0]);j++){
                    sw[int.Parse(input[j+1])-1].Add(i);
                }
            }
            string[] ps = Console.ReadLine().Split();
            int[] p = new int[m];
            for(int i=0;i<m;i++){
                p[i] = int.Parse(ps[i]);
            }
            bool[] dnonoff = new bool[m];
            for(int i =0;i<m;i++){
                if(p[i]==0){
                    dnonoff[i] = true;
                }
            }
            int ans = 0;
            Stack<int[]> st = new Stack<int[]>();
          st.Push(new int[]{0,1});
            st.Push(new int[]{0,0});
            
            while(st.Count>0){
                int[] ima = st.Pop();
                if(ima[1]>0){
                    foreach(int i in sw[ima[0]]){
                        dnonoff[i] = !dnonoff[i];
                    }
                }
                if(ima[0]==n-1){
                    bool allon = true;
                    for(int i=0;i<m;i++){
                        if(!dnonoff[i]){
                            allon = false;
                        }
                    }
                    if(allon){
                        ans += 1;
                    }
                    if(ima[1]>0){foreach(int i in sw[ima[0]]){
                        dnonoff[i] = !dnonoff[i];
                    }}
                }else{
                    st.Push(new int[]{ima[0]+1,1});
                    st.Push(new int[]{ima[0]+1,0});
                    
                }
            }

            Console.WriteLine(ans);
        }

    }
}

Measured memory_bytes: 13396
## for use in beginner level questions where speed is key
## and also for single test case code
## mastercopy for x,y,z

import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict

# read line as a string
# strr = input()

# read line as an integer
a,b,c = list(map(int,input().split()))
k = int(input())

# read one line and parse each word as a string
# lst = input().split()

# read one line and parse each word as an integer

cnt = 0

while b <= a:
    cnt += 1 
    b = b*2

while c <= b:
    cnt += 1 
    c = c*2

# print(cnt, a, b, c)

if cnt <= k:
    print("Yes")
else:
    print("No")


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


typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

#define DEBUG

void solve(long long X){
    int i=1;
    ll money = 100;
    while(true){
        money += money/100;
        if(money >= X){
            break;
        }
        i++;
    }

    cout << i << endl;
}

// 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 X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

const int MAX = 200000;

int main(){
    int k, n, a[MAX],d[MAX];
    cin >> k >> n;
    rep(i,n) cin >> a[i];
    
    for(int i = 1; i < n; i++){
        d[i] = a[i] - a[i-1];
    }
    d[0] = a[0] + k - a[n-1];

    int res = 0;
    rep(i,n){
        res = max(res,d[i]);
    }

    cout << k - res << endl;
}

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

int main() {
    string s;
    cin >> s;
    ll res = 0;
    for(ll i=0; i<s.size(); i++){
        res += (int)(s[i]-'0');
    }
    if(res%9==0) cout << "Yes" ;
    else cout << "No";
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    n=n-1;
    cout<<(n*(n+1))/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int l(int x,int y,int d[][14],int f[][14]){
  if(d[x][y]==0)
    return 0;
  if(f[x][y])
    return 0;
  f[x][y]=1;
  l(x-1,y,d,f);
  l(x,y-1,d,f);
  l(x+1,y,d,f);
  l(x,y+1,d,f);
  return 1;
}
int main(){
  int i,j;
  int d[14][14],f[14][14],n;
  memset(d,0,sizeof(d));
  char s[13];
  for(;;){
    for(i=0+1;i<12+1;i++){
      if(scanf("%s",s)==-1)
	break;
      for(j=0+1;j<12+1;j++)
	d[j][i]=s[j-1]-'0';
    }
    if(i!=12+1)
      break;
    memset(f,0,sizeof(f));
    n=0;
    for(i=0+1;i<12+1;i++){
      for(j=0+1;j<12+1;j++){
	if(l(i,j,d,f))
	  n++;
      }
    }
    printf("%d\n",n);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char S[201];

    scanf("%s", S);

    int len = strlen(S);

    int k = 0;

    for(int i = 1; i < len; i++){
        if((len-i) % 2 == 0){
            int f = 0;
            for(int j = 0; j < (len-i)/2; j++){
                if(S[j] != S[j+(len-i)/2]){
                    f = 1;
                    break;
                }
            }
            if(f == 0){
                k = i;
                break;
            }
        }
    }

    printf("%d\n", len-k);

    return 0;
}

Measured memory_bytes: 1696
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	A, B, C := sc.nextInt(), sc.nextInt(), sc.nextInt()
	if (A != B && B != C && A != C) || (A == B && B == C) {
		fmt.Fprintln(wtr, "No")
	} else {
		fmt.Fprintln(wtr, "Yes")
	}
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 110
#define MAXK 100500

int win[MAXK];
int a[MAXN];
int n, k;

int main() {
    scanf("%i%i", &n, &k);
    for(int i = 0; i < n; ++i) scanf("%i", &a[i]);

    for(int i = 0; i <= k; ++i) {
        win[i] = 0;
        for(int j = 0; j < n; ++j)
            if (i >= a[j] && !win[i - a[j]]) {
                win[i] = 1;
                break;
            }
        //printf("%i: %i\n", i, win[i]);
    }

    if (win[k]) printf("First\n"); else printf("Second\n");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
int mod = 1000000007;
using namespace std;
set <int>s;
int main()
{
    string str1,str2,str3;
    int a,b;
    while(cin>>a)
    {  
       s.clear();
       for(int i=1;i<=a;i++)
         {cin>>b;s.insert(b);}
         if(s.size()!=a)
         cout<<"NO"<<endl;
         else 
         cout<<"YES"<<endl;
    }
     
   return 0;   
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res%mod)*(x%mod))%mod;
        }
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}

  int c[21],n,a[21][21],check;

  ll dp[21][1<<21];

  ll fn(ll id,ll mask){

      if(id==n)return mask==check;

      if(dp[id][mask]!=-1)return dp[id][mask];

      ll res=0;

      for(int i=0;i<n;i++){
        if(!(mask&(1<<i))&&a[id][i]){
          mask|=(1<<i);
          res+=fn(id+1,mask);
          res%=mod;
          mask^=(1<<i);
        }

      }

      return dp[id][mask]=res;
  }
  

int main(){

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

  auto start = chrono::high_resolution_clock::now();

  
 

 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
  #endif*/

   cin>>n;
   mst(dp,-1);
   
   for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
   }

   check=(1<<n)-1;

   cout<<fn(0,0);
   



  auto end = chrono::high_resolution_clock::now();

 /* #ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

Measured memory_bytes: 347720
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let iter = buf.split_whitespace();
    let mut v: Vec<T> = Vec::new();
    for i in iter {
        v.push(i.parse().ok().unwrap());
    }
    v
}

fn main() {
    let a:u32 = procon_read()[0];
    println!("{}", a + a*a + a*a*a);
}

Measured memory_bytes: 2084
n = int(input())
li = [0]*n
for i in range(n):
  li[i] = input().split()
  li[i] = li[i] + [i]

li = sorted(li, key=lambda x:(x[0],-int(x[1])))
for i in range(n):
  print(li[i][2]+1)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

offset = []
for n in range(N):
	offset.append(A[n] - B[n])

offset.sort()

count = 0
sum_minus = 0
for n in offset:
	if 0 <= n:
		break
	count += 1
	sum_minus += n

for n in offset[::-1]:
	if 0 <= sum_minus:
		break
	if n < 0:
		count = -1
		break
	count += 1
	sum_minus += n

print(count)


Measured memory_bytes: 19536
local n,q=io.read("n","n","l")
local s=io.read()
local t={0}
for i=1,n-1 do
    t[i+1]=t[i]+(s:sub(i,i+1)=="AC" and 1 or 0)
end
for i=1,q do
    local l,r=io.read("n","n")
    print(t[r]-t[l])
end

Measured memory_bytes: 5012
#include <stdio.h>

int main(void)
{
	int day[13][32];
	int i, j;
	int n = 4;
	int month;
	int da;
	
	for (i = 1; i <= 12; i++){
		 if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12){
			for (j = 1; j <= 31; j++){
				day[i][j] = n;
				n++;
				if (n == 8){
					n = 1;
				}
			}
		}
		else if (i == 4 || i == 6 || i == 9 || i == 11){
			for (j = 1; j <= 30; j++){
				day[i][j] = n;
				n++;
				if (n == 8){
					n = 1;
				}
			}
		}
		else if (i == 2){
			for (j = 1; j <= 29; j++){
				day[i][j] = n;
				n++;
				if (n == 8){
					n = 1;
				}
			}
		}
	}
	
	while (1){
		
		scanf("%d %d", &month, &da);
		if (month == 0){
			return (0);
		}
		
		//printf("%d\n", day[month][da]);
		
		switch (day[month][da]){
			case 1:
			printf("Monday\n");
			break;
			
			case 2:
			printf("Tuesday\n");
			break;
			
			case 3:
			printf("Wednesday\n");
			break;
			
			case 4:
			printf("Thursday\n");
			break;
			
			case 5:
			printf("Friday\n");
			break;
			
			case 6:
			printf("Saturday\n");
			break;
			
			case 7:
			printf("Sunday\n");
			break;
		}
	}
}

Measured memory_bytes: 1012
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
#define kl k<<1
#define kr k<<1|1
using namespace std;
const int inf=1e9;
const int MAX_N=2e5+5;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
struct node{ int l,r,mn,lazy,tag; };
struct SegTree{//Î¬»¤Çø¼äºÍ
	node tr[MAX_N<<2];
	void pushup(int k){ tr[k].mn=min(tr[kl].mn,tr[kr].mn); }
	void pushdown(int k)
	{
		if(!tr[k].lazy) return;
		puttag(kl,tr[k].tag),puttag(kr,tr[k].tag);
		tr[k].lazy=0;
	}	
	void puttag(int k,int tag)
	{
		tr[k].tag=tag,tr[k].lazy=1,tr[k].mn=tag+tr[k].l;
	}
	void build(int k,int l,int r)
	{
		tr[k].l=l,tr[k].r=r,tr[k].lazy=0;
		if(l==r) { tr[k].mn=1; return; }//valÎª¶ÔÓ¦µãÖµ
		int mid=(l+r)>>1; build(kl,l,mid),build(kr,mid+1,r); pushup(k);
	}

	void update_interval(int k,int l,int r,int val)//Çø¼äÐÞ¸Ä
	{
		if(l<=tr[k].l&&tr[k].r<=r){ puttag(k,val); return; }
		pushdown(k);
		int mid=(tr[k].l+tr[k].r)>>1;
		if(l<=mid) update_interval(kl,l,r,val);
		if(r>mid) update_interval(kr,l,r,val);
		pushup(k);
	} 	
	int query_interval(int k,int l,int r)//Çø¼ä²éÑ¯
	{
		if(l<=tr[k].l&&tr[k].r<=r) return tr[k].mn;
		pushdown(k);
		int mid=(tr[k].l+tr[k].r)>>1;
		int ans=inf;
		if(l<=mid) ans=min(ans,query_interval(kl,l,r));
		if(r>mid) ans=min(ans,query_interval(kr,l,r));
		return ans;
	}
}Tr;
int main()
{
	int h=qi(),w=qi(); Tr.build(1,1,w);
	repi(i,1,h){
		int l=qi(),r=qi();
		int val=((l-1)?Tr.query_interval(1,l-1,l-1):inf);
		Tr.update_interval(1,l,r,val-l+1);
		int res=Tr.query_interval(1,1,w);
		if(res>w) puts("-1");
		else printf("%d\n",res+i-1);
	}
	return 0;
}


Measured memory_bytes: 13996
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a+b==15)
		printf("+");
	else
		if(a*b==15)
			printf("*");
		else
			printf("x");
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> u(41, 0);
    for (int i = 0; i < n; ++i) {
        ll tmp;
        cin >> tmp;
        for (int j = 0; j < 41; ++j) {
            u[40-j] += ((tmp >> j) & 1);
        }
    }
    int p = 41;
    string s;
    for (int i = 0; i < p; ++i) {
        s += (char)('0' + (k >> i & 1));
    }
    reverse(s.begin(), s.end());
    auto dp = make_v(p+1, 2, -1LL);
    dp[0][0] = 0;
    for (int i = 0; i < p; ++i) {
        for (int j = 0; j < 2; ++j) {
            if(dp[i][j] < 0) continue;
            int x = j ? 1 : s[i] - '0';
            for (int d = 0; d <= x; ++d) {
                ll y = (1LL << (p-i-1));
                ll tmp = (d == 0 ? u[i] : n-u[i])*y;
                dp[i+1][j || d < x] = max(dp[i+1][j || d < x], dp[i][j] + tmp);
            }
        }
    }
    cout << max(dp[p][0], dp[p][1]) << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int dp[100][1 << 8];
const int MOD = 1000000000 + 7;
const int BAD_PATTERN = (0 << 4) | (2 << 2) | (1 << 0);

string acgt = "ACGT";

void printStat(int stat)
{
	for (int i = 3; i >= 0; --i)
	{
		cout << acgt[((stat >> (i * 2)) & 3)] << ", ";
	}
	cout << endl;
}

int swapStat(int stat, int x, int y)
{
	int statArr[4];
	int swappedStat = 0;

	for (int i = 0; i < 4; ++i)
	{
		statArr[i] = (stat >> (i * 2)) & 3;
	}

	swap(statArr[x], statArr[y]);
		
	for (int i = 0; i < 4; ++i)
	{
		swappedStat = swappedStat | (statArr[i] << (i * 2));
	}

	return swappedStat;
}

bool check(int stat)
{
	if ((stat & ((1 << 6) - 1)) == BAD_PATTERN)
	{
		return false;
	}
	if (((stat >> 2) & ((1 << 6) - 1)) == BAD_PATTERN)
	{
		return false;
	}

	for (int i = 0; i < 3; ++i)
	{
		int swappedStat = swapStat(stat, i, i + 1);
		if ((swappedStat & ((1 << 6) - 1)) == BAD_PATTERN)
		{
			return false;
		}
		if (((swappedStat >> 2) & ((1 << 6) - 1)) == BAD_PATTERN)
		{
			return false;
		}
	}

	return true;
}

int solve(int n, int prevStat)
{
	if (n == 0)
	{
		return 1;
	}

	if (dp[n][prevStat] != -1)
	{
		return dp[n][prevStat];
	}

	int ret = 0;

	for (int i = 0; i < 4; ++i)
	{
		int nextStat = ((prevStat << 2) | i) & ((1 << 8) - 1);
		if (check(nextStat))
		{
			//printStat(nextStat);
			ret = (ret + solve(n - 1, (nextStat & ((1 << 6) - 1)))) % MOD;
		}
	}

	return dp[n][prevStat] = ret;
}

int main()
{
	int n;

	cin >> n;

	for (int i = 0; i < 100; ++i)
	{
		for (int j = 0; j < (1 << 8); ++j)
		{
			dp[i][j] = -1;
		}
	}

	int ans = 0;
	for (int i = 0; i < (1 << 6); ++i)
	{
		if (i == ((0 << 4) | (2 << 2) | (1 << 0))) continue;
		if (i == ((0 << 4) | (1 << 2) | (2 << 0))) continue;
		if (i == ((2 << 4) | (0 << 2) | (1 << 0))) continue;
		ans = (ans + solve(n - 3, i)) % MOD;
	}

	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}



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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    IN(string, s);
    RREPS(i, (s.size()-1)/2){
        if (s.substr(0,i)==s.substr(i,i)) {
            COUT(i*2);
            return 0;
        }
    }
}


Measured memory_bytes: 3588