akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
int main(){
	ll N;
	cin >> N;
	vl H(N);
	REP(i, N){
		cin >> H[i];
	}
	ll ans = 0;
	ll anskari = 0;
	REP(i, N-1){
		if(H[i] >= H[i+1]){
			anskari++;
		} else {
			if(anskari > ans){
				ans = anskari;
			}
			anskari = 0;
		}
	}
	if(anskari > ans){
		ans = anskari;
	}
	cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

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

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

	int arr[3];

	cin >> arr[0] >> arr[1] >> arr[2];

	sort(arr, arr + 3);

	if (arr[0] == 5 && arr[1] == 5 && arr[2] == 7) Out("YES");
	else Out("NO");
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]"):
    c = 0
    for i in range(N):
        b, a = B[i], A[i]
        if b >= a:
            c += a
            b -= a
            if A[i+1] >= b:
                c += b
                A[i+1] -= b
            else:
                c += A[i+1]
                A[i+1] = 0
        else:
            c += B[i]
    
    print(c)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N+1) ]  # type: "List[int]"
    B = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A, B)

if __name__ == '__main__':
    main()


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N,D;cin>>N>>D;
    vector<vector<int>> S(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>S[i][j];
        }
    }
    int cnt=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int sum=0;
            for(int k=0;k<D;k++){
                sum+=(S[i][k]-S[j][k])*(S[i][k]-S[j][k]);
            }
            for(int k=0;k*k<=sum;k++){
                if(k*k==sum) cnt++;
            }
        }
    }
    
    cout<<cnt<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
long long mod = 1e9+7;
string grid[1005];
long long dp[1005][1005];
int main() {
	int H, W; cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> grid[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i == 0 and j == 0) dp[i][j] = 1;
			if (i > 0 and grid[i][j] == '.') dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
			if (j > 0 and grid[i][j] == '.') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
		}
	}
	cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		
		if(x <= 599){
			System.out.println(8);
		}else if(x <= 799){
			System.out.println(7);
		}else if(x <= 999){
			System.out.println(6);
		}else if(x <= 1199){
			System.out.println(5);
		}else if(x <= 1399){
			System.out.println(4);
		}else if(x <= 1599){
			System.out.println(3);
		}else if(x <= 1799){
			System.out.println(2);
		}else {
			System.out.println(1);
		}
		
		

	}

}

Measured memory_bytes: 35684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define rvp(i,x,y) for(int i=y;i>=x;i--)
#define sc scanf
#define pr printf
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<string.h>
using namespace std;

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

struct P {
  int maxx,maxy,minx,miny;
  P() {
    maxx = maxy = -1;
    minx = miny = 51;
  }
};

int dist[26][26];
int visited[26];

bool visit(int i) {
  if(i<0 || i>25) return false;
  visited[i] = 2;
  for(int j=0; j<26; ++j) {
    if(dist[i][j] == 0) continue;
    if(visited[j] != 0) {
      if(visited[j] == 2) return false;
    } else if (!visit(j)) return false;
  }
  visited[i] = 1;
  return true;
}

int main() {
  int h,w,n,k,l,start,now,i,j;
  string s;
  cin>>n;
  while(n--) {
    cin>>h>>w;
    vector<string> in;
    memset(dist, 0, sizeof(dist));
    memset(visited, 0, sizeof(visited));
    for(i=0; i<h; ++i) {
      cin>>s;
      in.push_back(s);
    }

    for(k=0; k<26; ++k) {
      for(l=0; l<26; ++l) {
	dist[k][l] = 0;
      }
    }

    set<char> badget;
    map<char, P> mp;
    queue<int> Q;
    for(i=0; i<h; ++i) {
      for(j=0; j<w; ++j) {
	if(in[i].at(j) != '.') {
	  badget.insert(in[i].at(j));
	  mp[in[i].at(j)].maxx = max(mp[in[i].at(j)].maxx, j);
	  mp[in[i].at(j)].maxy = max(mp[in[i].at(j)].maxy, i);
	  mp[in[i].at(j)].minx = min(mp[in[i].at(j)].minx, j);
	  mp[in[i].at(j)].miny = min(mp[in[i].at(j)].miny, i);
	}
      }
    }

    if(badget.size() == 0) {
      cout<<"SAFE"<<endl;
      goto NEXT;
    }

    for(set<char>::iterator it = badget.begin(); it != badget.end(); ++it) {
      int maxx = mp[(*it)].maxx,maxy = mp[(*it)].maxy;
      int minx = mp[(*it)].minx,miny = mp[(*it)].miny;
      for(i=miny; i<=maxy; ++i) {
	for(j=minx; j<=maxx; ++j) {
	  if(in[i].at(j) == '.') {
	    cout<<"SUSPICIOUS"<<endl;
	    goto NEXT;
	  }else if(in[i].at(j) != (*it)) {
	    dist[(*it)-'A'][in[i].at(j)-'A'] = 1;
	  }
	}
      }
    }

    //±±Ég|WJ\[gð­
    //dist[i][j] Í iÌãÉjªæÁÄ¢éÆ¢¤ÖWð\·
    for(i=0; i<26; ++i) {
      if(!visit(i)) {
	cout<<"SUSPICIOUS"<<endl;
	goto NEXT;
      }
    }
    cout<<"SAFE"<<endl;

  NEXT:
    ;

  }
}

Measured memory_bytes: 932
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const array <ll,2> &a,const array <ll,2> &b){
    return a[1]<b[1];
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};
ll N=5e5+2;
vector <ll> bit(N);
vector <ll> lv(N,-1);
ll n;
vector <vector <array <ll,2> > >qr(N);
void upd(ll idx, ll val){
    for(;idx<n;idx=(idx | (idx+1)))
        bit[idx]+=val;
}
ll sum(ll idx){
    ll ret=0;
    for(;idx>=0;idx=(idx&(idx+1))-1)
        ret+=bit[idx];
    return ret;
}
ll sum(ll l, ll r){
    return sum(r)-sum(l-1);
}


int main(){
    IOS;
    cin>>n;
    make(ll,q);
    makevec(ll,a,n);
    vector <ll> ans(q);
    fr(i,q){
        make2(ll,l,r);
        qr[--r].push_back({--l,i});
    }
    fr(i,n){
        if(lv[a[i]]!=-1)
            upd(lv[a[i]],-1);
        lv[a[i]]=i;
        upd(i,1);
        for(auto x : qr[i]){
            ans[x[1]]=sum(x[0],i);
        }
    }
    fr(i,q) cout<<ans[i]<<endl;


    return 0;
}


Measured memory_bytes: 44180
#include <stdio.h>

int main(void){
     int turn = 0;
while(1){
    int i = 0;
    turn ++;
    scanf("%d\n",&i);
    if(i){
        printf("Case %d: %d\n",turn,i);
    }
    else{
        break;
    }
}
return 0; /*0?????????*/
}

Measured memory_bytes: 2704
MOD = 10**9+7
N, K = list(map(int, input().split()))
t = {}
ans = 0

for i in range(K, 0, -1):
    n = pow(K//i, N, MOD)

    for j in range(2*i, K+1, i):
        n -= t[j]
    t[i] = n
    ans = (ans + i * n) % MOD
print(ans)

Measured memory_bytes: 20720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int main() {
  ll n,k,cnt=0; cin >> n >> k;
  int ans=0;
  vector<p> v(n);
  for(int i=0; i<n; i++) {
    int a,b;
    cin >> a >> b;
    v[i].first=a;
    v[i].second=b;
  }
  sort(v.begin(),v.end());
  for(int i=0; i<n; i++) {
    cnt+=v[i].second;
    if(cnt>=k) {
      ans=v[i].first;
      break;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<stdlib.h>

using namespace std;

int main()
{
    int sum = 0,N,L,minidx = 0,minabs = 500;
    cin >> N >> L;
    int abs_taste[N];

    for(int i=0;i<N;i++)
    {
        abs_taste[i] = abs(L+1+i-1);
        if(abs_taste[i] < minabs)
        {
            minabs = abs_taste[i];
            minidx = i;
        } 
    }

    for(int i=0;i<N;i++)
    {
        sum += L+1+i-1;
    }

    sum -= L+1+minidx-1;

    cout << sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  vector<llong> L(87, 0);
  L[0] = 2;
  L[1] = 1;
  for(int i=2; i<=86; ++i){
    L[i] = L[i-1] + L[i-2];
  }
  int N;
  cin >> N;
  cout << L[N] << endl;
}

Measured memory_bytes: 3616
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::*;
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
use std::cmp::min;
 
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    
    // i < j, a[i] + i = j - a[j] <= j < n
    let mut ans: i64 = 0;
    let mut map  = std::collections::HashMap::new();
    for i in 0..n {
        let ind = i as i64 - a[i];
        ans += *map.get(&ind).unwrap_or(&0);
        *map.entry(a[i] + i as i64).or_insert(0) += 1;
    }
    
    println!("{}", ans);
}

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

using namespace std;

const long long NMAX = 1e5;
const long long BMAX = 60;

long long v[NMAX+2], N, K;
long long ans = 0;
long long nr[BMAX+2], sp_nr[BMAX+2], best_sp[BMAX+2];

int main()
{
    cin >> N >> K;
    for( long long i = 1;  i <= N;  ++i ) {
        cin >> v[i];
        for( long long j = 0;  j <= BMAX;  ++j ) {
            nr[j] += (((1LL << j) & v[i]) != 0);
        }
    }
    sp_nr[0] = nr[0];
    best_sp[0] = max(nr[0], N - nr[0]);
    for( long long i = 1;  i <= BMAX;  ++i )
        sp_nr[i] = sp_nr[i - 1] + (1LL << i) * nr[i],
        best_sp[i] = best_sp[i - 1] + (1LL << i) * max(nr[i], N - nr[i]);
    for( long long pre_sum = 0, b = BMAX;  b >= 0;  --b ) {
        if( ((1LL << b) & K) != 0 ) {
            if( b > 0 ) {
                ans = max(ans, pre_sum + nr[b] * (1LL << b) + best_sp[b - 1]);
            }
        }
        long long coef = nr[b];
        if( ((1LL << b) & K) != 0 )
            coef = N - nr[b];
        pre_sum += (1LL << b) * coef;

        ans = max(ans, pre_sum);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;//きゅー
int p(int a, int b) {
	int ans = 1;
	for (int i = 0; i < b; i++) {
		ans *= a;
	}

	return ans;
}
int main(void)
{
	int X;
	scanf("%d", &X);
	int max = 1;
	for (int i = 2; i < 11; i++) {
		for (int j = 1; j < 1000; j++) {
			if (p(j, i) > X) {
				break;
			}
			if (max <= p(j, i)) {
				max = p(j, i);
			}
		}
	}
	printf("%d", max);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    vector<bool> used(n+2);
    int ans = 0, x = 1;
    for(int i=n-1;i>=0;i--){
        used[p[i]] = true;
        if(p[i] == x){
            ans++;
            while(used[x]) x++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  
  if(s == u)
    a--;
  else
    b --;
  
  cout << a << " " << b << endl;
  
  return 0;
  
}

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
class E { static void Main() => new K(); }
class K
{
	const long InfL = 4011686018427387913L;
	int F => int.Parse(Console.ReadLine());
	static char[] sep = new char[] { ' ', '/' };
	int[] G => Console.ReadLine().Split(sep).Select(_ => int.Parse(_)).ToArray();
	public K()
	{
		var I = G;
		int N = I[0], M = I[1], Q = F;
		I = G;
		var a = new int[Q];
		for (var i = 0; i < Q; i++) a[i] = I[Q - i - 1] - 1;
		var ans = new List<int>(M);
		var s = new HashSet<int>();
		for (var i = 0; i < Q; i++) if (!s.Contains(a[i])) { s.Add(a[i]); ans.Add(a[i]); }
		for (var i = 0; i < M; i++) if (!s.Contains(i)) ans.Add(i);
		var rev = new Dictionary<int, int>(M);
		for (var i = 0; i < M; i++) rev[ans[i]] = i;
		var wait = new int[M + 1];
		wait[0] = N;
		for (var i = 0; i < Q; i++)
		{
			var id = rev[a[i]];
			if (wait[id] != 0) { wait[id] -= 1; wait[id + 1] += 1; }
		}
		for (var i = 0; i < M; i++)
			if (wait[i] != 0)
			{
				for (var j = i; j < M - 1; j++) if (ans[j] > ans[j + 1]) { Console.WriteLine("No"); return; }
				break;
			}
		Console.WriteLine("Yes");
	}
}

Measured memory_bytes: 18520
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int H, W;
	cin >> H >> W;

	int ways[H][W];

	for (int i = 0; i < H; ++i) {
		string row;
		cin >> row;
		for(int j = 0; j < W; ++j) {
			ways[i][j] = (row[j] == '.');
		}
	}

	for(int j = 1; j < W; ++j) {
		ways[0][j] *= ways[0][j - 1];
	}

	for(int i = 1; i < H; ++i) {
		ways[i][0] *= ways[i - 1][0];
	}
	const int mod = 1e9 + 7;
	for(int i = 1; i < H; ++i) {
		for(int j = 1; j < W; ++j) {
			if(ways[i][j] == 0) continue;
			ways[i][j] = ((ull)ways[i - 1][j] + ways[i][j - 1]) % mod;
		}
	}
	// for(int i = 0; i < H; ++i) {
	// 	for(int j = 0; j < W; ++j) {
	// 		cout << ways[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << ways[H - 1][W - 1] << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 4224
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e18
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b)  for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>
signed main(){
    FASTIO;
    ll tt=1;
    //cin>>tt;
    while(tt--){
         ll n;cin>>n;
         ll arr[n],sum=0;
         ll a[n],s=0;
         for(ll i=0;i<n;i++)cin>>a[i];
         for(ll i=n-1;i>=0;i--)s+=a[i],arr[i]=s,s%=mod;
         //for(ll i=0;i<n;i++)cout<<arr[i]<<" ";
         //cout<<"\n";
         for(ll i=0;i+1<n;i++){
            sum=(sum%mod+(a[i]%mod*arr[i+1]%mod)%mod)%mod;
         }
         cout<<sum%mod<<"\n";
    }
}


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

vector <int> graph[100003];
vector <int> ans;
queue <int >q;

int node,edge;
int indegree[100003];
bool del[100003], flag=1;

void topologicalSort(){
    for(int i=0; i<node; i++){
        if(indegree[i]==0) q.push(i);
    }

    while(!q.empty()){
        int u=q.front();
        del[u]=1;
        q.pop();
        ans.push_back(u);

        int len=graph[u].size();
        for(int i=0; i<len; i++){
            int v=graph[u][i];
            if(del[v]) flag=0;

            if(indegree[v]>0){
                indegree[v]--;
                if(indegree[v]==0) q.push(v);
            }
        }
    }
}

void print(){
    int len=ans.size();
    for(int i=0; i<len; i++){
        cout<<ans[i]<<endl;
    }
}

int main(){
    cin>>node>>edge;

    for(int i=0; i<edge; i++){
        int u,v;
        cin>>u>>v;

        graph[u].push_back(v);
        indegree[v]++;
    }

    topologicalSort();
    print();

//    if(ans.size()==node && flag) print();
//    else cout<<"-1"<<endl;
    return 0;
}

/*

6 6
0 1
1 2
3 1
3 4
4 5
5 2

*/



Measured memory_bytes: 5948
#include<bits/stdc++.h>
#define loop(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int a[250]={},b[250]={}; //aは上下、bは左右
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    for(int i=1; i<n; i++){
      int x,y;
      cin >> x >> y;
      if(y==0){  //左
	    a[i]=a[x];
	    b[i]=b[x]-1;
	  }
	  if(y==1){  //下
	    a[i]=a[x]-1;
	    b[i]=b[x];
	  }
	  if(y==2){  //右
	    a[i]=a[x];
	    b[i]=b[x]+1;
	  }
	  if(y==3){  //上
	    a[i]=a[x]+1;
	    b[i]=b[x];
	  }
    }
    int amax=0,amin=0,bmax=0,bmin=0;
    loop(i,n){
      amax = max(amax,a[i]);
      amin = min(amin,a[i]);
      bmax = max(bmax,b[i]);
      bmin = min(bmin,b[i]);
    }
    amax-=amin;
    amax++;
    bmax-=bmin;
    bmax++;
    cout << bmax << " " << amax << endl;
    }  
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//fixed<<setprecision(15);
#define yn(x) cout<<((x)?"Yes":"No")<<endl;

signed main(){
    string n; cin >> n;
    bool can=false;
    rep(i,3){
        if(n[i]=='7') can=true;
    }
    yn(can);
}


Measured memory_bytes: 3572
a, b, c, d = gets.split.map{|s| s.to_i }

times = (0..100).map{0}

(a...b).each do |i|
  times[i] += 1
end

(c...d).each do |i|
  times[i] += 1
end

times.delete(0)
times.delete(1)
puts times.size

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

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

  int ans = 0;
  for (int i = A; i <= B; i++) {
    string s = to_string(i);
    if (s.at(0) == s.at(4) && s.at(1) == s.at(3)) {
      ans++;
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,s,i,j,l;
int main(){
	scanf("%d%d",&k,&s);
	for (i=0;i<=k;i++){
		for (j=0;j<=k;j++){
			if (s-i-j<=k&&s-i-j>=0) l++;
		}
	}
	printf("%d\n",l);
}

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

int main(void){
  int i,j,k; 
  int n;
  double xave=0,esum=0;
  cin>>n;
  vector<int> x(n);
  rep(i,n){
    cin>>x.at(i);
    xave+=x.at(i);
  }
  xave/=n;
  rep(i,n){
    esum+=(x.at(i)-round(xave))*(x.at(i)-round(xave));
  }
  cout<<(int)(esum)<<endl;
}

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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

LL x, a, b;
vector<int> G[MAXN];

int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> x;
    for (a = -2000; a <= 2000; a++)
        for (b = -2000; b <= 2000; b++) {
            if (pow(a, 5) - pow(b, 5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    return 0;
}

Measured memory_bytes: 8932
#include <iostream>
using namespace std;
int a,b,c,d,e,f;
int main() {
	cin>>a>>b>>c>>d>>e>>f;
	if(a+b*5+c*10+d*50+e*100+f*500>=1000){cout<<1<<endl;}else cout<<0<<endl;
	return 0;
}


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

int main()
{
    long long int A,B;
    char s;
    cin>>A>>s>>B;

    if(s=='+')
    {
        cout<<A+B;
    }
    else
    {
        cout<<A-B;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,k;cin>>n>>k;
  vll a(n),tmp(n,0);
  vector<pair<bool,ll> > b(n);
  rep(i,0,n){
    cin>>a[i];
    a[i]--;
    b[i].first=false;
  }
  b[0].second=1;
  b[0].first=true;
  ll i=0,tmp2=1;
  while(!b[a[i]].first){
    tmp[tmp2]=a[i];
    tmp2++;
    b[a[i]].first=true;
    b[a[i]].second=tmp2;
    i=a[i];
    
  }
  ll l=b[a[i]].second,r=b[i].second;
  if(k>l-2){
    ll x=(k+2-l)%(r-l+1),ans;
    ans=x;
    if(x==0){ans=r-l+1;}
    cout<<tmp[l+ans-2]+1<<endl;
  }
  else{
    cout<<tmp[k]+1<<endl;
  }
  
}




Measured memory_bytes: 9528
import bisect
n = int(input())
l_list = list(map(int,input().split()))
l_list.sort()
ans = 0
right = 0
# print(l_list)
for i in range(n-2):
    for j in range(i+1,n-1):
        right = bisect.bisect_left(l_list[j+1:],l_list[i]+l_list[j])
        # print(right)
        ans += right
        
print(ans)

Measured memory_bytes: 50780
#include <iostream>
#define int long long
using namespace std;

int n;
int a[100000];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	int p = 1;
	int ans = 0;
	for (i = 0; i < n; i++) {
		ans += (a[i] - 1) / p;
		if (a[i] == p || p == 1) p++;
	}
	cout << ans << endl;
	return 0;
}

/*きたない思考だらけのメモ

[D]
・Pは昇順にしたほうが良い？
・前の人から買わせた方が良い？
---
これらの証明 or 反例だしは難しいので考えない。


(i)A1 = 1のとき, 人1は買わない＆P>=2

(ii)A1 >= 2のとき, 

P < A1にするとき…P = 1にするのが最適。

・P > A1にする必要はある？
人1が商品を買うようなPを{p1, …, pk}とし、そうでないPを{q1, …, ql}とする。
Pの列について, その価格設定を（順番に）全て実行できる場合、有効なPと呼ぶ。

どんな有効なPを設定しても、Pを(p1, …, pk, q1, …, ql)の順に並べ替えたものが有効であることを示せばよい。

並べ替えても人1はPが{p1, …, pk}のとき商品を買う。何故かと言うと, p1～pkの和が人1の所持金よりも少ないので、
piは常に人1の所持金より少ないから。

並べ替えても人1はPが{q1, …, ql}のとき商品を買わない。
・並べ替える前において、qiは常に人1の所持金よりも多かった
・並べ替える前において、人1の所持金は常にA1 - p1 - … - pk以上だった。
・並び替えたあとは、P=qiのとき常に所持金がA1 - p1 - … - pk以下になっている。

さらに、qiを買う人は変化しない。

よって、P > A1にする必要はない。同様に、客iが商品を買うことができるなら、P < 客iの所持金としてよい。
つまり、前の客からセールスすればよい。

----------------------

これより、最初の客に対する最善が見えた。
・A1 = 1のとき、P >= 2として次の客へ
・A1 >= 2のとき、P = 2はP = {1, 1}に分解できることから、A1 = 1になるまでP = 1で売る
と良い。A1 = 1になったら、P >= 2として次の客へ。

A2から先はP >= 2にする必要がある。同じ回数売って次の客に行くなら、客2の最終的な金額は小さい方がよいので…。
・A2 = 1のとき、P >= 2として次の客へ。
・A2 = 2のとき、P >= 3として次の客へ。
・A2 = 3のとき、P = 2で売り、P >= 2として次の客へ。
・A2 = 4のとき、P = 3で売り、P >= 2として次の客へ。
・A2 = 5のとき、P = 2,2で売り、P >= 2として次の客へ。
…
となる。より一般的には、A2 >= 3のとき
・A2が偶数のとき、P = 3を一回噛ませてからP = 2…で売る
・A2が奇数のとき、P = 2…で売る
のが最適になる。


客iに売るときを考えよう。P >= p (p >= 2)とする必要があるとします。このときの戦略は？
・Ai < pのとき、P >= pとして次の客へ
・Ai = pのとき、P >= p + 1として次の客へ
・Ai > p
	Ai % p = 0のとき、ずっとP = p…で売ると最終的な客iの所持金がpになるが、P = p+1, p…で売れば「同じ回数売って, 所持金をp-1以下にできる」ので
	P = p+1, p…で売って、P >= pとして次の客へ
	Ai % p ≠ 0のとき、P = p…で売ればP >= pとして次の客へいける。(次の客以降で設定するPの最小値が同じなら、たくさん客iに売りたいのでこれが最適）

で、1人に売る部分を割り算でO(1)にすれば、合計O(N)になります。



-----
教訓；
・探索思考は自由な発想を生む。
・漸化式的な場合分け（一人の戦略ずつで場合分け）するのも良い。

*/

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

int main() {

	int N, Q;
	cin >> N >> Q;

	queue<pair<string, int>> q;
	rep(i, N){
		pair<string, int> p;
		cin >> p.first >> p.second;
		q.push(p);
	}

	int tm = 0;

	while (!q.empty()){
		pair<string, int> p = q.front(); q.pop();
		if (p.second <= Q){
			tm += p.second;
			cout << p.first << " " << tm << endl;
		}
		else{
			tm += Q;
			p.second -= Q;
			q.push(p);
		}
	}
}

Measured memory_bytes: 6268
import collections
n = int(input())
a = list(map(int, input().split()))
l = [0]*n
ans = 0

for k,v in collections.Counter(a).items():
    l[k-1] = v
    ans += v*(v-1)//2

for i in range(n):
    print (ans-l[a[i]-1]+1)

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    std::vector< int > B(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i] >> B[i];
    }
    
    std::sort(A.begin(), A.end());
    std::sort(B.begin(), B.end());
    
    
    if(N % 2 == 0){
        int N_center_u = N / 2;
        int N_center_d = N / 2 - 1;
        std::cout << B[N_center_d] - A[N_center_d] + B[N_center_u] - A[N_center_u] + 1 << std::endl;
        
    }else{
        int N_center = N / 2;
        std::cout << B[N_center] - A[N_center] + 1 << std::endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 4772
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

int main() {
    int q;
    cin >> q;
    while(q--){
        string s;
        cin >> s;
        stack<pair<int, int>> S;
        int x = 0, cur = 0;
        for (auto &&i : s) {
            if(i == '['){
                cur++;
            }else if(i == ']'){
                if(x != 0){
                    S.emplace(cur-1, (x+1)/2);
                    x = 0;
                    cur--;
                }else {
                    vector<int> v;
                    while(!S.empty() && S.top().first == cur){
                        v.emplace_back(S.top().second); S.pop();
                    }
                    sort(v.begin(),v.end());
                    int y = 0;
                    for (int j = 0; j < v.size()/2+1; ++j) {
                        y += v[j];
                    }
                    cur--;
                    S.emplace(cur, y);
                }
            }else {
                x = x*10+(i-'0');
            }
        }
        cout << S.top().second << "\n";
    }
    return 0;
}


Measured memory_bytes: 3264
def main():
    H, W = map(int, input().split())
    C = [list(input()) for _ in range(H)]
    
    for x in range(H):
        for _ in range(2):
            for y in range(W):
                if y == W - 1:
                    print(C[x][y])
                else:
                    print(C[x][y], end = "")


if __name__ == "__main__":
    main()

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b;
    cin >> a >> b;
    if(b%a==0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int h,w;
  char s[110][110];
  bool masu[110][110]={false};
  cin>>h>>w;
  bool out=false;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
      if(s[i][j]=='#') out=true;
    }
    if(out==false){
      for(int j=0;j<w;j++) masu[i][j]=true;
    }
    out=false;
  }
  for(int j=0;j<w;j++){
    for(int i=0;i<h;i++){
      if(s[i][j]=='#') out=true;
    }
    if(out==false){
      for(int i=0;i<h;i++) masu[i][j]=true;
    }
    out=false;
  }
  int sum=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(masu[i][j]==false) cout<<s[i][j];
      else sum++;
    }
    if(sum!=w) cout<<'\n';
    sum=0;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<(int)s.size();i++)
		for(int j=i;j<=(int)s.size();j++)
		{
			string t=s;
			t.erase(t.begin()+i,t.begin()+j);
			if(t=="keyence")return puts("YES"),0;
		}
	puts("NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int a;
    cin >> a;
    
    int ac = 0, wa = 0, tle = 0, re = 0;

    string temp;
    for (int i = 0; i < a; i++) {
        cin >> temp;
        if (temp == "AC") {
            ac++;
        } else if (temp == "WA") {
            wa++;
        } else if (temp == "TLE") {
            tle++;
        } else if (temp == "RE") {
            re++;
        }
    }

    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";



    return 0;
}

Measured memory_bytes: 3624
red = list()
blue = list()
n = int(raw_input())

for i in range(0,n):
    red.append(map(int,raw_input().split()))
for i in range(0,n):
    blue.append(map(int, raw_input().split()))

red = sorted(red, key=lambda x:x[1], reverse=True)
blue = sorted(blue, key=lambda x:x[0])

c = int()
for b in blue:
    for i,r in enumerate(red):
        if r[0]<b[0] and r[1]<b[1]:
            red.pop(i)
            c+=1
            break

print c

Measured memory_bytes: 2568
D = int(input())
c = [int(x) for x in input().split()]
s = [input().split() for l in range(D)]
t = []
for i in range(D):
    t += [int(input())]
manzoku = 0
d = 1
last = [0]*26

for p in range(D):
    #タイプはt[p]-1,0~25 満足度増加 s[p][t[p]] p+1日目
    manzoku += int(s[p][t[p]-1])
    last[t[p]-1] = p+1
    for i in range(26):
        manzoku -= c[i] *(p+1-last[i])
    print(manzoku)

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans = "Left";
    if (a+b==c+d) ans = "Balanced";
    if (a+b<c+d) ans = "Right";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
# フェルマーの小定理
N, K = map(int, input().split())
A = list(map(int, input().split()))

m = 1000000007

fac = [0] * (N + 1)
fac[0] = 1
for i in range(N):
    fac[i + 1] = fac[i] * (i + 1) % m


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


A.sort(reverse=True)
result = 0
for i in range(N - K + 1):
    result += A[i] * mcomb(N - (i + 1), K - 1)
    result %= m

A.sort()
t = 0
for i in range(N - K + 1):
    t += A[i] * mcomb(N - (i + 1), K - 1)
    t %= m

result -= t
result %= m
print(result)


Measured memory_bytes: 20032
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;int h[n];for(int i=0;i<n;i++)cin>>h[i];
    int cnt=1;bool flag=true;
    for(int i=1;i<n;i++){
        for(int j=0;j<i;j++){
                if(h[i]>=h[j])flag=true;
                else {flag=false;break;}
        }
        cnt+=(flag?1:0);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  pr(n-m+1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main() {
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  int x = 0;
  int count = 1;
  for (int i = 0; i < N; i++) {
    x += L[i];
    if (x <= X) count++;
    else break;
  }

  cout << count << endl;



  return 0;
}


Measured memory_bytes: 256
<?php
define("MOD", 10**9+7);

$x = (int)trim(fgets(STDIN));
//$T = trim(fgets(STDIN));
//list($D,$T,$S) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ($x == 0) {
  echo "1";
}
else {
  echo "0";
}


Measured memory_bytes: 16124
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ab=[]
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort()
aa=[]
for i in range(k):
    if x*y-i-1>=0:
        aa.append(ab[x*y-i-1])
ans=[]
for i in range(len(aa)):
    for j in range(z):
        ans.append(aa[i]+c[j])
ans.sort()
for i in range(k):
    print(ans[len(ans)-i-1])
        

Measured memory_bytes: 148200
from fractions import gcd 

n = int(input())
a_set = set(map(int, input().split()))
max_a = max(a_set)
min_sub = max_a

for val in a_set:
    min_sub = min(gcd(max_a, val), min_sub)
    if min_sub == 1:
        print(1)
        exit()
print(min_sub)

Measured memory_bytes: 21840
#include<stdio.h>
int main(void){
    int a,b,c;
    int x,y;
    scanf("%d %d %d",&a,&b,&c);
    y=0;
    for(x=a;x<=b;x++){
        if(c%x==0){
            y+=1;
        }
    }
    printf("%d\n",y);
    return 0;
}


Measured memory_bytes: 2104
n, x = map(int, input().split())

# a <= b
def f(a, b):
    if b % a == 0:
        return (b // a) * 2 * a - a
    return (b // a) * a * 2 + f(b % a, a)

print(n + f(min(x, n - x), max(x, n - x)))

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int a, b, t;
    cin >> a >> b >> t;
    cout << (int)((t + 0.5) / a) * b << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 200010

vll v[N];
bool vis[N];
lli qry[N]={0},ans[N]={0};

void dfs(lli q , lli sum)
{
    vis[q]=1;
    ans[q]+= sum+qry[q];

    for(auto x:v[q])
    {
        if(!vis[x])
            dfs(x,sum+qry[q]);
    }

}

int main() 
{ 

/////////////////////////////////////
    
    fastio; 

    lli n,q;
    cin>>n>>q;

    loopl(i,0,n-1)
    {
        lli x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }

    while(q--)
    {
        lli p,x;
        cin>>p>>x;
        qry[p] += x;
    }

    dfs(1,0);

    loopl(i,1,n+1) cout<<ans[i]<<" ";

} 

Measured memory_bytes: 25856
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>

#define MP std::make_pair
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)
#define pb push_back
#define CL(a, b) memset(a, b, sizeof a)
#define PII std::pair<int, int>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int MAXN = 2e5 + 7;
const int INF = 0x7f7f7f7f;

int cnt[20];
int head[MAXN], n, sum[MAXN];
int f[(1 << 18) + 7];

struct Edge {
	int w, t, next;
} edge[MAXN << 1];

inline void add(int u, int v, int w) {
	static int cnt = 0;
	edge[++cnt] = (Edge){w, v, head[u]}; head[u] = cnt;
}

void init(int u, int pre) {
	PE(e, u) {
		int v = edge[e].t;
		if (v == pre) continue;
		sum[v] ^= edge[e].w;
		sum[u] ^= edge[e].w;
		init(v, u);
	}
	cnt[sum[u]]++;
}

int dfs(int s) {
	if (f[s] != INF) return f[s];
	int &ret = f[s];
	rep(i, 1, 15) if (s & (1 << i))
	rep(j, 1, 15) if (i != j && (s & (1 << j))) {
		if (s & (1 << (i ^ j))) ret = std::min(ret, 2 + dfs(s ^ (1 << i) ^ (1 << j) ^ (1 << (i ^ j))));
		else ret = std::min(ret, 1 + dfs(s ^ (1 << i) ^ (1 << j) ^ (1 << (i ^ j))));
	}
	return f[s];
}

int main() {
	CL(f, 0x7f);
	scanf("%d", &n);
	int u, v, w;
	rep(i, 1, n - 1) scanf("%d %d %d", &u, &v, &w), u++, v++, add(u, v, w), add(v, u, w);
	init(1, 0);
//	rep(i, 1, n) {
//		printf("sum[%d] = %d\n", i, sum[i]);
//	}
	
	int st = 0, ans = 0;
	rep(i, 1, 15) {
		ans += (cnt[i] / 2);
		cnt[i] &= 1;
		if (cnt[i]) st |= (1 << i);
	}
	f[0] = 0;
	printf("%d\n", ans + dfs(st));
	return 0;
}

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

int main(){
	int n;
	while(cin >> n,n){
		int res = 0;
		for(int i = 1;i < n;i++){
			for(int j = i;j < n;j++){
				if((i + j) * (j - i + 1) / 2 == n) res++;
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

int main() {
  int n; cin >>n;
  int ans = 0;
  for (int i=1; i<=n; i++){
    if (i<10) ans++;
    if (i<100) continue;
    if (i<1000) ans++;
    if (i<10000) continue;
    if (i<100000) ans++;
    else continue;
  }
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
def get_one_cnts(n):
    one_cnts_dic = []
    for i in range(0,40): 
        if i == 0:
            if n%4 in [1,2]:
                one_cnts_dic.append(1)
            else:
                one_cnts_dic.append(0)
        else:
            cycle = 2**(i+1) 
            if n%cycle in range(cycle//2, cycle, 2):
                one_cnts_dic.append(1)
            else:
                one_cnts_dic.append(0)
    return one_cnts_dic

a,b = map(int, input().split())
a_one_cnts = get_one_cnts(a-1)
b_one_cnts = get_one_cnts(b)
# print(a_one_cnts)
# print(b_one_cnts)
ans = 0
for i in range(40):
    if a_one_cnts[i] ^ b_one_cnts[i]:
        ans += 2**i

print(ans)

Measured memory_bytes: 3188