akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

void no() {
	cout << -1 << endl;
	exit(0);
}
signed main() {
	int n, a, b; cin >> n >> a >> b;
	if (a + b > n + 1)no();
	if ((n - 1) / a >= b)no();
	b -= (n - 1) / a + 1;
	rep(i, a)cout << n - a + i + 1 << " ";
	n -= a;
	while (1) {
		if (n <= 0) {
			cout << endl; return 0;
		}
		stack<int>st; queue<int>que;
		rep(i, a) {
			if (n - a + i + 1 >= 1)que.push(n - a + i + 1);
		}
		rep(i, min(a, b)) {
			int p = que.front(); que.pop(); st.push(p);
		}
		while (!que.empty()) {
			cout << que.front() << " "; que.pop();
		}
		while (!st.empty()) {
			cout << st.top() << " "; st.pop();
		}
		b -= a - 1;
		n -= a;
	}
}

Measured memory_bytes: 3456
#include<stdio.h>
 
int main(void){
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a<=2 && b<=2){ 
  printf("3\n");
  }else if(a>=2 && b>=2){
    printf("1\n");
  }else{
    printf("2\n");
  }
  return 0;
}

Measured memory_bytes: 1644
#include<stdio.h>

int main(void)
{
  int a;
  int b;
  int ans = 0;

  scanf("%d %d",&a,&b);
  // a >= b
  // a <= b
  // a > b
  // a != b
  if(a <= b){
    ans = a ;
  }
  else {
    ans = a - 1;
  }
  if(a == b && b == 1){
    ans = 1;
  }

  printf("%d",ans);

  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const ll MOD = 1e9+7;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;

 int main() {
     int n;
     cin >> n;
     vector<ll> x(n);
     vector<ll> y(n);
     rep(i,n) cin >> x[i] >> y[i];
     vector<ll> mx(n);
     vector<ll> my(n);
     rep(i,n) mx[i] = x[i]-y[i];
     rep(i,n) my[i] = x[i]+y[i];
     sort(mx.begin(),mx.end());
     sort(my.begin(),my.end());
     ll ans = max(mx.back()-mx[0],my.back()-my[0]);

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

Measured memory_bytes: 9572
#include<stdio.h>
int main()
{
int A,B;
scanf("%d %d",&A,&B);
if(A==1 && B==2)
printf("3");
else if(A==2 && B==3)
printf("1");
else if(A==1 && B==3)
printf("2");
if(A==2 && B==1)
printf("3");
if(A==3 && B==2)
printf("1");
if(A==3 && B==1)
printf("2");
return 0;
}


Measured memory_bytes: 128
unittest
{
	assert( [ "4 6", "2 1", "3 4", "4 10", "3 4" ].parse.expand.solve == 11 );
	assert( [ "4 6", "2 1", "3 7", "4 10", "3 6" ].parse.expand.solve == 13 );
	assert( [ "4 10", "1 100", "1 100", "1 100", "1 100" ].parse.expand.solve == 400 );
	assert( [ "4 1", "10 100", "10 100", "10 100", "10 100" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nw = input.front.split.to!( long[] );
	auto wvs = new long[ 2 ][ nw[ 0 ] ];
	foreach( ref wv; wvs )
	{
		input.popFront;
		wv = input.front.split.to!( long[] );
	}
	return tuple( nw[ 1 ], wvs );
}

auto solve( long wt, long[ 2 ][] wvs )
{
	wvs.multiSort!( ( a, b ) => b[ 0 ] < a[ 0 ], ( a, b ) => b[ 1 ] < a[ 1 ] );
	
	// 重さごとに分けて、価値の高い順で累積和表を作成
	auto sss = new long[][ 4 ];
	auto wm = wvs[ 0 ][ 0 ];
	foreach( i, ref ss; sss )
	{
		ss = [ 0 ];
		while( !wvs.empty && wvs.front[ 0 ] == wm - i )
		{
			ss ~= ss[ $ - 1 ] + wvs.front[ 1 ];
			wvs.popFront;
		}
	}
	
	// 重さwt以内で価値が最大になるパターンを全検索
	auto ans = 0L;
	foreach( c1, s1; sss[ 0 ] )
	{
		auto w1 = wm * c1;
		if( wt < w1 ) break;
		
		foreach( c2, s2; sss[ 1 ] )
		{
			auto w2 = ( wm - 1 ) * c2;
			if( wt < w1 + w2 ) break;
			
			foreach( c3, s3; sss[ 2 ] )
			{
				auto w3 = ( wm - 2 ) * c3;
				if( wt < w1 + w2 + w3 ) break;
				
				foreach( c4, s4; sss[ 3 ] )
				{
					auto w4 = ( wm - 3 ) * c4;
					if( wt < w1 + w2 + w3 + w4 ) break;
					
					ans = max( ans, s1 + s2 + s3 + s4 );
				}
			}
		}
	}
	return ans;
}


Measured memory_bytes: 256
num = gets.chomp.to_i
num.times do |n|
    x1, y1, x2, y2, x3, y3, x4, y4 = gets.chomp.split(" ").map(&:to_f)
    if y2 == y1 || y4 == y3
        if y2 == y1 && y4 == y3
            puts "YES"
        else
            puts "NO"
        end
        next
    elsif ((x2 - x1)/(y2 - y1) - (x4 - x3)/(y4 - y3)).abs < 1e-10
        puts "YES"
    else
        puts "NO"
    end
end

Measured memory_bytes: 8620
using namespace std;
//#include <bits/stdint.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/
int main(){
    string s, t;
    cin >> s >> t;
    bool f = true;
    REP(i,s.size()){
        if(s[i]!=t[i]){
            f=false;
            break;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

b = {}
for c in a:
    try:
        b[c] += 1
    except:
        b[c] = 1


pow2 = 1
while pow2 <= a[0]:
    pow2 *= 2
# print(a, pow2)
cnt = 0
for aa in a:
    while  aa < (pow2//2):
        pow2 //= 2
    
    v = aa
    rem = pow2 - aa
    # print(aa, pow2, v, rem)
    if (not v in b) or (not rem in b):
        continue

    if rem != v and (b[v] > 0 and b[rem] > 0):
        hit = min(b[v], b[rem])
        cnt += hit
        b[v] -= hit
        b[rem] -= hit
    elif rem == v and b[v] > 1:
        cnt += b[v]//2
        b[v] = b[v]%2

print(cnt)



# b = {}
# c = {}
# # print(a)
# for e,i in enumerate(a):
#     b[i] = (e, [(x[0]+e+1, x[1]) for x in enumerate(a[e+1:])])

# # print(b)
# for be in b: # (3, (0, [(1,5),...]) in [3,5,..]
#     for j in b[be][1]:
#         try:
#             if (not (b[be][0], j[0]) in c[be+j[1]]):
#                 # c[be + j[1]].append(b[be][0])
#                 # c[be + j[1]].append(j[0])
#                 c[be+j[1]].append((b[be][0], j[0]))
#         except:
#             c[be + j[1]]  = [(b[be][0], j[0])]
#             # c[be + j[1]].append(b[be][0])
#             # c[be + j[1]].append(j[0])


# # print("c: ", c)
# d= []

# twopowerlist = [2**p for p in range(30)]
# for n in twopowerlist:
#     try:
#         # print(n, c[n])
#         # d[n] = len(c[n])//2
#         d.append(c[n])
#     except:
#         pass
# d.sort(key=lambda x:len(x))
# d.reverse()

# for p in [x for y in d[0] for x in y]:
#     # print("p:",  p)
#     for e,q in enumerate(d[1:]):
#         for j in q:
#             if p in j:
#                 try:
#                     d.pop(e+1)
#                 except:
#                     pass

# # print(d)
# print(len(d[0]))






###########################3



# b = {}
# c = {}
# for e,i in enumerate(a):
#     b[i] = [copy.deepcopy(a)[e+1:], 1]
#     c[i] = 1

# for be in b:
#     for j in b[be][0]:
#         try:
#             c[j+be] += 1
#         except:
#             c[j+be] = 1


# sum = 0
# for n in twopowerlist:
#     try:
#         sum += c[n]
#     except:
#         pass
# print("list: ", c)
# print(sum)

Measured memory_bytes: 33696
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;

int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    if (A > B)
    {
        cout << 0 << endl;
    }
    else if (N == 1)
    {
        if (A == B)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
    else
    {
        cout << (N - 2) * (B - A) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int solve(const vector<int>& a, const int n) {
  int ans = 1 << 30;
  for (int i = -100; i <= 100; ++i) {
    int sum {};
    for (auto e : a) {
      sum += (e - i) * (e - i);
    }
    ans = min(ans, sum);
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  cout << solve(a, n) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//世の中いろいろあるんだなぁ

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int K = N / 2;
	int A[200000];
	rep(i, N) A[i] = getint() - i - 1;

	nth_element(A, A + K, A + N);

	ll kotae = 0;
	rep(i, N) kotae += abs(A[i] - A[K]);
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(T N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {

	const int r = inputVal<int>();
	outputVal((r*r));
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,x,i,j,k,temp,d,count;
	while(~scanf("%d %d %d %d", &a, &b, &c, &x))
    {
        count = 0;
		x/=50;
		for(i=0; i<=a; i++)
			for(j=0; j<=b; j++)
				for(k=0; k<=c; k++)
					if(i*10+j*2+k==x)
						count++;
		printf("%d\n", count);
    }

	return 0;
}


Measured memory_bytes: 256
#line 1 "/home/parallels/kyopro/cplib/template.cpp"
#include<bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;

void lyn(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

#line 1 "/home/parallels/kyopro/cplib/debug.cpp"
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
	return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}
#line 2 "main.cpp"

string pc = "pairwise coprime";
string sc = "setwise coprime";
string nc = "not coprime";
std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
std::vector<int> sieve(int n) {
  std::vector<int> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (int i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}
std::set<int> factor(int n, const std::vector<int>& min_factor) {
  // min_factor は sieve() で得られたものとする
  std::set<int> res;
  while (n > 1) {
    res.insert(min_factor[n]);
    n /= min_factor[n];
    // 割った後の値についても素因数を知っているので順次求まる
  }
  return res;
}
int main(int argc, char const* argv[])
{
  lyn();
  

  int n;cin >> n;
  vector<int> a(n);cin >> a;
  int g = a[0];REP(i,n) g = __gcd(g,a[i]);
  if(g != 1){
    cout << nc << '\n';
    return 0;
  }
  /////////////////////////
  auto minf = sieve(1000010);
  map<int,int> M;
  REP(i,n){
    auto e = factor(a[i],minf);
    for(int j : e){ 
      M[j]++;
      if(M[j] > 1){
        cout << sc << '\n';
        return 0;
      }
    }
  }
  cout << pc << '\n';
  return 0;
}


Measured memory_bytes: 11116
#include<bits/stdc++.h>
using namespace std;
bool fun(string sub){
	if(sub.length()&1) return false;
	else{
		int half=sub.length()/2;
		for(int i=0;i<half;++i){
			if(sub[i]!=sub[half+i]) return false;
		}
	}
	//cout<<sub<<'\n';
	return true;
}
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    int len=s.length();
    int i=1,ans=0;
    while(!(fun(s.substr(0,len-i)))) ++i;
    //fun("akasakaakasaka");
    //string temp="hello";
    //cout<<temp.substr(2,3)<<'\n';
    cout<<len-i;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll t, a;
    cin >> t >> a;
    ll ans = 1;
    long double minv = 100000;
    for(int i = 1; i <= n; ++i){
        long double h;
        cin >> h;
        const long double th = (long double)t - h * 0.006;
        if(minv > abs(a - th)){
            minv = abs(a - th);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=3005;
const int mo=1000000007;
int n,Q,ans,a[N];
int f[N][N];
int main(){
	scanf("%d%d",&n,&Q);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n) For(j,1,n) f[i][j]=(a[i]>a[j]);
	For(i,1,Q){
		int x,y;
		scanf("%d%d",&x,&y);
		For(j,1,n) if (j!=x&&j!=y){
			f[x][j]=f[y][j]=1ll*(f[x][j]+f[y][j])*(mo+1)/2%mo;
			f[j][x]=f[j][y]=1ll*(f[j][x]+f[j][y])*(mo+1)/2%mo;
		}
		f[x][y]=f[y][x]=
			1ll*(f[x][y]+f[y][x])*(mo+1)/2%mo;
	}
	For(i,1,n) For(j,i+1,n)
		ans=(ans+f[i][j])%mo;
	For(i,1,Q) ans=2ll*ans%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 35456
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

void solve() {
    int H, W;
    cin >> H >> W;

    multiset<int> steps;
    map<int, int> end2start;
    for (int c = 0; c < W; c++) {
        end2start[c] = c;
        steps.insert(0);
    }

    for (int r = 1; r <= H; r++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        // Erase pairs (e, s) that a <= e <= b + 1
        auto lb = end2start.lower_bound(a);
        auto ub = end2start.upper_bound(b + 1);
        auto max_start = -1;
        for (auto it = lb; it != ub; ++it) {
            int end = it->first;
            int start = it->second;
            steps.erase(steps.find(end - start));
            max_start = max(max_start, start);
        }
        end2start.erase(lb, ub);

        // Update pair (b + 1, s)
        if (b != W - 1 and lb != ub) {
            end2start[b + 1] = max_start;
            steps.insert(b + 1 - end2start[b + 1]);
        }

        if (steps.size() > 0) {
            cout << *steps.begin() + r << endl;
        } else {
            cout << "-1" << endl;
        }
    }
}

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

Measured memory_bytes: 22368
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

ll n, k;
ll dp[2500][2500];

signed main()
{
    srand(time(NULL));
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n >> k;
    k--;
    dp[0][0] = 1;
    for (int i = 0; i < k; i++)
    {
        ll s = dp[i][0];
        for (int j = 0; j < n - i - 1; j++)
        {
            s = s + dp[i][j + 1];
            if (s >= MOD) s -= MOD;
            dp[i + 1][j] = s;
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) ans += dp[k][i];
    ans %= MOD;
    for (int i = 0; i < n - k - 2; i++) ans = (ans + ans >= MOD ? ans + ans - MOD : ans + ans);
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
No def int long long for now.
*/


Measured memory_bytes: 41088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fto(i, s, e) for(int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for(int i = (s); i < (e); ++i)
#define fdto(i, s, e) for(int i = (s); i >= (e); --i)
#define fat(i, a) for(auto i : a)
#define fit(it, var) for(auto it = (var).begin(); it != (var).end(); ++it)
#define frit(it, var) for(auto it = (var).rbegin(); it != (var).rend(); ++it)

#define bc __builtin_popcountll
#define isbit(x, bit) (((x >> bit) & 1) != 0)
#define onbit(x, bit) (x | (1LL << (bit)))
#define offbit(x, bit) (x & ~(1LL << (bit)))
#define y1 ansdj
#define endl '\n'
#define _bug(...) bug(__func__, __LINE__, __VA_ARGS__)

#define ll long long
#define cd complex<double>
#define ii pair<int, int>
#define pl pair<ll, ll>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()

template<class T, class Cmp = less<T>> using oss = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

template<class T1, class T2> ostream& operator<<(ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

template<class T> ostream& operator<<(ostream &os, vector<T> const &v) {
	fto1 (i, 0, sz(v)) { os << v[i]; if (i < sz(v)-1) os << ' '; }
	return os;
}

template<class T> void buga(T const &v, int l, int r) { fto (i, l, r) { cout << v[i] << " \n"[i == r]; } }

template<class T> void bug(T const &v) { cout << v << endl; }
template<class T, class... Args> void bug(T const &v, Args const&... args) { cout << v << ' '; bug(args...); }
 
double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
int const maxn = 1e6+3;

int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int m1, d1;
	cin >> m1 >> d1;
	bug(d1 == d[m1]);

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            cnt = 0
            for k in range(-1, 2):
                for l in range(-1, 2):
                    x = i + k
                    y = j + l
                    if 0 <= x < H and 0 <= y < W and S[x][y] == '#':
                        cnt += 1
            S[i][j] = cnt
            
for i in range(H):
    print(''.join(map(str, S[i])))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 100001


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
long long N;	

int main () {

	long long  d, min;

	// 個数と長さの読込み
	scanf("%lld", &N);

	min = N - 1;
	for(long long i = 2; i * i <= N; i++) {
		if(N % i == 0 && min > i + (N / i) - 2) {
			min = i + (N / i) - 2;
		}
	}
						
	printf("%lld\n", min);

	return 0;
}

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

using namespace std;

const int INF = 1 << 30;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M), D(M);
  vector<vector<pair<int, int>>> G(N);
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--, R[i]--;
    G[L[i]].emplace_back(make_pair(R[i], D[i]));
    G[R[i]].emplace_back(make_pair(L[i], -D[i]));
  }
  vector<int> pos(N, INF);
  vector<bool> used(N, false);
  auto bfs = [&](int s) {
    if (pos[s] == INF) pos[s] = 0;
    used[s] = true;
    queue<int> que;
    que.push(s);
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (auto g : G[u]) {
        int v = g.first, d = g.second;
        if (!used[v]) {
          used[v] = true;
          pos[v] = pos[u] + d;
          que.push(v);
        }
      }
    }
  };
  for (int i = 0; i < N; i++) {
    if (!used[i]) bfs(i);
  }
  for (int i = 0; i < M; i++) {
    if (pos[R[i]] - pos[L[i]] != D[i]) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


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

int main() {
  int a,b,c,n;
  cin >>a>>b>>c>>n;
  int f=0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
        int m =500*i + 100*j +50 *k;
        if(m==n){
          f++;
        }
      }
    }
  }
  cout << f << endl;


}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 100;
//#define int long long
const int INF = 1e9;

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

	int h, w, k;
	cin >> h >> w >> k;
	vector<string> a(h);
	for (int i = 0; i < h; i++) cin >> a[i];

	auto test = [](int x, int pos) {
		return (x >> pos) & 1;
	};

	int ans = 0;
	for (int mh = 0; mh < (1 << h); mh++){
		
		for (int mw = 0; mw < (1 << w); mw++){
			vector<string> aa(h);
			for (int i = 0; i < h; i++) aa[i] = a[i];
			for (int i = 0; i < h; i++){
				if (test(mh, i)){
					for (int j = 0; j < w; j++) aa[i][j] = '.';
				}
			}
			for (int j = 0; j < w; j++){
				if (test(mw, j)){
					for (int i = 0; i < h; i++) aa[i][j] = '.';
				}
			}
			
			int res = 0;
			for (int i =0; i < h; i++){
				for (int j = 0; j < w; j++){
					if (aa[i][j] == '#') res++;
				}
			}
			
			if (res == k) ans++;
		}
	}

	cout << ans << '\n';
    return 0;
}


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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
    const string GL = ">=";
    int n,m; cin >> m >> n;
    vector<vector<int> > g(m, vector<int>(n,0));
    vector<vector<int> > l(m, vector<int>(n,100));
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int s,t; string c;
            cin >> s >> c >> t;
            s--;
            if(c == GL){
                g[i][s] = max(g[i][s], t);
            }
            else{
                l[i][s] = min(l[i][s], t);
            }
        }
    }
    vector<bool> isget(m, false);
    vector<int> skill(n, 0);
    for(int i = 0; i < m; i++){
        for(int j = 0; j < m+1; j++){
            if(j == m){
                cout << "No" << endl;
                return 0;
            }
            if(isget[j])continue;
            vector<int> st = skill;
            for(int k = 0; k < n; k++){
                if(st[k] < g[j][k])st[k] = g[j][k];
            }
            bool flag = true;
            for(int k = 0; k < m; k++){
                if(isget[k])continue;
                for(int p = 0; p < n; p++){
                    if(st[p] > l[k][p]){
                        flag = false;
                        k = m;
                        break;
                    }
                }
            }
            if(flag){
                swap(skill, st);
                isget[j] = true;
                break;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}




Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <queue>
using namespace std;

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


vector<long long int> calc(int K)
{
  vector<long long int> out(2);
  out[0] = K%10;
  while(K>9){
    K /= 10;
  }
  out[1] = K;
  return out;
}

int main(){
  int N; cin >> N;
  vector< vector<long long int> > count(10); REP(i,10){ count[i].resize(10); }
  rep(k,1,N+1){
    vector<long long int> tmp = calc(k);
    count[ tmp[0] ][ tmp[1] ] += 1;
  }
  
  long long int res = 0;
  REP(i,10){
    REP(j,10){
      res += count[i][j] * count[j][i];
    }
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
# print(n)
# print(k)
x = list(map(int, input().split()))
# print(x)

# print(sorted(x))
sort_x = sorted(x)

sum = 0
for i in range(k):
  # print(i)
  # print(sort_x[i])
  sum += sort_x[i]

print(sum)

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int arr[a], max1 = 0, max2 = -1;
	cin >> arr[0];
	for(int i=1; i<a; i++)
		cin >> arr[i];
	for(int i=1; i<a; i++)
		if(arr[i] > arr[max1]) max1 = i;
	for(int i=0; i<a; i++)
	{
		if(max2 == -1 && i == max1) continue;
		else if(max2 == -1) max2 = i;
		else if(arr[i] > arr[max2] && i != max1) max2 = i;
	}
	for(int i=0; i<a; i++)
	{
		if(i == max1) printf("%d\n",arr[max2]);
		else          printf("%d\n",arr[max1]);
	}
	return 0;
}

Measured memory_bytes: 2432
H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()

ans = H * W

# 縦３分割
for i in range(1, W):
    w2 = (W - i) // 2
    w3 = W - i - w2
    s1 = H * i
    s2 = H * w2
    s3 = H * w3
    diff = max(s1, s2, s3) - min(s1, s2, s3)
    ans = min(ans, diff)
# 横３分割
for i in range(1, H):
    h2 = (H - i) // 2
    h3 = H - i - h2
    s1 = i * W
    s2 = h2 * W
    s3 = h3 * W
    diff = max(s1, s2, s3) - min(s1, s2, s3)
    ans = min(ans, diff)

# 最初に縦に割る場合
for i in range(1, W):
    h2 = H // 2
    # 右側を半分にする場合
    s1 = i * H
    s2 = (W - i) * h2
    s3 = (W - i) * (H - h2)
    diff = max(s1, s2, s3) - min(s1, s2, s3)
    ans = min(ans, diff)
    # 左側を半分にする場合
    s1 = (W - i) * H
    s2 = i * h2
    s3 = i * (H - h2)
    diff = max(s1, s2, s3) - min(s1, s2, s3)
    ans = min(ans, diff)

# 最初に横に割る場合
for i in range(1, H):
    w2 = W // 2
    # 下側を半分にする場合
    s1 = W * i
    s2 = w2 * (H - i)
    s3 = (W - w2) * (H - i)
    diff = max(s1, s2, s3) - min(s1, s2, s3)
    ans = min(ans, diff)
    # 上側を半分にする場合
    s1 = W * (H - i)
    s2 = w2 * i
    s3 = (W - w2) * i
    diff = max(s1, s2, s3) - min(s1, s2, s3)
    ans = min(ans, diff)

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s == "ABC") puts("ARC");
    else puts("ABC");
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
string s, t;
int main(){
	while(true){
		int l = 0, r = 10, m;
		if(s == "100000000"){
			cout << "! 1000000000" << endl;
			break;
		}
		while(l+1<r){
			m = (l+r)/2;
			cout << "? " << s << m << endl;
			cin >> t;
			(t[0] == 'Y' ? l : r) = m;
		}
		if(l == 9){
			cout << "? " << s << (s == "" ? "10" : "00") << endl;
			cin >> t;
			if(t[0] == 'N'){
				l = -1; r = 9;
				while(l+1<r){
					m = (l+r)/2;
					cout << "? " << s << m << "0" << endl;
					cin >> t;
					(t[0] == 'N' ? l : r) = m;
				}
				cout << "! " << s << r << endl;
				break;
			}else{
				cout << "? " << s << "9000000000" << endl;
				cin >> t;
				if(t[0] == 'Y'){
					cout << "! " << s << (s == "" ? "1" : "0") << endl;
					break;
				}
			}
		}
		s += to_string(l);
	}
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n-1) {
    cin >> a[i];
    a[i]--;
  }

  vector<int> res(n);
  rep(i,n-1) res[a[i]]++;

  rep(i,n) cout << res[i] << "\n";

  
  return 0;
}


Measured memory_bytes: 4372
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
int main()
{

   int a,b,c;
   int a1,a2,a3,a4,a5,a6;
   cin>>a>>b>>c;
   a1=a+b;
   vec.push_back(a1);
   a2=a+c;
   vec.push_back(a2);
   a3=b+c;
   vec.push_back(a3);
   sort(vec.begin(),vec.end());
   cout<<vec[0]<<"\n";


return 0;
}


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

int main(void) {
	int A, B, C, D;
	int Ta, Ao;
	
	scanf("%d %d %d %d", &A, &B, &C, &D);
	
	Ta = C/B;
	Ao = A/D;
	if(C%B != 0) Ta++;
	if(A%D != 0) Ao++;
	
	if(Ta <= Ao) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}


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

int main(){
  int S;
  cin>>S;
  int lack =0;
  while(S-500>=0){
    lack = lack+1000;
    S = S-500;
  }
  while(S-5>=0){
    lack = lack+5;
    S = S-5;
  }
  cout << lack <<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N,counter=0;
    string S;
    cin >> N >> S ;
    if (N==3){
        if (S[0]=='A' && S[1]=='B' && S[2]=='C'){
            counter+=1;
        }
    }
    else if (N>3) {
        for (int i=0; i<=N-3; i++){
            if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
                counter+=1;
    }

        }
    }
    cout << counter ;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int[] menu=new int[5];
		int min;
		for(int i=0;i<5;i++){
			menu[i]=sc.nextInt();
		}
		min=menu[0]+menu[3];
		if(min>menu[0]+menu[4]){
			min=menu[0]+menu[4];
		}
		if(min>menu[1]+menu[3]){
			min=menu[1]+menu[3];
		}
		if(min>menu[1]+menu[4]){
			min=menu[1]+menu[4];
		}
		if(min>menu[2]+menu[3]){
			min=menu[2]+menu[3];
		}
		if(min>menu[2]+menu[4]){
			min=menu[2]+menu[4];
		}
		System.out.println(min-50);
	}
}

Measured memory_bytes: 17176
#include <iostream>

using namespace std;

int candy_cnt(int A[2][100],int i,int j,int N);

int main(){

  int N,ans = 0;
  int A[2][100] = {{0}};
  cin >> N;

  for(int i = 0; i < 2; i++){
    for(int j = 0; j < N; j++){
      cin >> A[i][j];
    }
  }

  ans = candy_cnt(A,0,0,N);
  
  cout << ans << "\n";

  return 0;
}

int candy_cnt(int A[2][100], int i, int j, int N){
  int r1,r2;
  if(i == 1){
    if(j == N-1){
      return A[i][j];
    }
    else{
      return A[i][j] + candy_cnt(A,i,j+1,N);
    }
  }
  else{
    if(j == N-1){
      return A[i][j] + candy_cnt(A,i+1,j,N);
    }
    else{
      r1 = candy_cnt(A,i+1,j,N);
      r2 = candy_cnt(A,i,j+1,N);
      if(r1 > r2){
	return A[i][j] + r1;
      }
      else{
	return A[i][j] + r2;
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);



		do {

			String str = sc.nextLine() ;
			if(str.equals("-")) {
				break;
			}

			char[] cards = str.toCharArray();

			int m = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.nextLine());
				cards = shuffle(cards, h);
			}

			for (int j = 0; j < cards.length; j++) {
				System.out.print(cards[j]);
			}
			System.out.println();

		}while(true);

		sc.close();

	}

	private static char[] shuffle(char[] cards, int h) {
		char[] cards_tmp1 = new char[h];
		char[] cards_tmp2 = new char[cards.length - h];
		char[] cards_ex = new char[cards.length];

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_tmp1[i] = cards[i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_tmp2[i] = cards[h + i];
		}

		for (int i = 0; i < cards_tmp2.length; i++) {
			cards_ex[i] = cards_tmp2[i];
		}

		for (int i = 0; i < cards_tmp1.length; i++) {
			cards_ex[cards.length - h + i] = cards_tmp1[i];
		}

	    return cards_ex;

	}
}



Measured memory_bytes: 26324
#include <stdio.h>

struct card_tag {
  char mark;
  int number;
};
typedef struct card_tag card;

int
main(void)
{
  int count, i, j, k;
  char mark[] = {'S', 'H', 'C', 'D'};

  scanf("%d", &count);
  card data[count];

  // input card
  for(i = 0; i < count; i++) {
    scanf(" %c %d", &data[i].mark, &data[i].number);
  }

  // check and print
  for (j = 0; j < 4; j++) {
    for (i = 1; i <= 13; i++) {
      int check = 0;
      for (k = 0; k < count; k++) {
        if (data[k].mark == mark[j] && data[k].number == i) {
          check++;
        }
      }
      if (check == 0) {
        printf("%c %d\n", mark[j], i);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1800
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;
#define mod (llint)1000000007
#define int_max 2147483647
#define ll_max (llint)9223372036854775807

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aのb乗を求める(1000000007で割った余りやで)
llint modpow(llint a, llint b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	llint tmp = modpow(a, b / 2);
	tmp %= mod;
	tmp = tmp * tmp % mod;
	if (b % 2)return tmp * a % mod;
	else return tmp;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= mod;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, mod);
		ans %= mod;
	}
	return ans;
}


int main() {
	char a, b;
	cin >> a >> b;
	if (a < b)cout << "<" << endl;
	else if (a > b)cout << ">" << endl;
	else cout << "=" << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

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

	int l;
	cin >> l;

	double len = (double) l / 3.0;

	cout.precision(10);
	cout << fixed << len * len * len << "\n";

	return 0;
}


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

int main(){
  int A, B = 0;
  int N,a,b,c,d,e = 0;
  int count = 0;
  cin >> A >> B;
  N = A;
  rep(i,B-A+1){
    e = N%10;
    d = N/10%10;
    //c = N/100%10;
    b = N/1000%10;
    a = N/10000%10;
    if(a==e && b==d)
      count++;
    N++;
  }  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


typedef pair<point,point> line;
const double EPS = 1e-10;

bool point_eq(point a,point b){
    return abs(a-b) < EPS;
}

// 内積 (dot product) : a・b = |a||b|cosΘ
double dot(point a,point b) {
    return (a.real() * b.real() + a.imag() * b.imag());
}

// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(point a, point b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

// a1,a2を端点とする線分とb1,b2を端点とする線分の交差判定
bool is_intersected_line(line la,line lb) {
    point a1=la.first,a2=la.second;
    point b1=lb.first,b2=lb.second;
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
        ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

// a1,a2を端点とする線分とb1,b2を端点とする線分の交点計算
point intersection_point(line la,line lb) {
    point a1 = la.first,a2=la.second;
    point b1 = lb.first,b2=lb.second;
    point b = b2-b1;
    double d1 = abs(cross(b, a1-b1));
    double d2 = abs(cross(b, a2-b1));
    double t = d1 / (d1 + d2);
    return a1 + (a2-a1) * t;
}

void cerr_point(point a){
    cerr << a.real() << " " << a.imag() << endl;
}

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<line> lines;

        int ret = 1;
        for(int line_number=0;line_number<n;line_number++){
            int x1,y1,x2,y2;
            cin >> x1 >> y1 >> x2 >> y2;
            line new_line = make_pair(point(y1,x1),point(y2,x2));
            int new_cross = 0;
            vector<point> cross_point;
            for(int i=0;i<(int)lines.size();i++){
                if(point_eq(new_line.first,lines[i].first) or point_eq(new_line.first,lines[i].second)
                   or point_eq(new_line.second,lines[i].first) or point_eq(new_line.second,lines[i].second)) continue;
                if(is_intersected_line(new_line,lines[i])){
                    point p = intersection_point(new_line,lines[i]);
                    bool ok = true;
                    for(int j=0;j<(int)cross_point.size();j++){
                        if(point_eq(cross_point[j],p)){
                            ok = false;
                            break;
                        }
                    }
                    if(ok){
                        cross_point.push_back(p);
                        new_cross++;
                    }
                }
            }
            lines.push_back(new_line);
            ret += (new_cross+1);
        }
        cout << ret << endl;
    }
    return 0;
}

Measured memory_bytes: 1224