akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
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;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	// 今どの方向を調べているか
	// R→true、L→false (最初はR)
	bool flag = true;
	bool rl = false;
	int cnt = 0;
	vector<int> a(n, 0),b(n, 0);
	int k = 0;
	for (int i = 0; i < n - 1; i++) {
		if (s.at(i) == 'R') {
			a[k]++;
		}
		else {
			b[k]++;
			if (s.at(i + 1) == 'R')k++;
		}
	}
	b[k]++;
	int c = 0;
	for (int i = 0; i < n - 1; i++) {
		// Rの場合、次がLかどうか確認する
		if (s.at(i) == 'R') {
			if (s.at(i + 1) == 'L') {
				int sum = a[c] + b[c];
				if (sum % 2 == 0) {
					cout << sum / 2 << " " << sum / 2 << " ";
				}
				else {
					if (a[c] % 2 == 0) {
						cout << sum / 2 << " " << sum / 2 + 1 << " ";
					}
					else {
						cout << sum / 2 + 1 << " " << sum / 2 << " ";
					}
				}
				for (int j = 1; j < b[c]; j++) {
					cout << 0 << " ";
				}
				i += b[c] - 1;
				c++;
			}
			else {
				cout << 0 << " ";
			}
		}
		
	}
	return 0;
}

Measured memory_bytes: 2256
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int main() {
	int x, t;

	cin >> x >> t;

	cout << max(0, x - t) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=110;
const LL mod=1e9+7;
template<typename T>inline T chkmax(T A,T B){return A>B?A:B;}
template<typename T>inline T chkmin(T A,T B){return A<B?A:B;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n;
char s1[N],s2[N];
LL ans;
int main()
{
	read(n);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	int type=0;ans=1;
	For(i,1,n)
	{
		//printf("%d\n",i);
		if(s1[i]!=s2[i])
		{
			if(type==0)ans=ans*6%mod;
			else
			if(type==1)ans=ans*2%mod;
			else
			if(type==2)ans=ans*3%mod;
			type=2;
			i++;
		}
		else
		{
			if(type==0)ans=ans*3%mod;
			else
			if(type==1)ans=ans*2%mod;
			else
			if(type==2)ans=ans*1%mod;
			type=1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

using R = long double;
const R EPS = 1e-10;
int sgn(const R &r) { return (r>EPS) - (r<-EPS); }
int sgn(const R &a, const R &b) { return sgn(a-b); }

void solve() {
    ll w, h, n;
    cin >> w >> h >> n;
    if(w == 0) exit(0);
    using P = pair<R,R>;
    vector<P> ps;
    vector<ll> x(2*n+4), y(2*n+4);
    REP(i, 2*n) {
        cin >> x[i] >> y[i];
        ps.push_back({x[i], y[i]});
    }
    x[2*n] = 0, y[2*n] = 0, ps.push_back({0, 0});
    x[2*n+1] = 0, y[2*n+1] = h, ps.push_back({0, h});
    x[2*n+2] = w, y[2*n+2] = 0, ps.push_back({w, 0});
    x[2*n+3] = w, y[2*n+3] = h, ps.push_back({w, h});

    dump(ps);

    vector<R> v;
    v.push_back(0);
    v.push_back(h);
    REP(i, ps.size()) FOR(j, i+1, ps.size()) {
        if(sgn(x[i],x[j]) == 0) continue;
        // ((x[i],y[i]), (x[j],y[j])) で分断したときN個ずつになるか
        ll cnt = 0, tc = 0;
        R a = ((R)y[i]-y[j])/((R)x[i]-x[j]), b = y[i] - a*x[i];
        REP(k, 2*n) {
            if(sgn(a*x[k]+b, y[k]) < 0) cnt++;
            else if(sgn(a*x[k]+b, y[k]) == 0) tc++;
        }
        while(cnt < n && tc > 0) cnt++, tc--;
        if(cnt == n) {
            // dump(i, j, x[i], y[i], x[j], y[j], a, b);
            v.push_back(b);
        }
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)), v.end());

    dump(v);

    R ans = 0;
    REP(i, (ll)v.size()-1) {
        // [y1,y2] の分を計算する
        R y1 = v[i], y2 = v[i+1];
        if(sgn(y1) < 0 || sgn(y2,h) > 0) continue;

        R midy = (y1+y2)/2.0;
        R miny = h, maxy = 0;
        for(auto p: ps) {
            if(sgn(p.first) <= 0) continue;
            // ((0,midy), p) で分断してN個ずつになるか
            ll cnt = 0, tc = 0;
            R a = (p.second-midy)/p.first, b = midy;
            // dump(p, a, b);
            REP(k, 2*n) {
                if(sgn(a*x[k]+b, y[k]) < 0) cnt++;
                else if(sgn(a*x[k]+b, y[k]) == 0) tc++;
            }
            while(cnt < n && tc > 0) cnt++, tc--;
            if(cnt == n) {
                R ty = a*w+b;
                // dump(ty);
                chmin(miny, ty);
                chmax(maxy, ty);
            }
        }
        chmax(miny, 0.0l);
        chmin(maxy, (R)h);

        dump(i, y1, y2, miny, maxy, (y2-y1) * max(0.0l, maxy-miny));
        ans += (y2-y1) * max(0.0l, maxy-miny);
    }

    dump("------------------------------------------");
    cout << fixed << setprecision(10) << ans/(h*h) << endl;
}

int main(void) {
    while(1) solve();

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



struct UnionFind { // UnionFind木
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(-d[x] < -d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};



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

  int n, m, k;
  cin >> n >> m >> k;
  vi fri(n);
  vii b(n);
  UnionFind uf(n);
  rep(i,m) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    fri[x]++;
    fri[y]++;
    uf.unite(x,y);
  }
  rep(i,k) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    b[x].push_back(y);
    b[y].push_back(x);
  }
  rep(i,n) {
    int ans = uf.size(i) - fri[i] - 1;
    for(int x : b[i]) {
      if(uf.same(i,x)) ans--;
    }
    cout << ans << ' ';
  }
  cout << endl;

}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n; cin >> n;
  set <string> S;
  for (int i = 1; i <= n; i++){
    string s; cin >> s;
    S.insert(s);
  }
  cout << S.size();
  return 0;
}

Measured memory_bytes: 19276
while(1):
    m, f, r = map(int, input().split())

    if m == -1 and f == -1 and r == -1:
        break

    score = m + f
    if m == -1 or f == -1:
        print("F")
        continue
    if score >= 80:
        print("A")
        continue
    if score >= 65 and score < 80:
        print("B")
        continue
    if score >= 50 and score < 65:
        print("C")
        continue
    if score >= 30 and score < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
        continue
    if score < 30:
        print("F")

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
    P[i]--;
  }

  int count = 0;
  for (int i = 0; i < N; i++) {
    if (P[i] == i) {
      if (i > 0) {
        if (i + 1 < N and P[i + 1] == i + 1) {
          swap(P[i], P[i + 1]);
        } else {
          swap(P[i - 1], P[i]);
        }
      } else {
        swap(P[i], P[i + 1]);
      }
      count++;
    }
  }
  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long long>a(n),b(n);
  long long ans = 0ll;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    cin >> b.at(i);
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for(int i = 0; i < n; i++){
    a.at(i) += ans;
    if(a.at(i) % b.at(i) == 0) continue;
    ans += b.at(i) - a.at(i) % b.at(i);
    a.at(i) += ans;
  }
  cout << ans;
}
  

Measured memory_bytes: 4792
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 998244353

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);

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

    sort(all(a));

    ll sum = 0;

    for(int i = 0; i < k; i++)
    {
        sum += a[i];
    }

    cout << sum << endl;
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
int n;
int a[300];

bool used[300][300];
int ans[300][300];
int can(int l, int r) {
	if (l > r)return 0;
	if (used[l][r])return ans[l][r];
	used[l][r] = true;
	int ret = 0;
	if (abs(a[l] - a[r]) <= 1) {
		ret = can(l + 1, r - 1);
		if (ret == r - l - 1) {
			ret += 2;
		}
	}
	ret = max(ret, can(l + 1, r));
	Rep1(i, l + 1, r - 1) {
		if (abs(a[i] - a[l]) > 1)continue;
		int le = can(l + 1, i - 1);
		if (le == i - l - 1)le += 2;
		int ri = can(i + 1, r);
		ret = max(ret, le + ri);
	}
	return ans[l][r] = ret;
}
void solve() {
	while (cin >> n, n) {
		rep(i, n) {
			cin >> a[i];
		}
		rep(i, n) {
			rep(j, n) {
				used[i][j] = false;
				ans[i][j] = 0;
			}
		}
		cout << can(0, n - 1) << endl;
	}

}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(7);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main() {
	int s,k,ans=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			int gyx=s-i-j;
			if(gyx<=k&&gyx>=0)ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3", "Ofast", "fast-math", "unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#define int long long
#define endl '\n'

using namespace std;

const int inf = -1e17;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int i, n;
    cin >> n;
    vector < int > a(n + 1);
    for (i = 1; i <= n; i++){
        cin >> a[i];
    }
    vector < vector < int > > dp(n + 1, vector < int > (2, inf));
    dp[1][0] = 0;
    dp[1][1] = a[1];
    dp[2][0] = max(a[1], a[2]);
    dp[2][1] = inf;
    for (i = 3; i <= n; i++){
        if (i % 2 == 0){
            dp[i][0] = max(dp[i][0], dp[i - 1][1]);
            dp[i][0] = max(dp[i][0], dp[i - 2][0] + a[i]);
            dp[i][1] = max(dp[i][1], dp[i - 2][1] + a[i]);
        }
        else{
            dp[i][0] = max(dp[i][0], dp[i - 1][0]);
            dp[i][0] = max(dp[i][0], dp[i - 2][0] + a[i]);
            dp[i][1] = max(dp[i][1], dp[i - 1][1]);
            dp[i][1] = max(dp[i][1], dp[i - 2][1] + a[i]);
        }
    }
    cout << dp[n][0] << endl;

    return 0;
}


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

int main() {
  int N; cin >> N;
  bool res = false;
  for (int a = 1; a <= 9; a++) {
    for (int b = 1; b <= 9; b++) {
      if (a * b == N) res = true;
    }
  }
  if (res) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

char in[11000];
int main(){
	scanf("%s",in);
	in[3]=0;
	printf("%s\n",in);
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct PrimalDual{
  const int INF = 1<<28;
  typedef pair<int,int> P;
  struct edge{
    int to,cap,cost,rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> h,dist,prevv,preve;

  PrimalDual(){}
  PrimalDual(int sz):n(sz),G(sz),h(sz),dist(sz),prevv(sz),preve(sz){}
  
  void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
  }

  int flow(int s,int t,int f){
    int res=0;
    fill(h.begin(),h.end(),0);
    while(f>0){
      priority_queue<P,vector<P>,greater<P> > que;
      fill(dist.begin(),dist.end(),INF);
      dist[s]=0;
      que.push(P(0,s));
      while(!que.empty()){
	P p=que.top();que.pop();
	int v=p.second;
	if(dist[v]<p.first) continue;
	for(int i=0;i<(int)G[v].size();i++){
	  edge &e=G[v][i];
	  if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
	    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
	    prevv[e.to]=v;
	    preve[e.to]=i;
	    que.push(P(dist[e.to],e.to));
	  }
	}
      }
      if(dist[t]==INF){
	return -1;
      }
      for(int v=0;v<n;v++) h[v]+=dist[v];

      int d=f;
      for(int v=t;v!=s;v=prevv[v]){
	d=min(d,G[prevv[v]][preve[v]].cap);
      }
      f-=d;
      res+=d*h[t];
      for(int v=t;v!=s;v=prevv[v]){
	edge &e=G[prevv[v]][preve[v]];
	e.cap-=d;
	G[v][e.rev].cap+=d;
      }
    }
    return res;
  }
};
//END CUT HERE

int main(){
  int v,e,f;
  cin>>v>>e>>f;
  PrimalDual pd(v);
  for(int i=0;i<e;i++){
    int u,v,c,d;
    cin>>u>>v>>c>>d;
    pd.add_edge(u,v,c,d);
  }
  cout<<pd.flow(0,v-1,f)<<endl;
  return 0;
}
/*
verified on 2017/10/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B&lang=jp
*/

Measured memory_bytes: 3164
n = int(input())
TXY = [(0, 0, 0)]
for i in range(n):
	TXY.append(tuple(map(int, input().split())))
for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:]):
	dist = abs(x2 - x1) + abs(y2 - y1)
	d = t2 - t1
	if dist > d or dist % 2 != d % 2:
		print("No")
		exit()
else:
	print("Yes")

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

typedef long long llong;
// -2.1e-9 <= int <= 2.1e9

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

    if ( H <= A) {
        cout << 1 << endl;
        return 0;
    }

    int ans;
    if ((H % A) == 0)
        ans = H / A;
    else
        ans = H / A + 1;
     cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    double sum=arr[0];
    for(int i=1;i<n;i++)
    {
        sum=(sum+arr[i])/2;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3010;
const int mod=1e9+7;
const int inv2=(mod+1)/2;
typedef long long ll;
int n,q;
int a[N];
ll res,dp[N][N];
ll pw(ll x,ll p){
	ll ret=1;
	while(p){
		if(p&1)ret=ret*x%mod;
		x=x*x%mod;
		p>>=1;
	}
	return ret;
}
void pri(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			printf("%lld ",dp[i][j]);
		puts("");
	}
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dp[i][j]=a[i]>a[j];
	//pri();
	for(int t=1;t<=q;t++){
		int x,y;scanf("%d%d",&x,&y);
		for(int i=1;i<=n;i++){
			if(i==x||i==y)continue;
			ll t1=dp[x][i],t2=dp[y][i],t3=dp[i][x],t4=dp[i][y];
			dp[x][i]=(t1+t2)%mod*inv2%mod;
			dp[i][x]=(t3+t4)%mod*inv2%mod;
			dp[y][i]=(t1+t2)%mod*inv2%mod;
			dp[i][y]=(t3+t4)%mod*inv2%mod;
		}
		ll t1=dp[x][y],t2=dp[y][x];
		dp[x][y]=(t1+t2)%mod*inv2%mod;
		dp[y][x]=(t1+t2)%mod*inv2%mod;
		//pri();
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			res=(res+dp[i][j])%mod;
	res=res*pw(2,q)%mod;
	res=(res+mod)%mod;
	printf("%lld\n",res);
	return 0;
}
/*
6
1 3 1 2 3 2
*/

Measured memory_bytes: 70784
#include "bits/stdc++.h"
using namespace std;

static int par[160000];

int root(int x) {
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

bool same(int x, int y) {
	return par[x] == par[y];
}

void unite(int x, int y) {
	x = root(x), y = root(y);
	if (x == y) return;
	par[x] = y;
}

int main() {
	int H, W;
	long long ans = 0;
	string S[400];
	map<int, pair<long long, long long> > mp;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
		for (int j = 0; j < W; j++) {
			par[i * W + j] = i * W + j;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W - 1; j++) {
			if (S[i][j] != S[i][j + 1]) unite(i * W + j, i * W + j + 1);
		}
	}
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] != S[i + 1][j]) unite(i * W + j, (i + 1) * W + j);
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			root(i * W + j);
			if (S[i][j] == '#') {
				mp[par[i * W + j]].first++;
			}
			else {
				mp[par[i * W + j]].second++;
			}
		}
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans += it->second.first * it->second.second;
	}
	cout << ans << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> Street(N);
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    Street.at(a - 1) += 1;
    Street.at(b - 1) += 1;
  }
  for(int i = 0; i < N; i++){
    cout << Street.at(i) << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

class Main {
	
	static class Queue {
		public void queue (InputReader ir) {
			
			// プロセス数
			int n = ir.nextInt();
			
			// クオンタム
			int q = ir.nextInt();
			
			// プロセス情報
			Deque<String> process = new ArrayDeque<String>();
			Deque<Integer> quantum = new ArrayDeque<Integer>();
			for (int i = 0; i < n; i++) {
				process.add(ir.nextString());
				quantum.add(ir.nextInt());
			}
			
			int time = 0;
			StringBuilder sb = new StringBuilder();
			
			while (!quantum.isEmpty()) {
				String posname = process.poll();
				int postime = quantum.poll();
				
				if ( postime <= q) {
					time += postime;
					sb.append(posname).append(" ").append(Integer.toString(time)).append("\n");
				} else {
					postime -= q;
					time += q;
					process.add(posname);
					quantum.add(postime);
				}
			}
			System.out.print(sb);
		}
	}
	
	static class InputReader {
		BufferedReader br;
		StringTokenizer st;
		
		public String nextString() {
			
			 while (!st.hasMoreTokens()) {
	                try {
	                    st = new StringTokenizer(br.readLine(), " ");
	                } catch (IOException e) {
	                    throw new InputMismatchException();
	                }
	            }
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(nextString());
		}
					
		public InputReader (InputStream inputStream) {
			br = new BufferedReader (new InputStreamReader (inputStream));
			st = new StringTokenizer ("");
		}
		
	}
	
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		InputReader ir = new InputReader (inputStream);
		Queue obj = new Queue();
		obj.queue(ir);
	}
}



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

using namespace std;

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

  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a.begin(), a.end(), greater<int>());

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

  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C)
{
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    vector<pair<ll, ll>> cards(M);
    for (int i = 0; i < M; i++)
    {
        ll b, c;
        cin >> b >> c;
        cards[i] = make_pair(c, b);
    }

    SORT(A);
    RSORT(cards);
    ll index = 0;
    ll ans = 0;
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < cards[i].second; j++)
        {
            if (index < N)
            {
                if (A[index] < cards[i].first)
                {
                    ans += cards[i].first;
                }
                else
                {
                    ans += A[index];
                }
            }
            else
            {
                break;
            }
            index++;
        }
    }
    for (int i = index; i < N; i++)
    {
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
module Main where

import Control.Applicative
import Text.Printf
import Numeric

main :: IO ()
main = loop

loop :: IO()
loop = do
  { [h, w] <- getInts
  ; if h == 0 && w == 0 then return ()
    else do
      { let oneline = replicate w '#'
      ; let rect    = replicate h oneline
      ; putStrLn $ unlines rect
      ; loop
      }
  }
--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble x = showFFloat Nothing x ""

getStrings :: IO [String]
getStrings = words <$> getLine

readInt' :: String -> Int
readInt' = read 



Measured memory_bytes: 4268
fun main(args: Array<String>) = p25()

fun p25() {
    data class Yx(val y: Int, val x: Int)

    val around = (-1..1).map { i1 -> (-1..1).map { i2 -> Yx(i1, i2) } }
        .flatten().filterNot { it == Yx(0, 0) }
    var (w, h) = readLine()!!.split(' ').map { it.toInt() }


    val answer = StringBuilder()

    while (w != 0 && h != 0) {
        val grounds = Array(h) {
            readLine()!!.split(' ').map { it == "1" }.toBooleanArray()
        }
        val visited = mutableSetOf<Yx>()

        fun dfs(yx: Yx): Boolean {
            if (!visited.add(yx)) return false

            val (y, x) = yx

            around.map { Yx(y + it.y, x + it.x) }.filter {
                it.y in grounds.indices && it.x in grounds.first().indices && grounds[it.y][it.x]
            }.forEach { dfs(it) }

            return true
        }

        val counts = (0 until h).map { y ->
            (0 until w).filter { x -> grounds[y][x] }.count { x -> dfs(Yx(y, x)) }
        }.sum()

        answer.appendln(counts)

        val (nw, nh) = readLine()!!.split(' ').map { it.toInt() }
        w = nw
        h = nh
    }

    print(answer)
}



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

ll GCD(ll x,ll y){
  if(y == 0) return x;
  return GCD(y,x%y);
}

vector<P>prime_factorize(ll n) {
    vector<P> res;
    for (ll p = 2; p*p <= n; ++p) {
        if (n%p != 0) continue;
        int num = 0;
        while (n % p == 0) {++num;n /= p;}
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
  ll a,b,gcd;
  cin >> a >> b;
  gcd = GCD(a,b);
  vector<P>ans = prime_factorize(gcd);
  cout << ans.size()+1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main()
{
  char input_st;
  int i;
  int counter[26] = {0};
  
  while(scanf("%c", &input_st) != EOF)
  {
    if(isupper(input_st))
    {
      i = input_st - 'A';
      counter[i]++;
    }
    else if(islower(input_st))
    {
      i = input_st - 'a';
      counter[i]++;
    }
  }

  for(i = 0 ; i < 26 ; i++)
    printf("%c : %d\n", 'a' + i, counter[i]);
}



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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
    cin >> N;
    vector<ll> B(N+1,0), v;
    for(int i=0;i<N+1;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
        B[a]++;
    }
    for(int i=0;i<N+1;i++) {
        if(B[i]==2) tmp = i;
    }
    for(int i=0;i<N+1;i++) {
        if(A[i]==tmp) v.push_back(i);
    }
    COMinit();
    for(int i=1;i<=N+1;i++) {
        ans = COM(N+1, i);
        if(i==1) ans--;
        else {
            ans -= COM(N-v[1]+v[0], i-1);
            ans %= MOD;
            if(ans<0) ans += MOD;
            /*
            for(int j=0;j<=i-1;j++) {
                ans -= COM(v[0], i-1-j)*COM(N-v[1], j);
                ans %= MOD;
                if(ans<0) ans += MOD;
            }
            */
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 9484
using System;
class Program
{
  static void Main(string[] args)
  {
    //ケース数
    int caseNum=int.Parse(Console.ReadLine());
    
    //各index
    int acNum=0;
    int waNum=0;
    int tleNum=0;
    int reNum=0;      
    
    for(int i=0;i<caseNum;i++)
    {
      string judge=Console.ReadLine();
      if(judge=="AC")
      {
        acNum++;
      }
	  else if(judge=="WA")
      {
        waNum++;
      }
	  else if(judge=="TLE")
	  {
        tleNum++;
	  }
	  else if(judge=="RE")
	  {
        reNum++;
	  }
    }
    
    Console.WriteLine("AC x "+acNum);
    Console.WriteLine("WA x "+waNum);
    Console.WriteLine("TLE x "+tleNum);
    Console.WriteLine("RE x "+reNum);
  }
}

Measured memory_bytes: 30692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  string s, t;
  cin >> s >> t;

  int cnt = 0;
  rep(i, 3) {
    if (s[i] == t[i]) cnt++;
  }
  cout << cnt << endl;
}


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

using namespace std;

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

    if (A == B)
    {
        cout << A + B << endl;
    }
    if (A > B)
    {
        cout << A + A - 1 << endl;
    }
    if (A < B)
    {
        cout << B + B - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ab = []
for i in range(M):
    ab.append(list(map(int,input().split())))
ab.sort(key = lambda ab:ab[1])
count = 0
now = 0
for a,b in ab:
    if a >= now:
        count += 1
        now = b
print(count)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  int N, Q; cin >> N >> Q;
  ll A[N]; rep(i,N) cin >> A[i];
  ll tk[(N+1)/2] = {}, pos[(N-1)/2] = {};
  for (int i=N-1; i>=N/2; i--) tk[0] += A[i];
  rep(i,(N-1)/2) {
    tk[i+1] = tk[i] - A[N/2+i] + A[i*2+(N+1)%2];
    pos[i] = (A[i*2+(N+1)%2]+A[N/2+i])/2;
  }
  // for (auto x: tk) cout << x << " "; cout << endl;
  // for (auto x: pos) cout << x << " "; cout << endl;

  rep(i,Q) {
    ll x; cin >> x;
    int p = lower_bound(pos,pos+(N-1)/2,x) - pos;
    cout << tk[p] << endl;
    // cout << x << "->" << p << ":" << tk[p] << endl;
  }
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,Q;
    int L[200001],R[200001];
    int p[100001],q[100001];
    int mp[501][501]={};
    int C[501][501]={};
    
    cin>>N>>M>>Q;
    for(int i=0;i<M;i++){
        cin>>L[i]>>R[i];
        mp[L[i]][R[i]]++;
    }
    
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            C[i][j] = C[i][j-1] + mp[i][j];
        }
    }
    
    for(int i=0;i<Q;i++){
        cin>>p[i]>>q[i];
        int sum=0;
        for(int j=p[i];j<=q[i];j++){
            sum+=C[j][q[i]] - C[j][p[i]-1];
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

typedef unsigned long long int ull;
typedef long long int ll;

using namespace std;

int main(void) {
    string s;
    cin >> s;
    long n = 0;
    while(n != s.size()) {
        if(s.substr(n,11) == "dreameraser") {
            n += 11;
            continue;
        }
        else if(s.substr(n,10) == "dreamerase") {
            n += 10;
            continue;
        }
        else if(s.substr(n,7) == "dreamer") {
            n += 7;
            continue;
        }
        else if(s.substr(n,6) == "eraser") {
            n += 6;
            continue;
        }
        else if(s.substr(n,5) == "dream" || s.substr(n,5) == "erase") {
            n += 5;
            continue;
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

public class Main {

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        char s[] = in.next().toCharArray();
        char t[] = in.next().toCharArray();
        int n = s.length, m = t.length;
        int min = Integer.MAX_VALUE;
        for(int i=0;i<=n-m;i++) {
        	int cnt = 0;
        	for(int j=0;j<m;j++) {
        		if(t[j]==s[j+i]) continue;
        		else {
        			cnt++;
        		}
        	}
        	min = Math.min(min, cnt);
        }
        out.println(min);
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
	
	static boolean arrayEquals(char a[], char b[]) {
		int n = a.length;
		boolean verdict = true;
		for(int i=0;i<n;i++) {
			if(a[i]!=b[i]) {
				verdict = false;break;
			}
		}
		return verdict;
	}
	
	static long lcm(long a, long b) {
		return (a*b)/gcd(a,b);
	}
	
	static long gcd(long a, long b) {
		if(b==0) return a;
		else return gcd(b,a%b);
	}
}









Measured memory_bytes: 25612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[200001];
ll invf[200001];
void fac(int n){
	f[0]=1;
	for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
	invf[n]=inv(f[n]);
	for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}

int main()
{
	int n, x, y; cin>>n>>x>>y; fac(n);
	vector<int> w[200001];
	for(int i=0; i<n; i++){
		int c, w1; cin>>c>>w1;
		c--;
		w[c].push_back(w1);
	}
	int i0=-1, i1=-1;
	for(int i=0; i<n; i++){
		sort(w[i].begin(), w[i].end());
		if(!w[i].empty()){
			if(i0==-1 || w[i0][0]>w[i][0]){
				i1=i0;
				i0=i;
			}else if(i1==-1 || w[i1][0]>w[i][0]){
				i1=i;
			}
		}
	}
	int s=0, ct[200001];
	for(int i=0; i<n; i++){
		if(w[i].empty() || w[i][0]+w[i0][0]>y){
			ct[i]=0;
			continue;
		}
		ct[i]=(int)(upper_bound(w[i].begin(), w[i].end(), x-w[i][0])-w[i].begin());
		if(i==i0){
			if(i1!=-1) ct[i]=max(ct[i], (int)(upper_bound(w[i].begin(), w[i].end(), y-w[i1][0])-w[i].begin()));
		}else{
			ct[i]=max(ct[i], (int)(upper_bound(w[i].begin(), w[i].end(), y-w[i0][0])-w[i].begin()));
		}
		s+=ct[i];
	}
	ll ans=f[s];
	for(int i=0; i<n; i++){
      //cout<<ct[i]<<endl;
		ans*=invf[ct[i]];
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13184
function F()
  N = parse(BigInt,readline())
  A= parse.(BigInt,split(readline()))
  ans = 0
  S = sum(A)
  for i =1:N-1
    S -= A[i]
    ans += A[i]*S
  end
  ans = mod(ans,10^9+7)
  println(ans)
end
F()
  

Measured memory_bytes: 319616
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

pair<ll,ll> op(ll a, ll b)
{
    if(a+b<10)
        return mp(1,a+b);
   return mp(2,1 + (a+b)-10);
}

pair<ll,ll> comb(pair<ll,ll> a, pair<ll,ll> b)
{
    auto temp = op(a.second,b.second);
    return mp(a.first+b.first+temp.first,temp.second);
}



pair<ll,ll> get(ll a, ll b)
{
    if(b == 1)
        return mp(0,a);
    auto temp = get(a,b/2);    
    if(b%2 == 1)
    {
        pair<ll,ll> temp1 = comb(temp,mp(0,a));
        temp1 = comb(temp1,temp);
        return temp1;
    }
    
    pair<ll,ll> temp1 = comb(temp,temp);
    return temp1;
}

int main()
{
   FAST/**/
   
   ll m;
   cin>>m;
   
   vector<pair<ll,ll>> hold;
   pair<ll,ll> ans = mp(-1,-1);
   for(ll i=0;i<m;i++)
   {
       ll a,b;
       cin>>a>>b;
       auto temp1 = get(a,b);
      if(i == 0)
            ans = temp1;
      else
          ans = comb(ans, temp1);
   }
   
   cout<<ans.first;
   
   return 0;
}  
   

Measured memory_bytes: 256
O = input()
E = input()
len_O = len(O)
len_E = len(E)
if len_O == len_E :
    for i in range(len_O) :
        print(O[i] + E[i], end="")
elif len_O > len_E :
    for i in range(len_O - 1) :
        print(O[i] + E[i], end="")
    print(O[len_O - 1])


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>

using namespace std;

const double PI = 3.14159265;

int n;
int angle[360];

int main(int argc, char** argv)
{
	double osum;
	while(cin >> n, n)
	{
		int last =360;
		for(int i=0; i<n-1; i++)
		{
			cin >> angle[i];
			last -= angle[i];
		}
		angle[n-1] = last;
		
		double sum = 0.0;
		for(int i=0; i<n; i++)
		{
			sum += sin(2.0 * angle[i] * PI / 360.0) / 2.0;
		}
		
		if(osum != 0.0)
		{
			if(osum > sum) cout << 1 << endl;
			else if(osum < sum) cout << 2 << endl;
			else cout << 0 << endl;
			osum = 0.0;
		}
		else
		{
			osum = sum;
		}
	}
}

Measured memory_bytes: 0
n,a,b = map(int,input().split())

ans = 0
n = str(n)
num = 1
while num <= int(n):
    sum1 = 0
    for s in str(num):
        sum1 += int(s)
        
    if a <= sum1 <= b:
        ans += num
        
    num += 1
    
print(ans)

Measured memory_bytes: 3060
S = input()
is_hitachi = True
if len(S) %2 == 0:
    for i in range(0, len(S), 2):
        if not (S[i] == 'h' and S[i + 1] == 'i'):
            is_hitachi = False
    print('YNeos'[not is_hitachi::2])
else:
    print('No')


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

int main() {
    int n;
    set<int> st;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(st.count(a))st.erase(a);
        else st.insert(a);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 4864
n,t = gets.strip.split.map(&:to_i)
num = gets.strip.split.map(&:to_i)
if n==1
  puts t
  exit
end
h = 0
for i in 0..n-2
  if num[i]+t < num[i+1]
    h += t
  else
    h += num[i+1]-num[i]
  end
end
puts h+t

Measured memory_bytes: 29844