akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
MOD = 10**9+7
N = int(input())
A = [int(i) for i in input().split()]
f0 = False
b = N & 1 ^ 1
c = Counter(A)
ans = 1
for n in range(N-1, 0, -2):
    if c[n] != 2:
        break
    ans *= 2
    ans %= MOD
else:
    if c[0] == N & 1:
        print(ans)
        exit()
print(0)


Measured memory_bytes: 55404
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int t = sc.nextInt();
		int [] time = new int[n];
		for(int i=0;i<n;i++) {
			time[i] = sc.nextInt();
		}
		int loss = m;
		for(int i=1;i<n;i++) {
			if(time[i]-time[i-1] > 2*m) {
				loss += 2*m;
			}else {
				loss += time[i]-time[i-1];
			}
		}
		if(t-time[n-1]>m) {
			loss += m;
		}else {
			loss += t-time[n-1];
		}
		System.out.println(t-loss);
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, y;
    cin >> n >> y;
    int sum = 0;

    rep(i, n + 1)
    {
        rep(j, n + 1)
        {
            if (i + j > n)
                continue;
            sum = 10000 * i + 5000 * j + 1000 * (n - i - j);
            if (sum == y)
            {
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

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

ll x;

int main()
{
  cin >> x;
  ll sum = 100;
  ll res = 0;
  while(sum < x)
  {
    sum += sum/100;
    res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define x1 xxx
#define y1 yyy
#define x2 xx
#define y2 yy
using namespace std;
typedef long long ll;
string s[109];
int main()
{
   ll n,x;
   cin>>n>>x;
   for(int i=0;i<n;i++){
    cin>>s[i];
   }
   sort(s,s+n);
   for(int i=0;i<n;i++)cout<<s[i];
   cout<<endl;
        return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool dp[200005];
int main(){
  ll n;
  cin>>n;
  for(int i=0;i<=n;i++) dp[i]=false;
  dp[0]=true;
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    if(dp[a-1]) dp[a]=true;
  }
  ll max_l=0;
  for(int i=1;i<=n;i++){
    if(dp[i]) max_l=i;
  }
  if(max_l==0) cout<<-1<<endl;
  else cout<<n-max_l<<endl;
}


Measured memory_bytes: 384
// HelloWorld.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <bits/stdc++.h>
using namespace std;

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	vector<int> input(3);
	int xmin = 0, xmax = w, ymin = 0, ymax = h;
	for (int i = 0; i < n; i++) {
		cin >> input.at(0) >> input.at(1) >> input.at(2);
		if (input.at(2) == 1 && xmin < input.at(0))xmin = input.at(0);
		if (input.at(2) == 2 && xmax > input.at(0))xmax = input.at(0);
		if (input.at(2) == 3 && ymin < input.at(1))ymin = input.at(1);
		if (input.at(2) == 4 && ymax > input.at(1))ymax = input.at(1);
	}
	if (xmax < xmin || ymax < ymin)cout << 0 << endl;
	else cout << (xmax - xmin) * (ymax - ymin) << endl;
}



// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define ld long double
#define fixset(val) cout << fixed << setprecision(10) << val << endl;
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, M, D; cin >> N >> M >> D;
  ld ans;
  if (D == 0) {
    ans = (ld)(M - 1) / N;
  } else {
    ans = (ld)(M - 1) * (N - D) * 2 / (N * N);
  }
  fixset(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
using namespace std;
int h,w,a,b,ans[1000][1000];
int main(){
    cin>>h>>w>>a>>b;
    rep(i,h){
        if(i<b){
            rep(j,w){
                ans[i][j]=1;
            }
        }
        else{
            rep(j,w){
                ans[i][j]=0;
            }
        }
    }
    rep(i,a){
        rep(j,h){
            if(!ans[j][i])
            ans[j][i]=1;
            else 
			ans[j][i]=0;
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j];
        }
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int value;
    for(int i = 0; i < N; i++) {
        cin >> value;
        if (value % 2 == 0 && !(value % 3 == 0 || value % 5 == 0)) {
            cout << "DENIED" << '\n';
            return 0;
        }
    }

    cout << "APPROVED" << '\n';
    
    return 0;
}

Measured memory_bytes: 256
# solution

import io
import sys

nim,mike=map(int, input().split())

S = [input() for _ in range(nim)]

d = [-1,0,1,0,-1]

b = 0

for h in range(nim):
    for w in range(mike):
        if S[h][w] == ".": continue
        if any(S[h+x][w+y]=="#" for x,y in zip(d,d[1:]) if 0<=h+x<nim and 0<=w+y<mike):
            continue
        b = 1
print("YNeos"[b::2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans=1000000001;
  for(int i=0;i<=100000;i++){
    ans=min(ans,i*2*c+max(0,x-i)*a+max(0,y-i)*b);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  string S; cin >> S;
  if(S[S.size()-1] == 's') cout << S << "es" << endl;
  else cout << S << 's' << endl;
  

}


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

int main(){
  int ret=100000000;
  string s;
  cin >> s;
  int n=s.length();
  for(int i=1; i<n; i++){
    if(s[i-1]!=s[i]){
      ret=min(ret, max(i, n-i));
    }
  }
  if(ret==100000000)ret=n;
  cout << ret;
  return 0;
}


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

#define ll long long

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(void){
    int N; cin >> N;

    ll ans = 1LL;

    for(int i = 0; i < N; i++){
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

ll n, m, ans, d;

int main(){
    cin >> n >> m;
    vector<ll> x(m), l(m - 1);
    for (int i = 0; i < m; i++)cin >> x[i];
    sort(x.begin(), x.end());
    for (int i = 0; i + 1 < m; i++){
        d = abs(x[i] - x[i + 1]), ans += d, l[i] = d;
    }
    sort(l.begin(), l.end(), greater<ll>());
    for (int i = 0; i < min(n - 1, m - 1); i++)ans -= l[i];
    cout << ans << endl;
}

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

const int _ = 2e5 + 7;
namespace segt{
	int mx[_ << 2] , mrk[_ << 2];

#define mid ((l + r) >> 1)
#define lch (x << 1)
#define rch (x << 1 | 1)
	
	void mark(int x , int val){mrk[x] += val; mx[x] += val;}
	void down(int x){mark(lch , mrk[x]); mark(rch , mrk[x]); mrk[x] = 0;}
	void up(int x){mx[x] = max(mx[lch] , mx[rch]);}
	
	void modify(int x , int l , int r , int L , int R , int val){
		if(l >= L && r <= R) return mark(x , val);
		down(x);
		if(mid >= L) modify(lch , l , mid , L , R , val);
		if(mid < R) modify(rch , mid + 1 , r , L , R , val);
		up(x);
	}

	int qry(int x , int l , int r , int L , int R){
		if(l >= L && r <= R) return mx[x];
		down(x); int mx = -1e9;
		if(mid >= L) mx = qry(lch , l , mid , L , R);
		if(mid < R) mx = max(mx , qry(rch , mid + 1 , r , L , R));
		return mx;
	}
}
int N , M , ans;
struct peo{int L , R; friend bool operator <(peo A , peo B){return A.L < B.L;}}now[_];

int main(){
	scanf("%d %d" , &N , &M); ans = max(N - M , 0);
	for(int i = 1 ; i <= N ; ++i) scanf("%d %d" , &now[i].L , &now[i].R);
	sort(now + 1 , now + N + 1); int pos = 0;
	for(int i = 1 ; i <= M + 1 ; ++i) segt::modify(1 , 1 , M + 1 , i , i , i - M - 1);
	for(int i = 0 ; i < M ; ++i){
		while(pos < N && now[pos + 1].L == i){++pos; segt::modify(1 , 1 , M + 1 , 1 , now[pos].R , 1);}
		ans = max(ans , segt::qry(1 , 1 , M + 1 , i + 2 , M + 1) - i);
	}
	cout << ans; return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> x(n);
  rep(i,n) cin>>x[i];
  int ans=0,a;
  rep(i,n){
    if(x[i]>(k+1)/2) a=k-x[i];
    else a=x[i];
    ans+=a*2;
  }
  cout<<ans;
}

Measured memory_bytes: 3600
import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

bool solve() {
  readln;
  auto a = readln.chomp.split.to!(long[]);
  std.algorithm.sort(a);
  for(long i=1; i<a.length; i++) if(a[i]==a[i-1]) return false;
  return true;
}

void main() {
  if(solve) writeln("YES");
  else writeln("NO");
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;

    ans=n/1.08;
    ll taxin1 = ans*1.08;
    ll taxin2 = (ans+1)*1.08;
    if (taxin1 == n){
        cout<<ans<<endl;
    } else if (taxin2 == n){
        ans += 1;
        cout<<ans<<endl;
    }else {
        cout<<":("<<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;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  combination c(n + 5);
  rep(i, k) {
    mint ans = c(k - 1, i) * c(n - k + 1, i + 1);
    cout << ans.x << endl;
  }
  return 0;
}

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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());
  ll l = -1; ll r = 1e12;
  while(r-l > 1) {
    ll c = (l+r)/2;
    bool ok = [&]() {
      ll s = 0;
      rep(i,n) {
        s += max(0ll, a[i]-c/f[i]);
      }
      return s <= k;
    }();
    if(ok) r=c; else l=c;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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

int search(const vector< vector<int> > cur, int target, int depth){
	int res = 0;
	int h = cur.size(), w = cur[0].size();
	for(int i=1;i<=6;i++){
		if(depth==5&&i!=target) continue;
		if(cur[0][0]==i) continue;
		int col = cur[0][0];
		vector< vector<int> > nxt = cur;
		queue< pair<int,int> > qu; qu.push(make_pair(0,0));
		int cnt = 0;
		while(!qu.empty()){
			pair<int,int> pr = qu.front(); qu.pop();
			int x = pr.first, y = pr.second;
			if(nxt[x][y]!=col) continue;
			nxt[x][y] = i;
			cnt++;
			for(int i=0;i<4;i++){
				int nx = x+dx[i], ny = y+dy[i];
				if(nx<0||h<=nx||ny<0||w<=ny) continue;
				qu.push(make_pair(nx,ny));
			}
		}
		if(depth==6) return cnt;
		res = max(res, search(nxt, target, depth+1));
	}
	return res;
}

int main(){
	int h, w, c;
	while(cin >> h >> w >> c, h){
		vector< vector<int> > vi(h, vector<int>(w,0));
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				cin >> vi[i][j];
		cout << search(vi, c, 1) << endl;
	}
}

Measured memory_bytes: 0
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    string s;
    cin >> s;
    vpii v(n);
    rep(i, n) cin >> v[i].fi >> v[i].se;
    reverse(all(v));
    for (auto &p : v) {
      int a, b;
      tie(a, b) = p;
      int diff = b - a;
      --a, --b;
      s[a] = (s[a] - 'a' + diff) % 26 + 'a';
      s[b] = (s[b] - 'a' + diff) % 26 + 'a';
      swap(s[a], s[b]);
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 3156
#include <stdio.h>

#define max(a, b) ((a)>(b) ? a : b)
#define foo(a, b) ((a)/(b) + ((a)%(b) ? 1 : 0))

int main()
{
  int a, b, c, d, l;
  scanf("%d %d %d %d %d", &l, &a, &b, &c, &d);

  printf("%d\n", l - max(foo(a, c), foo(b, d)));
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define eb emplace_back

void fastio()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}

void solve()
{

  int n;cin>>n;
  n%=1000;
  if(n==0)cout<<0;
  else
  cout<<1000-n;
}

int32_t main()
{
    // fastio();
    // int t;cin>>t;
    // while(t--)
        solve();
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[100];

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n, greater < int >());
	int alice = 0;
	int bob = 0;

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			alice += a[i];
		} else {
			bob += a[i];
		}
	}
	cout << alice - bob << endl;

	return 0;
}


Measured memory_bytes: 256
count1=0
count2=0
count3=0
count4=0
N=int(input())
for i in range(N):
  A=input()
  if A=="AC":
    count1=count1+1
  elif A=="WA":
    count2=count2+1
  elif A=="TLE":
    count3=count3+1
  elif A=="RE":
    count4=count4+1
print("AC x "+str(count1))
print("WA x "+str(count2))
print("TLE x "+str(count3))
print("RE x "+str(count4))
  

Measured memory_bytes: 9184
#include <stdlib.h>
#include <stdio.h>

int s[200][200];
int st1[40000],st2[40000];
int dis[200][200];

int _min(int &a ,int b){
    if (b<a) a=b;
}

int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    for (int i=0;i<=h;++i)
    for (int j=0;j<=w;++j)
        s[i][j]=-1;
    for (int i=0;i<h;++i)
        for (int j=0;j<w;++j){
            char ch=getchar();
            if (ch!='#' && ch!='.') ch=getchar();
            if (ch=='.') s[i][j]=1;
            else s[i][j]=0;
            dis[i][j]=h+w+h+w;
        }

    st1[0]=0;st2[0]=0;if (s[0][0]==0) dis[0][0]=1;else dis[0][0]=0;
    int top=1,low=0;
    while (top>low){
        int x=st1[low],y=st2[low];low++;
        //printf("%d %d\n",x,y);
        if (dis[x+1][y]==h+w+h+w) {st1[top]=x+1;st2[top]=y;top++;}
        if (dis[x][y+1]==h+w+h+w) {st1[top]=x;st2[top]=y+1;top++;}

        if (s[x+1][y]== s[x][y]) _min(dis[x+1][y],dis[x][y]);
        else
            if (s[x+1][y]==0) _min(dis[x+1][y],dis[x][y]+1);
        else
            if(s[x+1][y]==1) _min(dis[x+1][y],dis[x][y]);

        if (s[x][y+1]== s[x][y]) _min(dis[x][y+1],dis[x][y]);
        else
            if (s[x][y+1]==0) _min(dis[x][y+1],dis[x][y]+1);
        else
            if(s[x][y+1]==1) _min(dis[x][y+1],dis[x][y]);
    }
    printf("%d\n",dis[h-1][w-1]);

}


Measured memory_bytes: 384
K = int(input())


def digit_sum(s):
    return sum([int(i) for i in str(s)])


def f(n):
    n = str(n)
    f_min, f_ans = float('inf'), -1
    for i in range(len(n)):  # 上から何桁目をいじるか
        for x in range(int(n[i]), 10):
            s = n[:i] + str(x) + '9' * (len(n) - i - 1)
            if f_min > int(s) / digit_sum(s):
                f_min = int(s) / digit_sum(s)
                f_ans = int(s)
    return f_ans


ans = [1]
for k in range(K - 1):
    ans.append(f(ans[-1] + 1))

print(*ans, sep='\n')


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


int main() {
  long long n ;
  cin >> n ;
  
  vector<long long> vec(n+3);
  
  
  
  for(long long i = 0; i<n+1 ;i++){
    if(i==0){
      vec.at(i)=2;
    }
    if(i==1){
      vec.at(i)=1;
    }
    if(i>1){
      vec.at(i)=vec.at(i-1)+vec.at(i-2);
    }
    if(i==n){
      cout << vec.at(i) <<endl;
    }

  }
    
}

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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> a(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> a.at(i).at(j);
    }
  }
  int sum;
  int count = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      sum = 0;
      for (int k = 0; k < d; k++) {
        sum += (a.at(i).at(k) - a.at(j).at(k)) * (a.at(i).at(k) - a.at(j).at(k));
      }
      for (int p = 0; p < 150; p++) {
        if (sum == p * p) {
            count++;
        }
      }
    }
  }
  cout << count << endl;
      
        
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

int main(void){
    string S;
    cin>>S;
    int len=S.length();
    bool ans=true;
    rep(i,len){
        if(i%2==0 && S[i]=='L'){
            ans=false;
            break;
        }
        if(i%2==1 && S[i]=='R'){
            ans=false;
            break;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

const int N = 10000;
const int WHITE = 0;
const int  GRAY = 1;
const int BLACK = 2;

vector<int> G[N];
vector<int> ans;
int V;
int degIn[N], color[N];

queue<int> Q;

void bfs(int s){
    if( degIn[s] > 0 || color[s] == BLACK) return;

    Q.push(s);

    int u;
    while( !Q.empty() ){
        u = Q.front(); Q.pop();
        ans.push_back(u);
        color[u] = BLACK;
        for(int i = 0; i < G[u].size(); i++){
            int v = G[u][i];
            degIn[v]--;
            if(degIn[v] == 0 && color[v] != BLACK){
                Q.push(v);
            }
        } 
    }

}

void solve(){
    rep(i,V) bfs(i);

    rep(i,V) printf("%d\n", ans[i]);
}


int main(){
    int E;
    cin >> V >> E;

    rep(i,V){
        color[i] = WHITE;
        degIn[i] = 0;
    }

    int s, t;
    rep(i,E){
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        degIn[t]++;
    }

    solve();

    return 0;

}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;
    map<ll,int> m;
    cin >> n;
    vector<ll> v(n);
    vector<ll> u(n+1);
    u[0]=0;
    rep(i,n){
        cin >> v[i];
    }
    m[0]++;
    //cout << 0 << " ";
    for (int i=1;i < n+1;i++){
        u[i]=u[i-1]+v[i-1];
        //cout << u[i] << " ";
        m[u[i]]++;
    }
    cout << endl;
    ll ans=0;
    for (auto w:m){
        ans+=((ll)w.second*(w.second-1)/2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp0 = input[0].split(" ");
    var s = tmp0[0];
    var t = tmp0[1];
    
    tmp1 = input[1].split(" ");
    var a = parseInt(tmp1[0], 10);
    var b = parseInt(tmp1[1], 10);
	tmp2 = input[2].split(" ");
    var u =tmp2[0];
    if(u==s){a=a-1;}
      else{b=b-1;}
  console.log(a,b);
    }
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
L = 10

$<.gets.to_i.times do
  field = Array.new(L) {$<.gets.split.map(&:to_i)}.flatten
  result = Array.new(L * L, 0)
  reverse = ->(x, y) {
    [[0, 0], [1, 0], [0, -1], [-1, 0], [0, 1]].each do |dx, dy|
      x1 = x + dx
      y1 = y + dy
      next if x1 < 0 or x1 >= L or y1 < 0 or y1 >= L
      i = y1 * L + x1
      field[i] = 1 - field[i]
    end
  }
  top_row = ->(i) {
    if i >= L
      tmp1 = field.dup
      tmp2 = result.dup
      while i < L * L
        x, y = i % L, i / L
        if field[i - L] == 1
          result[i] = 1
          reverse.(x, y)
        end
        i += 1
      end
      if field.all? {|i| i.zero?}
        puts result.each_slice(L).map {|a| a.join(" ")}
        true
      else
        field  = tmp1
        result = tmp2
        false
      end
    else
      return true if top_row.(i + 1)
      
      result[i] = 1
      reverse.(i % L, i / L)
      return true if top_row.(i + 1)
      reverse.(i % L, i / L)
      result[i] = 0
      false
    end
  }
  top_row.(0)
end


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

using namespace std;
using ll = long long int;

int main(void){

    int n;
    cin >> n;

    ll ans = 0;

    ans += (n / 500) * 1000;
    n %= 500;
    ans += (n / 5) * 5;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        String S = sc.next();
        String T = sc.next();
        String s[] = S.split("");
        String t[] = T.split("");
        for(int i=0;i<s.length;i++){
            if(!s[i].equals(t[i])){
                sum++;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 67304
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    vector<int> a(n + 3, 0);

    for (int i = 0; i < n - 1; i++)
    {
        int x;
        cin >> x;

        a[x]++;
    }

    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 4048
<?php
$num=explode(' ',trim(fgets(STDIN)));

$left = $num[0] + $num[1];
$right = $num[2] + $num[3];

if ( $left > $right )
{
    echo "Left"."\n";
}
elseif ( $left < $right )
{
    echo "Right"."\n";
}
else
{
    echo "Balanced"."\n";
}
?>


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

int main() {
	int h1,h2,s1,s2,t;
	
	cin>>h1>>s1;
	cin>>h2>>s2;
	
	t = 1;
	while( h1 > 0 && h2 > 0 )
	{
		if(t%2 == 1)
		{
			h2 = h2 - s1;
		}
		else
		{
			h1 = h1 - s2;
		}
		t++;
	}
	if(h1 <= 0)
	{
		cout<<"No";
	}
	else
	{
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{

	int x,y,h;
};
Info info[105];

int main(){

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

	for(int i = 0; i < N; i++){

		scanf("%d %d %d",&info[i].x,&info[i].y,&info[i].h);
	}

	for(int Cx = 0; Cx <= 100; Cx++){
		for(int Cy = 0; Cy <= 100; Cy++){

			int H = -1;
			int maximum = BIG_NUM;
			bool FLG = true;

			for(int i = 0; i < N; i++){

				int minus = abs(info[i].x-Cx)+abs(info[i].y-Cy);

				if(info[i].h == 0){ //H <= minusであればよい

					if(H != -1 && H > minus){

						FLG = false;
						break;
					}
					maximum = min(maximum,minus);
					continue;
				}

				int tmp = abs(info[i].x-Cx)+abs(info[i].y-Cy)+info[i].h;

				if(H == -1){

					H = tmp;
				}else if(H != tmp){

					FLG = false;
					break;
				}
			}
			if(H > maximum)continue;
			if(FLG && H != -1){

				printf("%d %d %d\n",Cx,Cy,H);
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        ll x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.merge(x, y);
    }
    set<ll> cnt;
    rep(i, n) cnt.insert(uf.root(i));
    cout << sz(cnt) << endl;
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
string s;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(), cout.tie(0);
    int a[55] = {0}, n;
    while(cin >> n) {
        for(int i = 1; i <= n; ++i)
            cin >> a[i];
        sort(a + 1, a + n + 1);
        for(int i = n; i >= 1; --i) {
            if(!(i & 1)) a[i] = 24 - a[i];
        }
        sort(a + 1, a + n + 1);
        int mn = 24;
        for(int i = 1; i <= n; ++i)
            mn = min(mn, a[i] - a[i - 1]);
        cout << mn << endl;
    }
}

Measured memory_bytes: 256
s = gets.chomp.to_i

def collatz(n)
  n.even? ? n/2 : 3 * n + 1
end

a = []

a.push(s)

count = 1
loop do
  count += 1
  s = collatz(s)
  if a.include?(s)
    puts count
    exit 0
  end
  a.push(s)
end


Measured memory_bytes: 1916
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int a,ans=10000000000000,n,i;
  scanf("%lld\n",&n);
  for(i=1;i*i<=n;i++){
    if(n%i==0){
      a=n/i;
      if(a+i<ans){
        ans=a+i;
      }
    }
  }
  printf("%lld\n",ans-2);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <cmath>
 
using namespace std;
typedef long long ll;
 
signed main() {
    ll X, Y;
    cin >> X >> Y;
    cout << floor(log2((long double)Y / X)) + 1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector < long long > vll;
typedef pair <long long, long long> pll;
typedef pair <int, int> pii;
typedef vector < int > vii;
typedef complex < double > Point;

#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mp make_pair
#define fst first
#define snd second

ll t, n, m, u, v, q, r, ql, qr, k, l,  w, x, y, d, p, c, b, a, s;
const int N = 1e6 + 600;
const int T = 101;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 52LL;

ll aa[N], bb[N];
int main() {
  csl;
  cin >> n;
  
  for (int i = 1; i <= n; ++i) {
    cin >> aa[i] >> bb[i];
  }
  
  long long res = 0;
  for (int i = n; i >= 1; --i) {
    aa[i] = (aa[i] + res) % bb[i];
    res += (bb[i] - aa[i]) % bb[i];
  }
  cout << res << '\n';
  return 0;
}























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

int main(){
    int n;cin >> n;
	int ans=0;
	for(int i=1;i<=n;i+=2){
		int cnt=0;
		for(int j=1;j<=n;j++){
			if(i%j==0) cnt++;
		}
		if(cnt==8) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
ll x,cnt=0;;
fr(i,0,5)
{
	cin>>x;
	if(x==0) cnt=i+1;
}
cout<<cnt;
return 0;
}

Measured memory_bytes: 3648
import sys
from collections import defaultdict

sys.setrecursionlimit(2 * 10 ** 5)

(N,) = [int(x) for x in input().split()]
colors = [int(x) for x in input().split()]
edges = [[int(x) for x in input().split()] for i in range(N - 1)]
graph = defaultdict(list)
for u, v in edges:
    graph[u].append(v)
    graph[v].append(u)
parent = {1: None}
children = defaultdict(list)


def rootTree(node):
    for nbr in graph[node]:
        if nbr not in parent:
            parent[nbr] = node
            children[node].append(nbr)
            rootTree(nbr)


rootTree(1)


colorlessCount = [0 for c in range(N + 1)]
colorlessTime = [0 for c in range(N + 1)]
t = 0


def buildComps(node):
    global t
    t += 1
    currColor = colors[node - 1]
    colorlessTime[currColor] += 1
    for child in children[node]:
        oldCount = t - colorlessTime[currColor]
        colorlessTime[currColor] = t
        buildComps(child)
        s = t - colorlessTime[currColor]
        colorlessTime[currColor] = t - oldCount
        colorlessCount[currColor] += s * (s + 1) // 2


buildComps(1)

for c in range(1, N + 1):
    s = t - colorlessTime[c]
    colorlessCount[c] += s * (s + 1) // 2
maxPairs = N * (N + 1) // 2
for c in range(1, N + 1):
    print(maxPairs - colorlessCount[c])


Measured memory_bytes: 461932
s=input()
ans=[]
while len(s)>0:
    index=s.find("LR")+1
    if index>0:sub,s=s[:index],s[index:]
    else:sub,s=s,[]
    length=len(sub)
    nums=[0]*length
    stop=sub.find("RL")
    odd,even=(length+1)//2,length//2
    if stop%2==1:odd,even=even,odd
    nums[stop],nums[stop+1]=odd,even
    ans+=nums
print(*ans)

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

class RURM {
public:
	using t1 = int;
	using t2 = int;

	static t1 id1() {
		return INT_MAX;
	}
	static t2 id2() {
		return -1;
	}
	static t1 op1(const t1& l, const t1& r) {
		return min(l, r);
	}
	static t1 op2(const t1& l, const t2& r) {
		return r != id2() ? r : l;
	}
	static t2 op3(const t2& l, const t2& r) {
		return r != id2() ? r : l;
	}
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;

private:
	const int n;
	vector<T1> data;
	vector<T2> lazy;

private:
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	T1 sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return M::id1();
		if (l <= lb && ub <= r) return M::op2(data[node], lazy[node]);
		push(node);
		int c = (lb + ub) / 2;
		return M::op1(sub(l, r, node * 2, lb, c), sub(l, r, node * 2 + 1, c, ub));
	}
	void suc(int l, int r, int node, int lb, int ub, T2 val) {
		if (ub <= l || r <= lb) return;
		if (l <= lb && ub <= r) {
			lazy[node] = M::op3(lazy[node], val);
			return;
		}
		push(node);
		int c = (lb + ub) / 2;
		suc(l, r, node * 2, lb, c, val);
		suc(l, r, node * 2 + 1, c, ub, val);
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2])
			, M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}

public:
	LazySegmentTree(int n_)
		: n(size(n_)), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	LazySegmentTree(int n_, T1 v1)
		: n(size(n_)), data(n * 2, v1), lazy(n * 2, M::id2()) {}
	LazySegmentTree(const vector<T1>& data_)
		: n(size(data_.size())), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {
		init(data_);
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) data[i] = M::op1(data[i * 2], data[i * 2 + 1]);
	}
	void init(const vector<T1>& data_) {
		for (int i = 0; i < (int)data_.size(); i++) data[i + n] = data_[i];
		init();
	}
	T1 find(int l, int r) {
		return sub(l, r, 1, 0, n);
	}
	void update(int l, int r, T2 val) {
		suc(l, r, 1, 0, n, val);
	}
};

int main()
{
	int n, q, com, x, y, val;
	cin >> n >> q;
	LazySegmentTree<RURM> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y + 1));
		}
		else {
			cin >> val;
			st.update(x, y + 1, val);
		}
	}
	return 0;
}

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

int main() {
	int d;cin>>d;
	cout<<d/3600<<':';
	d%=3600;
	cout<<d/60<<':';
	d%=60;
	cout<<d<<endl;
}

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void) {
	int n, x;
	cin >> n >> x;

	while (n != 0 || x != 0)
	{
		int count = 0;
		for (int i = 1; i <= n - 2; i++)
		{
			for (int j = i + 1; j <= n - 1; j++)
			{
				for (int k = j + 1; k <= n; k++)
				{
					if (i + j + k == x)
					{
						count++;
					}
				}
			}
		}
		cout << count << endl;
		cin >> n >> x;
	}
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef array<int, 2> duo;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        string s; cin >> s;
        sort(all(s));
        if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) cout << "Yes";
        else cout << "No";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    int N,H,W;
    cin>>N>>H>>W;

    cout<<(N-H+1)*(N-W+1)<<endl;

    return 0;
}

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

signed main () {
	string s;
	cin >> s;
	deque < char > d;
	for (char &c: s)
		d.push_back(c);
	int q;
	cin >> q;
	bool rev = 0;
	for (int i = 0; i < q; ++i) {
		int t;
		cin >> t;
		if (t == 1) 
			rev ^= 1;
		else {
			int f;
			char c;
			cin >> f >> c;
			if (f == 1 && rev)
				d.push_back(c);
			else if (f == 2 && rev)
				d.push_front(c);
			else if (f == 1)
				d.push_front(c);
			else
				d.push_back(c);
		}
	}
	if (rev)
		reverse(d.begin(), d.end());
	for (char c: d)
		cout << c;
	cout << '\n';
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5+5;
const int mod = 1e9+7;

int dig(int n) {
	int ctr = 0;
	while (n)
		ctr++, n /= 10;
	return ctr;
}

int n, arr[3] = {3, 5, 7}, d, ctr;

vi tmp;
bitset<3> used;

void backtrack(int c) {

	if (c > d)
		return;

	int sz = tmp.size();
	if (c >= 3) {
		bool use1, use2, use3;
		use1 = use2 = use3 = 0;
		for (int i = 0; i < sz; i++) {
			if (tmp[i] == 3)
				use1 = 1;
			else if (tmp[i] == 5)
				use2 = 1;
			else if (tmp[i] == 7)
				use3 = 1;
		}
		if (use1 && use2 && use3) {
			int t = 0;
			for (int i = 0; i < sz; i++) {
				//cout << tmp[i] << ' ';
				t = t*10 + tmp[i];
			}

			if (t <= n)
				ctr++;
			//cout << '\n';
			//cout << ans << endl;

		}
	}

	for (int i = 0; i < 3; i++) {
		tmp.push_back(arr[i]);
		backtrack(c+1);
		tmp.pop_back();
	}
}

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

	//#ifndef ONLINE_JUDGE
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//#endif

	cin >> n;
	d = dig(n);
	backtrack(0);
	cout << ctr << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// 4611686018427387903
const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll N, M;
vector<tuple<ll, ll, ll>> lrc;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  lrc.resize(M);
  for (int i = 0; i < M; i++) {
    ll l, r, c;
    cin >> l >> r >> c;
    l--;
    r--;
    lrc[i] = make_tuple(l, r, c);
  }
  sort(lrc.begin(), lrc.end());

  vector<ll> ans(N, LL_INF);
  ans[0] = 0;
  for (int i = 0; i < M; i++) {
    ll l = get<0>(lrc[i]);
    ll r = get<1>(lrc[i]);
    if (ans[l] == LL_INF) {
      continue;
    }
    ll v = ans[l] + get<2>(lrc[i]);
    ll pos = upper_bound(ans.begin() + l, ans.begin() + r + 1, v) - ans.begin();
    while (pos <= r) {
      ans[pos] = v;
      pos++;
    }
  }

  if (ans[N - 1] == LL_INF) {
    cout << -1 << endl;
  } else {
    cout << ans[N - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int main()
{
	const long long int mod = 1000000007;
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	rep(i, n) cin >> a[i];
	long long int ans = 0;
	rep(i,61){
		long long int num0 = 0;
		rep(j,n){
			if(((a[j]>>i)&1) == 0)
				num0++;
		}
		long long int now = (num0 * (n - num0)) % mod;
		ans += (now * ((1LL << i) % mod)) % mod;
		ans = ans % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

int main()
{
	std::string a;
	std::cin >> a;
	for (auto iter = a.begin(); iter != a.end() - 1; ++iter)
	{
		if (*iter == *(iter + 1)) {
			std::cout << "Bad" << std::endl;
			break;
		}

		if (iter == a.end() - 2)
		{
			std::cout << "Good" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
		var x = sc.nextInt();
        var y = sc.nextInt();
        int A;
        if (x >= 10) {
            A = y;
        } else {
            var a = 10-x;
            var b = 100*a;
            A = y + b;
        }
        System.out.println(A);
    }
}


Measured memory_bytes: 35752