akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
A=[]
for i in range(m):
  a,b=map(int,input().split())
  C=[int(i) for i in input().split()]
  x=0
  for c in C:
    x|=(1<<(c-1))
  A.append((a,x))
DP=[float("inf")]*(2**n)
DP[0]=0
for i in range(m):
  a,x=A[i]
  for j in range(2**n):

    DP[j|x]=min(DP[j|x],DP[j]+a)

print(-1 if DP[2**n-1]==float("inf") else DP[2**n-1])

Measured memory_bytes: 47576
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int cnt = 0;
		while(x<=y){
			x *= 2;
			cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23124
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};
//mleしなければぜんぶllでかく。

ll cost(ll a,ll n){
      if(n==0||n==4){
            return a;
      }
      else if(n==1||n==3){
            if(a==0) return 2;
            else if(a%2==1) return 1;
            else return 0;
      }
      else{
            if(a==0) return 1;
            else if(a%2==1) return 0;
            else return 1;
      }
}
ll dp[200010][5];
ll a[200010];
int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      ll l;
      cin>>l;
      rep1(i,l) cin>>a[i];
      rep0(j,5) dp[0][j]=0;
      rep1(i,l)rep0(j,5){
            dp[i][j]=inf;
      }
      rep1(i,l)rep0(j,5)REP(k,j,5){
            dp[i][j]=min(dp[i][j],dp[i-1][k]+cost(a[i],j));
      }
      cout<<min({dp[l][0],dp[l][1],dp[l][2],dp[l][3],dp[l][4]})<<endl;

      return 0;
}

Measured memory_bytes: 9600
#include"bits/stdc++.h"
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<char> S(W);
  for(int i=0;i<W+2;i++){
    cout<<"#";}
  cout<<""<<endl;
  for(int x=0;x<H;x++){
  cout<<"#";
 for(int i=0;i<W;i++){
cin >> S.at(i);
   cout<<S.at(i);
  }
   
    cout<<"#"<<endl;
  }
for(int i=0;i<W+2;i++){
cout<<"#";
}}
  
  

Measured memory_bytes: 256
#include <stdio.h>
char s[101];
int d, ans;
int main() {
	scanf(" %s", s);
	for (int i = 0; i < 101; i++) {
		if (s[i] == NULL) {
			d = i;
			break;
		}
	}
	for (int i = 0; i < d; i++) {
		if (s[i] != s[d - i - 1]) {
			s[d - i - 1] = s[i];
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
MOD = 998244353
n, k = (int(x) for x in input().split())
LR = [tuple(int(x) for x in input().split()) for _ in range(k)]
LR.sort()
dp = [0] * (n + 1)
dp[1] = 1
dp[2] = -1
for i in range(1, n + 1):
    dp[i] += dp[i - 1] % MOD
    dp[i] %= MOD
    for l, r in LR:
        if i + l <= n:
            dp[i + l] += dp[i]
            dp[i + l] %= MOD
        if i + r + 1 <= n:
            dp[i + r + 1] -= dp[i]
            dp[i + r + 1] %= MOD

print(dp[n] % MOD)


Measured memory_bytes: 75248
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
#include<string>
using namespace std;
#define rep(i, n) for(int long long i=2;i<=n;i++)
#define setp(n) fixed<<setprecision(n)
int main(){
    int long long a, b;
    cin>>a>>b;
    int long long c=a*b, r, tmp;
        if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
        r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    cout<<c/b<<endl;
    return 0;
}

Measured memory_bytes: 256
h,w,k=map(int, input().split())
Black = []
for i in range(h):
    c = input()
    for j in range(w):
        if c[j] == "#":
            Black.append((i,j))
# print(Black, len(Black))

ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        a = len(Black)
        for b in Black:
            if ((i >> b[0]) & 1) or ((j >> b[1]) & 1):
            # if b[0] != i - 1 and b[1] != j - 1:
                a -= 1
        if a == k:
            ans += 1
            # print(bin(i),bin(j))
print(ans)

Measured memory_bytes: 9124
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int h,w;
vector<string> mp;
int l[2001][2001] = {0};
int r[2001][2001] = {0};
int u[2001][2001] = {0};
int d[2001][2001] = {0};
signed main(){
    
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        mp.pb(s);
    }
    for(int i = 0;i < h;i++){
        for(int j = 1;j < w;j++){
            if(mp[i][j-1] == '.')l[i][j] = l[i][j-1]+1;
            if(mp[i][j] != '.')l[i][j] = 0;
        }
    }
    for(int i = 0;i < h;i++){
        for(int j = w-2;j >= 0;j--){
            if(mp[i][j+1] == '.')r[i][j] = r[i][j+1]+1;
            if(mp[i][j] != '.')r[i][j] = 0;
        }
    }

    for(int i = 1;i < h;i++){
        for(int j = 0;j < w;j++){
            if(mp[i-1][j] == '.')u[i][j] = u[i-1][j]+1;
            if(mp[i][j] != '.')u[i][j] = 0;
        }
    }
    for(int i = h-2;i >= 0;i--){
        for(int j = 0;j < w;j++){
            if(mp[i+1][j] == '.')d[i][j] = d[i+1][j]+1;
            if(mp[i][j] != '.')d[i][j] = 0;
        }
    }
    int ans = 0;
    rep(i,h){
        rep(j,w){
            //cerr << l[i][j]  << " " <<  r[i][j] << " " <<  u[i][j]  << " " << d[i][j] << endl; 
            if(mp[i][j] == '.')ans = max(ans,l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1);
        }
    }
    cout << ans << endl;
    

    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc129.contest.atcoder.jp/tasks/abc129_a

Measured memory_bytes: 129536
N,M,a,b=gets.split.map &:to_i
z=N.times.map{['.']*M}
C=(N%2).step(N-1,2)
D=(M%2).step(M-1,2)
x=->i,j{a>0&&(z[i][j]='<';z[i][j+1]='>';a-=1)}
y=->i,j{b>0&&(z[i][j]='^';z[i+1][j]='v';b-=1)}

D.each{|j|x[0,j]} if N%2>0
C.each{|i|y[i,0]} if M%2>0
if N>2 && M>2 && N%2>0 && M%2>0 && a*b%4>0 && a>0&&b>0
	a+=1
	x[0,0];x[2,1];y[0,2]
end
C.each{|i|D.each{|j|
	if z[i][j+1]!='.'
	elsif a>0
		x[i,j];x[i+1,j]
	else
		y[i,j];y[i,j+1]
 	end
}}
if a+b>0
	puts :NO
else
	puts :YES
	puts z.map &:join
end

Measured memory_bytes: 55804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N; cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int l, r; cin >> l >> r;
        ans += r - l + 1;
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define inf (int)(1e9)

int max(int a, int b){
	return a >= b ? a : b;
}

int main(){
	int N, M, i, j, num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	scanf("%d%d", &N, &M);
	int *A = (int *)malloc(sizeof(int) * M);
	for(i = 0; i < M; i++){
		scanf("%d", &A[i]);
	}
	int *dp = (int *)malloc(sizeof(int) * (N + 1));
	dp[0] = 0;
	for(i = 1; i <= N; i++){
		dp[i] = -inf;
		for(j = 0; j < M; j++){
			if(i - num[A[j]] >= 0){
				dp[i] = max(dp[i], dp[i - num[A[j]]] + 1);
			}
		}
	}
	while(N > 0){
		for(i = 0, j = 0; i < M; i++){
			if(N - num[A[i]] >= 0 && dp[N] == dp[N - num[A[i]]] + 1){
				j = max(j, A[i]);
			}
		}
		printf("%d", j);
		N -= num[j];
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

struct TRAMP{
	char mark;
	int number;
};

int main(){
	int n,min;
	char buf[3];
	scanf("%d",&n);

	TRAMP selectArray[n],bubbleArray[n];

	for(int i = 0; i < n; i++){
		scanf("%s",buf);
		selectArray[i].mark = buf[0];
		selectArray[i].number = buf[1] - '0';
		bubbleArray[i] = selectArray[i];
	}

	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < i; j++){
			if(bubbleArray[j].number > bubbleArray[j+1].number) swap(bubbleArray[j], bubbleArray[j+1]);
		}
	}

	for(int i = 0; i < n-1; i++){
		min = i;
		for(int j = i+1; j < n; j++){
			if(selectArray[j].number < selectArray[min].number){
				min = j;
			}
		}
		if(i != min){
			swap(selectArray[i],selectArray[min]);
		}
	}

	for(int i = 0; i < n-1; i++) printf("%c%d ",bubbleArray[i].mark,bubbleArray[i].number);
	printf("%c%d\n",bubbleArray[n-1].mark,bubbleArray[n-1].number);
	printf("Stable\n");
	for(int i = 0; i < n-1; i++) printf("%c%d ",selectArray[i].mark,selectArray[i].number);
	printf("%c%d\n",selectArray[n-1].mark,selectArray[n-1].number);

	int p;
	for(p=0; p < n; p++){
		if(selectArray[p].number != bubbleArray[p].number || selectArray[p].mark != bubbleArray[p].mark)
			break;
	}
	if(p == n){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}

	return 0;
}



Measured memory_bytes: 2696
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  lint p=1000*1000*1000+7;
  cin>>N>>M;
  lint ans=1;
  if(int(abs(N-M))<=1){
    REP(i,N){
      ans*=i+1;
      ans%=p;
    }
    REP(i,M){
      ans*=i+1;
      ans%=p;
    }
    if((N+M)%2==0){
      ans*=2;
      ans%=p;
    }
  }else{
    ans=0;
  }


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 10005
int n, m, a[MN];

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

    cin >> n >> m;
    ll sm = 0;
    FOR(i, 1, m){ cin >> a[i]; sm += a[i]; }
    if(sm > n) cout << "-1\n";
    else cout << n-sm << "\n";

    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    bool flg = false;
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j <= k - i; j++)
        {
            int bb = b;
            int cc = c;
            REP(ii, i)
            {
                bb *= 2;
            }
            REP(jj, j)
            {
                cc *= 2;
            }
            if (a < bb && bb < cc)
            {
                flg = true;
            }
        }
    }
    if (flg)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<string> strList(N);
    for(int i = 0; i < N; i++) {
        cin >> strList[i];
    }
    bool loop = true;
    for(int i = 0; i < N-1; i++) {
        string str1 = strList[i], str2 = strList[i+1];
        if(str1.back() != str2.front()) loop = false;
        if(loop) {
            for(int ii = i+1; ii < N; ii++) {
                if(strList[i] == strList[ii]) {
                    loop = false;
                    break;
                }
            }
        } else {
            break;
        }
    }

    if(loop) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

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

int main() {
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};

  string s;
  cin >> s;

  reverse(s.begin(), s.end());
  rep (i, 4) reverse(divide[i].begin(), divide[i].end());

  bool ans;
  for (int i = 0; i < s.size(); i++) {
    bool can = false;
    for (int j = 0; j < 4; j++) {
      if (s.substr(i, divide[j].size()) == divide[j]) {
        i += divide[j].size() - 1;
        can = true;
        break;
      }
    }
    ans = can;
    if (!can) break; 
  }

  if (ans) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.stream.Stream;
import java.util.Collection;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BKagamiMochi solver = new BKagamiMochi();
        solver.solve(1, in, out);
        out.close();
    }

    static class BKagamiMochi {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = Integer.parseInt(in.next());
            List<Integer> l = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                l.add(Integer.parseInt(in.next()));
            }
            long ans = l.stream().sorted().distinct().count();
            out.println(ans);
        }

    }
}



Measured memory_bytes: 28884
#include<iostream>

using namespace std;

int main() {
    int num;
    cin >> num;
    int kazu[] = {100, 1};
    int flag[] = {0,0}; // YYMM, MMYY
    int input[2];
    for(int i = 0; i < 2; i++) {
        input[i] = num / kazu[i];
        num %= kazu[i];
    }
    if(input[0] > 0 && input[0] < 13) {
        flag[1] = 1;
    }
    if(input[1] > 0 && input[1] < 13) {
        flag[0] = 1;
    }

    if(flag[0] == 1 && flag[1] == 1) {
        cout << "AMBIGUOUS" << endl;
    } else if(flag[0] == 1) {
        cout << "YYMM" << endl;
    } else if(flag[1] == 1) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
x = max(list(map(int, input().split())))
y = min(list(map(int, input().split())))
if y - x > 0:
  if X < x < Y or X < y <= Y:
  	print('No War')
  else:
    print('War')
else:
  print('War')

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,ans;
	cin>>a>>b;
	set<ll> divA,divB,intersect;
	map<ll,bool> mp;
	for(ll i=1;i*i<=a;++i){
		if(a%i==0){
			divA.insert(i);
			divA.insert(a/i);
		}
	}
	for(ll i=1;i*i<=b;++i){
		if(b%i==0){
			divB.insert(i);
			divB.insert(b/i);
		}
	}
	for(auto &x:divA){
		if(divB.count(x))
			intersect.insert(x);
	}
	ans = intersect.size();
	for(auto &x:intersect){
		for(ll i=2;i*i<=x;++i){
			if(x%i==0 && (intersect.count(i) || intersect.count(x/i))){
				--ans;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cout<<setprecision(10);
#define randomINIT mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define gcj cout<<"Case #"<<tc<<": "
#define ld long double
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define MAP map<ll,ll>
#define MAPs map<ll,sl>
#define MAPv map<ll,vl>
#define mset1(x,val,n) foo(i,0,n+5) x[i]=val;
#define mset2(x,val,n,m) foo(i,0,n+5) foo(j,0,n+5) x[i][j]=val;
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define FOR(i,v) for(auto &(i):(v))
#define OUTv(v) for(auto &i:(v)) cout<<i<<" ";
#define deb1(a) cout<<a<<"\n";
#define deb2(a,b) cout<<a<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define deb4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define sl set<ll>
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

const ll   INF = 0x7f7f7f7f7f7f7f7f;
const ll NINF = -INF;
const ll MAXN  = 1e+6 + 8;

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

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()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#define UMAP unordered_map<ll,ll,custom_hash>

ll t = 1; randomINIT;
//<<-----Declare Variable Here------->>//
ll n, a[6000], dp[6000][6000], m = 0, ans = 0;

//<<-----Implement Functions Here---->>//
ll solve(ll l, ll r) {
    if (l == r) { return a[l];}
    if (dp[l][r] != INF) { return dp[l][r];}
    dp[l][r] = max(a[l] - solve(l + 1, r), a[r] - solve(l, r - 1));
    return dp[l][r];
}

//<<-----Start of Main--------------->>//
void MAIN(ll tc) {
    cin >> n;
    ll sum = 0;
    mset2(dp, INF, n, n);
    foo(i, 1, n) cin >> a[i], sum += a[i];
    ll x = solve(1, n);
    // cout << sum << " " << x << "\n";
    // cout << (sum + x) / 2 << "\n";
    cout << x << "\n";


}

int main() {
    fastio;
    // cin >> t;
    foo(i, 1, t) {
        MAIN(i);
    }

// #ifndef ONLINE_JUDGE
//  cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
}

Measured memory_bytes: 140928
# include "bits/stdc++.h"

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll INF = 1e10;
int MOD = 1e9+7;

int n, m;
vector<vector<int>> adj;
vector<bool> vis;
vector<int> in;
int ans = 0;

void dfs(int cur){
    if(vis[cur]) return;
    vis[cur] = 1;
    if(adj[cur].empty()) in[cur] = 1;
    for(auto nxt: adj[cur]){
        dfs(nxt);
        in[cur] = max(in[cur], in[nxt]+1);
    }
    ans = max(ans, in[cur]-1);
}



int main(){
    #ifndef ONLINE_JUDGE
        freopen("debug.txt", "w", stderr);
    #endif
    fastio();
    cin>>n>>m;
    adj.resize(n);
    vis.resize(n);
    in.resize(n);
    for(int i=0;i<m;++i){
        int x,y;
        cin>>x>>y;
        adj[x-1].push_back(y-1);
    }
    for(int i=0;i<n;++i)
        if(!vis[i])
            dfs(i);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11028
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


int modpow(int a,int n)
{
	int ans=1;
	while(n)
	{
		if(n%2)
			ans=(ans*a)%mod;
		a=(a*a)%mod;
		n/=2;
	}
	return ans;
}

int inv(int a)
{
	return modpow(a,mod-2);
}

signed main()
{
	fio
	
	int fact[100001];
	fact[0]=1;
	fo(i,100000)
		fact[i+1]=(fact[i]*(i+1))%mod;
	
	inp(n)
	inpa(a,n)
	vector<int> b(n-1);
	fo(i,n-1)
		b[i]=a[i+1]-a[i];
	int ans=0;
	
	// fo(i,n)
	// {
	// 	for(int j=i;j<n-1;j++)
	// 	{
	// 		int tans=(b[j]*inv(j-i+1))%mod;
			
	// 		// cerr<<i<<','<<j<<" = "<<tans<<'\n';
			
	// 		ans=(ans+tans)%mod;
	// 	}
	// }
	
	int curr=0;
	fo(i,n-1)
	{
		curr=(curr+inv(i+1))%mod;
		ans=(ans+(curr*b[i])%mod)%mod;
	}
	
	ans=(ans*fact[n-1])%mod;
	
	ans=(ans+mod)%mod;
	
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 2560
from sys import stdin

def mpow(n, p, mod):
    if mod == 0:
        return 0
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
def popcount(u):
    if u == 0:
        return 0
    a = u % bin(u).count('1')
    return 1 + popcount(a)
def main():
    input = stdin.readline
    n = int(input())
    x = '0b' + input()
    xs = int(x, 0)
    xc = x.count('1')
    xsp = mpow(xs, 1, xc + 1)
    xsm = mpow(xs, 1, xc - 1)
    for i in range(2, n + 2):
        if x[i] == '0':
            y = xsp + mpow(2, n - i + 1, xc + 1)
            y = mpow(y, 1, xc + 1)
            print(popcount(y) + 1)
        elif xc == 1:
            print(0)
        else:
            y = xsm - mpow(2, n - i + 1, xc - 1)
            y = mpow(y, 1, xc - 1)
            print(popcount(y) + 1)
main()

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

#define INF 1145141919
#define PI atan(-1)

using namespace std;

string S;

int main()
{
  cin >> S;

  bool n = false,s = false,e = false,w = false;

  for (size_t i = 0; i < S.length(); i++) {
    if(S[i] == 'N')
      n = true;
    else if(S[i] == 'S')
      s = true;
    else if(S[i] == 'E')
      e = true;
    else if(S[i] == 'W')
      w = true;
  }

  if((n ^ s) || (w ^ e)){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	string a, b;
	int temp;
	cin >> a >> b;
	temp = stoi(a + b);
	for (int i = 1; i <= 10000; i++) {
		if (i * i == temp) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
using namespace std;
stack<char> s;
string x;
int ans;
int main(){
	cin>>x;
	ans=x.length();
	for(int i=0;i<x.length();i++){		
		if(s.size()&&s.top()=='S'&&x[i]=='T'){
			ans-=2;
			s.pop();
			continue;
		}
		s.push(x[i]);
	}
	cout<<ans<<endl;
	 
	return 0;
	
} 

Measured memory_bytes: 644
import sys
operaciones = list()
p=0
lines = sys.stdin.readlines()
for linea in lines:
    c = linea.split()
    c = list(map(str,c))
list(c)
x = c[0]
a = list(x)
for k in range(len(a)):
  if a[k]== "I":
    p+=1
    operaciones.append(p)
  if a[k] == "D":
    p-=1
    operaciones.append(p)
mayor=operaciones[0]
for i in range(len(operaciones)):
    if operaciones[i]>mayor:
        mayor=operaciones[i]
if mayor <0:
  print(0)
else:  
  print(mayor)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

const ll MOD = 1000000007;
vector<vector<int>> a(25, vector<int>(25));
ll dp[1<<23];

int main() {
	int n;
	cin >> n;
	rep (i, n) rep (j, n) cin >> a[i][j];

	dp[0] = 1;
	for (int S = 1; S < (1<<n); S++) {
		int cnt = __builtin_popcount(S);
		rep (j, n) {
			if (S & 1<<j) if (a[cnt-1][j]) {
				dp[S] += dp[S^(1<<j)];
				dp[S] %= MOD;
			}
		}
	}

	cout << dp[(1<<n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  ll delta = d - c;
  b -= a;
  REP(i,n) {
    ll x = c * i - d * (n-i-1);
    if (b - x >= 0 && b - x <= delta * (n-1)) {
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 3648
# A - HonestOrDishonest
# https://atcoder.jp/contests/abc056/tasks/abc056_a

a, b = map(str, input().split())

h = 'H'
d = 'D'

result = h

if a == h:
    if b == d:
        result = d
else:
    if b == h:
        result = d
    else:
        result = h

print(result)


Measured memory_bytes: 8880
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
	int a[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,t=1;
	cin>>n;
	while(n!=4&&n!=1&&n!=2)
	{

		if(n%2==0)n/=2;
		else n=3*n+1;
		t++;
	}

		cout<<t+3;

}


Measured memory_bytes: 256
// 2020-09-20 19:53:35
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
#include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
using namespace atcoder;

// clang-format on
void answer() {
  string s;
  cin >> s;
  auto sa = suffix_array(s);
  auto lcp = lcp_array(s, sa);
  ll cnt = 0;
  for (auto x : lcp) cnt += x;
  ll ans = ll(s.size()) * (s.size() + 1) / 2 - cnt;
  cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 15552
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,m,ans=0;
    cin>>n>>m;
    if (n*2 <= m) { 
        ans = n; 
        m -= (n*2); 
        ans += m/4;
    } 
    else {
        ans = m/2;
    }
    cout << ans << endl;
}
signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int X;
	cin >> X;
	LL ans = 0;
	LL ret = 0;
	ret = X / 500;
	ans += ret * 1000;

	X -= ret * 500;

	ret = X / 5;
	ans += ret * 5;

	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int T;
    cin >> T;
    rep(t, T){
        int N;
        cin >> N;
        vector<int> L[N+1], R[N+1];
        ll sum = 0;
        rep(i, N){
            int k; ll l, r;
            cin >> k >> l >> r;
            if(l > r) sum += r, L[k].pb(l-r);
            else sum += l, R[k].pb(r-l);
        }
        priority_queue<ll, vector<ll>, greater<ll> > que;
        rep2(i, 0, N){
            for(auto &e: L[i]) que.push(e);
            while(sz(que) > i) que.pop();
        }
        while(!que.empty()) sum += que.top(), que.pop();
        rep3(i, N, 0){
            for(auto &e: R[i]) que.push(e);
            while(sz(que) > N-i) que.pop();
        }
        while(!que.empty()) sum += que.top(), que.pop();
        cout << sum << endl;
    }
}

Measured memory_bytes: 18084
S = gets.chomp
N = S.size
R, L = ?R.freeze, ?L.freeze

squares = Array.new(N, 0)

children = 0
N.times do |i|
  next(children += 1) if S[i] == R
  next if children == 0
  squares[i] += children / 2
  squares[i - 1] += (children + 1) / 2
  children = 0
end

children = 0
N.times.map {|n| N - n - 1}.each do |i|
  next(children += 1) if S[i] == L
  next if children == 0
  squares[i] += children / 2
  squares[i + 1] += (children + 1) / 2
  children = 0
end

puts squares.join(' ')


Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define mod 1000000007  
#define int long long int
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;

signed main(){
  fast_cin();
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
        float n,x;int k;
        cin>>n>>x>>k;
        int a=ceil(n/x);
        cout<<a*k<<endl;


          
          
      }
          

    

      
        


      
       
    
    
  
      

      




Measured memory_bytes: 3732
a, b = map(int, input().split())
for i in range(a + 1):
    for j in range(a + 1):
        if i + j > a:
            break
        else:
            if i * 10000 + j * 5000 + (a - i - j) * 1000 == b:
                print(i, j, a - i - j)
                exit()
print(-1, -1, -1)


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

using ll = long long int;

ll arr[100010] = {};

int main(void){
    
    int n,a,b;
    cin >> n >> a >> b;
    
    ll l = 1,r = 10000000010,ans = 10000000010;
    
    for(int i = 0; i < n ;i++){
        cin >> arr[i];
    }
    
    for(int i = 0; i < 100; i ++){
        ll mid = l+(r-l)/2;
        
        ll res = mid;
        
        for(int i = 0; i < n; i++){
            ll t = arr[i] - mid*b;
            
            if(t > 0){
                res -= (t+(a-b)-1) / (a-b);
            }
            
        }
        
        //cout << mid << " " << l << " " << r << " res:" << res << endl;
        if(res < 0){
            l = mid + 1;
        }else if(res > 0){
            r = mid - 1;
        }else{
            l = mid;
            break;
        }
        
    }
    
    cout <<l<< endl;
    
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 102
int m=0,n,t=0;
int pre[MAX],in[MAX];
int find(int c,int n,int in[]){
	int i;
	for(i=0;i<n;i++){
		if(in[i]==c)
		return i;
	}
}
void reconstruction(int l,int r){
	if(l>=r)
	return;
	int c=pre[m];
	m++;
	int mid=find(c,n,in);
	reconstruction(l,mid);
	reconstruction(mid+1,r);
	if(t)
	printf(" ");
	printf("%d",c);
	t++;
}
int main(){
	int i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&pre[i]);
	for(i=0;i<n;i++)
	scanf("%d",&in[i]);//输入
	reconstruction(0,n);
	printf("\n");
	return 0; 
} 


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;

  string s;
  cin >> s;

  bool reach_b = true;

  for(int i=B;i<D-2;i++){
    if(s[i] == '#' && s[i + 1] == '#')
    reach_b = false;
  }

  bool reach_a = true;

  if(C < D){
    for(int i=A;i<C - 2;i++){
      if(s[i] == '#' && s[i + 1] == '#')
      reach_a = false;
    }
  }

  else{
    reach_a = false;
    for(int i=B - 2;i<D - 1;i++){
      if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
      reach_a = true;
    }
    for(int i=A;i<C - 2;i++){
      if(s[i] == '#' && s[i + 1] == '#')
      reach_a = false;
    }
  }

  if(reach_a && reach_b)
  cout << "Yes" << endl;
  else
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;



void solve()
{
    vector<vector<int>> v(3, vector<int>(3));
    vector<vector<bool>> mark(3, vector<bool>(3));
    FOR(i, 0, 3)
    {
        FOR(j, 0, 3)
        {
            cin >> v[i][j];
        }
    }
    int n; cin >> n;
    FOR(k, 0, n)
    {
        int b; cin >> b;
        FOR(i, 0, 3)
        {
            FOR(j, 0, 3)
            {
                if (v[i][j] == b)
                {
                    mark[i][j] = 1;
                }
            }
        }
    }
    FOR(i, 0, 3)
    {
        if (mark[i][0] && mark[i][1] && mark[i][2])
        {
            cout << "Yes";
            return;
        }
        if (mark[0][i] && mark[1][i] && mark[2][i])
        {
            cout << "Yes";
            return;
        }
    }
    if (mark[0][0] && mark[1][1] && mark[2][2])
    {
        cout << "Yes";
        return;
    }
    if (mark[0][2] && mark[1][1] && mark[2][0])
    {
        cout << "Yes";
        return;
    }
    cout << "No";
}


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
    /*int tc; cin >> tc;
    while (tc--)*/
    solve();

    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ( a % 2 == 1 && b % 2 == 1 ){
      cout << "Odd" << endl;
  }
  else{
      cout << "Even" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int L = 0;
		int R = N;


		for (int i=0; i<M; i++) {
			int tmpL = sc.nextInt();
			int tmpR = sc.nextInt();

			L = Math.max(L, tmpL);
			R = Math.min(R, tmpR);

		}

		int ans = R-L+1;
		if (ans>0) System.out.println(ans);
		else System.out.println(0);

	}


}

Measured memory_bytes: 49096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 28)

template<typename T>
void remove(vector<T>& vector, unsigned int index){
vector.erase(vector.begin() + index);
}
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main(void){
	int n, r;
	while(cin >> n >> r, n | r){
		int card[n];
		card[0] = n;
		for(int i = 1; i < n; i++)card[i] = card[i-1]-1;
		rep(i,r){
			int p, c;
			cin >> p >> c;
			int abv[p];
			for(int j = 0; j < p-1; j++){
				abv[j] = card[j];
			}
			for(int j = 0; j < c; j++){
				card[j] = card[p-1+j];
			}
			for(int j = 0; j < p-1; j++){
				card[c+j] = abv[j];
			}
		}
		cout << card[0] << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++)cin >> L[i];
	sort(L.begin(), L.end(), greater<>());
	int longest = L[0];
	int sum = 0;
	for (int i = 1; i < N; i++)sum += L[i];
	if (longest < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n, k = map(int, input().split())

A = [-1] * n

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        x = a[j]-1
        if A[x] == -1:
            A[x] = 1

ans = 0

for i in range(n):
    if A[i] == -1:
        ans += 1

print(ans)


Measured memory_bytes: 9196
#include<stdio.h>
#include<math.h>

int main(void){

int N,K,i,j,c;
long double x=0;

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

for(j=1;j<=N;j++){
   i=j;
   c=0;
   while(i<K){
     i+=i;
     c++;
   }
   x=x+(1/(N*pow(2,c)));
}
   printf("%1.12Lf\n",x);

return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()

using ll = long long;
constexpr ll INF = 10000000000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
	int n; cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];

	int cnt = 0;
	int now = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == now) {
			now++;
		}
		else {
			cnt++;
		}
	}
	if (cnt == n) {
		cout << -1 << endl;
		return 0;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int A, B, K;
vector<int> X;

int main(){
  cin >> A >> B >> K;
  repi(i, 1, min(A, B)+1){
    if (A%i==0 && B%i==0) X.push_back(i);
  }
  cout << X[X.size()-K] << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   VEC(int,v,3);
   sort(ALL(v));
   cout<<v[0]+v[1];
}



Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def xor(n):
    if n%2==0:
        if (n//2)%2==0: return n^0
        else: return n^1
    else:
        if (n//2)%2==0: return 1
        else: return 0
    

def main():
    A, B = input_nums()
    print(xor(B)^xor(A-1))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);I++) cin >> x[i];

int main(){
  int N,ans ;
  cin >> N;
  for(int i=0;i<7;i++){
    if(pow(2,i) <= N && N < pow(2,i+1))
      ans = pow(2,i) ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

const int limit = 1050;		//eよりも大きく
const int inf = 10000000;

int d[1000];//sからの暫定最短距離
int v, e;	//頂点と辺数 //頂点は1..v
int s, g;	//スタートとゴール
struct edge {int to, cost;};
vector<edge> es[limit];

typedef pair<int, int>P;

int dijkstra(int s, int g)
{
  priority_queue<P, vector<P>, greater<P> > que;
  for (int i = 1; i < v + 1; i++)
  {
    d[i] = inf;
  }

  d[s] = 0;

  que.push(P(0, s));

  while (!que.empty())
  {
    P p = que.top();
    que.pop();
    if (d[p.second] < p.first)
    {
      continue;
    }

    int count = es[p.second].size();
    for (int loop = 0; loop < count; loop++)
    {
      edge e = es[p.second][loop];
      if (d[e.to] > d[p.second] + e.cost)
      {
        d[e.to] = d[p.second] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
  return d[g];
}

int main()
{
  cin >> v >> e;
  int a[limit], b[limit], c[limit];
  for (int i = 0; i < e; i++)
  {
    cin >> a[i] >> b[i] >> c[i];
    es[a[i]].push_back({b[i], c[i]});
    es[b[i]].push_back({a[i], c[i]});
  }
  int ans = 0;
  for (int i = 0; i < e; i++)
  {
    if (c[i] > dijkstra(a[i], b[i]))
    {
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
class _0001{
    static void Main(){
        var h = new int[10];
        for(var i=0;i<10;i++)h[i]=int.Parse(Console.ReadLine());
        Array.Sort(h);
        for(var i=0;i<3;i++)Console.WriteLine(h[9-i]);
    }
}


Measured memory_bytes: 9312