akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	vi x(n),y(n);
	rep(i,n)cin>>x[i]>>y[i];
	set<pi> s;
	rep(i,n)
		s.insert(pi(x[i],y[i]));
	int ans=n;
	rep(i,n)rep(j,i){
		int p=x[j]-x[i];
		int q=y[j]-y[i];
		int z=n;
		rep(k,n)
			z-=s.count(pi(x[k]+p,y[k]+q));
		chmin(ans,z);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(v) for(auto i:v)cout<<i<<" "
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define S(v) sort(v.begin(), v.end());
const ll mod = 1E9 + 7;

int main()
{
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        cout<<(n?0:1);

    }
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt(); 
    char[][] a = new char[H][W];
    boolean[] checkRow = new boolean[H];
    boolean[] checkColumn = new boolean[W];
    for (int i=0; i<H; i++) {
      String S = sc.next();
      for (int j=0; j<W; j++) {
        a[i][j] = S.charAt(j);
      }
    }
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        if(a[i][j] == '#') {
          checkRow[i] = true;
          checkColumn[j] = true;
        }
      }
    }
    for (int i=0; i<H; i++) {
      boolean check = false;
      for (int j=0; j<W; j++) {
        if(checkRow[i] && checkColumn[j]) {
          check = true;
          System.out.print(a[i][j]);
        }
      }
      if (check) System.out.println();
    }
  }
}

Measured memory_bytes: 31080
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int total_toppings;
  while(~scanf("%d",&total_toppings)){
    int dough_price,topping_price;
    int dough_cal;
    int topping_cal[100];
    scanf("%d %d",&dough_price,&topping_price);
    scanf("%d",&dough_cal);
    for(int i=0;i<total_toppings;i++){
      scanf("%d",topping_cal+i);
    }

    sort(topping_cal,topping_cal+total_toppings,greater<int>());

    int total_cal = dough_cal;
    int res = total_cal/dough_price;
    for(int i=0;i<total_toppings;i++){
      total_cal += topping_cal[i];
      res = max(total_cal/(dough_price + topping_price * (i+1)),res);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

// implemented after reading the editorial

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > v;
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(b, a));
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  int doneb = -1;
  for (int i = 0; i < M; ++i) {
    int a = v[i].second;
    int b = v[i].first;
    if (i == 0) {
      ++cnt;
      doneb = b;
    }
    else {
      if (a < doneb) {
	continue;
      }
      else {
	++cnt;
	doneb = b;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>

using namespace std;
int abs(int n){
  if(n < 0) n = -n;
  return n;
}
int main(){
  int N,L;
  cin >> N >> L;
  int minabs = abs(L);
  int minapple = L;
  int apple_fl = L;
  int apple_pie = L;
  for(int i = 1; i < N; i++){
	apple_fl++;
    apple_pie += apple_fl;
    if(abs(apple_fl) < minabs) {
      minabs = abs(apple_fl);
      minapple = apple_fl;
    }
  }
  cout << (apple_pie - minapple) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

    for i in range(11):
        if  1000 * i >= n:
            break

    print(1000*i-n)
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 72708
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

void print_stack(stack<char> st) {
    if (st.empty()) return;

    auto x = st.top();
    st.pop();

    print_stack(st);

    cout << x;
    st.push(x);
}

int main() {
    string s;
    cin >> s;

    stack<char> a;
    rep(i, s.length()) {
        if (s[i] == '0')
            a.push('0');
        else if (s[i] == '1')
            a.push('1');
        else if (s[i] == 'B') {
            if (!(a.empty())) {
                a.pop();
            }
        }
    }

    print_stack(a);
    cout << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
int main() {
	ll a,b,x;
	cin>>a>>b>>x;
	ll ans=b/x-(a-1)/x;
	if(a==0&&x!=1)++ans;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define mem(name,value) memset(name,value,sizeof(name))
#define loop(i,from,to) for(int i=from;i<to;i++)
#define loopr(i,from,to) for(int i=from;i>=to;i--)
#define pb push_back
using namespace std;
typedef long long ll;

const int maxn=10000+5;
int par[maxn],r[maxn],x[maxn],y[maxn],V,E;
typedef struct{int u,v; double cost;}edge;
vector<edge> es;

void init(int N)
{
    loop(i,0,N){
        par[i]=i;
        r[i]=0;
    }
}

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

void unite(int x,int y)
{
    x=Find(x); y=Find(y);
    if(x==y) return;

    if(r[x]<r[y]) par[x]=y;
    else par[y]=x;
    if(r[x]==r[y]) r[x]++;
}

bool same(int x,int y)
{
    return Find(x)==Find(y);
}

bool cmp(const edge& e1,const edge& e2)
{
    return e1.cost>e2.cost;
}

double kruskal()
{
    sort(es.begin(),es.end(),cmp);
    init(V+1);
    double ans=0;
    loop(i,0,E){
        edge e=es[i];
        if(!same(e.u , e.v)){
            unite(e.u , e.v);
            ans+=e.cost;
        }
    }
    return ans;
}

int main()
{
    double sum=0;
    scanf("%d%d",&V,&E);
    loop(i,1,V+1)
        scanf("%d%d",&x[i],&y[i]);
    loop(i,0,E){
        int f,t;
        double c;
        scanf("%d%d",&f,&t);
        c=sqrt((x[f]-x[t])*(x[f]-x[t])+(y[f]-y[t])*(y[f]-y[t]));
        edge e; e.u=f; e.v=t; e.cost=c; sum+=c;
        es.pb(e);
    }
    printf("%.3f\n",sum-kruskal());
}

Measured memory_bytes: 3684
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const int big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
vector<string>mat;int n;
void solve(int y,int x){
	if(y<0||n<=y||x<0||n<=x){return;}
	if(mat[y][x]=='x'){return;}
	mat[y][x]='x';
	solve(y+1,x);
	solve(y-1,x);
	solve(y,x+1);
	solve(y,x-1);
}
int main(void){
	int i,j,ans=0;cin>>n;
	mat.res(n);
	for(i=0;i<n;i++){cin>>mat[i];}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(mat[i][j]=='o'){solve(i,j);ans++;}
		}
	}
	cout<<ans/3<<endl;
	return 0;
}

Measured memory_bytes: 3196
n,*a=map(int,open(0).read().split()) 
MX=2005
dp=[0]*(MX*10000+MX+100)
p=sorted([(a[i]*MX+i) for i in range(n)])[::-1]
for i in range(n):
    ai,pi=divmod(p[i],MX)
    for l in range(n):
        r=i-l
        if not 0<=r<=n:
            break
        dp[(i+1)*10000+(l+1)]=max(dp[(i+1)*10000+(l+1)],dp[(i)*10000+(l)]+ai*(pi-l))
        dp[(i+1)*10000+(l+0)]=max(dp[(i+1)*10000+(l+0)],dp[(i)*10000+(l)]+ai*(n-r-1-pi))
        
ans=0
for i in range(n+1):
    ans=max(ans,dp[n*10000+i])
print(ans)
    
        
        
        



Measured memory_bytes: 223412
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

int n;
vector<int> adj[114514];
int d[2][114514];

// char X[100][100];
// int dp[1000000001];

void dfs(int peek, int current, int depth, int w) {
    // int i;
    
    d[w][peek] = depth;
    
    REP(i,0,adj[peek].size()) {
        if (adj[peek][i] == current) continue;
        
        dfs(adj[peek][i],peek,depth+1,w);
    }
}


int main(void){
    cin >> n;
    REP(i,0,n-1) {
        int a,b;
        cin >> a >> b;
        
        a--; 
        b--;
        
        // cout << a << b << endl;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    dfs(0,-1,0,0);
    dfs(n-1,-1,0,1);


    int c1 = 0;
    int c2 = 0;
    for (int i = 0; i < n; i++) {
        if (d[0][i] <= d[1][i]) {
            c1++;
        } else {
            c2++;
        }
    }
    
    if (c1 > c2) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
    
    return 0;

}

Measured memory_bytes: 14592
n,ma,mb=list(map(int,input().split()))
item=[]
for i in range(n):
  item.append(tuple(map(int,input().split())))

d={(0,0):0}
for i in range(n):
  nd={}
  for j in d:
    if j in nd:
      nd[j]=min(nd[j],d[j])
    else:
      nd[j]=d[j]
    s=(j[0]+item[i][0],j[1]+item[i][1])
    if s in nd:
      nd[s]=min(nd[s],d[j]+item[i][2])
    else:
      nd[s]=d[j]+item[i][2]
  d=nd
m=10**9
for i in d:
  if i==(0,0):
    continue
  if i[0]*mb==i[1]*ma:
    m=min(m,d[i])
if m==10**9:
  m=-1

print(m)

Measured memory_bytes: 13804
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int ans=0;
  int h;
  int w;
  cin >> h >> w;
  int k[h][w];
  int wi[h][w];
  int he[h][w];
  rep(i,h){
    rep(j,w){
      char t;
      cin >> t;
      if(t=='#'){
        k[i][j]=1;
      }
      else k[i][j]=0;
    }
  }
  rep(i,h){
    rep(j,w){
      if(k[i][j]==1){
        wi[i][j]=0;
        he[i][j]=0;
        continue;
      }
      if(i==0){
        int r=i+1;
        int cnt=1;
        while(r<h&&k[r][j]==0){
          cnt++;
          r++;
        }
        he[i][j]=cnt;
      }
      else if(k[i-1][j]==1){
        int r=i+1;
        int cnt=1;
        while(r<h&&k[r][j]==0){
          cnt++;
          r++;
        }
        he[i][j]=cnt;
      }
      else he[i][j]=he[i-1][j];
      if(j==0){
        int r=j+1;
        int cnt=1;
        while(r<w&&k[i][r]==0){
          cnt++;
          r++;
        }
        wi[i][j]=cnt;
      }
      else if(k[i][j-1]==1){
        int r=j+1;
        int cnt=1;
        while(r<w&&k[i][r]==0){
          cnt++;
          r++;
        }
        wi[i][j]=cnt;
      }
      else wi[i][j]=wi[i][j-1];
      ans=max(ans,he[i][j]+wi[i][j]-1);
    }
  }
  cout << ans << endl;
}  


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    stringstream a;
    string b,c;
    cin>>c>>b;
    a<<c<<c;
    c=a.str();
    for(int i=0;i<c.size()-b.size();i++){
      int d=c.compare(i,b.size(),b);
      if(d==0){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3224
N, M = gets.split.map(&:to_i)

hash = {}
readlines.each do |line|
  k, v = line.split.map(&:to_i)
  if hash[k]
    hash[k] += v
  else
    hash[k] = v
  end
end

ans = 0
hash.keys.sort!.each do |min|
  if M > hash[min]
    M -= hash[min]
    ans += min * hash[min]
  else
    ans += min * M
    break
  end
end

puts ans


Measured memory_bytes: 24424
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	vector<bool> dp(10010, false);
	dp[0] = true;
	rep(i, 0, n)for (int j = 10000; j >= 0; j--) {
		if (dp[j]) dp[j + a[i]] = true;
	}
	int ans=0;
	rep(i, 0, 10001) if (dp[i]&&i%10!=0) ans = i;
	printf("%d", ans);
	return 0;
}


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

int main(){
 int N,K,c,ans;
 cin>>N;
 vector<int> d(N);
 for(int i=0;i<N;i++)
  cin>>d.at(i);
 sort(d.begin(),d.end());
 c=d.size()/2;
 ans=d.at(c)-d.at(c-1);
 cout<<ans<<endl;
}


Measured memory_bytes: 640
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def bit_add(i,w):
    x = i+1
    while x <= n:
        bit[x-1] += w
        x += x & -x
    return

def bit_sum(i):
    res = 0
    x = i+1
    while x > 0:
        res += bit[x-1]
        x -= x & -x
    return res

n,d,a = LI()
bit = [0]*(n+1)
xh = [LI() for _ in range(n)]
xh.sort()
X = [x for x,_ in xh]
lst = []
for x,h in xh:
    r = br(X,x+2*d)
    lst.append((x,h,r))

ans = 0
for i in range(n):
    x,h,r = lst[i]
    tmp = max(0,math.ceil((h - bit_sum(i))/a))
    ans += tmp
    bit_add(r,-tmp*a)
    bit_add(i,tmp*a)
print(ans)


Measured memory_bytes: 126384
N = int(input())
S = str(input())


flag=0

if N%2 == 0:
    M= N//2
    for i in range(M):
        if S[i] != S[M+i]:
            flag = 1
            break
    if flag==1:
        print("No")
    else:
        print("Yes")


else:
    print("No")


    


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

}

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

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

    ll ans = a[0];
    for(int i = 1; i < n; i++){
        ans = mygcd(ans,a[i]);
    }

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

Measured memory_bytes: 1024
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, cnt = 0;
  scanf("%lld", &n);
  ll a[n + 1];
  bool ans[n + 1], b;
  for(i = 1; i <= n; ++i) scanf("%lld", &a[i]);
  for(i = n; i; --i) {
    b = a[i];
    for(j = 2; i * j <= n; ++j) if(ans[i * j]) b = !b;
    ans[i] = b;
    if(b) cnt++;
  }
  printf("%lld\n", cnt);
  for(i = 1; i <= n; ++i) if(ans[i]) printf("%lld ", i);
  return 0;
}

Measured memory_bytes: 2560
import math
import fractions
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def is_prime(p):
    if p == 1:
        return False
    for i in range(2,int(p ** .5) + 1):
        if p % i == 0:
            return False
    return True

A,B = map(int,input().split())

g = fractions.gcd(A, B)

div = make_divisors(g)
ans = 1
for i in div:
    if is_prime(i):
        ans += 1
print(ans)

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

int main(){
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    long long ans=0;
    int a=0,b=0;
    int c=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<s[i].size();j++){
            if(s[i][j-1]=='A' && s[i][j]=='B') ans++;
        }
        

        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A') c++;
        else if(s[i][0]=='B') b++;
        else if(s[i][s[i].size()-1]=='A') a++;
    }
    ans+=max(0,c-1);
    if(c&&a) ans++,a--;
    if(c&&b) ans++,b--;
    ans+=min(a,b);
    cout<<ans<<endl;

}

Measured memory_bytes: 768
package main

import "fmt"

func main() {
	var d int
	fmt.Scan(&d)
	if d == 22 {
		fmt.Println("Christmas Eve Eve Eve")
	} else if d == 23 {
		fmt.Println("Christmas Eve Eve")
	} else if d == 24 {
		fmt.Println("Christmas Eve")
	} else {
		fmt.Println("Christmas")
	}
}


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

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

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


        int ret = INT_MAX;
        for(int i=0; i<2; ++i){
            vector<vector<bool> > check(2, vector<bool>(n, false));
            int x = i;
            int y = 0;
            int tmp = 0;
            for(;;){
                if(!(y == n-1 && a[x][y] == 2) && y >= n-1)
                    break;
                if(check[x][y]){
                    tmp = INT_MAX;
                    break;
                }
                check[x][y] = true;
                if(a[x][y] == 2)
                    -- y;
                else if(a[x][y] == 1 && a[x][y+1] == 1)
                    ++ y;
                else{
                    (++x) %= 2;
                    y += 2;
                    ++ tmp;
                }
            }
            ret = min(ret, tmp);
        }

        if(ret == INT_MAX)
            cout << "NA" << endl;
        else
            cout << ret << endl;
    }
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
#include <atcoder/dsu>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()



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

	int n;

	vector<tuple<int, int, int>> xy;
	cin >> n;
	rep(i, n) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		xy.emplace_back(x, y, i);
	}
	sort(all(xy));

	atcoder::dsu d(n);

	vector<int> v;
	vector<pair<int, int>> unmerge;
	for (int i = n - 1; i >= 0; i--) {
		int x, y, idx;
		tie(x, y, idx) = xy[i];
		if (v.empty() || v.back() < y) {
			unmerge.emplace_back(y, v.size());
			v.push_back(y);
		}
		else {
			if (!v.empty() && v.back() > y) d.merge(y, v.back());
			while (!unmerge.empty()) {
				int a = unmerge.back().second;
				if (a == 0 || v[a - 1] < y)break;
				d.merge(v[a - 1], v[a]);
				unmerge.pop_back();
			}
		}
	}

	vector<int> ans(n);
	for (auto t: xy) {
		ans[get<2>(t)] = d.size(get<1>(t));
	}
	for (int x: ans) {
		cout << x << endl;
	}



	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

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

int bit[200010];  // 1-indexed

int main() {
  int n;
  cin >> n;
  vector<int> v(n), w(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    w[i] = v[i];
  }
  sort(w.begin(), w.end());

  // 圧縮する
  for (int i = 0; i < n; i++) v[i] = lower_bound(w.begin(), w.end(), v[i]) - w.begin() + 1;  // 0予防

  ll ans = 0;
  for (int k = 0; k < n; k++) {
    ll res = 0;
    for (int i = v[k]; i > 0; i -= i & -i) res += bit[i];
    ans += k - res;
    for (int i = v[k]; i <= 200010; i += i & -i) bit[i]++;  // BITに加算
  }
  cout << ans << endl;
}



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

// 解説用 //
 
int main(){
	int N;//線上にボールが跳ねる回数
    int X;//線上で最大の領域
    int L;//跳ねる座標の幅
    int S;//跳ねる最大の座標or途中の座標
    int i;//跳ねた回数
    int x;//跳ねた回数を入れる変数
    N = X = L = S = i = x = 0;
  
	cin >> N >> X;  //NとXを入力
  	S = 0;//跳ねる初期値は0からなので0を代入
	while (i < N+1){	//跳ねた回数が跳ねる回数を越したらルー
    cin >> L;	//跳ねる座標を入力
    S = S + L;	//跳ねる前と後の座標を加算し現在の座標を算出
    i++;	//跳ねた回数を算出
    x = i;	//跳ねた回数をxに代入
    	if (S > X){	//跳ねてる座標が線上の最大の領域だったら
		i = N+1;	//跳ねた回数を跳ねる回数にし、whileを強制終了
    	}
    }
  	cout << x;//跳ねた回数を出力
 	return 0;
}


Measured memory_bytes: 256
n = int(input())
dic = {}
for _ in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
  
m = int(input())
for _ in range(m):
  t = input()
  if t in dic:
    dic[t] -= 1
  else:
    dic[t] = -1

ans = 0
for k, v in dic.items():
  ans = max(ans, v)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define scanf___Am_I_a_joke_to_you  ios_base :: sync_with_stdio(false);
#define ll                          long long
#define MAXN                        200007

int main ()
{
    scanf___Am_I_a_joke_to_you

    char ch; cin >> ch;
    ch += 1;
    cout << ch << endl;


    return 0;
}



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

template<typename M>
void warshallFloyd(M &m, const int &n) {
  rep(k, n) rep(i, n) rep(j, n) cmin(m[i][j], m[i][k] + m[k][j]);
}

void solve() {
  int h, w;
  while (cin >> h >> w, h) {
    vs s(h);
    rep(i, h) cin >> s[i];
    int x = 0;
    rep(i, h) rep(j, w) {
      int t = 0;
      fn<void(int, int, char)> f = [&](int i, int j, char c) {
        if (i < 0 || j < 0 || i >= h || j >= w || c == '-' || s[i][j] != c) return;
        s[i][j]  = '-';
        int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};
        rep(k, 4) f(i + di[k], j + dj[k], c);
      };
      x += s[i][j] != '-';
      f(i, j, s[i][j]);
    }
    cout << x << endl;
  }
}

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

int main(){
  int K,N;
  cin >> K >> N;
  
  vector<int> A(N);
  for (int i=0;i<N;i++) {
  cin >> A.at(i);
  }
  
  int juko=A.at(1)-A.at(0);
  
  for (int i=0;i<N-1;i++){
    if(A.at(i+1)-A.at(i)>juko){
      juko=A.at(i+1)-A.at(i);
    }
  }
  
  if(juko>=K-A.at(N-1)+A.at(0)){
    cout << K-juko <<endl;
  }
  
  else if(juko<K-A.at(N-1)+A.at(0)){
    cout << A.at(N-1)-A.at(0) <<endl;
  }
}

Measured memory_bytes: 1024
N,M = map(int,input().split())
A = list(map(int,input().split()))
AA = max(A)
 
def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a
 
log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    from fractions import gcd
    l = 1
    dame = 0
    for i in A:
        l = (l*i)//gcd(l,i)
        if l//2 >= 10**9:
            dame = 1
            break
    l //= 2
    
    MAX = (M+l)//(2*l)
    MIN = max(1,-(-(AA+2*l)//(4*l)))
    ans = MAX-MIN +1
    #print(MIN)
    
    if dame==1:
        print(0)
    else:
        print(ans)

Measured memory_bytes: 85600
#include<stdio.h>

int main(){
	int i, n, a, b, c, tmp;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d %d %d", &a, &b, &c);
		
		tmp = c;
		
		if(a >= b && a >= c){
			c = a;
			a = tmp;
		}else if(b >= a && b >= c){
			c = b;
			b = tmp;
		}
		
		if(a * a + b * b == c * c) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1000000;
bool primes[N+1];
void soe()
{
	memset(primes,true,sizeof(primes));
	for(ll i=2;i*i<=N;i++)
	{
		if(primes[i] == true)
		{
			for(ll p=i*i;p<=N;p+=i)
				primes[p] = false;
		}
	}
}
int main()
{
	soe();
	ll n;
	cin >> n;
	ll ans = 0;
	ll temp = n;
	for(ll i=2;i<=N;i++)
	{
	    ll count = 0;
	    if(primes[i] && n%i == 0)
	    {
	        while(n%i == 0)
	        {
	            n /= i;
	            count++;
	        }
	        for(ll j=1;j<=N;j++)
	        {
	            if(count < j)
	                break;
                count -= j;
                ans++;
	        }
	    }
	}
	if(n > 1)
	    ans++;
	cout << ans << "\n";
}


Measured memory_bytes: 4608
#include<cstdio>
#include<algorithm>
#define N 505
#include<queue>
using namespace std;
int n;
bool b[N*N];
int dis[N*N];
int que[N*N], ql, qr;
void bfs(int x){
	que[ql=qr=1]=x;
	while(ql<=qr){
		int u = que[ql++];
		int i=u/n, j=u%n;
		if(i>0 && dis[u-n]>dis[u]+b[u]) dis[u-n]=dis[u]+b[u], que[++qr] = u-n;
		if(j>0 && dis[u-1]>dis[u]+b[u]) dis[u-1]=dis[u]+b[u], que[++qr] = u-1;
		if(i<n-1 && dis[u+n]>dis[u]+b[u]) dis[u+n]=dis[u]+b[u], que[++qr] = u+n;
		if(j<n-1 && dis[u+1]>dis[u]+b[u]) dis[u+1]=dis[u]+b[u], que[++qr] = u+1;
	}
}
int main(){
	scanf("%d", &n);
	for(int x=0; x<n*n; ++x){
		b[x] = true;
		int i=x/n, j=x%n;
		dis[x] = min(min(i, j), min(n-i-1, n-j-1));
	}
	int ans=0, x;
	for(int r=1; r<=n*n; ++r){
		scanf("%d", &x);
		--x;
		ans+=dis[x];
		b[x] = false;
		//printf("%d ", dis[x]);
		bfs(x);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3928
import java.io._
import java.text._
import java.util.regex._

object Main {

    def countingValleys(s: String): Int = {
      val weekDaysMap: Map[String, Int] = Map(
        "SUN" -> 7,
        "MON" -> 6,
        "TUE" -> 5,
        "WED" -> 4,
        "THU" -> 3,
        "FRI" -> 2,
        "SAT" -> 1
      )
      weekDaysMap(s)
    }

    def main(args: Array[String]) {
        val stdin = scala.io.StdIn
        val s: String = stdin.readLine
        println(countingValleys(s))
    }
}


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

int n, a, b;

int main() {
    scanf("%d %d %d", &n, &a, &b);
    if (a + b - 1 > n || 1LL * a * b < n) printf("-1\n"), exit(0);
    vector<int> V;
    int m = n - a; n = 0;
    for (int i = 1; i <= a; i++) {
        int k = min(b - 1, m);
        V.push_back(n + k + 1);
        for (int j = 1; j <= k; j++) {
            V.push_back(n + k - j + 1), m--;
        }
        n += k + 1;
    }
    for (int x : V) printf("%d ", x);
    return 0;
}

Measured memory_bytes: 3440
#include <stdio.h>

#define OP_NULL		100
#define OP_ADD		200
#define OP_SUB		300
#define OP_MUL		400
#define OP_EQUAL	500

int calc(int R1,int R2,int R3) {
	switch(R3) {
		case OP_NULL:
			return R2;
		case OP_ADD:
			return R1+R2;
		case OP_SUB:
			return R1-R2;
		case OP_MUL:
			return R1*R2;
		default:
			return -1;
	}
}

int main(void) {
	char input[100];
	int R1,R2,R3;
	int i,error;
	while(scanf("%s",input)==1) {
		R1=R2=0;
		R3=OP_NULL;
		error=0;
		for(i=0;input[i];i++) {
			if(error && input[i]!='=')continue;
			switch(input[i]) {
				case '+':
					R1=calc(R1,R2,R3);
					if(R1<0 || R1>9999)error=1;
					R2=0;
					R3=OP_ADD;
					break;
				case '-':
					R1=calc(R1,R2,R3);
					if(R1<0 || R1>9999)error=1;
					R2=0;
					R3=OP_SUB;
					break;
				case '*':
					R1=calc(R1,R2,R3);
					if(R1<0 || R1>9999)error=1;
					R2=0;
					R3=OP_MUL;
					break;
				case '=':
					R1=calc(R1,R2,R3);
					if(R1<0 || R1>9999)error=1;
					if(error) {
						puts("E");
						error=0;
					} else printf("%d\n",R1);
					R2=0;
					R3=OP_NULL;
					break;
				default:
					R2=R2*10+(input[i]-'0');
					if(R2<0 || R2>9999)error=1;
			}
		}
		if(error)puts("E");
	}
	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    int d = n / 1000;
    int c = (n - d * 1000) / 100;
    int b = (n - c * 100 - d * 1000) / 10;
    int a = n % 10;
    if (d + c + b + a == 7) {
        cout << d << "+" << c << "+" << b << "+" << a << "=7" << endl;
        return 0;
    } else if (d + c + b - a == 7) {
        cout << d << "+" << c << "+" << b << "-" << a << "=7" << endl;
        return 0;
    } else if (d + c - b + a == 7) {
        cout << d << "+" << c << "-" << b << "+" << a << "=7" << endl;
        return 0;
    } else if (d + c - b - a == 7) {
        cout << d << "+" << c << "-" << b << "-" << a << "=7" << endl;
        return 0;
    } else if (d - c + b + a == 7) {
        cout << d << "-" << c << "+" << b << "+" << a << "=7" << endl;
        return 0;
    } else if (d - c + b - a == 7) {
        cout << d << "-" << c << "+" << b << "-" << a << "=7" << endl;
        return 0;
    } else if (d - c - b + a == 7) {
        cout << d << "-" << c << "-" << b << "+" << a << "=7" << endl;
        return 0;
    } else if (d - c - b - a == 7) {
        cout << d << "-" << c << "-" << b << "-" << a << "=7" << endl;
        return 0;
    }
    return 0;
}






Measured memory_bytes: 256
#include<cstdio>
#include<stack>
#include<cctype>
#include<cstdlib>
using namespace std;

int main() {
	stack<int>	nums;
	char	s_tmp[20];
	int	n_tmp, op1, op2;

	while(scanf("%s", s_tmp) != EOF) {
		if(isdigit(s_tmp[0])) {
			n_tmp = atoi(s_tmp);
			nums.push(n_tmp);
		} else if(s_tmp[0] == '+') {
			op2 = nums.top(); nums.pop();
			op1 = nums.top(); nums.pop();
			nums.push(op1 + op2);
		} else if(s_tmp[0] == '-') {
			op2 = nums.top(); nums.pop();
			op1 = nums.top(); nums.pop();
			nums.push(op1 - op2);
		} else if(s_tmp[0] == '*') {
			op2 = nums.top(); nums.pop();
			op1 = nums.top(); nums.pop();
			nums.push(op1 * op2);
		}
	}

	printf("%d\n", nums.top());
}

Measured memory_bytes: 2736
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define MOD 1000000007
#define MAXN 2005
using namespace std;
typedef long long LL;
int d[MAXN][MAXN],num[MAXN][MAXN],inv[MAXN*MAXN],kinv,n,k;
void pre()
{
    inv[1]=1;kinv=1;
    for(int i=2;i<MAXN*MAXN;i++) inv[i]=(MOD-MOD/i)*(LL)inv[MOD%i]%MOD;
    for(int i=2;i<=k-2;i++) kinv=(LL)kinv*inv[i]%MOD;
    num[0][0]=1;
    for(int j=1;j<n;j++)
    {
        num[0][j]=1;
        for(int m=1;m<=k-2;m++) num[0][j]=(LL)num[0][j]*(j*k-j+m)%MOD;
        num[0][j]=(LL)num[0][j]*kinv%MOD;
        //cout<<j<<' '<<num[0][j]<<endl;
    }
    for(int j=1;j<n;j++)
        for(int i=1;i<=j;i++)
    {   num[i][j]=(LL)num[i-1][j]*(j*k-j+k+i-2)%MOD*inv[j*k-j+i]%MOD;
        //cout<<j*k-j+k-2+i<<' '<<k-2<<' '<<num[i][j]<<endl;
    }
}
int main()
{

    cin>>n>>k;
    if(k==1) {cout<<1<<endl;return 0;}
    pre();
    d[0][1]=1;
    for(int j=2;j<=n;j++)
        d[0][j]=(LL)d[0][j-1]*num[0][j-1]%MOD;
    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
    {
        d[i][j]=(d[i-1][j]+(LL)d[i][j-1]*num[i][j-1]%MOD)%MOD;
    }
    int ans=d[n][n];
    for(int i=2;i<=n;i++) ans=(LL)ans*i%MOD;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 47488
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

template<typename T>
T pmod(T a, T b)
{
	return a - std::floor(a / b) * b;
}


/** 10進 -> base進変換

    負進数にも対応
    12345, 10 -> [1, 2, 3, 4, 5]
*/
template<typename T>
std::vector<T> conv_base(T n, T base) {
    std::vector<T> ret;
    if (n == 0) {
        ret.push_back(0);
        return ret;
    }

    while (n != 0) {
        auto r = std::abs(n) % std::abs(base);
        ret.push_back(r);
        n -= r;
        n = n / base;;
    }

    std::reverse(std::begin(ret), std::end(ret));

    return ret;
}

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

    auto A = conv_base(N, (int64_t)-2);

    for (auto a: A) {
        std::cout << a;
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
int A[1000];
int main() {
    int N=0;
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%d", &A[i]);
    }
    long long int Min= 100000000000000;
    int Max =0;
    for(int i=0; i<N; i++){
        if(A[i]<Min){
            Min = A[i];
        }
        if(A[i]>Max){
            Max = A[i];
        }
    }
    printf("%d", Max-Min);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
char S[150];
char S1[150];


int main(void){
 int A,B;

 cin>>A>>B;

 std::cout<<A*B-(A+B-1)<<std::endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

#define MAX 100
#define MOD 100000
int W,H;
int dp[MAX][MAX][4];

void make(){
  memset(dp,0,sizeof(dp));

  for(int i = 0 ; i < MAX ; i++){
    dp[i][0][0] = 1;
    dp[0][i][1] = 1;
  }

  for(int i = 1 ; i < MAX ; i++){
    for(int j = 1 ; j < MAX ; j++){
      dp[i][j][0] += dp[i-1][j][0] + dp[i-1][j][2];
      dp[i][j][0] %= MOD;
      dp[i][j][1] += dp[i][j-1][1] + dp[i][j-1][3];
      dp[i][j][1] %= MOD;
      dp[i][j][2] += dp[i-1][j][1];
      dp[i][j][2] %= MOD;
      dp[i][j][3] += dp[i][j-1][0];
      dp[i][j][3] %= MOD;
    }
  }
}

int main(){
  make();
  while(cin >> W >> H, (W | H)){
    int ans = 0;
    for(int i = 0 ; i < 4 ; i++){
      ans += dp[H-1][W-1][i];
    }
    cout << ans % MOD << endl;
  }

  return 0;
}

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

#define ll long long
#define fi first
#define se second
#define inf 1e15

#define N 300005

int row[N];
int col[N];

vector<int>rowv,colv;

set<pair<int,int>>bomb;

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--){
	    
	    int n,m,k;
	    cin>>n>>m>>k;
	    
        int rowh=0,colh=0;
	    for(int i=0;i<k;i++){
	        int x,y;
	        cin>>x>>y;
	        x--;y--;
	        
	        bomb.insert({x,y});
	        
	        row[x]++;
	        col[y]++;
	        
	        rowh=max(rowh,row[x]);
	        colh=max(colh,col[y]);
	    }
	    
	    for(int i=0;i<n;i++){
	        if(row[i]==rowh){
	            rowv.push_back(i);
	        }
	    }
	     for(int i=0;i<m;i++){
	        if(col[i]==colh){
	            colv.push_back(i);
	        }
	    }
	    
	    ll ans=rowh+colh-1;
	    
	    for(auto i:rowv){
	        for(auto j:colv){
	            
	            if(bomb.find({i,j})==bomb.end()){
	                ans++;
	                goto end;
	                
	            }
	        }
	    }
	    
	    end:
	    cout<<ans<<"\n";
	    
	    
	}
	return 0;
}


Measured memory_bytes: 23708
#include <vector>
#include <climits>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	vector<vector<int>> a(n, vector<int>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			scanf("%d", &a[i][j]);

	long long ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			int found = false;
			for (int k = 0; k < n; k++)
			{
				if (k == i || k == j)
					continue;
				if (a[i][k] + a[k][j] == a[i][j])
				{
					found = true;
					break;
				}
				else if (a[i][k] + a[k][j] < a[i][j])
					ans = LLONG_MIN;
			}
			if (!found)
				ans += a[i][j];
		}
	if (ans < 0) ans = -1;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 640
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll x;
    ll a=100;
    ll ans=0;
    cin >> x;
    while(1){
        ans++;
        a *= 1.01;
        if(a >= x){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;

int main()
{
    string s,t;
    cin >> s >> t;
    string u(s.rbegin(), s.rend());
    if(u == t)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    string s; cin >> s;
    set<char> se;
    rep(i,s.size()){
        se.insert(s[i]);
    }
    if(s.size()==se.size()){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d=0,e=0,f,i,g[100000001],h=100000000000,j,m,n=0,z,x=1,k,y=1,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y25,x1;
    string s,s1,s2;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC";
    }
    if(s=="ARC"){
        cout<<"ABC";
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long l,r;
  cin>>l>>r;
  if(r-l>=2019){
    cout<<0<<endl;
    return 0;
  }
  l = l%2019;
  r = r%2019;
  if(l>=r){
    cout<<0<<endl;
    return 0;
  }
  int ans=2019;
  for(int i=l; i<r; i++){
    for(int j=i+1; j<r+1;j++){
      ans =min(ans, i*j%2019);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,j,k,x,y,z,l,m,n,count1=0,count2=0;
int gcd(int,int);
void A(void);
void B(void);
void C(void);
void D(void);
void E(void);
void F(void);

int main(void){
    B();
}

void B(){
    int a,b,c;
    cin>>a>>b>>c>>k;
    if(k<=a)cout<<k<<endl;
    else if(k<=(a+b))cout<<a<<endl;
    else cout<<a-(k-a-b)<<endl;
}


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

int main() {
  int a, b;
  std::cin >> a >> b;
  std::string s;
  std::cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (i == a) {
      if (s[i] != '-') {
        std::cout << "No" << std::endl;
        return 0;
      }
    } else {
      if (0 <= s[i] - '0' && s[i] - '0' <= 9) {
      } else {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }

  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main()
{
  int a[N], flag, i, j=0, n = 0, x, c = 0;
  
  scanf("%d",&x);

  for(i=0; i<x; i++) scanf("%d",&a[i]);

  i = 0;
  flag = 1;

  while(flag==1) {
    flag = 0;

    for(j=x-1; j>=i+1; j--){
      if(a[j]<a[j-1]){
	n = a[j];
	a[j] = a[j-1];
	a[j-1] = n;
	flag = 1;
	c++;
      }
    }
      i++;
    
  }

  for(j=0; j<x; j++){
    printf("%d",a[j]);
    if(j!=x-1) printf(" ");
  }
  printf("\n%d\n", c);


  return 0;
}

Measured memory_bytes: 604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, L := sc.nextInt(), sc.nextInt()
	first := L + 1 - 1
	min := first
	sum := first
	for i := 2; i <= N; i++ {
		n := L + i - 1
		if abs(n) < abs(min) {
			min = n
		}
		sum += n
	}
	fmt.Println(sum - min)
}


Measured memory_bytes: 640