akhauriyash/Code-Regression huggingface dataset:
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()
def factorization(n):
  res = []
  if n%2==0:
    res.append(2)
  for i in range(3,math.floor(n//2)+1,2):
    if n%i==0:
      c = 0
      for j in res:
        if i%j==0:
          c=1
      if c==0:
        res.append(i)
  if len(res)==0:
    res = [n]
  return res
def fact2(n):
  p = factorization(n)
  res = []
  for i in p:
    c=0
    z=n
    while 1:
      if z%i==0:
        c+=1
        z/=i
      else:
        break
    res.append([i,c])
  return res
def fact(n):#階乗
  ans = 1
  m=n
  for _i in range(n-1):
    ans*=m
    m-=1
  return ans
def comb(n,r):#コンビネーション
  if n<r:
    return 0
  l = min(r,n-r)
  m=n
  u=1
  for _i in range(l):
    u*=m
    m-=1
  return u//fact(l)
def combmod(n,r,mod):
  return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
  r=copyQueue(q)
  ans=[0]*r.qsize()
  for i in range(r.qsize()-1,-1,-1):
    ans[i] = r.get()
  print(ans)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1]*n

  def find(self, x): # root
    if self.parents[x]<0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)

    if x==y:
      return

    if self.parents[x]>self.parents[y]:
      x,y = y,x

    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self,x):
    return -1*self.parents[self.find(x)]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def members(self,x): # much time
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]

  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
  x = 1
  zero = "0"*n
  ans = []
  ans.append([0]*n)
  for i in range(2**n-1):
    ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
    x+=1
  return ans;
def arrsSum(a1,a2):
  for i in range(len(a1)):
    a1[i]+=a2[i]
  return a1
def maxValue(a,b,v):
  v2 = v
  for i in range(v2,-1,-1):
    for j in range(v2//a+1): #j:aの個数
      k = i-a*j
      if k%b==0:
        return i
  return -1
def copyQueue(q):
  nq = queue.Queue()
  n = q.qsize()
  for i in range(n):
    x = q.get()
    q.put(x)
    nq.put(x)
  return nq
def get_sieve_of_eratosthenes(n):
  data = [2]
  #data = [0,0,0]
  for i in range(3,n+1,2):
    data.append(i)
    data.append(0)
  for i in range(len(data)):
    interval = data[i]
    if interval!=0:
      for j in range(i+interval,n-1,interval):
        data[j] = 0
  ans = [x for x in data if x!=0]
  #ans = data[:]
  return ans


a,b = readInts()

#print(a+b)
print(a*b)

Measured memory_bytes: 9620
#include <iostream>
using namespace std;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(c-a)<=d || (abs(b-a) <= d && abs(c-b) <= d)) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    string S;
    cin >> S;
    rep(i,3) {
        if (S[i] == S[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double EPS = 1e-8;

LL x,a,b;


int main(){
	bool flag = 0;
	scanf("%lld", &x);
	for(LL i = -1000LL; i <= 1000LL; i++){
		for(LL j = -1000LL; j <= i; j++){
			if(i * i * i * i * i - j * j * j * j * j == x){
				printf("%lld %lld\n", i,j);
				flag = 1;
				break;
			}
		}
		if(flag) break;
	}
	//printf("%d\n", flag);
	return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  rep(i,H) cin >> a[i];
  rep(i,W+2) cout << "#";
  cout << endl;
  rep(i,H){
    cout << "#";
    cout << a[i];
    cout << "#";
    cout << endl;
  }
  rep(i,W+2) cout << "#";
  cout << endl;
  return 0;
}


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

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

    vector <char> v(N);

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

    int count = 0;

    int l=0;
    int r=N-1;

    if(N == 1){
        cout << 0 << endl;
    }

    while(l<r){
        if(v[r] == 'W' && v[l] == 'W'){
            r--;
        }

        if(v[l] == 'W' && v[r] == 'R'){
            r--;
            l++;
            count++;
        }

        if(v[l] == 'R' && v[r] == 'W'){
            r--;
            l++;
        }

        if(v[l] == 'R' && v[r] == 'R'){
            l++;
        }
    }

    cout << count << endl;
    

}

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

int main() {
    ll A,B,V,W,T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    ll dif = abs(A-B);
    ll difV = V-W;

    if((difV * T) >= dif){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N, K;
    cin >> N >> K;

    vll A(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    for (ll i = K + 1; i <= N; i++)
    {
        cout << (A[i - (K+1)] < A[i - 1] ? "Yes" : "No") << endl;
    }
    
    


    return 0;
}


Measured memory_bytes: 4844
using System;
using System.Linq;
public class Hello{
    public static void Main()
    {
        // Your code here!
        int[] s = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int A = s[0];
        int B = s[1];
        int C = s[2];
        int D = s[3];
        int ans = -1;
        if(D <= A || B <= C) ans = 0;
        else if((C <= A && A <= D) && D <= B) ans = D - A;
        else if(A <= C && D <= B) ans = D - C;
        else if((A <= C && C <= B) && B <= D) ans = B - C;
        else if(C <= A && B <= D) ans = B - A;
        
        Console.WriteLine(ans);
    }
}


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

int main() {
    long long D, N;
    cin >> D >> N;
    long long tmp = pow(100, D);
    if (N < 100) {
        cout << tmp * N << endl;
    } else {
        if (D == 0) {
            cout << 101 << endl;
        } else if (D == 1) {
            cout << 10100 << endl;
        } else {
            cout << 1010000 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
typedef long long lint;
const int N=2005;
const int mod=1e9+7;
int n,m,q,dp[N][2],pre_dp[N];
//dp([i])[j][0/1]: 枚举到第i位,现在有j个1,末尾为0/1的方案数

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

inline int get_dp(const int x){
	return x<0?0:pre_dp[x];
}

int main(){
	m=nxi(),n=nxi(),q=nxi();
	int len=(n+m-1)/(q-1);
	int ans=0;
	dp[0][0]=1;
	for(int i=1; i<=len; ++i){
		pre_dp[0]=(dp[0][0]+dp[0][1])%mod;
		for(int j=1; j<=n; ++j){
			pre_dp[j]=((lint)pre_dp[j-1]+dp[j][0]+dp[j][1])%mod;
		}
		for(int j=0; j<=n; ++j){
			dp[j][0]=(pre_dp[j]-get_dp(j-1)+mod)%mod;
			dp[j][1]=(get_dp(j-1)-get_dp(j-q)+mod)%mod;
		}
		int all_bit=(lint)(q-1)*i%mod;
		for(int j=0; j<=n; ++j){
			int zero_cnt=(all_bit-j+mod)%mod;
			if(j%(q-1)==n%(q-1)&&zero_cnt<m&&zero_cnt%(q-1)==(m-1)%(q-1)){
				ans=(ans+dp[j][1])%mod;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int V;
vector<int> G[300];
int match[300];
bool used[300];

void init(int v){
  V=v;
  for(int i=0;i<V;i++)G[i].clear();
}

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0; i<(int)G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0||(!used[w]&&dfs(w))){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_match(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0; v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}

bool isprime[10000010];

int N;
int x[110];
vector<int> xb;

int main(){
  repl(i,2,10000010)isprime[i]=true;
  repl(i,2,10000001){
    if(!isprime[i])continue;
    for(ll j=i*2;j<=10000000;j+=i)isprime[j]=false;
  }
  isprime[2]=false;
  cin>>N;
  rep(i,N){
    cin>>x[i];
  }
  for(ll i=0;i<N;){
    xb.push_back(x[i]-1);
    ll j=i;
    while(j<N&&x[j]-x[i]==j-i)j++;
    xb.push_back(x[j-1]);
    i=j;
  }

  N=xb.size();
  init(N);
  ll cnto=0,cnte=0;
  rep(i,N)repl(j,i+1,N){
    if(isprime[xb[j]-xb[i]]){
      add_edge(i,j);
    }
  }
  rep(i,N){
    if(xb[i]%2==0) cnte++;
    else cnto++;
  }
  ll k=bipartite_match();
  cnte-=k; cnto-=k;

  cout<<k+(cnte/2+cnto/2)*2+(cnte%2)*3<<endl;

  return 0;
}


Measured memory_bytes: 10112
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

signed main(){
	int A,B;
	cin>>A>>B;
	cout<<max(A+B,max(A-B,A*B))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[100010];
  int i,j,r;
  while(scanf("%s",s),s[0]-'0'){
    int a[15]={};
    for(i=r=0;s[i];i++){
      int b[15]={};
      for(j=0;j<11;j++)b[(j*10+s[i]-'0')%11]+=a[j];
      for(j=0;j<11;j++)a[j]=b[j];
      if(s[i]-'0')a[s[i]-'0']++;
      r+=b[0];
      //for(j=0;j<11;j++)printf("%2d ",j);printf("\n");
      //for(j=0;j<11;j++)printf("%2d ",a[j]);printf("\n\n");
      //a[0]=0;
    }
    printf("%d\n",r);
  }
  return 0;
}

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

int main(){
    int N,B;
    cin >> N;
    vector<int> A(N),C(N-1);
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    int sum = 0;
    for(int i = 0;i < N;i++){
        cin >> B;
        sum += B;
    }
    for(int i = 0;i < N-1;i++){
        cin >> C[i];
    }
    for(int i = 0;i < N-1;i++){
        if(A[i]+ 1 == A[i+1]){
            sum += C[A[i]-1];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    map<char, string> mp;
    mp['a'] = a;
    mp['b'] = b;
    mp['c'] = c;
    char res, winner, tmp = 'a';
    while(true){
        res = tmp;
        if(mp[res].size() == 0){
            winner = res - 32;
            break;
        }else{
            tmp = mp[res][0];
            mp[res].erase(mp[res].begin());
        }
    }
    cout << winner << endl;
    return 0;
}

Measured memory_bytes: 256
import time
start = time.time()
import random
D = int(input())
*c, = map(int, input().split())
S = []
for _ in [None] * D:
    *s, = map(int, input().split())
    S += s,
last = [-1] * 26
INF = float("inf")

def check(T):
    M = 0
    MM = []
    for d in range(D):
        t = T[d]  # int(input()) - 1
        M += S[d][t] - sum((d - last[i]) * c[i] for i in range(26) if i != t)
        last[t] = d
        # MM += M,
    return max(M + 10**6, 0)  # MM

def 貪欲():
    M = 0
    T = []
    for d in range(D):
        m = -INF
        for j in range(26):
            Q = S[d][j] - sum((d - last[i]) * c[i] for i in range(26) if i != j)
            if m < Q:
                t, m = j, Q
        T += t,
        last[t] = d
        M += m
        # print(M)
    return T, max(M + 10**6, 0) 

T, M = 貪欲()
# print(T, M)
while time.time() - start < 1.9:
    d, q = random.randrange(D), random.randrange(26)
    Check = T[:]
    Check[d] = q
    if (C := check(Check)) > M:
        M, T = C, Check
for s in T:print(s + 1)
# print(M)

Measured memory_bytes: 9788
from collections import deque 
import sys
input = sys.stdin.readline
q = deque([])
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
x=[[-1,0],[1,0],[0,-1],[0,1]]
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            for k in x:
                if 0<=i+k[0]<h and 0<=j+k[1]<w and a[i+k[0]][j+k[1]]==".":
                    a[i+k[0]][j+k[1]]="0"
                    q.append([i+k[0],j+k[1],1])
ans=0
while q:
    v=q.popleft()
    for k in x:
        if 0<=v[0]+k[0]<h and 0<=v[1]+k[1]<w and a[v[0]+k[0]][v[1]+k[1]]==".":
            a[v[0]+k[0]][v[1]+k[1]]="0"
            q.append((v[0]+k[0],v[1]+k[1],v[2]+1))
            ans=v[2]+1
print(ans)


Measured memory_bytes: 198696
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
int a,b,n;

void solve() {
  int sum = 0;
  a = a % b;
  for(int i=0;i<n;i++) {
    a *= 10;
    int c = a/b;
    sum += c;
    a -= c*b;
  }
  printf("%d\n",sum);
}

int main() {
  while(cin >> a >> b >> n) {
    solve();
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

void solve(){
    ull n, a, b;
    cin >> n >> a >> b;
    if(a > b || (n < 2 && a != b)){
        cout << "0" << endl;
        return;
    }else if(n == 1 && a == b){
        cout << "1" << endl;
        return;
    }
    cout << (b-a)*(n-2)+1 << endl;
}

int main() {
    solve();
    return 0;
}

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

using namespace std;

const int N = 1e6 + 6;

char s[N];

int cnt[256];

int main() {
  scanf("%s", s);
  memset(cnt, 0, sizeof cnt);
  int n = strlen(s);
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    for (char c = 'a'; c <= 'z'; c++)
      if (c != s[i])
        ans += cnt[c];
    cnt[s[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
N = int(input())
*A, = map(int,input().split())

A.sort()

for i,a in enumerate(A):
    if a>=0:break
B = A[:i]
C = A[i:]

ans = []
if not B:
    x = C[0]
    for a in C[1:-1]:
        ans.append((x,a))
        x -= a
    ans.append((C[-1],x))
    x = C[-1] - x
elif not C:
    x = B[-1]
    for a in B[:-1]:
        ans.append((x,a))
        x -= a
else:
    x = B[0]
    for a in C[1:]:
        ans.append((x,a))
        x -= a
    ans.append((C[0],x))
    x = C[0]-x
    for a in B[1:]:
        ans.append((x,a))
        x -= a

print(x)
for out in ans:
    print(*out)

Measured memory_bytes: 20980
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < N; i++) i % 2 ? ans -= a[i] : ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
A,B,C,D = (int(x) for x in input().split())

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

#最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)
lcm = lcm(C,D)

if A-1 < C:
  fst = B//C
else:
  fst = B//C - (A-1)//C

if A-1 < D:
  snd = B//D
else:
  snd = B//D - (A-1)//D

if A-1 < lcm:
  dlt = B//lcm
else:
  dlt = B//lcm - (A-1)//lcm

print(B-A+1 - (fst+snd-dlt))

Measured memory_bytes: 3064
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

typedef complex<int> point;
#define X real()
#define Y imag()

void move(vector<point>& line, const point& p) {
	for(int i = 0; i < (int)line.size(); ++i)
		line[i] += p;
}

void rotate90(vector<point>& line) {
	for(int i = 0; i < (int)line.size(); ++i)
		line[i] = point(-line[i].Y, line[i].X);
}

bool match(const vector<point>& a, vector<point>& b) {
	move(b, -b[0]);
	while(a[1] / abs(a[1]) != b[1] / abs(b[1]))
		rotate90(b);

	for(int i = 1; i < (int)a.size(); ++i)
		if(a[i] != b[i])
			return false;

	return true;
}

bool search(const vector<point>& a, vector<point>& b) {
	if(match(a, b))
		return true;

	reverse(b.begin(), b.end());
	return match(a, b);
}

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

	for(int n; cin >> n, n;) {
		int m;
		cin >> m;

		vector<point> ori(m);
		for(int i = 0; i < m; ++i)
			cin >> ori[i].X >> ori[i].Y;

		move(ori, -ori[0]);

		vector<int> ans;
		ans.reserve(n);
		for(int i = 0; i < n; ++i) {
			int mm;
			cin >> mm;

			vector<point> line(mm);
			for(int j = 0; j < mm; ++j)
				cin >> line[j].X >> line[j].Y;

			if(m != mm)
				continue;

			if(search(ori, line))
				ans.push_back(i + 1);
		}

		for(int i = 0; i < (int)ans.size(); ++i)
			cout << ans[i] << endl;

		cout << "+++++" << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    bool flag = true;

    for (int i = 1; i < n; ++i) {
        if(h[n - 1 - i] == h[n - i] + 1)h[n - 1 - i]--;
        if(h[n - 1 - i] > h[n - i]){
            flag = false;
            break;
        }
    }
    if(flag)print("Yes");
    else print("No");
}

Measured memory_bytes: 1024
import math
def Sosu(N) :
    if N == 1 :
        return False
    else :
        for i in range(2, int(math.sqrt(N))+1) :
            if N % i == 0 :
                return False
        return True
    

def amount_sosu(a, b) :
    ans = 0
    for i in range(a+1, b+1) :
        if Sosu(i) :
            ans += 1
    return ans

while True :
    n = int(input())
    if n == 0 :
        break
    
    print(amount_sosu(n, n*2))



Measured memory_bytes: 5656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>
#include <type_traits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//constexpr long long MOD = 1e9 + 7;
//constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll h, w;
vector<ll> dx = { -1, 0, 1, 0 };
vector<ll> dy = { 0, -1, 0, 1 };


bool isInField(ll x, ll y) {
    bool f = x >= 0 && x < w && y >= 0 && y < h;
    return f;
}

bool compare_first(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.first != y.first) {
        return x.first < y.first;
    }
    else {
        return x.second < y.second;
    }
}

bool compare_second(pair<ll, ll> x, pair<ll, ll> y)
{
    if (x.second != y.second) {
        return x.second < y.second;
    }
    else {
        return x.first < y.first;
    }
}

struct {
    bool operator()(pair<string, int> x, pair<string, int> y) const
    {
        return x.second <= y.second && x.first < y.first;
    }
} compare_map;

const ll MAX = 500000000;
const ll MOD = 1000000007;


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

    string s;
    cin >> s;

    for (int i = 0; i < s.size() / 2; i++)
    {
        int r = s.size() - 1 - i;
        if (s[i] != s[r]) {
            cout << "No" << "\n";
            return 0;
        }
    }

    for (int i = 0; i < (s.size() - 1) / 2; i++)
    {
        int r = (s.size() - 1) / 2 - i - 1;
        if (s[i] != s[r]) {
            cout << "No" << "\n";
            return 0;
        }
    }

    for (int i = 0; i < s.size() / 2; i++)
    {
        int l = (s.size() + 3) / 2 - 2;
        l += i + 1;
        int r = s.size() - 1 - i;
        if (s[l] != s[r]) {
            cout << "No" << "\n";
            return 0;
        }
    }

    cout << "Yes" << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int count = 0;
    for (int i = 0; i < N; i++) {
      int h = scanner.nextInt();
      if (h >= K) count++;
    }
    System.out.println(count);
  }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

void ABC129E()
{
	string L;
	cin >> L;
	int n = L.size();

	ll MOD = 1000000007;
	vl a(n + 1);
	a[0] = 3;
	for (int i = 1; i < n; ++i)
	{
		a[i] = (a[i - 1] - 2) * 3 + 2;
		a[i] %= MOD;
	}
	ll mult = 1;
	ll sum = 0;
	for (int i = 0; i < n; ++i)
	{
		if (L[i] == '1')
		{
			sum += (a[n - i - 1] - 1) * mult;
			sum %= MOD;
			mult <<= 1;
			mult %= MOD;
		}
	}
	++sum;
	sum %= MOD;
	cout << sum << endl;
}
int main()
{
	ABC129E();
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   long A = sc.nextLong();
 
   long ans = 0;
   long tmp = A;
   long t10 = 10;
      for(int i = 1;i<100;i++)
   {
     if(A%2==1) break;
     tmp=A/t10;
     ans+= tmp;
     t10*=5;
 
     if(tmp == 0) break; 
   }
   
   
   System.out.println(ans);
  
 }
}

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

int main()
{
	string a, b;
	cin >> a >> b;
	int s, d;
	cin >> s >> d;
	string c;
	cin >> c;
	if (c == a) {
		s--;
	}
	else if (c == b) {
		d--;
	}

	cout << s <<" "<< d << endl;
	cin.get();
    cin.get();
    return 0;
}

Measured memory_bytes: 256
// 2020/07/30 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	
	int a[100000];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	
	int DP[100001];
	DP[0] = -1;
	for(int i=1; i<=n; i++){
		DP[i] = 1000000001;
	}
	int L = 0;
	
	for(int i=0; i<n; i++){
		if(DP[L]<a[i]){
			L++;
			DP[L] = a[i];
		}
		else{
			for(int j=L; j>=1; j--){
				if(DP[j-1]<a[i] && DP[j]>=a[i]){
					DP[j] = a[i];
					break;
				}
			}
		}
	}
	
	cout << L << endl;
	
	return 0;
}



Measured memory_bytes: 3908
#include <iostream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <cmath>
#include <complex>

using namespace std;

#define INFD numeric_limits<double>::infinity()
#define INFL (int)1e8
#define INFLL (long long)1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define rnd(d) (ll)((double)d + ((d >= 0) ? 0.5 : -0.5))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

int main() {
  ll n; cin >> n;
  ll m; cin >> m;
  vll cnt(4, 0);
  //
  Loop(i, 2) {
    Loop(j, 2) {
      if (i < n && j < m) cnt[0]++;
    }
  }
  //
  Loop(i, 2) {
    Loop(j, 3) {
      if (i < n && j < m) cnt[1]++;
    }
  }
  //
  Loop(i, 3) {
    Loop(j, 2) {
      if (i < n && j < m) cnt[2]++;
    }
  }
  cnt[3] = 9;
  //
  vll a(4, 0);
  //
  if (n == 1 && m == 1) a[0] = 1;
  else if (n == 1 || m == 1) a[0] = 2;
  else a[0] = 4;
  //
  if (m >= 3) {
    if (n == 1) a[1] = m - 2;
    else a[1] = (m - 2) * 2;
  }
  //
  if (n >= 3) {
    if (m == 1) a[2] = n - 2;
    else a[2] = (n - 2) * 2;
  }
  //
  if (m >= 3 && n >= 3) {
    a[3] = (m - 2) * (n - 2);
  }
  ll ans = 0;
  Loop(i, 4) {
    ans += (cnt[i] % 2) * a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
	string S, T;
	cin >> S >> T;
	int cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0 ; i < n ; i++)

using namespace std;

int n,q,A[20],M[200];

bool solve(int p,int t){
  if(p >= n && t != 0) return false;
  if(t == 0) return true;
  if(t < 0) return false;

  if(t - A[p] >= 0 && solve(p+1,t - A[p])){
    return true;
  }

  return solve(p+1,t);
}

int main(){
  cin >> n;
  rep(i,n) cin >> A[i];

  cin >> q;
  rep(i,q) cin >> M[i];

  sort(A,A+n);
  
  for(int i = 0 ; i < q ; i++){

    if(solve(0,M[i])){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  
  }
  
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cstdio>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	while(n != 0)
	{
		if(n%10==9)
		{
			printf("Yes\n");
			return 0;
		}
		n /= 10;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import scala.math.{ceil, floor}

object Main extends App {

  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val X = ceil(N / 1.08 ).toInt
  if (floor(X * 1.08) == N) {
    print(X)
  } else {
    print(":(")
  }
}


Measured memory_bytes: 55484
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let sunny: String = String::from("Sunny");
    let cloudy = String::from("Cloudy");
    let rainy = String::from("Rainy");

    let s: String = read();

    if s.eq(&sunny) {
        println!("{}", cloudy);
    }
    if s.eq(&cloudy) {
        println!("{}", rainy);
    }
    if s.eq(&rainy) {
        println!("{}", sunny);
    }
}


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

int main() {
	// your code goes here
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
				cout<<"OK";
				return 0;
		}
	
	}
	cout<<"NG";
	return 0;
}

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

main() {
    int A[3]; rep(i,3) cin >> A[i];
    sort(A,A+3);
    cout << A[2]-A[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[25],b[25],c[25],ans,n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		ans+=b[i];
	}
	for(int i=1;i<n;i++)
	cin>>c[i];
	for(int i=1;i<n;i++)
	{
		if(a[i]==a[i+1]-1)
		ans+=c[a[i]];	
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fori(n) for(int i=0;i<n;i++)
using namespace std;
int main(){
ll n;cin>>n;
  
ll x=n/3;ll y=n/5;ll z=n/15;
x=x*(x+1)*3;x=x/2;
y=y*(y+1)*5;y=y/2;
z=z*(z+1)*15;z=z/2;
x=x+y-z;
n=n*(n+1);n=n/2;
cout<<n-x;  



 return 0;    
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

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

using namespace std;

int count(int n) {
	int cnt = 0;
	for (int i = 1; i < n + 1; i++) {
		if (n%i == 0)cnt++;
	}
	return cnt;
}

int main(){
	int N;
	int cnt = 0;
	scanf("%d", &N);
	for (int i = 1; i < N + 1; i += 2) {
		if (count(i) == 8)cnt++;
	}
	printf("%d", cnt);
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=3003;
int a[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	int sum = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		sum += a[i];
	}
	cout << sum-n << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int main()
{
    int a[101] = {0}, b;
    
    for( int i = 0; i < 12; i++ )
    {
        cin >> b;
        a[b]++;
    }
    
    int cnt = 0;
    for( int i = 1; i < 101; i++ )
        cnt += a[i] / 4;

    if( cnt == 3 )
        cout << "yes" << endl;
    else
        cout << "no" << endl;
    return 0;
}


Measured memory_bytes: 3124
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()))

h=int(input())
w=int(input())
n=int(input())
a=max(h,w)
print((n-1)//a+1)

Measured memory_bytes: 77332
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const ll inf = 1000000000000000000LL;

ll mul(ll a, ll b) {
	if (a == 0 or b == 0) {
		return 0;
	} else if (a  <= inf / b) {
		return a * b;
	} else {
		return inf + 1LL;
	}
}

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

	ll ans = 1LL;
	rep(i, n) {
		ll a;
		cin >> a;
		ans = mul(ans, a);
	}

	if(ans > inf) ans = -1;
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

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

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, k;
    cin >> n >> k;
    vector<P> d;
    rep(i, 0, n){
        int a, b;
        cin >> a >> b;
        d. push_back(P(a, b));
    } 
    sort(all(d));
    int now = 0;
    int ans = -1;
    rep(i, 0, n){
        now += d[i].second;
        if(now >= k){
            ans = d[i].first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
#define  int    long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff         first
#define  ss    second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    int n,k,ans=0;
    cin>>n>>k;
    int a[n+1];
    f(i,1,n)
        cin>>a[i];
    sort(a+1,a+n+1);
    f(i,1,k)
        ans+=a[i];
    cout<<ans;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000

int main(){
  int n;

  cin >> n;

  cout << n * (n+1) /2 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define rap(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  string a,b,c;
  int n;
  cin>>a>>b>>c;
a = a + b + c;
n =std::stoi(a);
if(n%4==0){
  cout<<"YES\n";
}else{
  cout<<"NO\n";
}
}


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

int main() {
  using std::max;
  using std::min;

  int n, x, y;
  std::scanf("%d%d%d", &n, &x, &y);
  int l = y - x + 1;
  int a = x - 1;
  int b = n - y;

  for (int k = 1; k != n; k += 1) {
    int ans = 0;

    for (int z : {a, b}) {
      ans += max(0, z - k);

      if (0 <= z - k)
        ans += 1;
      ans += max(0, min(z, z + (l + 1) / 2 - k) - max(0, z + 1 - k)) * 2;
      if (l % 2 == 0) {
        int temp = z + l / 2 - k;
        if (0 <= temp && temp < z)
          ans += 1;
      }
    }

    if (k * 2 < l)
      ans += l;
    if (k * 2 == l)
      ans += l / 2;

    ans += max(0, min(a, a + 2 + b - k) - max(0, a + 2 - k));

    std::printf("%d\n", ans);
  }
}


Measured memory_bytes: 760
// Alert!!! This program may have some NARGLE.
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define endl '\n'

using namespace std;

const int Mod = 1e9 + 7, Inf = 1e9;

int32_t main ()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int k, n = 0, x, y;
	cin >> k;
	bool f = 0;
	while (k--)
	{
		cin >> x >> y;
		if (x == y)
			n++;
		else
			n = 0;
		if (n == 3)
			f = 1;
	}
	cout << (f? "Yes": "No");
	return 0;
}

Measured memory_bytes: 3580
import java.awt.geom.Point2D;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			double[][] cost = new double[n][n];
			for (double[] c : cost) {
				Arrays.fill(c, -1);
			}
			int[] id = new int[n];
			Point2D.Double[] data = new Point2D.Double[n];
			for (int i = 0; i < n; i++) {
				id[i] = scanner.nextInt();
				data[i] = new Point2D.Double(scanner.nextDouble(),
						scanner.nextDouble());
				for (int j = i - 1; j >= 0; j--) {
					double dis = data[i].distance(data[j]);
					if (dis <= 50) {
						cost[i][j] = dis;
						cost[j][i] = dis;
					}
				}
			}
			int m = scanner.nextInt();
			int s = -1;
			int g = -1;
			for (int z = 0; z < m; z++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				for (int i = 0; i < n; i++) {
					if (a == id[i]) {
						s = i;
					}
					if (b == id[i]) {
						g = i;
					}
				}
				double[] min = new double[n];
				Arrays.fill(min, 1 << 24);
				min[s] = 0;
				int[] path = new int[n];
				Arrays.fill(path, -1);
				Deque<Integer> deque = new ArrayDeque<Integer>();
				deque.offer(s);
				while (!deque.isEmpty()) {
					int q = deque.pop();
					for (int i = 0; i < n; i++) {
						if (cost[q][i] != -1 && min[i] > min[q] + cost[q][i]) {
							min[i] = min[q] + cost[q][i];
							path[i] = q;
							deque.offer(i);
						}
					}
				}
				Deque<Integer> list = new LinkedList<Integer>();
				boolean flag = true;
				while (s != g) {
					if (g == -1) {
						flag = false;
						break;
					}
					
					list.push(path[g]);
					g = path[g];
				}
				if (flag) {
					for (int t : list) {
						System.out.print(id[t] + " ");
					}
					System.out.println(b);
				} else {
					System.out.println("NA");
				}
			}

		}
	}
}

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

using namespace std;

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

  vector<long long> powers;
  for(long long i = 0; i<200; ++i) {
    powers.push_back(i*i*i*i*i);
  }

  long long n; cin >> n;
  for(int i = 0; i<200; ++i) {
    for(int j = 0; j<200; ++j) {
      long long x = powers[i];
      long long y = powers[j];
      int ii = i;
      int jj = j;
      for(int a = 0; a<2; ++a) {
        for(int b = 0; b<2; ++b) {
          if(x-y == n) {
            cout << ii << " " << jj << endl;
            return 0;
          }

          x *= -1;
          ii *= -1;
        }
        y *= -1;
        jj *= -1;
      }
    }
  }
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = 0;
	
	void doIt() {
		int n = sc.nextInt();
		String s = sc.next();
		char c[] = s.toCharArray();
		LEN = c.length;
		for(int i = 0; i < LEN; i++) {
			int num = (c[i] - 'A' + n) % 26;
			c[i] = (char)(num + 'A');
		}
		System.out.println(new String(c));
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

int main(void){
    int A, B;
    cin >> A >> B;
    int a, b, c, d;
    double time{0};
    int sum{0};

    for(int i{A}; i<=B; ++i){
        a = i/10000;
        b = i/1000%10;
        c = i/10%10;
        d = i%10;
        if(a==d and b==c)
            ++sum;
    }
    cout << sum << endl;

}


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

    string s[55];
    rep(i, h){
        cin >> s[i];
    }
    int count = 0;
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '.'){
                count = 0;
                for(int k = i-1; k <= i+1; k++){
                    for(int l = j-1; l <= j+1; l++){
                        if(k >= 0 && l >= 0){
                            if(s[k][l] == '#'){
                                count++;
                            }
                        }
                    }
                }
                cout << count;
            }
            else{
                cout << s[i][j];
            }
        }
        printf("\n");
    }
    

    return 0;
}

Measured memory_bytes: 256
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <math.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;

int main(){
    int N;
    int m;
    cin >> N;
    vector<ll> H(N);
    int c = 0;
    rep(i,N) cin >> H[i];
    rep(i,N-1){
        if(H[i] > H[i+1]+1){
            c += 1;
        }else if(H[i] > H[i+1]){
            H[i+1] += 1;
        }
    }
    if(c > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 1024
main = do
  [n, y] <- map read . words <$> getLine
  putStrLn . unwords . map show $ head ([[i, j, k] | i <- [0 .. n], j <- [0 .. n - i],
    let k = n - i - j, 10000 * i + 5000 * j + 1000 * k == y] ++ [[-1, -1, -1]])

Measured memory_bytes: 892
n = input()
K = int(input())
L = len(n)

dp = [[[0] * (K + 2) for _ in range(2)] for __ in range(L + 1)]
dp[0][1][0] = 1

for i in range(L):
    d = int(n[i])
    for j in [0, 1]:
        for k in range(K + 1):
            if j == 0:
                dp[i + 1][j][k] += dp[i][j][k]
                dp[i + 1][j][k + 1] += dp[i][j][k] * 9
            else:
                if d > 0:
                    dp[i + 1][0][k] += dp[i][j][k]
                    dp[i + 1][0][k + 1] += dp[i][j][k] * (d - 1)
                    dp[i + 1][1][k + 1] += dp[i][j][k]
                else:
                    dp[i + 1][1][k] += dp[i][j][k]


print(dp[L][0][K] + dp[L][1][K])



Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int>a(n+1);
	vector<int>b(n);
	rep(i,n+1)cin>>a[i];
	rep(i,n)cin>>b[i];
	long long int cnt=0;
	rep(i,n){
		if(b[i]<a[i]){
			cnt+=b[i];
			a[i]-=b[i];
		}else{
			if(b[i]<a[i]+a[i+1]){
				cnt+=b[i];
				a[i+1]-=b[i]-a[i];
			}else{
				cnt+=a[i]+a[i+1];
				a[i+1]=0;
			}
		}
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1024
/*  
    Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    816 Hours of Solitude
    Quarantine_Day : 34
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005

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

	string s; cin>>s;
	int a = s.find('A');
	int z = s.rfind('Z');

	cout<<z - a + 1<<"\n";

	return 0;
}


Measured memory_bytes: 720