akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using LL = long long;

int main() {
	int a_start, b_start, a_end, b_end;
	cin >> a_start >> a_end >> b_start >> b_end;
	int a[100] = { 0 };
	int time = 0;
	for (int i = a_start; i <a_end; i++)
	{
		a[i]++;
	}
	for (int i = b_start ; i < b_end; i++)
	{
		a[i]++;
	}
	for (int i = 0; i < 100; i++)
	{
		if (a[i] == 2)time++;
	}
	cout << time;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
int main(void){
    long n;
    cin >> n;
    int bef=0;
    int a[100010];
    int b[100010];
    long long biff[100010]={};
    long long sum=0;
    long long my=0;
    vector<int>po;
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> bef;
        a[i]=bef;
    }
    for(int i=0;i<n;i++){
        cin >> bef;
        b[i]=bef;
        biff[i]=a[i]-b[i];
        sum+=biff[i];
        if(biff[i]>0){
            po.push_back(biff[i]);
        }else if(biff[i]<0){
            my+=biff[i];
            ans++;
        }

    }
   //cout <<sum <<endl;
    int count=0;
    if(sum <0){
        ans=-1;
        cout <<-1 <<endl;
    }else{
        sort(po.begin(), po.end(), greater<int>());
        while(my <0){
            my+=po.at(count);
            count++;
        }
        cout << ans+count << endl;
    }
    
}


Measured memory_bytes: 1024
import collections
n=int(input())
s=list(input())
ans=10**6
tmp=collections.Counter(s[1:])['E']
ans=min(tmp,ans)
i=1
while i<n:
  if s[i-1]=='W':
    tmp+=1
  if s[i]=='E':
    tmp-=1
  ans=min(tmp,ans)
  i+=1

print(ans)

Measured memory_bytes: 8524
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    rep(i,n)std::cin >> a[i];
    int ans=1;
    rep(i,n){
        if(a[i]%2==0)ans*=2;
    }
    std::cout << pow(3,n)-ans << std::endl;
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long M) {
  ll ret = 0;
  if(N>1) ret += N * (N-1) / 2;
  if(M>1) ret += M * (M-1) / 2;
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long M;
  std::cin >> M;
  solve(N, M);
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
 
int main(void)
 
 
{
 
 
    int x,X;
 
 
X=0; 
 
 
scanf("%d",&x);
 
 
 X=x*x*x;
 
 
  printf("%d\n",X);
 
 
return 0;
 
 
}
 

 

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int a, b;
	cin >> a >> b;

	if (!(a % 2 == 0 || b % 2 == 0))yn

	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int>B(N-1);
  vector<int>A(N);
  for(int i=0;i<N-1;i++){
    cin>>B.at(i);
  }
  long long int ans = B.at(0);
  A.at(0)=ans;
  for(int i = 1;i<N-1;i++){
    A.at(i)=min(B.at(i),B.at(i-1));
    ans+=A.at(i);
  }
  ans+=B.at(N-2);

 cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

char s[8];
int cnt[26];

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

	scanf("%s", s);
	for (int i = 0; i < 4; i++)
		cnt[s[i]-'A']++;
	for (int i = 0; i < 26; i++) if (cnt[i] != 0 && cnt[i] != 2) {
		puts("No");
		return 0;
	}
	puts("Yes");
}


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

int64_t gcd(int64_t a, int64_t b) {
    int64_t c;
    while (a) {
        c = a;
        a = b % a;
        b = c;
    }
    return b;
}

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    vector<int64_t> A(N), L(N), R(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        int j = N - 1 - i;
        L[i] = i == 0 ? A[i] : gcd(A[i], L[i - 1]);
        R[i] = i == 0 ? A[j] : gcd(A[j], R[i - 1]);
    }
    // N - 1, 0
    int64_t ans = max(L[N - 2], R[N - 2]);
    for(int i = 0; i < N - 2; i++) {
        ans = max(ans, gcd(L[i], R[N - 3 - i]));
    }
    cout << ans << endl;
    return 0;
}

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

bool judge(int j, char *a, char *b, int M){
  bool ans=false;
  int l=0;
  for(int k=j; k<M+j; k++){
    if(a[k]!=b[l]){
      ans=false;
      break;
    }
    l++;
    ans=true;
  }
  return ans;
}

int main(){

  int M, N;
  cin >> N >> M;

  char A[N][N], B[M][M];
  bool ans=false;

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

  for(int i=0; i<N-M+1; i++){
    for(int j=0; j<N-M+1; j++){
      if(A[i][j]==B[i][0]){
        for(int k=i; k<M+i; k++){
            ans = judge(j, A[k], B[k], M);
            if(!ans) break;
        }
        if(ans){
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
const int maxn=3005;
const int M=998244353;
int dp[maxn][maxn],A,B,C,D;
void add(int &x,int y){
    x+=y; if(x>=M) x-=M;
}
int main(){
    cin >> A >> B >> C >> D;
    dp[A][B]=1;
    for (int i=A;i<=C;i++)
    for (int j=B;j<=D;j++){
        add(dp[i][j],1ll*dp[i-1][j]*j%M);
        add(dp[i][j],1ll*dp[i][j-1]*i%M);
        add(dp[i][j],M-1ll*dp[i-1][j-1]*(i-1)*(j-1)%M);
    }
    cout << dp[C][D] << endl;
    return 0;
}


Measured memory_bytes: 38736
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long[] h = new long[n];
		long max = 0;
		for(int i = 0; i < n; i++){
		    h[i] = sc.nextLong();
		    max = max(max, h[i]);
		}
		
		// 計算
		long result = 0;
		long l = -1;
		long r = max;
		while(r-l > 1){
			long c = (r + l)/2;
			
			if(func(c, a, b, h)){
				r = c;
			}else{
				l = c;
			}
		}
		result = r;
		
		// 出力
		System.out.println(result);
	}
	
	static boolean func(long cnt, long a, long b, long[] h){
	    long tmp = 0;
	    for(long i : h){
	        tmp += (max(i - b*cnt, 0) + (a-b-1))/(a-b);
	    }
	    if(cnt < tmp) return false;
	    return true;
	}
}


Measured memory_bytes: 60220
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n,x;
	cin>>n>>x;
	ll l[n+1];
	for(ll i=1;i<=n;i++)
	{
		cin>>l[i];
	}
	vector<ll> dp;
	dp.pb(0);
	for(ll i=1;i<=n;i++)
	{
		dp.pb(dp[dp.size()-1]+l[i]);
	}
	cout<<upper_bound(dp.begin(),dp.end(),x)-dp.begin()<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int n;
    cin>>n;
    vector<int> d1(n),d2(n);
    rep(i,n){
        cin>>d1[i]>>d2[i];
    }
    for(int i=0;i<n-2;i++){
        if(d1[i]==d2[i]){
            if(d1[i+1]==d2[i+1]){
                if(d1[i+2]==d2[i+2]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
}

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

int main(){

	int N, A, B;
	
	cin>>N;
	
	if(N == 1){
	    cout<<"Hello World\n";
	}
	if(N==2){
	    cin>>A>>B;
	    cout<<A+B<<"\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define f(a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define ll long long
#define INF 1000000000
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);
void solve()
{
	ll n,q,b,c;
	cin>>n;
	ll a[n],s=0;
	map<ll,ll> mp;
	for(ll i=0;i<n;i++) cin>>a[i],mp[a[i]]++,s+=a[i];
	cin>>q;
	for(ll i=0;i<q;i++)
	{
		cin>>b>>c;	
			s=s-b*mp[b]+mp[b]*c,mp[c]+=mp[b],mp[b]=0;
		cout<<s<<endl;
	}
}
int main()
{
//	int t;
//	cin>>t;
//	while(t--)
	solve();
}


Measured memory_bytes: 10144
#include <bits/stdc++.h>
using namespace std;
long long int n, a, b, ans=0;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> a >> b;
	ans = a*(n/(a+b));
	long long int res=n%(a+b);
	ans += min(res, a);
	cout << ans;
	return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int n, m;
int k;

int main()
{
  cin >> n >> m;
  vi res(2 * n);
  rep(i, 2 * n) res[i] = i + 1;

  while(m--){
    vi tmp(2 * n);
    cin >> k;
    if(k == 0){
      rep(i, n) tmp[2 * i] = res[i];
      rep(i, n) tmp[2 * i + 1] = res[i + n];
    }
    else{
      rep(i, k) tmp[2 * n - k + i] = res[i];
      rrep(i, k, 2 * n) tmp[i - k] = res[i];
    }
    res = tmp;
  }

  rep(i, 2 * n) cout << res[i] << endl;

  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#define N 20
#define M 10000

using namespace std;

int data[N][N];

void Init(){
  for(int i=0; i<N; ++i){
    for(int j=0; j<N; ++j){
      if(i == j) data[i][j] = 0;
      else data[i][j] = M;
    }
  }
}

void InputData(int* a, int* b, int* c, int* d){
  char dm;
  cin >> *a >> dm >> *b >> dm >> *c >> dm >> *d;
  --*a;
  --*b;
}

void WarshallFloyd(int& n){
  for(int k=0; k<n; ++k){
    for(int i=0; i<n; ++i){
      for(int j=0; j<n; ++j){
	data[i][j] = min(data[i][j], data[i][k] + data[k][j]);
      }
    }
  }
}

int main(){
  int n, m;
  int a, b, c, d;
  int x1, x2, y1, y2;
  char dm;

  Init();
  cin >> n >> m;

  for(int i=0; i<m; ++i){
    InputData(&a, &b, &c, &d);
    data[a][b] = c;
    data[b][a] = d;
  }

  WarshallFloyd(n);
  InputData(&x1, &x2, &y1, &y2);

  cout << (y1 - (y2 + data[x1][x2] + data[x2][x1])) << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
#define MAX 120

int main(void)
{
    int n, b, f, r, v, rn;
    int room[MAX] = {0};
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> b >> f >> r >> v;
        rn = (b - 1) * 30 + (f - 1) * 10 + (r - 1);
        room[rn] += v;
    }

    for (int i = 0; i < MAX; i++)
    {
        if (i % 10 == 0 && i != 0)
            cout << endl;
        if (i % 30 == 0 && i != 0)
            cout << "####################" << endl;
        cout << " " << room[i];
    }
    cout << endl;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(int)rept;++i)
typedef long long ll;
using namespace std;


int main() {
	//20日目 

	cin.tie(0); ios::sync_with_stdio(false);
	ll h = 0, w = 0;
	ll sa = 0, sb = 0, sc = 0, f = 0,ansa = 0, ansb = 0;
	ll ww = 0,hh = 0;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}
	else {
		ansa = ansb = std::min(h, w);
	}

	rep(i, h) {
		ww = w / 2;
		sa = i * w;
		sb = ww * (h - i);
		sc = (w - ww) * (h - i);
		f = std::max({ sa,sb,sc }) - std::min({ sa,sb,sc });

		ansa = std::min(f, ansa);
	}
	rep(i, w) {
		hh = h / 2;
		sa = i * h;
		sb = hh * (w - i);
		sc = (h - hh) * (w - i);
		f = std::max({ sa,sb,sc }) - std::min({ sa,sb,sc });

		ansb = std::min(f, ansb);
	}
	cout << std::min(ansa, ansb) << endl;

	return 0;

}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

const int ENDTIME = 1260;

int main() {
	int N, M;

	while(cin >> N >> M, N) {
		vvi pc(N, vi(ENDTIME, 0));
		vvi user(M, vi(ENDTIME, 0));

		int r;
		cin >> r;
		REP(i, r) {
			int t, m, n, s;
			cin >> t >> n >> m >> s;

			if(s == 1) {
				FOR(j, t, ENDTIME) {
					pc[n-1][j] = m;
				}
			}
			else {
				FOR(j, t, ENDTIME) {
					pc[n-1][j] = 0;
				}
			}

		}

		REP(i,N) {
			FOR(j, 0, ENDTIME) {
				if(pc[i][j]) {
					user[pc[i][j]-1][j] = 1;
				}
			}
		}

		int q;
		cin >> q;
		REP(i, q) {
			int ts, te, m;
			cin >> ts >> te >> m;

			int riyoujikan = 0;

			FOR(t, ts, te) {
				if(user[m-1][t]) {
					riyoujikan++;
				}
			}

			cout << riyoujikan << endl;
		}
	}
}

Measured memory_bytes: 45000
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	if n/100 == 7 || (n/10)%10 == 7 || n%10 == 7 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1816
#include<atcoder/all>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;
using namespace atcoder;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}


// dsu d(int n) // n頂点(頂点番号 0 ~ n-1) 0辺の無向グラフの作成。グラフ名をdとして使うときは "dsu d(n);"
// d.merge(int a, int b) // 辺(a,b)の追加
// bool d.same(int a, int b) // 頂点a,bが連結かどうかを返す
// int d.size(int a) // 頂点aの属する連結成分のサイズを返す
// vector<vector<int>> d.groups() // グラフを連結成分に分け、その情報を返す。返り値は「「一つの連結成分の頂点番号のリスト」のリスト」。


signed main(){
    int n,q;
    cin >> n >> q;
    dsu d(n);

    REP(i,q){
        int t1,u1,v1;
        cin >> t1 >> u1 >> v1;
        if(t1==0){
            d.merge(u1,v1);
        }
        else{
            cout << d.same(u1,v1) << endl;
        }
    }
    

    



    return 0;
}


Measured memory_bytes: 4044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input =new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(input.readLine());
        int K = Integer.parseInt(input.readLine());
        int X = Integer.parseInt(input.readLine());
        int Y = Integer.parseInt(input.readLine());

        if (N>K) {
            System.out.println(X*K + Y*(N-K));
        } else {
            System.out.println(X*N);
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
#define ll long long
using namespace std;
const int LIM = 3e5+3;
int cost[LIM+3], d[LIM+3];
ll INF = 1e18;
ll Ans = 0;

void solve(int l,int r)
{
  if(l >= r)return;
  int mid = (l+r)/2;
  vector<pair<int,ll> > V,W;
  int mx = 0; ll cur = 0;
  for(int i = mid+1;i<=r;i++)
  {
    cur += cost[i];
    if(abs(d[i]-d[i-1]) > mx)
      mx = abs(d[i]-d[i-1]), V.push_back(mp(mx,cur));
    else 
      V[V.size()-1].S = min(V.back().S, cur);
  }
  for(int i = 1; i<V.size();i++)
    V[i].S = min(V[i].S, V[i-1].S);
  mx = 0, cur = cost[mid];
  W.push_back(mp(0,cur));
  for(int i = mid-1;i>=l;i--)
  {
    cur += cost[i];
    if(abs(d[i+1]-d[i]) > mx)
      mx = abs(d[i+1]-d[i]), W.push_back(mp(mx,cur));
    else 
      W[W.size()-1].S = min(W.back().S, cur);
    int ind = upper_bound(V.begin(), V.end(), mp(mx,0ll))-V.begin();
    ind--;
    if(ind < 0)continue;
    Ans = min(Ans, cur+1ll*mx*mx+V[ind].S); 
  }
  for(int i = 1; i<W.size();i++)
    W[i].S = min(W[i].S, W[i-1].S);
  mx = 0, cur = 0;
  for(int i = mid+1;i<=r;i++)
  {
    cur += cost[i];
    mx = max(mx,abs(d[i]-d[i-1]));
    int ind = upper_bound(W.begin(), W.end(), mp(mx,0ll))-W.begin();
    ind--;
    if(ind < 0)continue;
    Ans = min(Ans, cur+1ll*mx*mx+W[ind].S); 
  }
  solve(l, mid);
  solve(mid+1,r);
}


int main(){
    long long a,b;cin >> a >> b;
    double mid = (a+b)/2.0;
    if(int(mid) == mid)cout << fixed << (int)mid << endl;
    else puts("IMPOSSIBLE");
}

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;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

const int MAX_COIN = 2501;
const int MAX_V = 50 * 2501;
const ll INF = 1e17;
typedef pair<ll,int> P;

struct Edge { int to; ll cost; };
vector<Edge> G[MAX_V];

int main() {
    int N, M, S;
    cin >> N >> M >> S;
    S = min(S, MAX_COIN - 1);
    for (int i=0; i<M; ++i) {
        int U, V, A;
        ll B;
        cin >> U >> V >> A >> B;
        U--; V--;
        for (int j=A; j<MAX_COIN; ++j) {
            G[U * MAX_COIN + j].push_back((Edge){ V * MAX_COIN + j - A, B });
            G[V * MAX_COIN + j].push_back((Edge){ U * MAX_COIN + j - A, B });
        }
    }
    for (int i=0; i<N; ++i) {
        ll C, D;
        cin >> C >> D;
        for (int j=0; j<MAX_COIN; ++j) {
            int CC = min(j + (int)C, MAX_COIN - 1);
            G[i * MAX_COIN + j].push_back((Edge){ i * MAX_COIN + CC, D });
        }
    }
    
    // dijkstra
    vector<ll> d(MAX_V, INF);
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0LL, S));
    while ( ! q.empty()) {
        P p = q.top(); q.pop();
        if (d[p.second] <= p.first) continue;
        d[p.second] = p.first;
        for (Edge &e: G[p.second]) {
            if (d[e.to] > p.first + e.cost) {
                q.push(P(p.first + e.cost, e.to));
            }
        }
    }

    for (int t=1; t<N; ++t) {
        ll res = INF;
        for (int j=0; j<MAX_COIN; ++j) {
            res = min(res, d[t * MAX_COIN + j]);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 25760
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n), b(n);
	vector<P> p(n);
	REP(i, n) {
		cin >> p[i].first >> p[i].second;
	}
	
	sort(all(p));
	priority_queue<ll> q;
	ll res = 0;
	
	int i=0;
	for (int j = 1; j <= m; ++j) {
		for (;i<n; +i) {
			if (p[i].first == j) {
				q.push(p[i].second);
				i++;
			}
			else {
				break;
			}
		}
		if (!q.empty()) {
			res += q.top();
			q.pop();
		}
	}
	put(res);
	return 0;
}

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

ll gcd(ll x,ll y){
    if(x<y){
        ll r = y;
        y = x;
        x = r;
    }

    ll r = x % y;
    if(r==0){
        return y;
    }else{
        return gcd(y, x % y);
    }

}

int main(){
    ll a, b, c;
    cin >> a >> b;

    c = a*b/gcd(a, b);

    cout << c << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, m;
    cin >> n >> m;
    vi ans(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >>a >> b;
        ans[a-1]++;
        ans[b-1]++;
    }
    rep(i,n) cout << ans[i] << endl;
}

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


int main(){
	string A,B,C;
	int a=0,b=0,c=0;
	bool JuegaA=true,JuegaB=false,JuegaC=false;
	cin >> A;
	cin >> B;
	cin >> C;
	while (true){
		char sigue;
		if ((a==A.length())&JuegaA){
			printf("A");
			break;
		}
		if ((b==B.length())&JuegaB){
			printf("B");
			break;
		}
		if ((c==C.length())&JuegaC){
			printf("C");
			break;
		}
		if (JuegaA){
			sigue=A[a];
			a++;
		}
		if (JuegaB){
			sigue=B[b];
			b++;
		}
		if (JuegaC){
			sigue=C[c];
			c++;
		}
		if (sigue=='a'){
			JuegaA=true;
			JuegaB=false;
			JuegaC=false;
		}
		if (sigue=='b'){
			JuegaA=false;
			JuegaB=true;
			JuegaC=false;
		}
		if (sigue=='c'){
			JuegaA=false;
			JuegaB=false;
			JuegaC=true;
		}
	}
	return 0;
}

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

int main()
{
	int i;
	string s;
	getline(cin, s);
	for (i = 0; i < s.length(); i++) {
		if (s[i] >= 'a'&&s[i] <= 'z') s[i] += 'A' - 'a';
		else if (s[i] >= 'A'&&s[i] <= 'Z') s[i] += 'a' - 'A';
	}
	cout << s << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    string S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    int N = S.size();

    int K;
    cin >> K;

    vector<string> vs;

    string tmp;
    for (int i = 0; i < N; i++) {
        int k = S[i] - '0';
        if (k >= 0 && k <= 9) {
            tmp += S[i];
        }
        else {
            if (tmp.size())
                vs.push_back(tmp);
            tmp.clear();
        }
    }
    if (tmp.size())
        vs.push_back(tmp);

    cout << vs[K - 1] << endl;

    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if (a < b)
    {
        for(int i = 0; i < b; i++) cout << a;
    }else{
        for(int i = 0; i < a; i++) cout << b;
    }
    
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
as = []
H.times do |i|
    as[i] = gets.split.map(&:to_i)
end

ans = []

H.times do |i|
    (W-1).times do |j|
        if as[i][j] % 2 == 1
            ans.push([i, j, i, j+1])
            as[i][j+1] += 1
        end
    end
end
(H-1).times do |i|
    if as[i][W-1] % 2 == 1
        ans.push([i, W-1, i+1, W-1])
        as[i+1][W-1] += 1
    end
end

puts ans.length
ans.each do |arr|
    puts arr.map{|n| n+1}.join(' ')
end

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

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



signed main() {
  int a, b;
  cin >> a >> b;
  rep1 (i, 3) {
    if (a != i and b != i) {
      cout << i << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, a[100010];
int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) scanf ("%d", &a[i]);
	int x = -1, ans = 1;
	for (int i = 2; i <= n; i++) {
		if (a[i] == a[i - 1]) continue;
		if (a[i] > a[i - 1] && x != 0) { x = 1; continue; }
		if (a[i] < a[i - 1] && x != 1) { x = 0; continue; }
		x = -1, ans++;
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s = new String[N];
		for(int i = 0; i < N; i++) {
			s[i] = sc.next();
		}
		
		boolean f = false;
		for(int i = 0; i < s.length; i++) {
			if(s[i].equals("Y")) f = true;
		}
		
		if(f) {
			System.out.println("Four");
		} else {
			System.out.println("Three");
		}
		
		sc.close();

	}

}

Measured memory_bytes: 23892
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    double r;
    cin >> n >> r;

    set<pair<int, int> > s;
    for(int i=0; i<n; ++i){
        double x, y;
        cin >> x >> y;
        int a = floor(x / r);
        int b = floor(y / r);

        bool same = false;
        for(int j=0; j<9; ++j){
            int a2 = a + j/3 - 1;
            int b2 = b + j%3 - 1;
            if(s.find(make_pair(a2, b2)) != s.end())
                same = true;
        }

        if(!same)
            s.insert(make_pair(a, b));
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 5976
N=int(input())
A=list(map(int,input().split()))

S=[]
s=0
for i in range(N):
    s+=A[i]
    S.append(s)
sm=sum(A)
ans=10**18
for i in range(N):
    val=abs(S[i]-(sm-S[i]))
    ans=min(ans,val)
print(ans)

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

long long N,maxW;
long long dp[102][100002];
struct asdfklj{
    long long val,w;
}arr[102];

long long knapsack(long long i, long long current){
    if(current<0)return INT_MAX;
    if(i==N){
        if(current==0)return 0;
        return INT_MAX;
    }
    long long &ret=dp[i][current];
    if(ret!=-1)return ret;
    return ret = min(arr[i].w+knapsack(i+1,current-arr[i].val), knapsack(i+1,current));
}

int main(){
    cin>>N>>maxW;
    memset(dp,-1,sizeof(dp));
    for(long long i=0; i<N; i++)cin>>arr[i].w>>arr[i].val;
    for(long long i=100000;;i--)
        if(knapsack(0,i)<=maxW)
            printf("%d",i),exit(0);
}


Measured memory_bytes: 80000
n = gets.to_i
ss = []
n.times do
  ss << gets.chomp.chars
end

tmp = ss.shift
ss.each do |s|
  indexes = []
  tmp.each_with_index do |t,i|
    if s.include?(t)
      ind = s.index(t)
      s.delete_at(ind)
    else
      tmp[i] = nil
    end
  end
  tmp.compact!
end

puts tmp.sort.join


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            double r = double.Parse(input[0]);
            double area = Math.PI * r * r;
            double length = 2 * Math.PI * r;
            Console.WriteLine(area + " " + length);
        }
    }
}


Measured memory_bytes: 17944
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

int main()
{
	long double a;
	long double b;
	cin >> a >> b;
	cout << (long long)(a*b) << endl;
}

Measured memory_bytes: 3172
#include <stdio.h>
#include <iostream>
#include <queue>
#include <list>
using namespace std;

struct MiniNode
{
	int id;
	int weight_from_0;
};

class Node
{
private:
	list<int> next_node_list;
	list<int> next_weight_list;
public:
	Node();
	void AddNextNode(int id, int weight);
	void SetWeight(int weight);
	void DistributeWeight();
	int weight_from_0;
	bool check;
};

Node::Node()
{
	weight_from_0 = -1;
	check = false;
}

Node *Node_list;

struct GreatNode
{
	bool operator()(const MiniNode n1, const MiniNode n2) const;
};
bool GreatNode::operator()(const MiniNode n1, const MiniNode n2) const
{
	return n1.weight_from_0 > n2.weight_from_0;
}
priority_queue<MiniNode, vector<MiniNode>, GreatNode > Q;

void Node::AddNextNode(int id, int weight)
{
	next_node_list.push_back(id);
	next_weight_list.push_back(weight);
}

void Node::SetWeight(int weight)
{
	if (weight_from_0 == -1 || weight < weight_from_0) {
		weight_from_0 = weight;
	}
}

void Node::DistributeWeight()
{
	check = true;
	list<int>::iterator itr2 = next_weight_list.begin();
	for(list<int>::iterator itr = next_node_list.begin(); itr != next_node_list.end(); itr++){	
		if (Node_list[*itr].check == false) {
			Node_list[*itr].SetWeight(weight_from_0 + *itr2);
			MiniNode mini_node;
			mini_node.id = *itr;
			mini_node.weight_from_0 = Node_list[*itr].weight_from_0;
			Q.push(mini_node);
		}
		itr2++;
	}
	next_node_list.clear();
	next_weight_list.clear();
}

int main(void)
{
	//input
	int n;
	cin >> n;
	Node_list = new Node[n]();
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c;
			cin >> v >> c;
			Node_list[u].AddNextNode(v, c);
		}
	}

	//weight from 0 ?
	Node_list[0].weight_from_0 = 0;
	Node_list[0].DistributeWeight();
	while (!Q.empty()) {
		MiniNode mini_node = Q.top();
		Q.pop();
		Node_list[mini_node.id].DistributeWeight();
	}

	//output
	for (int i = 0; i < n; i++) {
		cout << i << " " << Node_list[i].weight_from_0 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 35984
while True:
  n, m = map(int, input().split())
  if not n:
    break
  smap = [int(input()) for _ in range(n)]
  ind = 0
  cnt = 0
  flag = True
  for _ in range(m):
    ind += int(input())
    if flag:
      cnt += 1
      if ind >= n - 1:
        print(cnt)
        flag = False
      else:
        ind += smap[ind]
        if ind >= n:
          print(cnt)
          flag = False



Measured memory_bytes: 5632
import java.io.*;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);


        int n = in.nextInt();
        int odd = n/2;
        int even = n%2 == 0 ? n/2 : n/2 + 1;
        int ans = odd*even;
        out.println(ans);




        out.flush();

    }
    static boolean check(char [] ca,char [] cb) {
        for (char c = 'a';c<='z';c++) {
            HashSet<Character> set = new HashSet<>();
            for (int i = 0; i < ca.length; i++) {
                if(ca[i] == c) {
                    set.add(cb[i]);
                }
                if(set.size() > 1) {
                    return false;
                }
            }
        }
        return  true;
    }
}

class Envelope {
    private int width;
    private int height;

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public Envelope(int width,int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public String toString() {
        return width + " " + height;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt() {return Integer.valueOf(next());}
    public Long nextLong() {return  Long.valueOf(next());}
    public Double nextDouble() {return Double.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define IO             freopen (task".inp", "r", stdin), freopen (task".out", "w", stdout)
#define FORR(i, a, b)  for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b)  for (int i = (b), _a = (a); i >= _a; i--)
#define REPP(i, a, b)  for (int i = (a); _b = (b); i < _b; ++i)
#define REPD(i, a, b)  for (int i = (b); _a = (a); i > _a; --i)
#define mem(a, x)      memset(x, (a), sizeof(x))
#define cmin(a, b)     if ((a) > (b)) (a) = (b)
#define cmax(a, b)     if ((a) < (b)) (a) = (b)
#define reset(x)       memset(x, 0, sizeof(x))
#define bitcount(x)    __builtin_popcountll((x))
#define all(a)         (a).begin(), (a).end()
#define debug(x)       cout << (x) << "\n"
#define BIT(x, i)      (((x) >> (i)) & 1)
#define sz(a)          ((int) (a).size())
#define ii             pair<int, int>
#define MASK(i)        (1LL << (i))
#define pf             push_front
#define mp             make_pair
#define pb             push_back
#define se             second
#define fi             first
#define task           ""

using namespace std;

const int MOD = 1000000007;
const int inf = 2000000000;
const int mod = 1007050321;
const int base = 521;
const int N = 200005;

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

    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < sz(s); ++i)
        cnt += (s[i] != t[i]);
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3780
N, K = map(int, input().split())
A = list(map(int, input().split()))

dict = {}

for a in A:
    if a not in dict:
        dict[a] = 1
    else:
        dict[a] += 1

countlist = sorted([a for a in dict.values()], reverse=True)

print(sum(countlist[K:]))

Measured memory_bytes: 32184
MOD = 10**6+3

def main():
    # preprocess
    fac = [1, 1]
    f_inv = [1, 1]
    inv = [0, 1]

    for i in range(2, MOD+1):
        fac.append((fac[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD//i)) % MOD)
        f_inv.append((f_inv[-1] * inv[-1]) % MOD)

    Q = int(input())
    for i in range(Q):
        x, d, n = map(int, input().split())

        if d == 0:
            print(pow(x, n, MOD))
            continue
        
        xd = (x * pow(d, MOD-2, MOD)) % MOD
        if xd == 0 or xd + (n-1) >= MOD:
            print(0)
            continue

        print(pow(d, n, MOD) * fac[xd+(n-1)] * f_inv[xd-1] % MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 127428
while 1:
	n,k = map(int,raw_input().split())
	s = [0]*(n+1)
	if n == 0: break
	c = sorted([int(raw_input()) for i in range(k)])
	p = 1 if c[0] == 0 else 0
	jump = 0
	for i in c[p:]:
		s[i] = s[i-1] + 1
		if p and s[i-1] == 0:
			if s[i-2] > 0:
				s[i] += s[i-2] + 1 - jump
				jump = s[i-2] + 1
			if s[i-2] == 0:
				jump = 0
	print max(s)

Measured memory_bytes: 10268
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N ;
  vl x(N); rep(i,N) cin >> x[i] ;
  ll L; cin >> L ;
  int MAX_BIT = 30;
  vvi to(N,vi(MAX_BIT));
  rep(i,N){
    int idx = int(upper_bound(x.begin(),x.end(),x[i]+L)-x.begin()) - 1;
    to[i][0] = idx;
  }
  REP(bit,1,MAX_BIT) rep(i,N){
    to[i][bit] = to[to[i][bit-1]][bit-1];
  }
  dump(to);
  int Q; cin >> Q ;
  auto query = [&](int a,int b){
    int ans = 0;
    RREP(bit,MAX_BIT-1,0){
      if(to[a][bit]>=b) continue;
      dump(a,b,bit,1<<bit,to[a][bit]);
      a = to[a][bit];
      ans += (1<<bit);
    }
    if(a<b) ans++;
    cout << ans << endl;
  };
  rep(i,Q){
    int a,b; cin >> a >> b ;
    a--; b--;
    if(a>b) swap(a,b);
    query(a,b);
  }
  return 0;
}


Measured memory_bytes: 16512
a,b,k = map(int,input().split())
count = 0
for i in range(k):
    if a % 2 == 1:
        a -= 1
    a /= 2
    b += a
    count += 1
    if count == k:
        break
    if b % 2 == 1:
        b -= 1
    b /= 2
    a += b
    count += 1
    if count == k:
        break
print(str(round(a)) + " " + str(round(b)))

Measured memory_bytes: 9168