akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using std::pair;
using std::make_pair;
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
#include<vector>
using std::vector;
#include<set>
using std::set;
#define reg register
 
const int MAXN=1000+5;
const int MAXM=2000+5;
 
bool vis[MAXN];
int n,m;
int cnt,head[MAXN],to[MAXM],Next[MAXM];
vector<pair<int,int>/**/> E;
set<int> S;
 
inline void Add_Edge(reg int,reg int);
inline bool DFS1(reg int,reg int);
inline void DFS2(reg int,reg int);
inline void Check(reg int);
 
int main(void){
	reg int i;
	cin>>n>>m;
	//scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i){
		int a,b;
		cin>>a>>b;
		//scanf("%d%d",&a,&b);
		Add_Edge(a,b);
		E.push_back(make_pair(a,b));
	}
	for(i=1;i<=n;++i){
		memset(vis,false,sizeof(vis));
		S.clear();
		vis[i]=true;
		if(DFS1(i,i)){
			memset(vis,false,sizeof(vis));
			DFS2(i,i);
		}
	}
	cout<<-1<<endl;
	//puts("-1");
	return 0;
}
 
inline void Add_Edge(reg int u,reg int v){
	Next[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
	return;
}
 
inline bool DFS1(reg int ID,reg int aim){
	reg bool flag=false;
	reg int i;
	for(i=head[ID];i;i=Next[i]){
		if(!vis[to[i]]){
			vis[to[i]]=true;
			if(DFS1(to[i],aim))
				flag=true;
		}
		if(to[i]==aim)
			return true;
	}
	return flag;
}
 
inline void DFS2(reg int ID,reg int aim){
	reg int i;
	for(i=head[ID];i;i=Next[i]){
		if(!vis[to[i]]){
			vis[to[i]]=true;
			S.insert(to[i]);
			DFS2(to[i],aim);
			S.erase(to[i]);
		}
		if(to[i]==aim)
			Check(to[i]);
	}
	return;
}
 
inline void Check(reg int aim){
	reg int i,cnt=0;
	S.insert((int)aim);
	for(i=0;i<(int)E.size();++i)
		if(S.find(E[i].first)!=S.end()&&S.find(E[i].second)!=S.end())
			++cnt;
	if(cnt!=(int)S.size())
		return;
	cout<<S.size()<<endl;
	//printf("%d\n",(int)S.size());
	for(set<int>::iterator it=S.begin();it!=S.end();++it)
		cout<<*it<<endl;
		//printf("%d\n",*it);
	exit(0);
	return;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N;
    N = sc.nextInt();
    int h[] = new int[N];
    boolean exi = false;
    int ans = 0;
    for(int i=0; i<N; i++) h[i] = sc.nextInt();
    for(int i=1; i<=100; i++){
      for(int j=0; j<N; j++){
        if(h[j] >= i){
          if(exi == false){
            ans++;
            exi = true;
          }
        }else{
          exi = false;
        }
      }
      exi = false;
    }
    System.out.println(ans);
                               
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll X,K,D;cin>>X>>K>>D;X=abs(X);
  if(X/D>K)cout<<X-K*D<<endl;
  else{
    K-=X/D;X-=X/D*D;
    if(K%2==0)cout<<X<<endl;
    else cout<<D-X<<endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll N;
ll a[200010], S;
ll ans = 1ll<<60;

int main()
{
  std::cin >> N;

  rep( i, N )
    std::cin >> a[i], S += a[i];

  ll sum = 0;

  rep( i, N )
  {
    sum += a[i];

    if( i < N-1 )
      chmin( ans, llabs(S-sum-sum) );
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1792
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
s=[]
for i in range(n):
    w=sorted(list(input()))
    s.append("".join(w))
l=list(Counter(s).values())
ans=0
for i in l:
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 108524
#include <stdio.h>

int main()
{
    int N, H, W;
    int i, k=0;
    scanf("%d",&N);
    scanf("%d",&H);
    scanf("%d",&W);

    int A[N], B[N];
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        scanf("%d",&B[i]);
    }

    for(i=0;i<N;i++){
        if((A[i] >= H) && (B[i] >= W)) k++;
    }

    printf("%d\n",k);

    return 0;
}

Measured memory_bytes: 128
// Example program
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


int main()
{
 int a[3];
 cin >> a[0] >> a[1] >> a[2];
  sort ( a, a+3 );
  cout << a[0] << " " << a[1] << " " << a[2] <<endl;
}

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

int main() {
  // Collatz Problem
  int s; cin >> s;
  map<int,int> am;
  int n = s;
  int i=1, m = 0;
  while(i<=1000000) {
    am[n] = i;
    if (n % 2 == 0) n /= 2;
    else n = 3 * n + 1;
    i++;
    if (am.count(n)) {
      m = i;
      break;
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    int k = stoi(a + b);
    int v = sqrt(k);
    cout << (k == v*v ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<unordered_map>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL N, A, B, C, D;

unordered_map<LL, LL> mem;
const LL INF = 1LL<<62;
LL LIMIT;

LL F(const LL n) {
    if (n == 0) return 0;
    if (n == 1) return D;

    auto it = mem.find(n);
    if (it != mem.end() && it->first == n) return it->second;

    LL tmp = INF;
    if (LIMIT > n) amin(tmp, n*D);

    LL x = (n+4) / 5;
    assert(x < n);

    if (LIMIT > abs(x*5-n)) {
	amin(tmp, F(x) + C + abs(x*5-n) * D);
    }
    x = n / 5;
    if (LIMIT > abs(x*5-n)) {
	amin(tmp, F(x) + C + abs(x*5-n) * D);
    }

    x = (n+2) / 3;
    assert(x < n);
    if (LIMIT > abs(x*3-n)) {
	amin(tmp, F(x) + B + abs(x*3-n) * D);
    }
    x = n / 3;
    if (LIMIT > abs(x*3-n)) {
	amin(tmp, F(x) + B + abs(x*3-n) * D);
    }

    x = (n+1) / 2;
    assert(x < n);
    if (LIMIT > abs(x*2-n)) {
	amin(tmp, F(x) + A + abs(x*2-n) * D);
    }
    x = n / 2;
    if (LIMIT > abs(x*2-n)) {
	amin(tmp, F(x) + A + abs(x*2-n) * D);
    }

    mem.insert(make_pair(n, tmp));
    return tmp;
}

void MAIN() {
    scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);

    mem.clear();

    LIMIT = INF / D;
    LL ans = F(N);

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 4204
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const S = inputList[0];
    const T = inputList[1];
    // if (T.indexOf(S) >= 0) {
    if (T.slice(0, -1) == S) {
      console.log("Yes");
    } else {
      console.log("No")
    }
  
  }

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29624
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a[26]={};
	for(int i=0;i<s.size();i++){
		a[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]%2==1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N;
	int T, A;
	int target, diff, diff_min = 2147483647;
	int ret = 1;

	cin >> N;
	cin >> T >> A;

	int* H = new int[N];
	for (int i = 0; i < N; i++) cin >> H[i];

	target = 500 * (T - A) / 3;

	for (int i = 0; i < N; i++) {
		diff = abs(target - H[i]);
		if (diff < diff_min) {
			diff_min = diff;
			ret = i + 1;
		}
	}

	delete[] H;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

int main(void) {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (0 <= x - r and 0 <= y - r and x + r <= w and y + r <= h) cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 3116
#include <iostream>
using namespace std;
long a,b,v,w,t;
int main()
{
	cin >> a >> v >> b >> w >> t;
	if ( a < b && a+v*t >= b+w*t ) cout << "YES";
	else if ( a > b && a-v*t <= b-w*t ) cout << "YES";
	else if ( a == b ) cout << "YES";
	else cout << "NO";
} 

Measured memory_bytes: 3076
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    long tmpxor;
    foreach (i; iota(1, n))
    {
        tmpxor ^= a[i];
    }
    foreach (i; iota(n))
    {
        tmpxor.write(" ");
        tmpxor ^= a[i];
        tmpxor ^= a[(i + 1) % n];
    }
    writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 11784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)

int main(int argc, char *argv[])
{
    string s, t;
    cin >> s;
    cin >> t;
    int ns = static_cast<int>(s.size());
    int nt = static_cast<int>(t.size());

    vector<vector<int>> dp(ns + 1, vector<int>(nt + 1));

    // dp[i][j]: s[1:i+1]とt[1:j+1]のLCSの1つ
    // 先頭に他と重複しない文字列を追加
    s = "A" + s;
    t = "B" + t;

    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[1][0] = 0;
    for (int i=1; i<ns+1; i++) {
        for (int j=1; j<nt+1; j++) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    vector<char> l;
    int ii = ns, jj = nt;

    // 共通文字列があったときは斜めにしか動かないことをもとに
    // dpからもとの文字列を逆順にたどる
    while (ii > 0 && jj > 0) {
        if (dp[ii][jj] == dp[ii-1][jj]) {
            // 上へ
            ii--;
            continue;
        }
        if (dp[ii][jj] == dp[ii][jj-1]) {
            // 左へ
            jj--;
            continue;
        }

        // 斜めへ
        l.push_back(s[ii]);
        ii--;
        jj--;
    }

    for (auto it=l.crbegin(); it!=l.crend(); ++it) {
        cout << *it;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
long long s[200004]={0},s1[200005]={0};
int main() {
	int n,m,k,a[200005],b[200005];
	scanf("%d %d %d",&n,&m,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]), s[i] = i==0 ? a[i]:s[i-1]+a[i];
	for(int i=0;i<m;i++) scanf("%d",&b[i]), s1[i] = i==0 ? b[i]:s1[i-1]+b[i];
	int ans = 0;
	
	for(int i=0;i<n;i++) {
		if(s[i]>k) {
			break;
		}
		long long l = k-s[i];
		//printf("%lld\n",l);
		int in = lower_bound(s1,s1+m,l)-s1;
		//printf("%d\n",in);
		if(in == m) {
			ans = max(ans, in+i+1);
		} else {
			if(s1[in] > l) {
				ans = max(ans, in+1+i);
			} else {
				ans = max(ans, in+i+2);
			}
		}
		
	}
	int in = lower_bound(s1,s1+m,k)-s1;
	if(in == m) {
		ans = max(ans, in);
	} else {
		if(s1[in] > k) {
			ans = max(ans, in);
		} else {
			ans = max(ans, in+1);
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 8496
<?php
fscanf(STDIN, "%d %d", $h, $w);
$pic = [];
for($i = 0; $i < $h; $i++) {
    fscanf(STDIN, "%s", $l);
    $pic[] = $l;
}
foreach($pic as $l) {
    echo $l, PHP_EOL;
    echo $l, PHP_EOL;
}

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

const int64_t mod = 1e9 + 7;

signed main() {
  int n;
  cin >> n;
  char s[n][2];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j)
      cin >> s[j][i];
  }
  vector < int64_t > dp(n, 1);
  for (int i = 0; i < n; ++i) {
    if (s[i][0] == s[i][1]) {
      if (i && s[i - 1][0] == s[i - 1][1])
        dp[i] = (dp[i - 1] * 2) % mod;
      else if (i) 
        dp[i] = dp[i - 1];
      else
        dp[i] = 3;
    }
    else {
      if (i >= 2 && s[i - 2][0] == s[i - 2][1])
        dp[i] = (dp[i - 2] * 2) % mod;
      else if (i >= 2)
        dp[i] = (dp[i - 2] * 3) % mod;
      else
        dp[i] = 6;
    }
  }
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin>>N;
	vector<int> V(N);
	vector<int> C(N);
	for(int i=0; i<N; i++)
	{
		cin>>V[i];
	}
	for(int i=0; i<N; i++)
	{
		cin>>C[i];
	}
	int answer=0;
	for(int i=0; i<N; i++)
	{
		if(V[i]>C[i])
		{
			answer+=(V[i]-C[i]);
		}
	}
	cout<<answer<<endl;
	
}

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

int cost(vector<int> x, int target){
  if(x.size() == 0){
    return 0;
  }
  int s = 0;
  int cost = 10 * (x.size()-1);
  for(int i = 0; i < x.size(); i++){
    s += x[i];
  }
  if(target - s > 0){
    cost += target - s;
  } else { 
    cost += s - target;
  }
  return cost;
}

int dfs(int counter, int x, int y,int z, int A, int B, int C, int cost, vector<int> v){
  if(counter == v.size()){
    if(x*y*z == 0){
      return 10000000;
    } else { 
      return(cost + abs(x-A) + abs(y-B) + abs(z-C));
    }
  } else {
    counter++; 
    int tmp1 = dfs(counter, x+v[counter], y, z, A,B,C, cost + 10*(x!=0), v);
    int tmp2 = dfs(counter, x, y + v[counter], z, A,B,C, cost + 10*(y!=0), v);
    int tmp3 = dfs(counter, x, y, z+v[counter], A,B,C, cost + 10*(z!=0), v);
    int tmp4 = dfs(counter, x, y, z, A,B,C, cost, v);
    return(min(min(tmp1,tmp2), min(tmp3,tmp4)));
  }

}

int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  vector<int> v(N);
  
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  cout << dfs(-1, 0,0,0, A,B,C, 0, v) << endl;
}

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

int main() {
    int ans;
    string s; cin >> s;
    s += 'A';
    for(int i = 0; i < s.length()-2; i++) {
        if (s.at(i) == s.at(i+1)) {
            ans = i;
            cout << ans + 1 << " " <<  ans + 2 << endl;
            break;
        }
        if (s.at(i) == s.at(i+2)) {
            ans = i;
            cout << ans + 1 << " " << ans + 3 << endl;
            break;
        } 
        if (i == s.length() - 3) {
            cout << -1 << " " << -1 << endl;
        }
    }  
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define INF LONG_LONG_MAX
#define int long long
#define ar array
const int mxn=5e5+4;
int t[mxn];
int n,q;
void upd(int u,int d)
{
    while(u<=n)
    {
        t[u]+=d;
        u+=u&-u;
    }
}
int sum(int u)
{
    int s=0;
    while(u)
    {
       s+=t[u];
       u-=u&-u; 
    }
    return(s);
}
int que(int l,int r)
{
    return(sum(r)-sum(l-1));
}
int c[mxn];
vector<int> qr[mxn],qi[mxn];
int cnt[mxn],ans[mxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for (int i=1;i<=n;i++) cin>>c[i];
    for (int i=0;i<q;i++)
    {
        int l,r;
        cin>>l>>r;
        qr[r].push_back(l);
        qi[r].push_back(i);
    }
    for (int i=1;i<=n;i++)
    {   
        if (cnt[c[i]]>0) upd(cnt[c[i]],-1);
        upd(i,1);   
        cnt[c[i]]=i;
        for (int j=0;j<qr[i].size();j++)
        {
            ans[qi[i][j]]=que(qr[i][j],i);
        }
    }
    for (int i=0;i<q;i++) cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 62736
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<utility>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#define pb push_back
#define st first
#define nd second
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long lo;
const int mod=1000000007,N=500005;
lo a,b,c,d,e,g=1,arr[N],h[N];

void solve(){
	cin >> a;
	for(lo i=1;i<=a;i++){
		cin >> arr[i];
		h[i]=h[i-1]+arr[i];
	}
	lo x=0,ans=mod;
	for(lo i=a;i>=1;i--){
		ans=min(ans,abs(x-h[i]));
		x+=arr[i];
	}
	cout << min(ans,x) << endl;
}

int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	// cin >> g;
	while(g--) solve();
}

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
int n,m,a[5001],l,r;
bool jl[INF];
bool dp[5001];
bool check(int k){
//	cout<<k<<endl;
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	rep(i,n){
		if(i==k){
			continue;
		}
		for(int j=m-a[i];j>=0;j--){
			dp[j+a[i]]|=dp[j];
		}
		/*rep0(j,g){
			cout<<dp[j]<<' ';
		}
		cout<<endl;*/
	}
	ll t=max(m-a[k],m-m);
//	cout<<t<<endl;
	for(int i=t;i<=m-1;i++){
		if(dp[i]){
			return 0; 
		}
	}
	return 1;
}
int has(int a,int b){
	return (a*101+b*37)%INF; 
}
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	l=1;
	r=n;
	while(l<=r){
		ll mid=(l+r)/2;
		if(check(mid)){
//			cout<<1<<' '<<mid<<endl<<endl;
			l=mid+1;
		}
		else{
//			cout<<0<<' '<<mid<<endl<<endl;
			r=mid-1;
		}
		if(jl[has(l,r)]){
			break;
		}
		jl[has(l,r)]=1;
	}
	cout<<(l+r)/2;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  bool b[8]={false};
  int sum=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<8;j++){
      if(a[i]>=j*400&&a[i]<(j+1)*400){
        b[j]=true;
      }
    }
    if(a[i]>=3200) sum++;
  }
  int summ=0;
  for(int i=0;i<8;i++){
    if(b[i]) summ++;
  }
  if(summ==0){
    cout<<1<<" "<<sum<<endl;
  }
  else{
    cout<<summ<<" "<<summ+sum<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vvi A(2,vi(N));
  rep(i,N) cin >> A[0][i];
  rep(i,N) cin >> A[1][i];
  vi S1(N+1),S2(N+1);
  rep(i,N) {
    S1[i+1]=S1[i]+A[0][i];
    S2[i+1]=S2[i]+A[1][i];
  }
  
  int ans=0;
  rep(i,N) ans=max(ans,S1[i+1]+S2[N]-S2[i]);
  
  cout << ans << endl;
}

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

int n, a[128], ans;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
        for(int j = i+1; j <= n; j++)
            for(int k = j+1; k <= n; k++)
                if(a[i]!=a[j] && a[j]!= a[k] && a[i] != a[k] && a[i]+a[j] > a[k] && a[i]+a[k] > a[j] && a[j]+a[k] > a[i])
                    ans++;
    cout << ans;
}


Measured memory_bytes: 3520
#include <iostream>

using namespace std;
int main(){
	long long i,n,a,b;
	cin >> n >> a >> b;
	n %= 12;
	for(i=0;i<n;i++){
		if(!(i&1)){
			a -= b;
		}else{
			b += a;
		}
	}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 3120
# -*- coding: utf-8 -*-

N, M = map(int, input().split())

a_dict = {}

for _ in range(0, M):
    p, s = map(str, input().split())
    if p in a_dict:
        a_dict[p].append(s)
    else:
        a_dict[p] = [s]

ans = 0
pena = 0

for k, v in a_dict.items():
    if 'AC' in v:
        ans += 1

        for b in v:
            if b == 'AC':
                break
            else:
                pena += 1

print('{} {}'.format(ans, pena))

Measured memory_bytes: 69336
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
    string s;
    
    char c;
    int sum=0;
    getline(cin,s);
    while(s[0]!='0' || s.size()!=1){
        for (int i = 0; i<s.size(); i++){
            c = s[i];
            sum+=atoi(&c);
        }
        cout << sum<<"\n";
        getline(cin,s);
        sum=0;

    }
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int a,b;
cin >> a >> b;

if(a >= 13) cout << b << endl;
else if(a <= 12 && a >= 6) cout << b / 2 << endl;
else cout << 0 << endl;

return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int INF = 10000000;
const int MAX_H = 1003;
const int MAX_W = 1003;
int H, W, N;
char blocks[MAX_H][MAX_W];
int init_row, init_col;

int init() {
	fill_n((char*)blocks, MAX_H * MAX_W, 'X');
	cin >> H >> W >> N;
	for (int i = 1; i <= H; i++) {
		scanf("%s", blocks[i] + 1);
		blocks[i][strlen(blocks[i])] = 'X';
	}
	
	H += 2;
	W += 2;
	
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (blocks[i][j] == 'S') {
				init_row = i;
				init_col = j;
			}
		}
	}
	
	return 0;
}

int bfs(int start_row, int start_col, int goal_row, int goal_col) {
	queue<int> que_i;
	queue<int> que_j;
	que_i.push(start_row);
	que_j.push(start_col);
	
	int d[MAX_H][MAX_W];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			d[i][j] = INF;
		}
	}
	d[start_row][start_col] = 0;
	
	while (!que_i.empty()) {
		int i = que_i.front(); que_i.pop();
		int j = que_j.front(); que_j.pop();
		
		int di[] = {1, -1, 0, 0};
		int dj[] = {0, 0, 1, -1};
		
		if (i == goal_row && j == goal_col) return d[i][j];
		
		for (int k = 0; k < 4; k++) {
			int ti = i + di[k];
			int tj = j + dj[k];
			
			if (blocks[ti][tj] != 'X') {
				if (d[ti][tj] > d[i][j] + 1) {
					d[ti][tj] = d[i][j] + 1;
					que_i.push(ti);
					que_j.push(tj);
				}
			}
		}
	}
	
	return 0;
}

void solve() {
	vector<int> to_i(N);
	vector<int> to_j(N);
	
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char ch = blocks[i][j];
			if ('1' <= ch && ch <= '9') {
				to_i[(int)(ch - '1')] = i;
				to_j[(int)(ch - '1')] = j;
			}
		}
	}
	
	int s_i = init_row;
	int s_j = init_col;
	
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int n = bfs(s_i, s_j, to_i[i], to_j[i]);
		ans += n;
		s_i = to_i[i];
		s_j = to_j[i];
	}
	
	cout << ans << endl;
}

int main() {
	init();
	solve();
}

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

int main() {
  int A, B, C, D;

  cin >> A >> B >> C >> D;
  
  if (A < 1 || A > 10) {
    cout << "error" << endl;
  }  
  else if (B < 1 || B > 10) {
    cout << "error" << endl;
  }
  else if (C < 1 || C > 10) {
    cout << "error" << endl;
  }
  else if (D < 1 || D > 10) {
    cout << "error" << endl;
  }
  else if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  else {
    cout << "Left" << endl;
  }
}

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

int main(){
  int K,X;
  cin >> K >> X;
  rep(i,K-1){
    if(X-K+i+1 < -100000) break;
    cout << X-K+i+1 <<" ";
  }
  rep(i,K){
    if(X+i > 100000) break;
    if(i == K-1) cout << X+i;
    else cout << X+i <<" ";
  }
  cout << endl;
}

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

int main(int argc, const char * argv[]) {
    string S;
    
    cin >> S;
    
    S[0] = '2';
    S[1] = '0';
    S[2] = '1';
    S[3] = '8';
    
    cout << S << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = (long) 1e9 + 7;

int main(){
    
    int n, m, q;
    cin >> n >> m >> q;
    
    vector<int> a(q,0), b(q,0), c(q,0), d(q,0);
    
    rep(i,q){
        int aa, bb;
        cin >> aa >> bb >> c[i] >> d[i];
        aa--;
        bb--;
        a[i] = aa;
        b[i] = bb;
    }

    vector<int> l(10,1);
    
    int ans = 0;
    
    while(1){
        
        int sum = 0;
        
        rep(i,q){
            if(l[b[i]] - l[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        
        int x;
        
        for(x = n - 1; x >= 0; x--){
            if(l[x] < m) break;
        }
        
        if(x <= 0) break;
        
        l[x]++;
        for(int j = x + 1; j < n; j++){
            l[j] = l[x];
        }
  
    }
    
    cout << ans << "\n";
    
    return 0;
}



Measured memory_bytes: 3176
#include<iostream>
#include<string>
using namespace std;
int main(){
	string w,inp;
	int count = 0;
	cin >> w;
	for (int i = 0; i < w.size(); i++)
		w[i] = ('A' <= w[i]&&w[i] <= 'Z') ? (char)w[i]+'a'-'A' : w[i];
	while (true){
		cin >> inp;
		if (inp == "END_OF_TEXT")
			break;
		for (int i = 0; i < inp.size(); i++)
			inp[i] = ('A' <= inp[i] && inp[i] <= 'Z') ? (char)inp[i] + 'a' - 'A' : inp[i];
		if (w == inp)
			count++;
	}
	cout << count << endl;
}
//s[i + j] == p[j] || (i + j)>s.size() && s[i + j-s.size()]==p[j]


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,K;cin>>N>>K;
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<N;i++){
    if(i)if(s[i-1]=='L'&&s[i]=='L')ans++;
    if(i)if(s[i-1]=='R'&&s[i]=='R')ans++;
  }
  int c=0;
  for(int i=1;i<N-1;i++)if(s[i-1]!=s[i]&&s[i]!=s[i+1])c++;
  if(c==0)fin(N-1);

  int l=0,r=0;
  for(int i=1;i<N;i++){
    if(s[i-1]=='L'&&s[i]=='R')l++;
    if(s[i-1]=='R'&&s[i]=='L')r++;
  }
  c=min(l,r);
  if(s[N-1]=='L')l++;
  if(s[N-1]=='R')r++;
  if(K>=min(l,r))fin(N-1);
  ans+=min(c,K)*2;K-=min(c,K);

  if(K==0)fin(ans);
  if(K>=2)ans++;
  if(K>=1)ans++;
  fin(min(ans,N-1));
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int k,a,b; cin >> k >> a >> b;
    bool flg=false;
    for(int i=a; i<=b; i++){
        if(i%k==0) flg=true;
    }
    if (flg) cout << "OK" << endl;
    else cout << "NG" << endl;

}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ a.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
コード変えたらコンパイルする
不正解ならWAが出る
*/

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

const int INF = 1e9;
int H, W, dist[52][52], di[4] = {1, 0, -1, 0}, dj[4] = {0, 1, 0, -1};
char grid[52][52];

void bfs(int si, int sj){
    queue<P> q;
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) dist[i][j] = INF;
    dist[si][sj] = 0; q.push(P(si, sj));

    while(q.size()){
        P p = q.front(); q.pop();
        int ui = p.first, uj = p.second;
        for(int i=0;i<4;i++){
            int ni = ui + di[i], nj = uj + dj[i];
            if(0<=ni && ni<=H && 0<=nj && nj<=W && grid[ni][nj] == '.' && dist[ni][nj] == INF){
                dist[ni][nj] = dist[ui][uj] + 1;
                q.push(P(ni, nj));
            }
        }
    }
}

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

    int cnt = 0;
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
        cin >> grid[i][j];
        if(grid[i][j] == '.') cnt++;
    }

    bfs(0, 0);

    if(dist[H-1][W-1] == INF) cout << -1 << endl;
    else cout << cnt - dist[H-1][W-1] - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES":"NO");}
void Yn(bool z){cout<<(z?"Yes":"No");}
void yn(bool z){cout<<(z?"yes":"no");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 998244353;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 4001;
ll fac[N], rfac[N], s[N];
int n, k;
ll comb(int a, int b){
  if(b<0||a<b) return 0;
  return fac[a] * rfac[b] % mod * rfac[a-b] % mod;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  fac[0] = 1;
  rfac[0] = 1;
  FOR(i, 1, N){
    fac[i] = fac[i-1]*i%mod;
    rfac[i] = modpow(fac[i], mod-2, mod);
  }
  cin >> k >> n;
  FOR(i, 2, k+2){
    ll ans = 0;
    int p = i/2;
    if(i%2){
      FOR(j, 0, p+1) ans += comb(p, j) * modpow(2, j, mod) % mod * comb(n-j+k-2*p+j-1, k-2*p+j-1) % mod;
    }else{
      p--;
      FOR(j, 0, p+1) ans += comb(p, j) * modpow(2, j, mod) % mod * (comb(n-j+k-2*p+j-2, k-2*p+j-2) + comb(n-j+k-2*p+j-3, k-2*p+j-2)) % mod;
    }
    s[i] = ans%mod;
    cout << s[i] << endl;
  }
  FOR(i, k+2, k*2+1) cout << s[k*2+2-i] << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n,k,q;
  cin >> n >> k >> q;
  
  vector<int> A(n,0);
  int a;
  
  rep(i,q){
    cin >> a;
    A[a-1]+=1;
  }
  
  rep(i,n){
    if(q-A[i]<k)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
}



Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,a,b;

int main(){
	cin>>n>>a>>b;
	if(n==1&&a!=b||a>b) cout<<0<<endl;
	else cout<<a*(-n+2)+b*(n-2)+1<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int A;
    static int B;
    static int[] a;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        A = scanner.nextInt();
        B = scanner.nextInt();
        scanner.close();
    }


    public static void main(String args[]) {
        init();

        boolean isExists = false;
        for(int c = 1; c <= 3; c++) {
            if(A * B * c % 2 == 1) isExists = true; break;
        }

        if(isExists) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 23764
import math
a, b, x=(int(i) for i in input().split())

if a**2*b==x:
    print(0)
elif a**2*b//2<=x:
    ans_tan=2*(a*a*b-x)/a**3
    ans=math.degrees(math.atan(ans_tan))
    print(ans)
else:
    ans_tan=2*x/(a*b**2)
    ans=math.degrees(math.atan(ans_tan))
    print(90-ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 1e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;



int main() {
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    int n,y;
    scanf("%d%d",&n,&y);
    for(int i=n; i>=0; i--) {
        for(int j=n-i; j>=0; j--) {
            int k = n - i - j;
            int sum = 10000 * i + 5000 * j + 1000 * k;
            if(sum == y) {
                printf("%d %d %d\n",i,j,k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 256
// ABC 129 D Lamp

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

typedef long long ll;

int solve(int H, int W, vector<vector<char>> masu) {
  vector<vector<int>> ue(H, vector<int>(W));
  for (int j=0; j<W; j++){
    for (int i=H-1; i>=0; i--) {
      if (masu.at(i).at(j) == '#') {
        ue.at(i).at(j) = 0;
        continue;
      }
      if (i+1 >= H) {
        ue.at(i).at(j) = 1;
        continue;
      }
      ue.at(i).at(j) = ue.at(i+1).at(j) + 1;
    }
  }
  vector<vector<int>> shita(H, vector<int>(W));
  for (int j=0; j<W; j++){
    for (int i=0; i<H; i++) {
      if (masu.at(i).at(j) == '#') {
        shita.at(i).at(j) = 0;
        continue;
      }
      if (i-1 < 0) {
        shita.at(i).at(j) = 1;
        continue;
      }
      shita.at(i).at(j) = shita.at(i-1).at(j) + 1;
    }
  }
  vector<vector<int>> migi(H, vector<int>(W));
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++) {
      if (masu.at(i).at(j) == '#') {
        migi.at(i).at(j) = 0;
        continue;
      }
      if (j-1 < 0) {
        migi.at(i).at(j) = 1;
        continue;
      }
      migi.at(i).at(j) = migi.at(i).at(j-1) + 1;
    }
  }
  vector<vector<int>> hidari(H, vector<int>(W));
  for (int i=0; i<H; i++){
    for (int j=W-1; j>=0; j--) {
      if (masu.at(i).at(j) == '#') {
        hidari.at(i).at(j) = 0;
        continue;
      }
      if (j+1 >= W) {
        hidari.at(i).at(j) = 1;
        continue;
      }
      hidari.at(i).at(j) = hidari.at(i).at(j+1) + 1;
    }
  }
  int max = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      int value = ue.at(i).at(j) + migi.at(i).at(j) + shita.at(i).at(j) + hidari.at(i).at(j) - 3;
      if (max < value) {
        max = value;
      }
    }
  }
  return max;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> masu(H, vector<char>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> masu.at(i).at(j);
    }
  }
  cout << solve(H, W, masu) << endl;
  return 0;
}



Measured memory_bytes: 74028
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt(), k = sc.nextInt();
        long[][] dp = new long[h + 1][w + 2];
        long[][] baai = new long[w][3];
        for (int i = 0; i < w; i++) {
            long left = i - 1;
            long right = w - i - 2;
            baai[i] = new long[]{myPow(left) * myPow(right), myPow(left - 1) * myPow(right), myPow(left) * myPow(right - 1)};
        }
        dp[0][1] = 1;
        for (int i = 0; i < h; i++)
            for (int j = 1; j <= w; j++)
                dp[i + 1][j] = (dp[i][j] * baai[j - 1][0] + dp[i][j - 1] * baai[j - 1][1] + dp[i][j + 1] * baai[j - 1][2]) % 1000000007;
        System.out.println(dp[h][k]);
    }

    static long myPow(long weight) {
        if (weight <= 0) return 1;

        long retV = 0;
        loop:
        for (int j = 0; j < (1L << weight); j++) {
            verify:
            for (int k = 0; k < weight; k++) {
                if (k == 0) continue verify;
                if (((j >> k) & 1) == 1 && ((j >> k - 1) & 1) == 1) continue loop;
            }
            retV++;
        }
        return retV;
    }
}

Measured memory_bytes: 21844
#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;


//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;}
int mypow(int _x, int _n){
	int ret = 1;
	while(0 < _n){
		if((_n % 2) == 0){
			_x *= _x;
            _x %= MOD;
			_n >>= 1;
		}
		else{
			ret *= _x;
            ret %= MOD;
			--_n;
		}
	}
	return ret;
}

typedef pair<int, int> P;
map <P,int> mp;

signed main(){
    int n;
    cin >> n;
    REP(i,n){
        int a1,b1;
        cin >> a1 >> b1;
        if(a1==0 && b1 == 0){
            mp[P(0,0)] ++; //最後にしっかりと考える
        }
        else if(a1==0){
            mp[P(0,1)] ++;
        }
        else if(b1 == 0){
            mp[P(1,0)] ++;
        }
        
        else if(a1 < 0){
            a1 = -a1;
            b1 = -b1;
            int cc = abs(b1);
            int dd = gcd(a1,cc);
            a1 /= dd;
            b1 /= dd;
            mp[P(a1,b1)] ++; 
        }
        else{
            int cc = abs(b1);
            int dd = gcd(a1,cc);
            a1 /= dd;
            b1 /= dd;
            mp[P(a1,b1)] ++; 
        }
    }
    int ans = 1;
    for (map<P, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
        P now = it->first;
        if(it->second == 0) continue;
        //cout <<"it=" <<  it->first.first <<" " <<  it->first.second << " " << it-> second << endl;
        if(now.second > 0){
            if(mp[P(now.second,-now.first)] > 0) continue;
            else if(now == P(0,1)&& mp[P(1,0)]>0) continue;
            ans *= mypow(2,it->second);
            ans %= MOD;
        }
        else if(now == P(0,0)){
            continue;
        }
        else{
            //cout << now.first << " " << now.second << endl;
            //cout << "ans=" << ans << endl;
            ans *= mypow(2, it->second) + mypow(2,mp[P(-now.second,now.first)]) - 1;
            ans %= MOD;
        }
        //cout << "ans=" << ans << endl;
        
    }
    ans += MOD - 1;
    ans %= MOD;
    ans += mp[P(0,0)];
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

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



int main(){

	int N;

	scanf("%d",&N);

	if(N == 1){

		printf("Hello World\n");

	}else{

		int A,B;
		scanf("%d %d",&A,&B);
		printf("%d\n",A+B);
	}

	return 0;
}


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

int main(){

  int cnt;
  int n;
  int i;
  cin >> n; //価格を入力する
  
  for(i = 0 ; n - 1000*i > 0 ; i++){
    continue;
  }
  
  cnt = 1000*i - n;
  
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200000;
int N, A, B, C, D;
string S;

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

  cin >> N >> A >> B >> C >> D;
  cin >> S;

  --A; --B; --C; --D;

  bool ok = true;
  for (int i = A; i < C; ++i) {
    if (S.substr(i, 2) == "##") {
      ok = false; break;
    }
  }

  for (int i = B; i < D; ++i) {
    if (S.substr(i, 2) == "##") {
      ok = false; break;
    }
  }

  if (!ok) {
    cout << "No" << endl;
    return 0;
  }

  if (A < B && D < C) {
    bool judge = false;
    for (int i = B; i <= D; ++i) {
      if (i-1 != A && S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
        judge = true; break;
      }
    }

    if (!judge) ok = false;
  }


  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;

}


Measured memory_bytes: 576
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
vector<int> r,g,b;
char s[4005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R') r.pb(i);
        else if (s[i]=='G') g.pb(i);
        else b.pb(i);
    }
    int sr=r.size(),sg=g.size(),sb=b.size();
    ll ans = (ll)sr*sg*sb;
    for(int d=1;d<=n;d++)
    {
        for(int a=0;a+d+d<n;a++)
        {
            if(s[a]!=s[a+d] && s[a]!=s[a+d+d] && s[a+d]!=s[a+d+d]) ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
bool isg1(int a) {
  if (a == 4 || a == 6 || a == 9 || a == 11) {
    return 0;
  } else {
    return 1;
  }
}
int main(void) {
  int x, y;
  cin >> x >> y;
  if (x == 2 || y == 2) {
    cout << "No" << endl;
    return 0;
  }
  if (isg1(x) == isg1(y)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define int long long
#define MN 100005
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int c[MN<<2],d[MN],sum[MN],a[MN],b[MN];
int n,tot,l,r,res;
ll num;
inline void add(int x,int v){
	for (int i=x;i<=((n<<1)|1);i+=i&(-i)) c[i]+=v; 
}
inline int query(int x){
	int res=0;
	for (int i=x;i;i-=i&(-i)) res+=c[i];
	return res;
}
inline bool check(int x){
	for (int i=1;i<=n;++i) sum[i]=sum[i-1]+(a[i]>b[x]);
	for (int i=1;i<=n;++i) d[i]=(sum[i]<<1)-i+n+1;d[0]=n+1;
	memset(c,0,sizeof(c));
	add(d[0],1);num=0ll;
	for (int i=1;i<=n;++i)
	num+=1ll*(query(((n<<1)|1))-query(d[i])),add(d[i],1);
	return (num>1ll*(n*(n+1ll))/4ll);
}
signed main()
{
	n=in();
	for (int i=1;i<=n;++i) a[i]=b[i]=in();
	sort(b+1,b+n+1);
	tot=unique(b+1,b+n+1)-b-1;
	l=0,r=tot,res=0;
	while (l<=r){
		int mid=(l+r)>>1;
		if (check(mid)) res=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d",b[res]);return 0;
}

Measured memory_bytes: 6400
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
total=0
M=[0]*n
for i in range(n):
  if t[i]=='r' and (i<k or M[i-k]!='p'):
    M[i]='p'
    total+=p
  elif t[i]=='s' and (i<k or M[i-k]!='r'):
    M[i]='r'
    total+=r
  elif t[i]=='p' and (i<k or M[i-k]!='s'):
    M[i]='s'
    total+=s
  #print(total,t[i-k],t[i],i-k)
print(total)

Measured memory_bytes: 76336
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> p(n);
	REP(i, n) cin >> p[i];
	ll c1 = 0, c2 = 0, c3 = 0;
	REP(i, n) {
		if(p[i] <= a) c1++;
		else if(p[i] <= b) c2++;
		else c3++;
	}
	cout << min(c1, min(c2, c3)) << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
k = 2
dp = [1<<30] * n
dp[0] = 0
for i in range(n):
    for j in range(min(k, n) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
print(dp[-1])


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

using namespace std;

#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string x; cin>>x;
    if(x[x.length()-1]=='s')
    {
        cout<<x<<"es";
        return 0;
    } else {
        cout<<x<<'s';
        return 0;
    }
}

Measured memory_bytes: 3648