akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define p_q priority_queue
#define MN 200000000

int r, c, n, x, x2, y, y2, a, b, t, C=0;
vector<pii> v;
bool im(int x, int y){
    if (x==0 || y==0 || x==r || y==c) return 1;
    return 0;
}
int ins(int x, int y, int v){
    if (x==0) return (-y+MN);
    if (y==0) return (x+2*MN);
    if (x==r) return (y+3*MN);
    if (y==c) return (-x+4*MN);
}
vector<int> pre;
int main(){
    cin >> r >> c >> n;
    for (int l=0; l<n; ++l){
        cin >> x >> y >> x2 >> y2;
        if (im(x, y) && im(x2, y2)){
            //cout << "*";
            a=ins(x, y, 1);
            b=ins(x2, y2, -1);
            if (a>b){t=a; a=b; b=t;}
            //cout << a << ' ' << b << endl;
            v.pb(mp(a, -l-1));
            v.pb(mp(b, l+1));
        }
    }
    sort(v.begin(), v.end());
    for (int l=0; l<v.size(); ++l){
        //cout << v[l].x << ' ' << v[l].y << endl;
        if (v[l].y<0) pre.pb(-v[l].y);
        else {
            if (pre.back()!=v[l].y){
                cout << "NO"; return 0;
            }
            pre.pop_back();
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 2420
import java.util.*;

public class Main {

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

        String s = scanner.next();
        String t = scanner.next();

        if(!t.startsWith(s)){
            System.out.println("No");
            System.exit(0);
        }
        if(t.length() != s.length() + 1){
            System.out.println("No");
            System.exit(0);
        }

        System.out.println("Yes");
    }
}

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

// * Shortcut

#define sort(s) sort(s.begin(), s.end());
#define ll long long
#define real long double

// * Constant
const ll mod = 1E9 + 7;
const ll fftmod = 998244353;
const ll inf = LONG_LONG_MAX;
const ll n_inf = LONG_LONG_MIN;

using namespace std;

bool prime(ll x)
{
	if (x < 2)
	{
		return false;
	}
	else if (x > 2)
	{
		if (x % 2 == 0)
			return false;
		else
		{
			for (ll i = 3; i <= sqrt(x); i += 2)
			{
				if (x % i == 0)
					return false;
			}
		}
	}
	return true;
}

bool vowel(char ch)
{
	ch = tolower(ch);
	return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y');
}

ll fact(ll n)
{
	if (n == 0 || n == 1)
		return 1;
	else
		return n * fact(n - 1);
}

ll C(ll n, ll r)
{
	if (r == 0)
		return 1;
	if (n < r)
		return 0;

	/*
     Extra computation saving for large R,
     using property:
     N choose R = N choose (N-R)
    */
	if (r > n / 2)
		return C(n, n - r);

	double res = 1;

	for (int k = 1; k <= r; ++k)
	{
		res *= n - k + 1;
		res /= k;
	}

	return (ll)(res);
}

//  Variable

// ? Problem Local Function

ll fib(int n)
{
	long long p1 = 1, p2 = 1, ans;
	if (n <= 2)
		return 1;
	else
	{
		for (int i = 3; i <= n; i++)
		{
			ans = p1 + p2;
			p1 = p2;
			p2 = ans;
		}
	}
	return ans;
}

ll calls(int n)
{
	vector<ll> c;
	c.push_back(0);
	c.push_back(0);
	c.push_back(2);
	for (int i = 3; i <= n; i++)
	{
		c.push_back(c[i - 1] + c[i - 2] + 2);
	}
	return c[n];
}

int main()
{
	freopen("submit.err", "w+", stderr);
	ll n;
	cin >> n;
	int a[2][n], dp[2][n];
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin >> a[i][j];
		}
	}
	dp[0][0] = a[0][0];
	dp[1][0] = a[1][0] + a[0][0];
	for (int i = 1; i < n; i++)
	{
		dp[0][i] = dp[0][i - 1] + a[0][i];
	}
	for (int i = 1; i < n; i++)
	{
		dp[1][i] = max(dp[1][i - 1], dp[0][i]) + a[1][i];
	}
	cout << dp[1][n - 1];
	return 0;
}


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

void swap(int &a, int &b) {
	int temp;
	temp = a;
	a = b;
	b = temp;
}

int main() {
	// your code goes here
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

d = deque()
for i in range(N):
    p = bisect.bisect_left(d, A[i])
    if p==0:
        d.appendleft(A[i])
    else:
        d[p-1] = A[i]
ans = len(d)
print(ans)


Measured memory_bytes: 8060
n = gets.to_i
p = gets.split(' ').map(&:to_i)
count = 0
n.times do |i|
  next if i == 0 || i == n-1
  count += 1 if [p[i-1], p[i], p[i+1]].sort[1] == p[i]
end
puts count

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1 && b == 2) {
		cout << "3" << endl;
	}
	else if (a == 1 && b == 3) {
		cout << "2" << endl;
	}
	else if (a == 2 && b == 1) {
		cout << "3" << endl;
	}
	else if (a == 2 && b == 3) {
		cout << "1" << endl;
	}
	else if (a == 3 && b == 1) {
		cout << "2" << endl;
	}
	else if (a == 3 && b == 2) {
		cout << "1" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//MessageBox(GetForegroundWindow(),"标题","内容",MB_YESNO);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int s=a*c;
	int sum=a*d;
	int ans=b*c;
	int x=b*d;
	cout<<max(s,max(sum,max(ans,x)))<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
          int x,y;
           cin>>x>>y;
           int ans=0;
           if(x==3)ans+=100000;
           if(x==2)ans+=200000;
           if(x==1)ans+=300000;
           if(y==3)ans+=100000;
           if(y==2)ans+=200000;
           if(y==1)ans+=300000;
           if(x==1&&y==1)ans+=400000;
           cout<<ans<<endl;
}

Measured memory_bytes: 3640
require "date"
arr = Array.new
until (line = gets) == "0 0\n"
  arr << line
end
arr.each do |i|
  a = i.split(" ")
  a.map!{|j| j.to_i}
  m = a[0]
  d = a[1]
  wday = ["Sunday",
          "Monday",
          "Tuesday",
          "Wednesday",
          "Thursday",
          "Friday",
          "Saturday"]
  day = Date::new(2004, m, d)
  puts wday[day.wday]
end

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

int main(){
	vector<string> w={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string s;
	cin >> s;

	for(int i=0; i<7; ++i){
		if(s==w[i]){
			cout << 7-i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // header file includes every Standard library
using namespace std;
#define mod 1000000007

long long power(long long  x, unsigned int y)
{
    long long  res = 1;     // Initialize result

    x = x % mod; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % mod;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % mod;
    }
    return res;
}
int main()
{

    int n;
    cin>>n;
    long long ans=0;
    long long temp;
    vector<long long> t;
    while(n--)
    {
        cin>>temp;
        t.push_back(temp);

    }
    long long sum[t.size()]={0};
    for(int i=t.size()-2;i>=0;i--)
    {
        sum[i]=(sum[i]+sum[i+1]+t[i+1])%mod;
    }
    for(int i=0;i<t.size();i++)
    {


            ans=(ans+(t[i]%mod*sum[i]%mod)%mod)%mod;
    }
    cout<<ans;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int R,G,B,N; cin>>R>>G>>B>>N;
  int cnt=0;
  for (int i=0; i<=N; i++) {
    for (int j=0; j<=N; j++) {
      int left = N - R*i - G*j;
      if (left<0) continue;
      double q = left/(double)B;
      if (floor(q) == q) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
dic = {}
for si in s:
    dic[si] = 0
for si in s:
    dic[si] += 1
#dic
cnt = 0
cnt_len = 0
for i, j in dic.items():
    #print(i, j)
    cnt_len += 1
    if j == 2:
        cnt += 1
if cnt == 2 and cnt_len == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main ( ) {
	int x ;
	int a ;
	int b ;
	int f ;
	int n ;
	cin >> x >> a >> b ;
	f = fabs ( x - a ) ;
	n = fabs ( x - b ) ;
	if ( f < n ) {
		cout << "A";
		cout << endl ;
	}
	else if ( f > n ) {
		cout << "B";
		cout << endl ;
	}
	return 0 ; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long fac[3005],fx[3005],inv[3005];
const int mod=1e9+7;
void init()
{
	fac[1]=1;for(int i=2;i<=3001;++i)fac[i]=fac[i-1]*i%mod;
	inv[0]=inv[1]=1;for(int i=2;i<=3001;++i)inv[i]=(mod-mod/i)%mod*inv[mod%i]%mod;
	fx[0]=fx[1]=1;for(int i=2;i<=3001;++i)fx[i]=inv[i]*fx[i-1]%mod;
}
struct node
{
	int l,r;
}p[3005],q[3005];
int a[3005];
char s[3005];
long long dp[3005][3005];
int n,m;
long long c[3005][3005];
void pre_C(){
	for(int i=0;i<=3000;i++){
		c[i][0]=1;
		for(int j=1;j<=i;j++){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	}
}
long long C(int n,int m)
{
	return c[n][m];
}
int main()
{
	pre_C();
	scanf("%d%d",&n,&m);scanf("%s",s);
	for(int i=0;i<n;++i)
	a[i+1]=a[i]+s[i]-'0';
	int cnt=0;
	for(int i=1;i<=m;++i)scanf("%d%d",&p[i].l,&p[i].r);
	for(int i=1;i<=m;i++)
	{
		if(p[i].l==p[i+1].l&&p[i].r<=p[i+1].r){
			continue;
		}
		int j=i+1;
		while(p[i].l<=p[j].l&&p[i].r>=p[j].r&&j<=m)
		{
			++j;
		}
		q[++cnt].l=p[i].l;q[cnt].r=p[i].r;
		i=j-1;
	}m=cnt;
	memset(dp,0,sizeof(dp));
	q[m+1].l=n+1;q[m+1].r=n+1;a[n+1]=a[n];
	dp[1][a[q[1].r]-a[q[1].l-1]]=1;
	for(int i=1;i<=m;++i){
		if(q[i].r<q[i+1].l){
			int tmp=a[q[i+1].r]-a[q[i+1].l-1];
			for(int j=0;j<=q[i].r-q[i].l+1;++j)
			dp[i+1][tmp]=(dp[i+1][tmp]+dp[i][j]*C(q[i].r-q[i].l+1,j)%mod)%mod;
			
		}
		else
		{
			int tmp=a[q[i+1].r]-a[q[i].r];
			int t=q[i].r-q[i].l+1;
			int pre=q[i+1].l-q[i].l;
			int len=q[i].r-q[i+1].l+1;
			for(int j=0;j<=t;++j)
			for(int k=max(0,j-pre);k<=j&&k<=len;++k){
				dp[i+1][tmp+k]=(dp[i+1][tmp+k]+dp[i][j]*C(pre,j-k)%mod)%mod;
			}
		}
	}
	printf("%lld",dp[m+1][0]%mod);
	return 0;
} 

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

int gcd(int a, int b){
  while(1){
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = gcd(a[0], a[1]);
  for(int i = 2; i < n; i++){
    ans = gcd(ans, a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#define rep(i,n)for(int i=0;i<n;i++)
#define l int64_t
using namespace std;l q,x,y,f[99]={0,1},m=1e9+7;main(){cin>>q;rep(i,97)f[i+2]=f[i]+f[i+1];rep(i,q){cin>>x>>y;if(x>y)swap(x,y);if(y<=2){cout<<1<<" "<<(y==1?1:x==1?2:4)<<" ";continue;}rep(j,99){if(x<f[j]||y<f[j+1]){l a=x==1?2:1;rep(k,j-2){l n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];if(n<=x&&m<=y)a+=(y-m)/n+1;}if(f[j]<=x){a++;rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);}cout<<j-2<<" "<<a%m<<" ";j=99;}}}}

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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int a,b;
	
	cin >> a >> b;
	
	cout << max(a+b,max(a-b,a*b)) << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

int n,k,sum,x,mul,pul;
cin >> n >> k;
x = 1;
for (int  i = 0; i < n; i++)
{
    mul = x*2;
    pul = x+k;
    x = min(mul,pul);    
}
cout << x << endl;



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    char[] S = in.nextLine().toCharArray();
    int one = 0, zero = 0;
    for (int i = 0; i < S.length; i++) {
      if (i % 2 == 0) {
        if (S[i] == '0') {
          one++;
        } else {
          zero++;
        }
      } else {
        if (S[i] == '1') {
          one++;
        } else {
          zero++;
        }
      }
    }
    System.out.println(Math.min(one, zero));
  }
}

Measured memory_bytes: 26176
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int MAXN = 200005;
long long a[MAXN], b[MAXN], cnt0;
map<pair<long long, long long>, long long> mp;
set<pair<long long, long long>> vis;
long long fac[MAXN], invfac[MAXN], inv[MAXN];
int n;
void init(int n)
{
    invfac[0] = 1;
    fac[0] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = ((mod - mod / i) * inv[mod % i]) % mod;
    for (int i = 1; i <= n; ++i)
        fac[i] = fac[i - 1] * i % mod, invfac[i] = invfac[i - 1] * inv[i] % mod;
}
long long C(int n, int m)
{
    return fac[n] * invfac[m] % mod * invfac[n - m] % mod;
}
long long quickpow(long long x, long long y)
{
    long long ans = 1;
    while (y)
    {
        if (y & 1)
        {
            ans = (x * ans) % mod;
        }
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
int main()
{
    scanf("%d", &n);
    init(200000);
    int cntl = 0, cntr = 0;
    for (int i = 1; i <= n; ++i)
    {
        scanf("%lld %lld", &a[i], &b[i]);
        if (a[i] == 0 && b[i] == 0)
        {
            ++cnt0;
            continue;
        }
        if (a[i] == 0)
        {
            cntl++;
            continue;
        }
        if (b[i] == 0)
        {
            cntr++;
            continue;
        }
        long long _g = abs(__gcd(a[i], b[i]));
        a[i] /= _g;
        b[i] /= _g;
        if (a[i] >= 0)
            mp[make_pair(a[i], b[i])]++;
        else
            mp[make_pair(-a[i], -b[i])]++;
    }
    long long ans = 1;
    for (auto &i : mp)
    {
        pair<long long, long long> nex = make_pair(-i.first.second, i.first.first);
        if (nex.first < 0)
        {
            nex.first *= -1;
            nex.second *= -1;
        }
        if (vis.find(i.first) == vis.end() && vis.find(nex) == vis.end())
        {
            long long A = i.second;
            long long B;

            map<pair<long long, long long>, long long>::iterator it = mp.find(nex);
            if (it != mp.end())
            {
                B = it->second;
            }
            else
            {
                B = 0;
            }

            ans = ans * ((quickpow(2, A) + quickpow(2, B) - 1) % mod);
            ans %= mod;

            vis.insert(i.first);
            vis.insert(nex);
        }
    }
    ans = ans * (quickpow(2, cntl) + quickpow(2, cntr) - 1) % mod;
    ans--;
    ans = ((ans % mod) + mod) % mod;

    printf("%lld\n", (ans + cnt0) % mod);
    return 0;
}


Measured memory_bytes: 48996
//took help from errichto
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> dp(3);
    for(int i =0;i<n;i++)
    {
	vector<int> current_dp(3,0);	// local dp solution after taking current input
	vector<int> inp(3);		// To take input

	for(int j=0;j<3;j++)
	    cin>>inp[j];
	for(int i=0;i<3;i++)
	{
	    for(int j=0;j<3;j++)
	    {
		if(i!=j)
		{
		   current_dp[j] = max(current_dp[j], dp[i] + inp[j]); 
		}
	    }
	}

	dp = current_dp;
    }

    cout<<max(dp[0],max(dp[1],dp[2]));
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort()
ok=a[-1]*f[-1]
ng=0
if sum(a)<=k:print(0);exit()
ma=ok
while ng+1!=ok:
  mid=(ok+ng)//2
  b=[mid//i for i in f]
  b.sort()
  h=0
  for i in range(n):h+=max(0,a[i]-b[i])
  if h<=k:ok=mid
  else:ng=mid
print(ok)

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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n),x(n,0);
  r(i,n){
    cin >> v[i];
    if(!i)x[0]+=v[i];
    else if(i%2==0)x[0]-=v[i];
    else x[0]+=v[i];
  }
  x[n-1]=(v[0]-x[0]/2)*2;
  r(i,n-2) x[i+1]=(v[i+1]-x[i]/2)*2;
  cout<<x[n-1]<<" ";
  r(i,n-2)cout<<x[i]<<" ";
  cout<<x[n-2]<<endl;
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main(){
int a,b,c,k,x[1000][4],p[500];
while(true){
for(int i=0;i<500;i++){p[i]=2;}
cin>>a>>b>>c;
if(a==0 && b==0 && c==0){break;}
cin>>k;
for(int i=0;i<k;i++){
cin>>x[i][0]>>x[i][1]>>x[i][2]>>x[i][3];
if(x[i][3]==1){p[x[i][0]]=1;p[x[i][1]]=1;p[x[i][2]]=1;}
}
for(int i=0;i<k;i++){
if(p[x[i][0]]==1 && p[x[i][1]]==1&& x[i][3]==0){p[x[i][2]]=0;}
if(p[x[i][0]]==1 && p[x[i][2]]==1&& x[i][3]==0){p[x[i][1]]=0;}
if(p[x[i][1]]==1 && p[x[i][2]]==1&& x[i][3]==0){p[x[i][0]]=0;}
}
for(int i=1;i<=a+b+c;i++){cout<<p[i]<<endl;}
}
return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<ll> p(n);

    REP(i, n) cin >> p[i];

    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 1);

    sort(ord.begin(), ord.end(), [&](int i, int j) {
        return p[i - 1] > p[j - 1];
    });

    multiset<int> s; ll ans = 0;
    REP(i, 2) {
        s.insert(0); s.insert(n + 1);
    }
    
    for (int i : ord) {
        auto itr = s.upper_bound(i);
        auto w = *prev(itr, 2), x = *prev(itr), y = *itr,  z = *next(itr);
        
        ans += p[i - 1] * ((i - x) * (z - y) + (x - w) * (y - i));

        s.insert(i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6144
import math
n=int(input())
if n==1:
  print(0)
else:
  x=[]
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      x.append(i)
      if n//i!=i:
        x.append(n//i)
  x.append(n)
  x.sort()
  sosu=[]
  for i in x:
    for j in range(2,int(math.sqrt(i))+1):
      if i%j==0:
        break
    else:
      sosu.append(i)
  ans=0
  for i in x:
    if n//i>=1:
      for j in sosu:
        for k in range(1,int(math.log(i,j))+1):
          if j**k==i:
            if n%i==0:
              ans+=1
              n/=i
              break
    else:
      break
  print(ans)

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

namespace ALDS1_11_C
{
    class Program
    {
        static int n;
        static int[,] neighborList;
        static int[] shortestPath;
        static bool[] isVisited;


        static void Main(string[] args)
        {
            Program.n = int.Parse(Console.ReadLine());
            Program.neighborList = new int[n, n];
            Program.shortestPath = new int[n];
            Program.shortestPath[0] = 0;
            Program.isVisited = new bool[Program.n];
            Program.isVisited[0] = true;
            for (int i = 1; i < Program.n; i++)
            {
                Program.shortestPath[i] = -1;
            }
            for (int i = 0; i < Program.n; i++)
            {
                int[] tmpLine = Console.ReadLine()
                                       .Split(' ')
                                       .Select(s => int.Parse(s))
                                       .ToArray();
                for (int j = 2; j <= tmpLine[1] + 1; j++)
                {
                    Program.neighborList[tmpLine[0] - 1, tmpLine[j] - 1] = 1;
                }
            }
            Queue<int> nodeQueue = new Queue<int>();
            nodeQueue.Enqueue(1);
            while (nodeQueue.Count() > 0)
            {
                Program.BreadthFirstSearch(nodeQueue);
            }
            for (int i = 0; i < Program.n; i++)
            {
                Console.WriteLine(string.Format("{0} {1}", i + 1, Program.shortestPath[i]));
            }
        }

        static void BreadthFirstSearch(Queue<int> nodeQueue)
        {
            int tmpNode = nodeQueue.Dequeue();

            for (int i = 0; i < Program.n; i++)
            {
                if (!Program.isVisited[i] && Program.neighborList[tmpNode - 1, i] == 1)
                {
                    Program.shortestPath[i] = Program.shortestPath[tmpNode - 1] + 1;
                    Program.isVisited[i] = true;
                    nodeQueue.Enqueue(i + 1);
                }
            }

        }
    }
}



Measured memory_bytes: 18716
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 3 * 100 * 1000;
int nbSurColonne[MAXN];

struct Objet
{
	int x , y;
	bool operator < (const Objet & autre) const
	{
		return x < autre.x || (x == autre.x && y < autre.y);
	}
};

struct pr_set
{
	int val , id;
	bool operator < (const pr_set & autre) const
	{
		return val > autre.val || (val == autre.val && id > autre.id);
	}
};

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int nbLignes , nbColonnes;
	cin >> nbLignes >> nbColonnes;
	int nbObjets;
	cin >> nbObjets;
	Objet objets[nbObjets];
	for (int i = 0 ; i < nbObjets ; i++)
	{
		cin >> objets[i].x >> objets[i].y;
		objets[i].x--;
		objets[i].y--;
		nbSurColonne[objets[i].y]++;
	}
	sort(objets , objets + nbObjets);
	set <pr_set> enCours;
	int maxi = 0;
	int in = 0;
	for (int i = 0 ; i < nbColonnes ; i++)
	{
		enCours.insert({nbSurColonne[i] , i});
	}
	for (int iLig = 0 ; iLig < nbLignes ; iLig++)
	{
		int inFin = in;
		while (inFin < nbObjets && objets[inFin].x == iLig)
		{
			enCours.erase({nbSurColonne[objets[inFin].y] , objets[inFin].y});
			enCours.insert({nbSurColonne[objets[inFin].y] - 1, objets[inFin].y});
			inFin++;
		}
		auto it = enCours.begin();
		auto pp = *it;
		maxi = max(maxi , inFin - in + pp.val );
		for (int j = in ; j < inFin ; j++)
		{
			enCours.erase({nbSurColonne[objets[j].y] - 1 , objets[j].y});
			enCours.insert({nbSurColonne[objets[j].y], objets[j].y});	
		}
		in = inFin;
	}
	cout<<maxi<<endl;
}

Measured memory_bytes: 29436
#!/usr/bin/env python3

import collections
N = int(input())
A = sorted(list(map(int, input().split())))[::-1]

ret = A[0]

cnt = 2
for i in range(1, N):
    for j in range(2):
        if cnt == N:
            print(ret)
            exit()
        ret += A[i]
        cnt += 1

print(ret)


Measured memory_bytes: 96256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim],Height[lim],C[lim];
inline lld powerFive(lld x) {
    return x * x * x * x * x;
}

int main(){
    lld x = sc();
    rep(i,-300,300) rep(j,-300,300) {
        if(powerFive(i) - powerFive(j) == x) {
            printf("%lld %lld\n", i, j);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3812
#include <iostream>
using namespace std; 
int main(){
    int x,y,w,h,r;
    cin >>w>>h>>x>>y>>r;     
    if(x<=w-r&&x>=r&&y<=h-r&&y>=r)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <algorithm>
#include <cassert>
#include <cstring>
#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)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  vector<vector<int>> sol;
  int P = 37;

  REP(i, P) REP(j, P) {
    // i = start col
    // j = shift between cols
    vector<int> v;

    REP(r, P) {
      int c = (j + i * r) % P;
      v.push_back(r*P + c);
    }
    v.push_back(P*P + i);
    
    sol.push_back(v);
  }

  REP(i, P+1) {
    vector<int> v;
    REP(j, P) {
      v.push_back(i*P + j);
    }
    v.push_back(P*P + P);
    
    sol.push_back(v);
  }


  int N = P*P + P + 1;
  int K = P + 1;

  printf("%d %d\n", N, K);
  for (auto& row: sol) {
    for (int x: row) printf("%d ", x+1);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 768
# created by dipta10 

n = int(input())
ls = list(map(int, input().split(' ')))

ls = sorted(ls)
f = 1
ans = 1
inf = 1000000000000000000
for x in ls:
    ans *= x
    if ans > inf:
        f = 0
        break

if f == 1:
    print(ans)
else:
    print("-1")



Measured memory_bytes: 21480
A,B =gets.chomp.split.map(&:to_i)

if B == 1
  puts 0
elsif A == 2
  puts (B-1)
else
  n = B/(A-1)
  remainder = B%(A-1)

  if remainder == 1 || remainder == 0
    puts n
  else
    puts (n+1)
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   ll n, k;
   cin >> n >> k;
   ll ans = n % k;
   ans = min(ans, k - ans);
   cout << ans << endl;
   return 0;
}

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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

int main()
{
    int N, M;
    while (cin >> N >> M && N)
    {
        vector<int> P(N + 1);
        P[0] = 0;
        rep(i, N) cin >> P[i + 1];

        vector<ll> candi;

        rep(i, N + 1)
        {
            for (int j = i + 1; j <= N; j++)
            {
                candi.push_back(P[i] + P[j]);
            }
        }

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

        ll ans = 0;

        rep(i, candi.size())
        {
            ll diff = M - candi[i];

            if (diff < 0) break;

            int l = 0, r = candi.size();

            auto itr = upper_bound(candi.begin(), candi.end(), diff);

            ans = max(ans, (M >= candi[i] + *(itr - 1) ? candi[i] + *(itr - 1) : 0));
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 10800
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    total = sum(A)
    ans = N - total
    if ans < 0:
        print(-1)
    else:
        print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 10676
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int n; 
	while (cin >> n, n) {
		double val, ave, sum = 0, sqsum = 0;
		for (int i = 0; i < n; ++i) {
			cin >> val;
			sum += val;
			sqsum += val*val;
		}
		ave = sum/n;
		cout << setprecision(20) << fixed << sqrt(sqsum/n - (ave*ave)) << endl;
	}
	return 0;
}



Measured memory_bytes: 3292
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long a[n+1];
    long long b[n+1];
    for(long long i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
	for(long long i=1;i<=n;i++)
    {
    	cin>>b[i];
	}
	long long sum1=0,sum2=0;
	for(long long i=1;i<=n;i++)
    {
        if(a[i]>b[i])
		{
			sum1+=(a[i]-b[i]);
		 } 
        if(a[i]<b[i]) 
		{
			sum2+=(b[i]-a[i])/2;
		}
    }
    if(sum1<=sum2)
	{
		cout<<"Yes"<<endl;
	 }
    else
	{
		cout<<"No"<<endl;
	 }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	HashMap<String, String> map=new HashMap<String, String>();
	String start, end;
	int ans;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			map.clear();
			for(int i=0; i<n; i++){
				String s=sc.next();
				String t=sc.next();
				map.put(s, t);
			}
			start=sc.next();
			end=sc.next();
			ans=-1;
			dfs(start, 0);
			println(""+ans);
		}
	}

	void dfs(String s, int r){
		if(r>=ans&&r>=10){
			return;
		}else if(s.length()>end.length()){
			return;
		}else if(s.equals(end)){
			if(ans==-1||r<ans){
				ans=r;
			}
			return;
		}
		for(Entry<String, String> entry : map.entrySet()){
			if(s.contains(entry.getKey())){
				String t=s.replaceAll(entry.getKey(), entry.getValue());
				dfs(t, r+1);
			}
		}
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();

	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    long long n; cin>>n;
    long long x,y;
    x= n*800;
    y= (n/15)*200;
    cout<<x-y;
}


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

int n, m;
std::vector<std::string> a, b;
bool ans;

int main(){
	std::cin >> n >> m;
	std::string s;
	for(int i=0; i<n; ++i){
		std::cin >> s;
		a.push_back(s);
	}
	for(int i=0; i<m; ++i){
		std::cin >> s;
		b.push_back(s);
	}
	for(int i=0; i+m<=n; ++i)
		for(int j=0; j+m<=n; ++j){
			bool f = true;
			for(int k=0; k<m; ++k)
				for(int l=0; l<m; ++l)
					if(a[i+k][j+l] != b[k][l])
						f = false;
			if(f) ans = true;
		}
	if(ans) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array

const int MOD = 1000000007;

void add_self(int& a, int b){
	a += b;
	if(a >= MOD){
		a -= MOD;
	}
}

void solve(){
	int h, w;
	cin >> h >> w;
	vector<string> vecs(h);
	for(int i = 0;i < h; i++){
		cin >> vecs[i];
	}
	vector<vector<int>> dp(h,vector<int>(w,0));
	dp[0][0] = 1;
	for(int r = 0; r < h; ++r){
		for(int c = 0; c < w; ++c){
			for(int r2 : {r, r+1}){
				int c2 = c;
				if(r2 == r){
					c2++;
				}
				if(c2 < w && r2 < h && vecs[r2][c2]=='.'){
					add_self(dp[r2][c2], dp[r][c]);
				}
			}
		}
	}
	cout << dp[h-1][w-1] << "\n";
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 12152
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <climits>
#include <stack>
#include <string>
#include <random>
std::vector<int> primes(const int upper) {
	std::vector<int> res;
	std::vector<bool> memo(upper + 1, true);
	for (auto i = 2; i * i < upper; ++i) {
		if (memo[i]) {
			for (auto j = 2 * i; j < upper; j += i) {
				memo[j] = false;
			}
		}
	}
	for (auto i = 2; i <= upper; ++i) {
		if (memo[i]) res.push_back(i);
	}
	return res;
}
int cal_prime_factor(int n, const int prime) {
	int res = 0;
	while (n != 0) {
		res += n / prime;
		n /= prime;
	}
	return res;
}
int main() {
	auto prime = primes(100);
	int n;
	std::cin >> n;
	int over74 = 0;
	int over24 = 0;
	int over14 = 0;
	int over4 = 0;
	int over2 = 0;
	for (const auto p : prime) {
		auto r = cal_prime_factor(n, p);
		if (r >= 74) ++over74;
		if (r >= 24) ++over24;
		if (r >= 14) ++over14;
		if (r >= 4) ++over4;
		if (r >= 2) ++over2;
	}
	int res = over74;
	res += over24 * (over2 - 1);
	res += over14 * (over4 - 1);
	res += over4 * (over4 - 1) * (over2 - 2) / 2;
	std::cout << res << std::endl;
}
/*



*/


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int,int>> sc(m);
  REP(i,m) {
    cin >> sc[i].first >> sc[i].second;
    sc[i].first--;
  }
  int max_num = 1;
  REP(i,n) max_num *= 10;
  int sta_num;
  if (n==1) sta_num = 0;
  else if (n==2) sta_num = 10;
  else sta_num = 100;
  FOR(i,sta_num,max_num) {
    string s = to_string(i);
    bool judge = true;
    REP(j,m) {
      int sj = s[sc[j].first]-'0';
      if (sj!=sc[j].second) judge = false;
    }
    if (judge) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<int(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using Weight = string;
Weight INF = "~";
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
  while(true) {
    int n,a,s,g;
    cin>>n>>a>>s>>g;
    if(!n) break;
    Edges ve;
    REP(i,a) {
      int x,y;
      string lab;
      cin>>x>>y>>lab;
      ve.push_back((Edge){x, y, lab});
    }
    int v = n*6*2;
    Matrix d(v+1, Array(n, INF));
    d[0][s] = "";
    REP(i,v) {
      for(Edge e:ve) {
        int l=e.weight.size();
        if (i+l > v) continue;
        d[i+l][e.dest] = min(d[i+l][e.dest], d[i][e.src]+e.weight);
      }
    }
    string res = INF;
    bool ok = true;
    REP(i,v+1) {
      if (d[i][g] < res) {
        res = d[i][g];
        if (i >= n*6) ok = false;
      }
    }
    if (res != INF && ok) {
      cout << res << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 11660
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct tup {ll x,s,t;};

int main(){
    ll N, Q; cin >> N >> Q;
    vector<tup> tpl(N);
    vpl pidx;
    REP(i, N){
        ll s,t,x; cin >> s >> t >> x;
        tpl[i].x = x;
        tpl[i].s = s;
        tpl[i].t = t;
        pidx.pb({x,i});
    }
    sort(pidx.begin(), pidx.end());
    vl D(Q+1); REP(i, Q) cin >> D[i]; D[Q] = LINF;
    
    vl ans(Q, -1); set<PL> se; REP(i, Q) se.insert({D[i], i});
    REP(i, N){
        auto tt = tpl[pidx[i].ss];
        ll x = tt.x;
        ll s = tt.s - x;
        ll t = tt.t - x;
        auto its = se.lower_bound({s, -1});
        while(!se.empty() && its != se.end() && its->ff < t){
            ans[its->ss] = x;
            se.erase(its++);
        }
    }
    
    REP(i, Q){
        cout << ans[i] << endstr;
    }
    return 0;
}


Measured memory_bytes: 25324
a, b, c = map(int, input().split())#赤midoriao
k = int(input())
#赤＜緑＜青
if (a < b) and (b<c):
  print("Yes")
else:
  while (a>=b) and (k>0):
    b = b*2
    k-=1
  #print(b)
  #print(k)
  while (b>=c) and (k>0):
    c = c*2
    k-=1
  #print(c)
  #print(k)
#print(a,b,c,k)
  if (a < b) and (b<c) and (k>=0):
    print("Yes")
  else:
    print("No")
    

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

int my_ceil(int a, int b){
  return (a + b - 1) / b;
}

int main(){
  int H, A;
  cin >> H >> A;
  cout << my_ceil(H, A) << endl;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int n = line[0], m = line[1];

            var dic = new Dictionary<int, int>();

            foreach (var i in Enumerable.Range(1, m))
            {
                dic[i] = 0;
            }

            for (var i = 0; i < n; i++)
            {
                var k = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();

                for (var j = 1; j <= k[0]; j++)
                {
                    dic[k[j]]++;
                }
            }

            Console.WriteLine($"{dic.Values.Count(c => c == n)}");
        }
    }
}


Measured memory_bytes: 13524
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        String t=sc.next();
        for(int i=0;i<s.length();i++){
            s=s.charAt(s.length()-1)+s.substring(0,s.length()-1);
            if(s.equals(t)){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21588
N, K = gets.split(' ').map(&:to_i)
R, S, P = gets.split(' ').map(&:to_i)
T = $stdin.read
# r グー, s チョキ p パー
result = 0

STR_R = "r"
STR_S = "s"
STR_X = "!"

N.times do |i|

  rsp = T[i]
  if i < K || rsp != T[i-K]
    case rsp
    when STR_R
      result += P
    when STR_S
      result += R
    else
      result += S
    end
  else
    T[i] = STR_X
  end
end
puts result

Measured memory_bytes: 1916
#include<iostream>

using namespace std;

int MAX_N = 100;

int main()
{
    // スペース区切りの整数の入力
    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    



    


    return 0;
}

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

int main() {
  int N,X;cin>>N>>X;
  vector<int> L(N);
  for(int i=0;i<N;i++) cin>>L.at(i);
  
  int sum=0,count=1;
  for(int i=0;i<N;i++){
    sum+=L.at(i);
    if(sum<=X)count++;
    else break;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3592
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
ans = [-1]*n

for i in range(m):
    s, c = MAP()
    s -= 1
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()

if ans[0] == 0:
    if n == 1:
        print(0)
    else:
        print(-1)
    exit()
else:
    for i in range(n):
        if ans[i] == -1:
            if n != 1 and i == 0:
                ans[i] = 1
            else:
                ans[i] = 0
    print(*ans, sep='')

Measured memory_bytes: 9948
#include <bits/stdc++.h>
using namespace std;
vector<int> ls[100];
bool visited[100];
int dfs(int now,int l){
	int ans=l;
	visited[now]=true;
	for(int i=0;i<(int)ls[now].size();i++){
		if(visited[ls[now][i]])	continue;
		ans=max(ans,dfs(ls[now][i],l+1));
	}
	visited[now]=false;
	return ans;
}
int main(){
	while(true){
		int n;	cin>>n;
		if(n==0)	return 0;
		for(int i=0;i<100;i++)	ls[i].clear();
		set<int> uses;
		for(int i=0;i<n;i++){
			int a,b;	cin>>a>>b;	a--;	b--;
			uses.insert(a);	uses.insert(b);
			ls[a].push_back(b);	ls[b].push_back(a);
		}
		int ans=0;
		for(auto it=uses.begin();it!=uses.end();it++){
			ans=max(ans,dfs(*it,1));
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, T; cin >> N >> T;
    vl A(N); REP(i, N) cin >> A[i];
    vl B(N);
    ll m = INFL;
    REP(i, N)
    {
        chmin(m, A[i]);
        B[i] = (A[i] - m) * T / 2;
    }
    m = *max_element(ALL(B));
    ll c = 0;
    REP(i, N) if(B[i] == m) c++;
    cout << c << endl;
}

Measured memory_bytes: 4752