akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,k;
	cin>>n>>m>>k;
	string s[n];
	for(ll i=0;i<n;i++){
		cin>>s[i];
	}
	ll ans=0;
	for(ll mr=0;mr< (1<<n);mr++){
		for(ll mc=0;mc<(1<<m);mc++){
			ll cnt=0;
			for(ll i=0;i<n;i++){
				for(ll j=0;j<m;j++){
					if(mr&(1<<i) || mc&(1<<j)) continue;
					if(s[i][j]=='#') cnt++;
				}
			}
			//cout<<mr<<" "<<mc<<" "<<cnt<<"\n";
			if(cnt==k) ans++;
		}
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3652
def gcd(a, b):
    if a < b:
        a, b = b, a
    return b if a % b == 0 else gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)

def count(a):
    res = 0
    while a % 2 == 0:
        a //= 2
        res += 1
    return res

def solve(n, m, a):
    S = set(map(count, a))
    if len(S) > 1:
        return 0
    b = a[0]
    for i in range(1, n):
        b = lcm(b, a[i])
    b //= 2
    return (m // b + 1) // 2

n, m = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, m, a))

Measured memory_bytes: 15060
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
int a[5];
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	rep (i,1,3) a[i]=read(); sort(a+1,a+3+1);
	int ans=(a[2]-a[1])/2;
	a[1]+=ans*2; if (a[1]<a[2]) a[3]++,a[1]++,ans++;
	ans+=a[3]-a[2];
	cout<<ans<<endl;
	return 0;
}
// sample data:
/*
2 5 4

2 6 3

31 41 5

*/

// rest:
/*

*/

/*
If you find any bug in my code or solution, please tell me. Thanks so much.
email: 2411280037@qq.com
*/

Measured memory_bytes: 256
cat<<EOF>Source.cpp

extern "C"{
int printf (const char *__restrict __format, ...);
int scanf (const char *__restrict __format, ...) ;
}
int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x/k&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x%k]--;
		}
		else{
			cnt[k-x%k]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x%k]++;
		}
		else{
			cnt[0]++;
			cnt[k-x%k]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	for(int i=0;i<k;i++){
		int d=max(n,k);
		int cnt[d];
		for(int j=0;j<d;j++)cnt[j]=0;
		for(int j=0;j<n;j++){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,y[j],0);
				}
				else{
					add(cnt,y[j],1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,y[j],1);
				}
				else{
					add(cnt,y[j],0);
				}
			}
		}
		for(int j=0;j<k;j++){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	for(int i=0;i<k;i++)Max=max(Max,ans[i]);
	printf("%d\n",Max);
}
EOF
clang++ -Ofast Source.cpp -o Source -fopenmp -std=c++11
./Source

Measured memory_bytes: 11256
def pol_calc(symbols):
    stack = []
    for s in symbols:
        if s.isdigit():
            stack.append(int(s))
        elif s == '+':
            y = stack.pop()
            x = stack.pop()
            stack.append(x + y)
        elif s == '-':
            y = stack.pop()
            x = stack.pop()
            stack.append(x - y)
        elif s == '*':
            y = stack.pop()
            x = stack.pop()
            stack.append(x * y)
    return stack.pop()

if __name__ == "__main__":
    symbols = input().split()
    print(pol_calc(symbols))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  int y=0;
  for(int i=0;i<3;i++){
    if(a[i]!=a[2-i]) y=1;
  }
  if(y==1) cout<<"No";
  else cout<<"Yes";
  cout<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long int llint;

int main()
{
    llint a,b,k;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(a>k) printf("%lld %lld\n",a-k,b);
    else if(b>k-a) printf("%lld %lld\n",(llint)0,b-k+a);
    else printf("%lld %lld\n",(llint)0,(llint)0);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void)
{
  int a,b,c; cin>>a>>b>>c;
  int ans=2;
  if(a!=b&&b!=c&&c!=a)ans=3;
  else if(a==b&&b==c)ans=1;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;

int main() {
	cin >> s;
	int w;
	cin >> w;
	for (int i = 0; i < s.size(); i += w) {
		cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
// AOJ 2516 Amidakuji
// 2018.5.7 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int N, M;  // N: 縦線の本数、人数に対応。M: 横線の数。M=0なら、くじの意味なし

int a[10];
int res[10];   // 正解となるくじ結果（0-origin）]

int b[10];     // a[] の値が順列で変わって入る
int chk[10];
char tbl[10][10];

int ans;
void check(int *a, int *res);

void calc_perm(char *p)
{
	int i, j, x, y, h;

//	for (i = 0; i < M; i++) printf(" %d", p[i]);
//  p[i]: 1,2,3,4... の順列数が入る
	for (i = 0; i < M; i++) b[i+1] = a[p[i]];
//	printf(" -->");
//	for (i = 1; i <= M; i++) printf(" %d", b[i]); printf("\n");

	check(b, chk);
	if (memcmp(chk, res, (N+1)<<2) == 0) {
		// 正解となる順列に対し、高さを圧縮する
		memset(tbl, 0, sizeof(tbl));
		h = 1;
		for (i = 1; i <= M; i++) {
			x = b[i], y = x+1;
			for (j = i-1; j >= 1; j--) {
				if (tbl[j][x] || tbl[j][y]) break;
			}
			tbl[j+1][x] = tbl[j+1][y] = 1;
			if (j+1 > h) h = j+1;
		}
		if (h < ans) ans = h;
	}
}

/*
   Kの数 {0,1,2} の順列 k! を高速生成する
   1 2 3
   1 3 2
   2 1 3
   2 3 1
   3 1 2
   3 2 1
*/
void gen_perm(int K)
{
	int k, t;
	char c[10], *pc, *q;
	char p[10] = {1,1,1,1,1,1,1,1,1,1};

	q = p, pc = c;
	for (k = 1; k <= K; ) *q++ = *pc++ = k++;
	k = 1, pc = c;
	do {
		t = *(p + k);
		*(p + k) = *(q = p + ((k & 1)? *pc: 0));
		*q = t;
		calc_perm(p);
		k = 1, pc = c;
		while(*pc == 0)	*pc++ = k++;
		(*pc)--;
	} while (k < K);
}

void check(int *a, int *res)
{
	int i, t, x, y;

	for (i = 1; i <= N; i++) res[i] = i;
	for (i = 1; i <= M; i++) {
		x = a[i], y = x+1;
		t = res[x], res[x] = res[y], res[y] = t;  // swap x, y
	}
}

int main() 
{
	int i;

	N = in(), M = in();
	for (i = 1; i <= M; i++) a[i] = in();
	check(a, res);

	ans = 10;
	gen_perm(M);	// 順列を生成し、それぞれについて高さを圧縮
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int a;
    cin >> a;
    set<int> st;
    REP(_,a) {
        int s; cin >> s;
        st.insert(s);
    }

    int q;
    cin >> q;
    ll sm = 0;
    REP(_,q) {
        int t; cin >> t;
        sm += st.count(t);
    }
    cout << sm << endl;
}

int main() {
    solve();
    return 0;
}


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



int main(){
    int n, r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
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; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	string s;
	cin >> s;
	int n = s.size() - 1;
	if (!n) {
		cout << s;
		return(0);
	}
	ll ans = 0;
	int bit;
	for (bit = 0; bit < (1 << n); bit++) {
		ll tmp = 0;
		for (int i = 0; i < s.size(); i++) {
			tmp = tmp * 10 + (s[i] - '0');
			if (1 & (bit >> i)) {
				ans += tmp;
				tmp = 0;
			}
		}
		ans += tmp;
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 256
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int L[1000+10][1000+10];
string S1, S2;

int main() {
  cin >> S1 >> S2;
  for (int j = 0; j < 1000+10; j++) {
    L[0][j] = j; L[j][0] = j;
  }
  for (int x = 1; x <= S1.length(); x++) {
    for (int y = 1; y <= S2.length(); y++) {
      if (S1[x-1] == S2[y-1])
        L[x][y] = L[x-1][y-1];
      else {
        int A[3] = {L[x-1][y], L[x][y-1], L[x-1][y-1]};
        L[x][y] = *min_element(A, A+3) + 1;
      }
    }
  }
  /*for (int i = 0; i <= S1.length(); i++) {
    for (int j = 0; j <= S2.length(); j++) {
      cout << L[i][j] << ' ';
    }
    cout << endl;
  }*/
  cout << L[S1.length()][S2.length()] << endl;
}



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

int main(void) {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  vector<vector<int>> DP(H+1, vector<int>(W+1, H*W+1));
  DP[0][0] = (S[0][0] == '#') ? 1 : 0;
  for(int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      int nx = x + 1;
      if (nx < W) {
        int nx_s = (S[y][x] == '.') && (S[y][nx] == '#');
        DP[y][nx] = min(DP[y][nx], DP[y][x] + nx_s);
      }
      int ny = y + 1;
      if (ny < H) {
        int ny_s = (S[y][x] == '.') && (S[ny][x] == '#');
        DP[ny][x] = min(DP[ny][x], DP[y][x] + ny_s);
      }
    }
  }
  cout << DP[H-1][W-1] << endl;
  return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  bool can = false;
  string T = "keyence";
  for (int i = 0; i <= 7; i++)
  {
    if (S.substr(0, i) == T.substr(0, i) && S.substr(S.size() - (7 - i), 7 - i) == T.substr(i, 7 - i))
      can = true;
  }
  if (can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

ll n , M[N] , H[N] , p[N] ;
set<ll> G[N] ;
set<pll> s ;
void DFS(ll v , ll par = -1 , ll h = 0) {
	H[v] = h ;
	M[v] = 1 ;
	p[v] = par; 
	for (auto u : G[v]) if (!M[u]) DFS(u , v , h + 1) ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    cin >> n ;
    for (int i = 0 ; i < n - 1;  i ++) {
    	ll v, u ;
    	cin >> v >> u ;
    	G[v].insert(u) ;
    	G[u].insert(v) ;
	}
    DFS(1) ;
    string ans = "Second" ;
    for (int i = 1 ; i <= n ; i ++) s.insert({H[i] , i}) ;
    while (s.size()) {
    	auto x = *s.rbegin() ;
    	ll d = x.F , v = x.S ;
    	if (p[v] == -1 || s.find({H[p[v]] , p[v]}) == s.end()) {
    		ans = "First" ;
    		break ;
		}
		s.erase(x) ;
		s.erase({d - 1 , p[v]}) ;
		for (auto u : G[v]) G[u].erase(v) ;
		for (auto u : G[p[v]]) G[p[v]].erase(p[v]) ;
		
	}
	if (s.size()) ans = "First" ;
	cout << ans ;
    return (0) ;
}

Measured memory_bytes: 28928
#include <bits/stdc++.h>
#define ii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define ll long long    
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define vll vector<long long>
#define inf (int) 2e9
#define infll (long long) 2e18
#define N 200005
using namespace std;



void printline(vector<int> v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}

void printcol(vector<int> v){
    for(auto x : v)
        cout << x << endl;
}

long long a,b,c,d;


int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int n;
    cin >> n;

    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    int psumIndo[n], psumVoltando[n];
    psumIndo[0] = v[0];
    psumVoltando[n - 1] = v[n - 1];

    for(int i = 1; i < n; i++) psumIndo[i] = __gcd(psumIndo[i - 1], v[i]);
    for(int i = n - 2; i >= 0; i--) psumVoltando[i] = __gcd(psumVoltando[i + 1], v[i]);

    int ans = max(psumIndo[n - 2], psumVoltando[1]);

    for(int i = 1; i < n - 1; i++){
        ans = max(ans, __gcd(psumIndo[i - 1], psumVoltando[i + 1]));
    }

    cout << ans << endl;




	return 0;
}



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

int main(){
    /*input*/
    int n;  cin >> n;
    /*calculation*/
    ll L[87];
    L[0] = 2LL, L[1] = 1LL;
    for(int i = 2; i <= n; i++)L[i] = L[i - 2] + L[i - 1];
    /*output*/
    printf("%lld\n", L[n]);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
S = [None] * N

for i in range(N):
    t = input().strip().split()
    
    S[i] = [t[0], int(t[1]), i]
    
S.sort(key = lambda x:(x[0], -x[1]))

for v in S:
    print(v[2] + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

int h, w;
vector<string> s;
vector<vector<bool> > used;

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

int bfs(int x, int y) {
	queue<pair<pair<int, int>, int> > q;
	q.push({ { x, y }, 0 });
	used[x][y] = true;
	int res = 0;
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int ex = p.first.first, ey = p.first.second;
		res = max(res, p.second);
		for (int i = 0; i < 4; ++i) {
			int nx = ex + dx[i], ny = ey + dy[i];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
			if (s[nx][ny] == '#') continue;
			if (used[nx][ny]) continue;
			used[nx][ny] = true;
			q.push({ {nx, ny}, p.second + 1 });
		}
	}

	return res;
}

int main() {
	cin >> h >> w;
	s.resize(h);
	for (int i = 0; i < h; ++i) cin >> s[i];
	int ans = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			used.assign(h, vector<bool>(w, false));
			if (s[i][j] == '#') continue;
			ans = max(ans, bfs(i, j));
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define free -1
#define notfree 1
#define FALSE 2
#define TRUE 3

 int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
 int X[N][N];

 void initialize(void);
 void printbord(void);
 void recursive(int);

 int main(){
            int i,j,k,r,c;
            initialize();
            
            for(i=0;i<N;i++){
                             for(j=0;j<N;j++){
                                              X[i][j]=FALSE;
                                              }
                             }
            scanf("%d",&k);
            for(i=0;i<k;i++){
                             scanf("%d%d",&r,&c);
                             X[r][c]=TRUE;
                             }
            recursive(0);

            return 0;
            }


 void initialize(){
                   int i;
                   for(i=0;i<N;i++){
                                    row[i]=free;
                                    col[i]=free;
                                    }

                   for(i=0;i<2*N-1;i++){
                                        dpos[i]=free;
                                        dneg[i]=free;
                                        }
                    }

 void printboard(){
  int i,j;
 
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(X[i][j] == TRUE){
    if(row[i] != j)return;
      }
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 void recursive(int i){
                    int j;
                    if(i==N){
                             printboard();
                             return;
                             }
                    for(j=0;j<N;j++){
                      if(notfree==col[j]||notfree==dpos[i+j]||notfree==dneg[i-j+N-1])continue;
                      row[i]=j;
                      col[j]=dpos[i+j]=dneg[i-j+N-1]=notfree;
                      recursive(i+1);
                      row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=free;
                      }
                     }





Measured memory_bytes: 2116
num_queen = 8

def check_puttable(candidate, queens):
    cx, cy = candidate
    for queen in queens:
        qx, qy = queen
        if cx == qx or cy == qy or abs(cx - qx) == abs(cy - qy):
            return False
    return True

def create_candidates(queens):
    return [(i, j) for i in range(num_queen) for j in range(num_queen)
            if check_puttable((i,j), queens)]

def add_queen(queens):
    if len(queens) == num_queen: return queens
    candidates = create_candidates(queens)
    for candidate in candidates:
        _queens = add_queen(queens | {candidate})
        if _queens: return _queens

def show_queens(queens):
    for i in range(num_queen):
        for j in range(num_queen):
            if (i, j) in queens:
                print("Q", end="")
            else:
                print(".", end="")
        print("")

N = int(input())
queens = set()
for _ in range(N):
    i, j = map(int, input().split())
    queens.add((i, j))

queens = add_queen(queens)
show_queens(queens)



Measured memory_bytes: 5624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//最大公約数
long long gcd(long long a, long long b){
    //a>bになるように入れ替え
    if(a<b){
        long tmp=a;
        a=b;
        b=tmp;
    }

    //ユークリッドの互除法
    if(a%b==0) return b;
    return gcd(b,a%b);
}

//最小公倍数
long long lcm(long long a,long long b){
    return a*(b/gcd(a,b));
}

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

    //A[0]~A[N-1]に格納する
    long long* T;
    NEW(T,N);
    for(int i=0;i<N;i++){
        scanf("%lld",&T[i]);
    }

    long long ans=1;
    for(int i=0;i<N;i++){
        ans=lcm(ans,T[i]);
    }
    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Great Ocean View
            int n = int.Parse(Console.ReadLine());
            var h = ReadLine();
            int views = 1;
            
            for(int i = 1; i < n; i++)
            {
                int max = h.Take(i).Max();

                if (h[i] >= max)
                {
                    views++;
                }
            }

            Console.WriteLine(views);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
import sys
input = sys.stdin.readline
class UnionFind(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]


    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])


    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)
def compute_mst_kruskal(N, edges):#N = 頂点数、edges 0-indexed
    edges = sorted(edges, key = lambda x:x[2])
    UF = UnionFind(N)
    cost = 0
    for edge in edges:
        x, y, w = edge
        if not UF.same(x, y):
            UF.unite(x, y)
            cost+=w
    return cost
N = int(input())
ixy = []
for i in range(N):
    x, y = map(int, input().split())
    ixy.append((i, x, y))
xy_x = sorted(ixy, key = lambda x:x[1])
xy_y = sorted(ixy, key = lambda x:x[2])
edges = []
for i in range(N-1):
    i1, x1, y1 = xy_x[i]
    i2, x2, y2 = xy_x[i+1]
    edges.append([i1, i2, x2-x1])
    i1, x1, y1 = xy_y[i]
    i2, x2, y2 = xy_y[i+1]
    edges.append([i1, i2, y2-y1])
ans = compute_mst_kruskal(N, edges)
print(ans)


Measured memory_bytes: 131164
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Random rand = new Random();
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>(200000);
        
        int number = sc.nextInt();
        for(int i = 0; i < number ; i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);
        int count = 0;
        for(int i = 0; i < number - 1 ; i++){
            if(list.get(i).equals(list.get(i+1))){
                count++;
            }else{}
        }
        //System.out.println(list);

        if(count == 0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
        


    
	}
}

Measured memory_bytes: 94452
import collections
H, W = map(int, input().split())
S = [input() for _ in range(H)]

def dfs(sy, sx):
    q = collections.deque()
    q.append((sy, sx))
    dist = [[-1] * W for _ in range(H)]
    dist[sy][sx] = 0
    dx = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    while len(q) != 0:
        h, w = q.popleft()
        d = dist[h][w]
        for x, y in dx:
            h2 = h + y
            w2 = w + x
            if h2 >= 0 and h2 < H and w2 >= 0 and w2 < W:
                if S[h2][w2] == "." and dist[h2][w2] == -1:
                    dist[h2][w2] = d+1
                    q.append((h2, w2))
    return dist
ans = 0
for sy in range(H):
    for sx in range(W):
        if S[sy][sx] == '#':
            continue
        d = dfs(sy,sx)
        for i in range(H):
            for k in range(W):
                ans = max(ans,d[i][k])
print(ans)

Measured memory_bytes: 47212
N, M = map(int, input().split())
maxl=0
minr=1000000
for i in range(M):
  L, R=map(int, input().split())
  maxl=max(maxl, L)
  minr=min(minr, R)
ans=minr-maxl+1
if ans<=0:
  ans=0
print(ans)

Measured memory_bytes: 3060
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())
ma = max(A)
num = A.index(ma)
A.remove(ma)
ma2 = max(A)
A.insert(num, ma)
if ma == ma2:
    for _ in range(N):
        print(ma)
else:
    for i in range(N):
        if i == num:
            print(ma2)
        else:
            print(ma)


Measured memory_bytes: 20428
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

using namespace std;

// clang-format on

int K;
int ia = 0, na = 0;
int result = 0;

int _f(string I, string N, int *_ia, int *_na) {
  if (I == "kougekida" && N == "kougekida") {
    if (*_ia > *_na) {
      return 1;
    }
    if (*_ia < *_na) {
      return -1;
    }
    *_ia = *_na = 0;
    return 0;
  }
  if (I == "kougekida" && N == "mamoru") {
    if (*_ia == 0) {
      return -1;
    }
    if (*_ia == 5) {
      return 1;
    }
    *_ia = 0;
    return 0;
  }
  if (I == "kougekida" && N == "tameru") {
    return *_ia == 0 ? -1 : 1;
  }
  if (I == "mamoru" && N == "mamoru") {
    return 0;
  }
  if (I == "mamoru" && N == "tameru") {
    *_na = min<int>(5, *_na + 1);
    return 0;
  }
  if (I == "tameru" && N == "tameru") {
    *_ia = min<int>(5, *_ia + 1);
    *_na = min<int>(5, *_na + 1);
    return 0;
  }
  return -_f(N, I, _na, _ia); // テ」ツ?セテ」ツ?陛」ツ?凝」ツ?ョテ・ツ?催・ツクツーテ」ツ?愿」ツ?愿」ツ?愿ッツシツ?ッツシツ?ッツシツ?
}

void f(string I, string N) {
  if (result == 0) {
    result = _f(I, N, &ia, &na);
  }
}

main {
  cin >> K;
  string I[K], N[K];
  rep(i, K) cin >> I[i];
  rep(i, K) cin >> N[i];
  rep(i, K) f(I[i], N[i]);
  cout << (result == 1 ? "Isono-kun"
                       : result == -1 ? "Nakajima-kun" : "Hikiwake-kun")
       << endl;
  bye;
}

Measured memory_bytes: 3208
fn main() {
    // 複数行 1行複数要素
    loop {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.trim().split_whitespace();
        // 2要素変換
        let element1: i32 = iter.next().unwrap().parse().unwrap();
        let op = iter.next().unwrap();
        let element2: i32 = iter.next().unwrap().parse().unwrap();
        match op {
            "+" => println!("{}", element1 + element2),
            "-" => println!("{}", element1 - element2),
            "/" => println!("{}", element1 / element2),
            "*" => println!("{}", element1 * element2),
            _ => break,
        }
    }
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a[3];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(int i = 0; i < 3; i++) cin >> a[i];
	sort(a, a + 3);
	cout << a[1] - a[0] + a[2] - a[1] << "\n";
	return 0;
}

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

vector<long> xFive;

void rowFiveGen(){
	int base = 0;
  	while(pow(base,5) <= 2000000000000){
    	xFive.push_back(pow(base, 5));
        base++;
        //cout << pow(base, 5) << " ";
    }
}

int main(){
  rowFiveGen();
  int X;
  cin >> X;
  int xFiveSize = xFive.size();
  for(int i = 0; i < xFiveSize; i++){
  	for(int s= 0; s < xFiveSize; s++){
    	if(X == (xFive[i] - xFive[s])){
        	cout << i << " " << s;
          	return 0;
        }      	
        if(X == (xFive[i] + xFive[s])){
        	cout << i << " " << -s;
          	return 0;
        }
        if(X == (-xFive[i] - xFive[s])){
        	cout << -i << " " << s;
          	return 0;
        }      	
        if(X == (-xFive[i] + xFive[s])){
        	cout << -i << " " << -s;
          	return 0;
        }  
     }
  }
}


Measured memory_bytes: 4080
ss = $stdin.read.chomp.each_char.to_a
t = ss.length - 3 + 1
min_diff = -1
t.times do |i|
  n = ss.slice(i, 3).join.to_i
  diff = (753 - n).abs
  if min_diff < 0
    min_diff = diff
  else
    if diff < min_diff
      min_diff = diff
    end
  end
  if min_diff == 0
    break
  end
end

puts min_diff


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    ll ans = SZ(s);
    ll n = SZ(s);
    repr(i, 1, n){
        if(s[i-1] != s[i]){
            chmin(ans, max(n-i, i));
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	ll a,b,ans;
	cin>>a>>b;
	ans=(a+b)/2;
	if((a+b)%2==0)
	cout<<ans;
	else
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int A, P;
    cin >> A >> P;

    cout << (A * 3  + P)/ 2 << endl;

    return 0;
}

Measured memory_bytes: 256
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

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

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

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

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

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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())

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

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

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

int main()
{
    int N, L;
    cin >> N >> L;
    VI points(N + 1);
    int sum = 0, min = INF;
    for (int i = 1; i <= N; ++i)
    {
        points[i] = L + i - 1;
        //dump(points[i]);
        sum += points[i];
        //dump(sum);
        if (abs(min) > abs(points[i]))
        {
            min = points[i];
            //dump(min);
        }
    }
    cout << sum - min << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func solve() {
	s := getString()
	n := len(s)
	ans := strings.Repeat("x", n)
	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=1e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T,D,S;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

signed main(){
    //file(a);
    D=read(),T=read(),S=read();
    if(T*S>=D)puts("Yes");
    else puts("No");


    return 0;
}


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

int main() {
  Int K;
  cin >> K;
  vector<bool> a(K,false);
  Int ans = 1;
  Int seven = 7;
  seven = seven % K;
  while(true) {
    if (a[seven]) {
      cout << -1 << endl;
      return 0;
    }
    if (seven % K == 0) break;
    a[seven] = true;
    seven = (seven * 10 + 7) % K;
    ans++;
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 3744
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a, b;
    cin>>a>>b;
    cout<<b+a<<endl;
}

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

int main() {
  
  int N;
  string S;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if (i == N-1 && S != "Y"){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
import Control.Monad

iterate_cards :: [String]
iterate_cards = [unwords [suit, show num] | suit <- ["S", "H", "C", "D"], num <- [1..13]]

main :: IO ()
main = do
  n <- readLn
  cards <- replicateM n getLine
  mapM_ putStrLn [card | card <- iterate_cards, not $ elem card cards]

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

int read(){
    int h, m, s;
    char c;
    cin >> h >> c >> m >> c >> s;
    return 3600*h + 60*m + s;
}

int main(){
    int n;

    while(true){
        cin >> n;
        if(n == 0) break;
        vector<pair<int, int>> timetable;
        for(int i=0;i<n;i++){
            timetable.emplace_back(read(), 1);
            timetable.emplace_back(read(), -1);
        }
        sort(timetable.begin(), timetable.end());
        int max_train = 0;
        int train = 0;
        for(auto t:timetable){
            train += t.second;
            max_train = max(max_train, train);
        }
        cout << max_train << "\n";
    }


    return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
  int i, n;
  char s[110];

  scanf("%s", s);

  n=strlen(s);

  for(i=0; i<n; i++){
    if((i+1)%2==1){
      //奇数
      if(s[i]=='L'){
        printf("No\n");
        return 0;
      }
    }else{
      //偶数
      if(s[i]=='R'){
        printf("No\n");
        return 0;
      }
    }
  }

  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

ll dp[N][101][2];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	string s;
	int d;
	cin >> s >> d;

	for (int i = 0; i < s[0] - '0'; i++) {
		dp[0][i % d][0]++;
	}
	dp[0][(s[0] - '0') % d][1]++;

	for (int i = 1; i < s.size(); i++) {
		for (int j = 0; j < d; j++) {
			for (int x = 0; x < s[i] - '0'; x++) {
				(dp[i][(j + x) % d][0] += dp[i - 1][j][1]) %= mod;
			}

			(dp[i][(j + s[i] - '0') % d][1] += dp[i - 1][j][1]) %= mod;

			for (int x = 0; x < 10; x++) {
				(dp[i][(j + x) % d][0] += dp[i - 1][j][0]) %= mod;
			}
		}
	}

	cout << ((dp[s.size() - 1][0][0] + dp[s.size() - 1][0][1]) % mod - 1 + mod) % mod;
}

Measured memory_bytes: 16640
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

struct Info{
	Info(int arg_item,int arg_bridge){
		item = arg_item;
		bridge = arg_bridge;
	}
	bool operator<(const struct Info &arg) const{
			return bridge > arg.bridge;
	};

	int item,bridge;
};

void func(int N){

	int left,right;

	priority_queue<Info> Q;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&left,&right);
		Q.push(Info(left,right));
	}

	int sum = 0;

	bool FLG = true;

	while(!Q.empty()){

		sum += Q.top().item;
		if(sum > Q.top().bridge){
			FLG = false;
			break;
		}
		Q.pop();
	}

	if(FLG){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

}

int main(){

	int N;
	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

	return 0;
}

Measured memory_bytes: 3116
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll r;
		cin>>r;
		double pi = 3.141592653589793238;
		printf("%0.9f",2.0*pi*r);
	}
	return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int N;
  cin >> N;
  set<string> goods;
  rep(i,N) {
    string s;
    cin >> s;
    goods.insert(s);
  }
  cout << goods.size() << endl;

  return 0;
}

Measured memory_bytes: 15644
#n = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
# (ａ－ｂ)(ａ⁴＋ａ³ｂ＋ａ²ｂ²＋ａｂ³＋ｂ⁴) = X
x = int(input())

for a in range(-301,301):
    for b in range(-301,301):
        if a**5 - b**5 ==x:
            print(a,b)
            exit()


# a = x+b**5
# if a**(1/5).is_integer():
# print(int(a**(1/5)),b)
# exit()


Measured memory_bytes: 81156
// abc046_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, K;
    cin >> N >> K;

    ll ans = K * pow(K - 1, N - 1);
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(LL i=0;i<(LL)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<LL,LL>
#define pll pair<LL,LL>

using namespace std;

int main(){

    LL N;cin>>N;
    string s;cin>>s;
    int dp[N+1];
    fill_n(dp,N+1,0);
    int last=0;
    for(int i=3;i<=N;i++){
        dp[i]=dp[i-1];
        if(s[i-1]=='1'&&s[i-2]=='0'&&s[i-3]=='1') {
            last=i;
            for(int j=i-2;s[j-1]!='0'&&j>=1;j--){
                dp[i]=max(dp[i],dp[j-1]+i-1-j);
            }
        }
        if(s[i-1]=='0')last=0;
        if(s[i-1]=='1'&&last)dp[i]=max(dp[i],dp[last-3]+i-last+1);
    }

    cout<<dp[N]<<endl;






    return 0;
}

Measured memory_bytes: 2820
#! /usr/bin/env ruby
n = gets.to_i
a_arr = gets.split.map(&:to_i).sort_by { |a| a * -1 }
if a_arr.include?(0)
  puts 0
  exit 
end

max = 10 ** 18
mul_a = 1
a_arr.each do |a| 
  mul_a = mul_a * a
  if mul_a > max
    puts -1
    exit
  end
end
puts mul_a

Measured memory_bytes: 24724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,n,b,c,d,i,m=0,x,sum=0;
    cin >> x;
    for(i=1;i<=x;i++)
    {
        if(i%3==0 || i%5==0)
        {

        }else

        {
            sum+=i;
        }




    }
    cout << sum << endl;


}


Measured memory_bytes: 3636