akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

#define MAX_N 200000

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int par[MAX_N];
int rnk[MAX_N];
long long int num[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
        num[i] = i;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
    num[x_par] = num[y_par] = max(num[x_par], num[y_par]);
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int ans[110000] = {};

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    PP pp;
    vector<PP> v;
    long long int MUL = 1e12;
    for(int i = 0; i < M; i++){
        long long int D, A, B;
        cin >> D >> A >> B;
        pp = PP(P(D, 1), P(A, B));
        v.push_back(pp);
    }
    for(int i = 0; i < Q; i++){
        long long int D, A, B;
        cin >> D >> A >> B;
        pp = PP(P(D, 0), P(A, B + i * MUL));
        v.push_back(pp);
    }
    sort(v.begin(), v.end());
    init(MAX_N);
    for(int i = 0; i < v.size(); i++){
        int S = v[i].second.first;
        int T = v[i].second.second % MUL;
        int pos = v[i].second.second / MUL;
        if(v[i].first.second){
            int nex = num[find(S)];
            while(nex < T){
                unite(nex, T);
                nex = num[find(nex + 1)];
            }
        }else{
            ans[pos] = (num[find(S)] >= T);
        }
    }
    for(int i = 0; i < Q; i++){
        if(ans[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12696
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            long[] S = new long[N];

            int minus = 0;

            for(int i = 0 ; i < N ; i++){
                S[i] = sc.nextLong();
                if(S[i] < 0){
                    minus++;
                    S[i] = Math.abs(S[i]);
                }
            }
        sc.close();

        Arrays.sort(S);

        long ans = 0 ;
        for (int i = 0 ; i < N ; i++){
                ans += Math.abs(S[i]);
        }

        if(minus%2 == 0){
            System.out.println(ans);
        }else{
            System.out.println(ans-Math.abs(S[0])-Math.abs(S[0]));
        }
        
    }
}


Measured memory_bytes: 61256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<map>
#include<set>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char s[30];
int u[30];
int main()
{
	int n,i,j,k;
    scanf("%s",s);n=strlen(s);
    if(n<26)
    {
    	for(i=0;i<n;++i)++u[s[i]-'a'],putchar(s[i]);
    	for(i=0;i<26;++i)if(!u[i])return 0*putchar(i+'a');
	}
	for(i=24;i>=0;--i)
	{
		for(j=i,k=0;j<26;++j)if(s[j]>s[i])k=k?min(k,(int)s[j]):s[j];
		if(k)
		{
			for(j=0;j<i;++j)putchar(s[j]);
			putchar(k);
			return 0;
		}
	}
	puts("-1");
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))
# print(f'{a+b+c} {s}')
a,b,c = map(int, input().split())
a,b = b,a
a,c = c,a
print("{} {} {}".format(a,b,c))

Measured memory_bytes: 9032
#include <stdio.h>
int main(void)
{
	int h,m,s;
	int ans;
	int ansm;

	scanf("%d %d %d", &h, &m, &s);
	while(h != -1){

		ans = 7200 - (h * 3600 + m * 60 + s);

		printf("0%d:",ans / 3600);

		ansm = (ans % 3600) / 60;

		if(ansm < 10){
			printf("0%d:",ansm);
		}else{
			printf("%d:",ansm);
		}

		ansm = ans % 60;

		if(ansm < 10){
			printf("0%d\n",ansm);
		}else{
			printf("%d\n",ansm);
		}
		ans = (7200 - (h * 3600 + m * 60 + s)) * 3;

		printf("0%d:",ans / 3600);

		ansm = (ans % 3600) / 60;

		if(ansm < 10){
			printf("0%d:",ansm);
		}else{
			printf("%d:",ansm);
		}

		ansm = ans % 60;

		if(ansm < 10){
			printf("0%d\n",ansm);
		}else{
			printf("%d\n",ansm);
		}


		scanf("%d %d %d", &h, &m, &s);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    int ans = INF;
    eFOR(i, 1, n - 1) {
        int sum = 0;
        for (int a = i; 0 < a; a /= 10)sum += a % 10;
        for (int a = n - i; 0 < a; a /= 10)sum += a % 10;
        chmin(ans, sum);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    return n*(n-1)/2


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 5140
abcd = input()
n = len(abcd)
for i in range(1<<n-1):
    ans = abcd[0]
    for j in range(n-1):
        if i>>j&1:
            ans += "-" + abcd[j+1]
        else:
            ans += "+" + abcd[j+1]
    if eval(ans) == 7:
        print(ans+"=7")
        break

Measured memory_bytes: 9116
li_abck = list(int(i) for i in input().split())
k = li_abck[3]
ans = li_abck[0]-li_abck[1]
x=1

if li_abck[0]==li_abck[1]==li_abck[2]:
    print(0)
    x = 0
if x!=0:
    if k%2==0:
        print(ans)
    else:
        print(-ans)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue<LL>
#define PQS priority_queue<LL, vector<LL>, greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
//#define MOD 1000000007
#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}

struct UF{
private:
  VL par;
public:
  UF(LL n){par.resize(n,-1);}
  LL root(LL x){if(par[x]<0)return x;else return par[x]=root(par[x]);}
  LL size(LL x){return -par[root(x)];}
  bool same(LL x,LL y){return root(x)==root(y);}
  void unite(LL x,LL y){x=root(x);y=root(y);if(x!=y){if(size(x)<size(y))swap(x,y);par[x]+=par[y];par[y]=x;}}
};

int main(){
  LL i,N,M;
  cin>>N>>M;
  VL A(M),B(M),dp(M);
  rep(i,M)cin>>A[i]>>B[i];
  UF u(N+1);
  dp[M-1]=N*(N-1)/2;
  for(i=M-2;i>=0;i--){
    dp[i]=dp[i+1];
    if(!u.same(A[i+1],B[i+1])){
      dp[i]-=u.size(A[i+1])*u.size(B[i+1]);
      u.unite(A[i+1],B[i+1]);
    }
  }
  rep(i,M)cout<<dp[i]<<endl;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678];
signed main() {
	ll n, m, q, k, a = 0, b = 0, c = 0, d = 0, e, cnt = 0; string s, t;
	cin >> a >> b >> c >> d >> e; vector<ll>v;
	cnt = abs(a - c);
	if (b <= d) { cout << "NO" << endl; return 0; }
	if (abs(b - d) * e >= cnt) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a==1){
		if(b==1){
			cout << "Draw" << endl;
		}else{
			cout << "Alice" << endl;
		}
	}else if(b==1){
		cout << "Bob" << endl;
	}else if(a==b){
		cout << "Draw" << endl;
	}else if(a>b){
		cout << "Alice" << endl;
	}else if(a<b){
		cout << "Bob" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    ll ans = 0;
    for (ll i = 0; i < S.size(); i++) {
        for (ll j = i; j < S.size() + 1; j++) {
            auto sub = S.substr(i, j - i);
            bool all = true;
            for (char c : sub) {
                if (!(c == 'A' || c == 'T' || c == 'C' || c == 'G')) {
                    all = false;
                }
            }

            if (all) {
                ans = max(ans, j - i);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  pair<int,int> inter[10];
  for(int i=0;i<K;i++){
    int L,R;
    cin>>L>>R;
    inter[i]=make_pair(L,R);
  }
  long long tree[4000000];
  int k=1;
  while(k<N) k*=2;
  for(int i=1;i<2*k;i++) tree[i]=0;
  tree[k]=1;
  for(int i=k;i<=k+N-1;i++){
    int n=i/2;
    while(n!=0){
      tree[i]=(tree[i]+tree[n])%998244353; n/=2;
    }
    for(int j=0;j<K;j++){
      int l=i+inter[j].first;
      int r=min(k*2-1,i+inter[j].second);
      if(l<=r){
      while(r-l>0){
        if(l%2==0){
          l/=2;
          if(r%2==0){
            tree[r]+=tree[i]; r=(r-1)/2;
          }
          else r/=2;
        }
        else{
          tree[l]+=tree[i]; l=(l+1)/2;
          if(r%2==0){
            tree[r]+=tree[i]; r=(r-1)/2;
          }
          else r/=2;
        }
      }
        if(l==r) tree[l]+=tree[i];
      }
    }
  }
  cout<<tree[k+N-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 7292
// A - Placing Marbles
#include <bits/stdc++.h>
using namespace std;

int main(){
	string s; cin>>s;
	int ans = 0;
	if(s[0]=='1') ans++;
	if(s[1]=='1') ans++;
	if(s[2]=='1') ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-05-17 22:04:10 +0900
# LastModified: 2020-05-17 22:24:55 +0900
#

from collections import deque

def bfs(path_list,guide,n):
    color = [0]*(n+1)
    color[1] = 1
    Q = deque()
    Q.append(1)
    while Q:
        u = Q.popleft()
        for v in path_list[u]:
            if color[v] == 0:
                color[v]=1
                Q.append(v)
                guide[v]=u

def main():
    n,m = map(int,input().split())
    path_list = [[] for _ in range(n+1)]
    for _ in range(m):
        a,b = map(int,input().split())
#        print(a,b)
        path_list[a].append(b)
        path_list[b].append(a)

#    print(path_list)
    
    guide = [0]*(n+1)
    bfs(path_list,guide,n)
    print("Yes")
    for i in range(2,n+1):
        print(guide[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 34552
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)
count = 0
(0...n - 2).each do |i|
    (i + 1...n - 1).each do |j|
        (j + 1...n).each do |k|
            buf = arr[i], arr[j], arr[k]
            a, b, c = buf
            if buf.uniq.length == buf.length && (b - c).abs < a && a < b + c
                count += 1
            end
        end
    end
end
puts count

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  double a, b;
  cin >> a >> b;

  int ans = 0;
  int outlets = 1;
  while(outlets < b){
    outlets--;
    outlets += a;
    ans++;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[3000];
ll dp[3000][3000][2];
ll solve(ll i,ll j,ll t)
{
    if(i>j)
        return 0;
    if(i==j)
        return (t==0)?a[i]:(-a[i]);
    if(dp[i][j][t]!=0)
        return dp[i][j][t];
    if(t==0)
        dp[i][j][t]=max(a[i]+solve(i+1,j,1-t),a[j]+solve(i,j-1,1-t));
    else
        dp[i][j][t]=min(solve(i+1,j,1-t)-a[i],solve(i,j-1,1-t)-a[j]);
    return dp[i][j][t];
}
int main()
{
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll v=solve(0,n-1,0);
    cout<<(v)<<endl;

    return 0;
}


Measured memory_bytes: 139776
import heapq as hq

n,m = map(int,input().split())
A = list(map(int,input().split()))
ops = []
for _ in range(m):
    b,c = map(int,input().split())
    ops.append((c,b))

hq.heapify(A)
ops.sort(reverse=True)

for c,b in ops:
    a = hq.heappop(A)
    if c<=a:
        print(sum(A)+a)
        exit()
    else:
        hq.heappush(A,a)
        count = b
        while b:
            a = hq.heappop(A)
            if c<=a:
                hq.heappush(A,a)
                break
            else:
                hq.heappush(A,c)
                b -=1
print(sum(A))
        
        

Measured memory_bytes: 20984
#include <bits/stdc++.h>		//线段树维护区间和
#define ll long long
#define inf 0x3f3f3f3f 
using namespace std;
const int maxn = 1e5+10;

int main(){
	int n;
	scanf("%d", &n);
	if(n>=30) printf("Yes");
	else printf("No");

	return 0;
}



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

int main() {
    int n, d, x;
    cin >> n >> d >> x;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a.at(i);

    int s = 0;
    for (int i = 0; i < n; i++)
        s += (d - 1) / a.at(i) + 1;

    cout << s + x << endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

typedef pair<int, int> pii;

int encode(int *tile) {
	int res = tile[0];
	
	FOR(i, 1, 8) {
		res <<= 3;
		res |= tile[i];
	}
	return res;
}

void decode(int x, int *tile) {
	for (int i = 7; i >= 0; i--) {
		tile[i] = x & 7;
		x >>= 3;
	}
}

int main() {
	int tile[8];
	map<int, int> m[8];
		
	while (cin >> tile[0]) {
		FOR(i, 1, 8) cin >> tile[i];
		int ansT = encode(tile);
		
		if (m[tile[0]].find(ansT) != m[tile[0]].end()) {
			cout << m[tile[0]][ansT] << endl;
			continue;
		}
		
		set<int> s[8];
		queue<pii> que;
		int ans;
		
		REP(i, 8) tile[i] = i;
		
		que.push(pii(encode(tile), 0));
		while (!que.empty()) {
			int now = que.front().first;
			int cnt = que.front().second;
			que.pop();
			
			decode(now, tile);
			if (s[tile[0]].find(now) != s[tile[0]].end()) continue;
			
			s[tile[0]].insert(now);
			m[tile[0]][now] = cnt;
			
			if (now == ansT) { ans = cnt; break; }
			
			int x, y;
			REP(i, 8) if (tile[i] == 0) {
				x = i % 4;
				y = i / 4;
			}
			
			int dx[4] = {1,0,-1,0};
			int dy[4] = {0,1,0,-1};
			REP(i, 4) {
				int nx = x + dx[i], ny = y + dy[i];
				if (!(nx >= 0 && nx < 4 && ny >= 0 && ny < 2)) continue;
				
				swap(tile[y * 4 + x], tile[ny * 4 + nx]);
				que.push(pii(encode(tile), cnt + 1));
				swap(tile[y * 4 + x], tile[ny * 4 + nx]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;


int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
    int n;
    scanf("%d", &n);
    int pt = 0, px = 0, py = 0;
    for (int i = 0; i < n; ++i) {
        int t, x, y;
        scanf("%d %d %d", &t, &x, &y);
        int dt = abs(pt - t);
        int dx = abs(px - x);
        int dy = abs(py - y);
        int d = dx + dy;
        if (d > dt || abs(d - dt) % 2 == 1)
            return printf("No"), 0;
    }
    printf("Yes");
    
    return 0;
} 

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

#define MAXN 100000
int N,M;
struct Edge{
    int v,w[2];
    Edge(){}
    Edge(int a,int w1,int w2){
        v=a,w[0]=w1,w[1]=w2;
    }
};
vector<Edge> G[MAXN+5];

bool vis[MAXN+5];
long long dist[2][MAXN+5];
void SPFA(int S,int opt){
    memset(vis,0,sizeof vis);
    memset(dist[opt],0x3f,sizeof dist[opt]);
    queue<int> Q;Q.push(S);
    dist[opt][S]=0;vis[S]=1;
    while(!Q.empty()){
        int u=Q.front();
        vis[u]=0;Q.pop();
        for(int i=0;i<int(G[u].size());i++){
            int v=G[u][i].v,w=G[u][i].w[opt];
            if(dist[opt][v]>dist[opt][u]+w){
                dist[opt][v]=dist[opt][u]+w;
                if(!vis[v]){
                    vis[v]=1;
                    Q.push(v);
                }
            }
        }
    }
}

long long Ans[MAXN+5];
int main(){
    int S,T;
    scanf("%d%d%d%d",&N,&M,&S,&T);
    for(int i=1;i<=M;i++){
        int u,v,w1,w2;
        scanf("%d%d%d%d",&u,&v,&w1,&w2);
        G[u].push_back(Edge(v,w1,w2));
        G[v].push_back(Edge(u,w1,w2));
    }
    SPFA(S,0);
    SPFA(T,1);
    Ans[N]=dist[0][N]+dist[1][N];
    for(int i=N-1;i>=1;i--)
        Ans[i]=min(Ans[i+1],dist[0][i]+dist[1][i]);
    for(int i=1;i<=N;i++)
        printf("%lld\n",1000000000000000ll-Ans[i]);
    return 0;
}


Measured memory_bytes: 10880
#N枚のIDカードとM個のゲートがある
n,m = map(int, input().split())
L = [0]*m
R = [0]*m
#答えとなる変数の定義
ans = 0
#インフィニティ
infi = 1000000000000000
#Lの最大値とRの最小値を保管する関数
l_max =0
r_min =infi
#入力
for i in range(m):
    L[i],R[i] = map(int, input().split())
    if(l_max<L[i]):
        l_max = L[i]
    if(r_min>R[i]):
        r_min = R[i]

ans = (r_min - l_max)+1
if(ans<=0):
    ans =0
        
print(ans)

Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
	int N,M;
  cin >> N >> M;
  vec2(a,char,N,N,' ');
  vec2(b,char,M,M,' ');
  froop1(0,N){
    for(int j = 0;j < N;j++){
    cin >> a.at(i).at(j);  
    }
  }
  
  froop1(0,M){
    for(int j = 0;j < M;j++){
    cin >> b.at(i).at(j);  
    }
  }
  froop1(0,N - M + 1){
   for(int j = 0;j < N - M + 1;j++){
     int sw = 1;
    for(int k = 0;k < M;k++){
     for(int l = 0;l < M;l++){
       if(a.at(i + k).at(j + l) != b.at(k).at(l)) sw = 0;
    }
   }
     if(sw == 1){
      cout << "Yes" << endl;
       return 0;
     }
  }
  }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int xMax = -200, yMin = 200;
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        if(b > xMax){
            xMax = b;
        }
    }
    for(int i = 0; i < m; i++){
        int b;
        cin >> b;
        if(b < yMin){
            yMin = b;
        }
    }
    if(xMax < y && yMin > x && xMax < yMin){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }

    
    return 0;
}


Measured memory_bytes: 256
def is_even(a):
    if a%2 == 0:
        return int(a/2)
    else:
        return False

if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    count = 0
    A = list(map(is_even, A))
    while all(A):
        count += 1
        A = list(map(is_even, A))
    print(count)

Measured memory_bytes: 3064
L, R = [int(i) for i in input().split()]
R = min(R, L + 4038)
ans = 2018
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        x = (i * j) % 2019
        if x == 0:
            ans = 0
            break
        ans = min(ans, x)
print(ans)


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

int main()
{
  int x,h;
  while (scanf("%d\n%d",&x,&h)){
    if ((x==0) && (h==0))
      break;
    printf("%f\n",x*x+x*sqrt(4*h*h+x*x));
  }

  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, h;
  int a[100001], b[100001];
  cin >> n >> h;
  rep(i, 0, n) {
    cin >> a[i] >> b[i];
  }
  sort(a, a + n);
  sort(b, b + n);

  int g = 0, k = 0;
  for(int i = n - 1; i >= 0; i--) {
    if(a[n - 1] < b[i]) {
      g += b[i];
      k++;
      if(g >= h) {
        cout << k << endl;
        return 0;
      }
    }else {
      break;
    }
  }
  k += (h - g) / a[n - 1];
  if((h - g) % a[n - 1] != 0) k++;
  cout << k << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,m,T;
    cin>>T;
    if (T==3||T==5||T==7) cout<<"YES";
  else cout<<"NO";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 102
#define NIL -1
int n, pos = 0;
int Pre[MAX], In[MAX];

vector<int> Post;

int find(int id){
    for(int i=0;i<n;++i){
        if(In[i]==id) return i;
    }
}

void rebuild(int l, int r){
    if(l>=r) return;
    int id = Pre[pos];
    pos++;
    int m = find(id);
    rebuild(l,m);
    rebuild(m+1,r);
    Post.push_back(id);
}

int main(){

    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",&Pre[i]);
    }
    for(int i=0;i<n;++i){
        scanf("%d",&In[i]);
    }
    rebuild(0,n);
    vector<int>::iterator it;
    for(it=Post.begin();it!=Post.end()-1;++it){
        printf("%d ",*it);
    }
    printf("%d\n",*it);


    return 0;
}




Measured memory_bytes: 3280
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val H = sc.next().toInt()
        val W = sc.next().toInt()
        val S = Array(H) { sc.next().map { it == '#' }.toTypedArray() }
        val A = Array(H) { IntArray(W) }

        for (y in 0 until H) {
            var p = 0
            for (x in 0 until W) {
                if (S[y][x]) {
                    for (xx in p until x) A[y][xx] += x - p
                    p = x + 1
                }
            }
            for (xx in p until W) A[y][xx] += W - p
        }

        for (x in 0 until W) {
            var p = 0
            for (y in 0 until H) {
                if (S[y][x]) {
                    for (yy in p until y) A[yy][x] += y - p
                    p = y + 1
                }
            }
            for (yy in p until H) A[yy][x] += H - p
        }
        var ans = 0
        for (y in 0 until H) for (x in 0 until W)
            if (ans < A[y][x]) ans = A[y][x]

        pw.println(ans - 1)
    }
}


Measured memory_bytes: 109688
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    if N % 2 == 0:
        print(N)
    else:
        print(2 * N)


if __name__ == '__main__':
    main()


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


int main() {
    ll n; cin >> n;
    ll ans = 0;
    for(ll a=1; a<=n; a++) {
        for(ll b=1; b<=n; b++) {
            if(n - (a * b) > 0) ans++;
            else break;
        }
    }
    cout << ans << endl;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, K, count = 0;
	
	cin >> N >> K;
	
	int h[N];
	
	rep(i, N){
		cin >> h[i];
		if(h[i] >= K)
			count++;
	}
	
	cout << count;
	
	return 0;
}

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

int main(){
    int h,w;
    cin>>h>>w;
    int k;
    cin>>k;
    vector<string> s(h);

    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    
    int ans = 0;
    for(int m=0;m<(1<<h);m++){
        for(int l=0;l<(1<<w);l++){
            int count = 0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((~m>>i & 1) && (~l>>j & 1) && s[i][j]=='#') count++;
                }
            }
            if(count==k) ans++;
        }
    }

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

Measured memory_bytes: 3588
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
//list($N,$K) =  explode(" ",trim(fgets(STDIN)));
$S = trim(fgets(STDIN));

$yy = (int)substr($S,0,2);
$mm = (int)substr($S,2,2);

if (($yy > 0 && $yy <= 12) && ($mm <= 12 && $mm > 0)) {
  printf("AMBIGUOUS\n");
}
else if (($yy > 12 || $yy==0) && ($mm <=12 && $mm > 0)) {
  printf("YYMM\n");
}
else if (($mm > 12 || $mm==0) && ($yy <= 12 && $yy > 0)) {
  printf("MMYY\n");
}
else {
  printf("NA\n");
}


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	Int mi = 1e9;
	for(auto i:a) mi = min(mi, i);
	if(mi > 1){
		cout << -1 << "\n";
		return 0;
	}
	Int ans = 0;
	Int t = 1;
	for(Int i=0; i<n; ++i){
		if(a[i] != t) ++ans;
		else ++t;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1792
var
    n,min,max,i,x:longint;
begin
    readln(n);
    max:=0;min:=maxlongint;
    for i:=1 to n do
        begin
            read(x);
            if x<min then min:=x;
            if x>max then max:=x;
        end;
    writeln(max-min);
end.

Measured memory_bytes: 128
def convert(s):
    o = ord(s)
    if o >= 65 and o <= 90:
        return s.lower()
    elif o >= 97 and o <= 122:
        return s.upper()
    return s


def main():
    strings = input()
    answer = ""
    for s in strings:
        s = s
        answer += convert(s)
    print(answer)

if __name__ == "__main__":
    main()

Measured memory_bytes: 7440
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long  inf = 2e5+9;
long long  n,a[inf],ans= 0;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++){
        if(a[i-1] > a[i])
            ans += a[i-1]- a[i];
        a[i] = max(a[i],a[i-1]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    ll x,y;
    cin>>x>>y;

    string a = "Alice";
    string b = "Brown";
    string ans;

    if(abs(x - y) <= 1) ans = b;
    else ans = a;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#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>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    map<string,int> mp;
    cin >> N;
    rep(i,0,N){
        string tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    cin >> N;
    rep(i,0,N){
        string tmp;
        cin >> tmp;
        mp[tmp]--;
    }

    int ans = 0;
    for(auto it : mp){
        ans = max(it.second , ans);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
      	boolean Current=true;
 		
		for(int i=0; i<str.length(); i++){
			if(i%2==1)
            {
              if (str.charAt(i)=='R')
              {
                Current=false;
              }
            }
          	else
            {
              if (str.charAt(i)=='L')
              {
                Current=false;
              }
            }
		}
      	if (Current==true){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
	}
}

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

class Main {
  public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int D = Integer.parseInt(st.nextToken());
    int T = Integer.parseInt(st.nextToken());
    int S = Integer.parseInt(st.nextToken());
    float tmp = (float)D/T;
    if(S >= tmp)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 32828
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const double INF=1e9;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))



int main(){
	int N,K;cin>>N>>K;
	bool D[10];
	CLR(D);
	REP(i,K){
		int t;
		cin>>t;
		D[t]=true;
	}
	int res=N;
	while(1){
		string str=toString(res);
		bool flag=0;
		REP(i,SZ(str))if(D[(int)(str[i]-'0')]){
			flag=1;
			break;
		}
		if(!flag){
			cout<<str<<endl;
			return 0;
		}
		res++;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
    ll a , b , c , k ;
    cin >> a >> b >> c >> k ;
    if(k<=a){
        cout << k ;
        return ;
    }
    k-=a;
    if(k<=b){
        cout << a ;
        return ;
    }
    k-=b;
    cout << a-min(c,k) ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}



Measured memory_bytes: 3652
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//fac[]はn! inv[]はMODにおける逆元 finv[]はinv[]とfinv[]の累積積
const long long MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算(nCkをO(1)で)
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    COMinit();
    long long N,K;cin >> N >> K;
    long long ans = 0;
    long long red = N-K;
    long long blue = K;
    for(long long i = 1;i<=K;i++){
        long long combination = 1;
        //Rを先に並べてからi個の隙間（または端っこ）を選ぶ
        combination *= COM(red+1,i);
        combination %= MOD;
        //Bを何個で分けるかを決める = Bを並べてからi-1個の隙間を選ぶ
        combination *= COM(blue-1,i-1);
        combination %= MOD;
        cout << combination << endl;
    }

}


Measured memory_bytes: 15528
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define log(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  
  int k;cin>>k;
  int a,b;cin>>a>>b;
  for(int i = a;i <= b;++i){
    if(i % k == 0){
      print("OK");
      return 0;
    }
  }
  print("NG");
  return 0; 
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int a[12345678], dp[12345678];

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

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

    for(int i = 0; i < 12345678; i++) {
        dp[i] = 2e9;
    }

    dp[1] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = 1; j <= k; j++) {
            dp[i + j] = min(dp[i] + abs(a[i] - a[i + j]),
                            dp[i + j]);
        }
    }
    cout << dp[n];
}



Measured memory_bytes: 49408
# coding: utf-8

# In[65]:


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

like = [0]*(M)
for _ in range(N):
    tmp = list(map(int, input().split()))
    for i in range(tmp[0]):
        like[tmp[i+1]-1] += 1


# In[66]:


print(like.count(N))



Measured memory_bytes: 3060
import math
a,b,C = map(float,input().split())
C_rad=math.pi*C/180
print("{0:.8f}".format(math.sin(C_rad)*a*b/2))
print("{0:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C_rad))))
print("{0:.8f}".format(b*math.sin(C_rad)))


Measured memory_bytes: 5692
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    if A + B >= 10:
        print('error')
    else:
        print(A + B)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << (A+B>C+D ? "Left":(A+B==C+D ? "Balanced":"Right")) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll a, b;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> a >> b;
	
	ll ans = 1;
	rep(i, 2, 1e6){
		if(a%i == 0 && b%i == 0){
			ans++;
		}
		while(a%i == 0){a /= i;}
		while(b%i == 0){b /= i;}
	}
	if(a > 1e6 && a == b){ans++;}
	print(ans)
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,j,num,id,nextnum,next,array[100][100];
  scanf("%d",&num);
  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      array[i][j]=0;
    }
  }
  for(i=0;i<num;i++){
    scanf("%d%d",&id,&nextnum);
    for(j=0;j<nextnum;j++){
      scanf("%d",&next);
      array[i][next-1]=1;
    }
  }
  for(i=0;i<num;i++){             
    for(j=0;j<num;j++){
      if(j!=0) printf(" ");
      printf("%d",array[i][j]);  /*output*/
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
N=int(input())
A=[]
for i in range(N):
    a=list(map(int,input().split()))
    A.append(a)
ans=0
for i in range(N):
    for j in range(N):
        ans+=A[i][j]
        for k in range(i+1,N):
            if A[i][j]+A[j][k]<A[i][k]:
                print(-1)
                quit()
ans//=2
for i in range(N):
    for k in range(i+1,N):
        for j in range(N):
            if i==j or j==k:
                continue
            if A[i][j]+A[j][k]==A[i][k]:
                ans-=A[i][k]
                break

print(ans)


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

#define int             long long
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl             '\n'
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr <<'}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i);cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int string_to_int(string s){
	int ans = 0;
	int p=1;
	for(int i=s.size()-1;i>=0;i--){
		ans += (s[i]-'0')*p;
		 p *= 10;
	}
	return ans;
}

void t_c_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	char a; cin >> a;
	if('A'<=a and a<= 'Z'){
		cout << "A" << endl;
	}
	else{
		cout << "a" << endl;
	}

}

int32_t main()
{
	t_c_c();
	return 0;
}


Measured memory_bytes: 3668