akhauriyash/Code-Regression huggingface dataset:
cards = []
for i in range(3):
    cards.append([ int(x) for x in input().split()])

N = int(input())

bolls = []
for _ in range(N):
    bolls.append( int(input()) )

checklist = [[0,0,0],[0,0,0],[0,0,0]]

for idx1, nums in enumerate(cards):
    for idx2, num  in enumerate(nums):
        for boll in bolls:
            if num == boll:
                checklist[idx1][idx2] = 1

ans = 'No'

if checklist[0][0] and checklist[1][1] and checklist[2][2]:
    ans = 'Yes'

if checklist[0][2] and checklist[1][1] and checklist[2][0]:
    ans = 'Yes'

if checklist[0][0] and checklist[0][1] and checklist[0][2]:
    ans = 'Yes'

if checklist[1][0] and checklist[1][1] and checklist[1][2]:
    ans = 'Yes'

if checklist[2][0] and checklist[2][1] and checklist[2][2]:
    ans = 'Yes'


if checklist[0][0] and checklist[1][0] and checklist[2][0]:
    ans = 'Yes'

if checklist[0][1] and checklist[1][1] and checklist[2][1]:
    ans = 'Yes'

if checklist[0][2] and checklist[1][2] and checklist[2][2]:
    ans = 'Yes'

print(ans)


Measured memory_bytes: 3064
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N,M = map(int,input().split())
    edge = [[] for _ in range(N)]
    pcount = [0 for _ in range(N)]
    
    for _ in range(N-1+M):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        pcount[b-1] += 1

    for x,num in enumerate(pcount):
        if num == 0:
            root = x
            
    ans = [None for _ in range(N)]
    ans[root] = 0
    q = deque([root])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            pcount[fol] -= 1
            if pcount[fol] == 0:
                ans[fol] = now+1
                q.append(fol)
    
    print(*ans,sep="\n")
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 25428
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

ll gcd (ll a, ll b){
    ll k = a % b;
    while (k > 0){
        a = b;
        b = k;
        k = a % b;
    }
    return b;
}

int main() {
    int d; cin >> d;
    vector<int> ar(26);
    rep(i,26) cin >> ar[i];
    vector<int> ans(d);
    rep(i,d){
        int ma = -1;
        int as = 0;
        rep(j,26){
            int a; cin >> a;
            if (ma < a){
                ma = a;
                as = j+1;
            }
        }
        ans[i] = as;
    }
    rep(i,d) cout << ans[i] << endl;
}

Measured memory_bytes: 3636
"use strict";

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

function main(input) {
  const [a, b, c, d] = input.split(" ").map(Number);

  const ans = Math.max(0, Math.min(b, d) - Math.max(a, c));
  console.log(ans);
}

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), s(n);
  rep(i, n) {
    cin >> a[i];
    a[i] %= 1000000007;
    s[i] = (i == 0) ? a[0] : (s[i-1] + a[i]);
    s[i] %= 1000000007;
  }

  ll ans = 0;
  for(int i = 1; i < n; i++) {
    ans += (a[i] * s[i-1]) % 1000000007;
  }

  cout << ans % 1000000007 << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    set<int> st;
    int N, Q; cin >> N >> Q;
    vector<pair<pair<int, int>, int>> events(N*2);
    rep(i, N){
        int s, t, x; cin >> s >> t >> x;
        events[i] = make_pair(make_pair(s-x, 1), x);
        events[i+N] = make_pair(make_pair(t-x, -1), x);
    }
    sort(events.begin(), events.end());
    vector<int> ans;
    int idx = 0;
    int sz = N*2;
    rep(i, Q){
        int d; cin >> d;
        while(idx < sz && events[idx].first.first <= d){
            if(events[idx].first.second == 1) st.insert(events[idx].second);
            else st.erase(events[idx].second);
            idx++;
        }
        if(st.size() == 0) ans.push_back(-1);
        else ans.push_back(*st.begin());
    }
    rep(i, Q) cout << ans[i] << endl;
    return 0;
}

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

int main()
{
    int h1, m1, s1, h2, m2, s2;
    
    for( int i = 0; i < 3; i++ )
    {
        cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
        int sum1 = h1 * 60 * 60 + m1 * 60 + s1;
        int sum2 = h2 * 60 * 60 + m2 * 60 + s2;
        sum2 = sum2 - sum1;

        cout << sum2 / 3600 << " " << sum2 % 3600 / 60 << " " << sum2 % 60 % 60 << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
main(){

	int first_ta,last_ta;
	int i = 1,j = 1,n;
	int num = 1,tem = 0;
	while(~scanf("%d%d",&first_ta,&last_ta))
	{
			for(n = 1;n<=first_ta;n++)
			{
				i = i * 2 ;
				if(i>=i/2+last_ta)
				{					
					num = num + last_ta;
				}
				else 
				{
					num  = num * 2;
				}
			}	
			printf("%d\n",num);
	}
	return 0;
}

Measured memory_bytes: 128
import bisect

s = input()
t = input()
p = {}
for i in range(len(s)):
    c = s[i]
    if c not in p:
        p[c] = []
    p[c].append(i)

over = 0
ret = 0
for c in t:
    if c not in p:
        print(-1)
        exit(0)
    ind = bisect.bisect_left(p[c], ret)
    if ind < len(p[c]):
        ret = p[c][ind] + 1
    else:
        ret = p[c][0] + 1
        over += 1

print(over * len(s) + ret)

Measured memory_bytes: 45808
while True:
    n = int(input())
    if n == 0:
        break
    chg = 1000 - n
    m = [500, 100, 50, 10, 5, 1]
    cnt = [0,0,0,0,0,0]
    for i in range(len(m)):
        cnt[i] = chg//m[i]
        chg -=cnt[i]*m[i]
    ans = 0
    for i in range(len(cnt)):
        ans += cnt[i]
    print(ans)


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

int main(){
	
  string s;
  cin >> s;
  string ans = "";
  for(int i=0;i<s.size();i++){
    if(s[i]=='B') {if(ans.size()) {
        ans.pop_back();continue;
    }
    }
     else ans.push_back(s[i]);
   }
    cout << ans;
    
       return 0;
}
  
  

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x) {
  return x * x;
}

signed main() {
  int R, G;
  cin >> R >> G;
  cout << 2. * G - R << endl;
  return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b;
  char c;
  cin>>a>>c>>b;
  if(c=='+') cout<<a+b<<endl;
  else cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

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

    int N, Q;
    string S;
    cin >> N >> Q >> S;
    S.insert(0, "1");
    vector<int> l(Q), r(Q);
    REP(i, Q) { cin >> l.at(i) >> r.at(i); }

    vector<int> count(N + 1);
    count[0] = 0;
    REP(i, N) {
        if (S[i] == 'A' && S[i + 1] == 'C') {
            count[i + 1] = count[i] + 1;
        } else {
            count[i + 1] = count[i];
        }
    }


    REP(i, Q) {
        int ans = count[r[i]] - count[l[i] - 1];
        if (S[l[i] - 1] == 'A' && S[l[i]] == 'C') {
            ans--;
        }
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 2256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    X = I()
    if X in [3,5,7]:
        print("YES")
    else:
        print("NO")


main()



Measured memory_bytes: 83528
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


int main()
{
	ll N;
	cin >> N;
	ll ans = 0;

	for (ll a = 1; a*a <= N - a; ++a)
	{
		if ((N - a) % a == 0 && a < (N - a) / a)ans += (N - a) / a;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    vector<int> a(n);
    for(int i = 1; i < n; i++) {
        for(int j = i+1; j <= n; j++) {
            a[min(j-i, min(abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)))]++;
        }
    }

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

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

int main()
{
	string s;
	cin >> s;
	int ans;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '+') ans++;
		else ans--;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
int main(){
    string s; cin >> s;
    string devide[4] = {"dream", "dreamer", "erase", "eraser"};
    reverse(s.begin(),s.end());
    rep(i,4) reverse(devide[i].begin(), devide[i].end());
    
    bool can = true;
    int n = s.size();
    for(int i = 0; i < n; ){
        bool can2 = false;
        rep(j,4){
            string d = devide[j];
            if(s.substr(i, d.size()) == d){ // devideで
                can2 = true;
                i += d.size();
                break;
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from decimal import getcontext, Decimal

def count5(n):
    count = 0
    while n%5 == 0:
        count += 1
        n //= 5
    return count

def count2(n):
    count = 0
    while n%2 == 0:
        count += 1
        n //= 2
    return count

N = I()
A = []
for i in range(N):
    A.append(int(10**9*Decimal(input())))

counter = [[0]*30 for _ in range(50)]
for i in range(N):
    c2 = count2(A[i])
    c5 = count5(A[i])
    counter[c2][c5] += 1

same = 0
diff = 0
for i in range(50):
    for j in range(30):
        if counter[i][j]:
            for p in range(18-i,50):
                for q in range(18-j,30):
                    if i != p or j != q:
                        diff += counter[i][j]*counter[p][q]
                    else:
                        same += counter[i][j]*(counter[p][q]-1)//2

print(diff//2+same)

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

int main(){
    int a,b;

    cin >> a >> b;
  if (a < b){
      cout << "a < b" << endl;
  }else if(a > b){
      cout << "a > b" << endl;
  }else if(a == b){
      cout << "a == b" << endl;
  }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    char last = '{';
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'a') {
            continue;
        }
        if(last - s[i] <= k) {
            k -= (last - s[i]);
            s[i] = 'a';
        }
    }
    k %= 26;
    s.back() += k;
    cout << s << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <deque>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

 
ll dp[2020][2020];
ll sum[2020][2020];

int main(void){
	ll S;
	cin>>S;
	for(ll i=3;i<=S;i++){
		dp[1][i] = 1; 
	}
	for(ll i=1;i<=S;i++){
		sum[1][i] = (sum[1][i-1]+dp[1][i])%N;
	}
	for(ll i=2;i<=S;i++){
		for(ll j=3;j<=S;j++){
				dp[i][j] = (dp[i][j]+sum[i-1][j-3])%N;
				sum[i][j] = (sum[i][j-1]+dp[i][j])%N;
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	ll ans = 0;
	for(ll i=1;i<=S;i++)ans = (ans+dp[i][S])%N;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 66764
#include <iostream>
#include <string>

using namespace std;

int main(){
  int a=0,b=0;
  string str;
  
  int N,A,B;
  
  cin >> N >> A >> B >> str;
  
  for(int i=0;i<str.size();i++){
    switch(str[i]){
    case 'a':
      a++;
      if(a+b<=A+B){
        cout << "Yes" <<endl;
      }else{
        cout << "No" <<endl;
      }
      break;
    case 'b':
      b++;
      if(a+b<=A+B&&b<=B){
        cout << "Yes" <<endl;
      }else{
        cout << "No" <<endl;
        b--;
      }
      break;
    case 'c':
      cout << "No" <<endl;
      break;
    }
  }
  return 0;
}

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

int main(){
 while(1){
 int m, f, r;
 cin >> m >> f >> r;
 if(m == -1 && f == -1 && r == -1) break;
 
 char result;
 if(m == -1 || f == -1){
    result = 'F';
 }else if(m + f >= 80){
    result = 'A';
 }else if(m + f >= 65){
    result = 'B';
 }else if(m + f >= 50){
    result = 'C';
 }else if(m + f >= 30 && r >= 50){
    result = 'C';
 }else if(m + f >= 30 && r < 50){
    result = 'D';
 }else{
    result = 'F';
 }
 cout << result << endl;
}
return 0;
} 


Measured memory_bytes: 3076
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;


int main(){
    int n;
    int a,b;
    cin>>n>>a>>b;
    int mm[3];
    mm[0]=0;mm[1]=0;mm[2]=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x<=a){
            mm[0]++;
        }else if(x>=a+1&&x<=b){
            mm[1]++;
        }else if(b<x){
            mm[2]++;
        }
    }
    
        
        
        
    cout<<min({mm[0],mm[1],mm[2]})<<endl;
  
    
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second

typedef __int128 LL;
#define LBW std::pair <LL, int>

const int MOD = 998244353;
inline int add(int x, int y) { return x + y >= MOD ? x + y - MOD : x + y; }
inline int mul(int x, int y) { return 1LL * x * y % MOD; }

char s[233];
std::map <LBW, int> mp;

int dfs(LBW now) {
	if (now.y == 0) return 1;
	if (now.y == 1) return now.x + 1;
	if (mp.count(now)) return mp[now];
	int ans = mul(dfs(LBW(now.x >> 1, now.y - 1)), dfs(LBW(now.x & 1, 1)));
	for (int len = 1; len <= now.y >> 1; ++len) {
		LL base = ((LL) 1 << len) - 1, S = base, tmp = now.x;
		S &= tmp & base, tmp >>= len, S &= tmp & base, tmp >>= len;
		for (int i = now.y - (len << 1); i >= 0; i -= len, S &= tmp & base, tmp >>= len) ans = add(ans, mul(dfs(LBW(S, len)), dfs(LBW(tmp, i))));
	}
	return mp[now] = ans;
}

int main() {
	scanf(" %s", s + 1);
	int len = strlen(s + 1); LL num = 0;
	for (int i = 1; i <= len; ++i) num = (num << 1) + (s[i] ^ 48);
	printf("%d\n", dfs(LBW(num, len)));
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    Fast;
    long long t,n,m,i,j,k,x=0,y=0,z;
    cin>>m>>n;
    if(m<10){
        n=n+(100*(10-m));
    }
    cout<<n<<endl;
}


Measured memory_bytes: 256
// by piano
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=30;
int n,op[N];
char s[N];
map <string,int> tot;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	tot.clear();
	for (int i=0;i<(1<<n);i++){
		string now="";
		for (int j=0;j<n;j++)
			if (!((i>>j)&1))
				now+=s[j+1];
		now+="*";
		for (int j=n-1;j>=0;j--)
			if ((i>>j)&1)
				now+=s[j+1];
//		cout << now << endl;
		tot[now]++;
	}
//	cout << endl;
	LL ans=0;
	for (int i=0;i<(1<<n);i++){
		string now="";
		for (int j=0;j<n;j++)
			if ((i>>j)&1)
				now+=s[n*2-j];
		now+="*";
		for (int j=n-1;j>=0;j--)
			if (!((i>>j)&1))
				now+=s[n*2-j];
//		cout << now << tot[now] << endl;
		ans+=tot[now];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 73984
/*
http://chaste.web.fc2.com/Reference.files/Algo.html
fukumen.c -- 覆面算 (slightly modified)
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
enum {FALSE, TRUE};

#define N 15  /* 最大の行数 */

int imax, jmax, solution, digit[128], low[128], ok[N];
char word[N][16];
void found(void)  /* 解の表示 */
{
	int i, j, c;
	for (i = 0; i <= imax; i++){
		if(strlen(word[i])>1&&digit[word[i][strlen(word[i])-1]]==0)return;
	}
	++solution;
/*
	printf("\n解 %d\n", solution);
	for (i = 0; i <= imax; i++) {
		for (j = jmax; j >= 0; j--) {
			c = word[i][j];
			if (c != '\0') printf("%d", digit[c]);
			else           printf(" ");
		}
		printf("\n");
	}
*/
}

void try(int sum)  /* 再帰的に試みる */
{
	static int i = 0, j = 0, carry;
	int c, d;

	c = word[i][j];
	if (i < imax) {
		i++;
		if ((d = digit[c]) < 0) {  /* 定まっていないなら */
			for (d = low[c]; d <= 9; d++)
				if (ok[d]) {
					digit[c] = d;  ok[d] = FALSE;
					try(sum + d);  ok[d] = TRUE;
				}
			digit[c] = -1;
		} else try(sum + d);
		i--;
	} else {
		j++;  i = 0;  d = sum % 10;  carry = sum / 10;
		if (digit[c] == d) {
			if (j <= jmax) try(carry);
			else if (carry == 0) found();
		} else if (digit[c] < 0 && ok[d] && d >= low[c]) {
			digit[c] = d;  ok[d] = FALSE;
			if (j <= jmax) try(carry);
			else if (carry == 0) found();
			digit[c] = -1;  ok[d] = TRUE;
		}
		j--;  i = imax;
	}
}

int main()
{
	int i, j, k, c;
	char buffer[128];

	jmax = 0;
loop:
	//printf("行数? ");
	scanf("%d", &imax);
	if(!imax)return 0;
	imax--;
	memset(word,0,sizeof(word));
	memset(digit,0,sizeof(digit));
	//memset(low,0,sizeof(low));
	memset(ok,0,sizeof(ok));
	for (i = 0; i < N && i <= imax; i++) {
		//printf("%2d: ", i + 1);
		scanf("%s", buffer);
		//low[buffer[0]] = strlen(buffer)>1;
		k = strlen((char *)buffer) - 1;
		if (k > jmax) jmax = k;
		for (j = 0; j <= k; j++) {
			word[i][j] = c = buffer[k - j];
			if (isalpha(c)) digit[c] = -1;
			else if (isdigit(c)) digit[c] = c - '0';
		}
	}
	for (i = 0; i <= 9; i++) ok[i] = TRUE;
	solution = 0;  try(0);
	//if (solution == 0) printf("解はありません.\n");
	printf("%d\n",solution);
	goto loop;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  int n;
  cin >> n;
  string s="No";
  r(i, 9) {
    if (n%(i+1)==0 && n/(i+1)<10) s="Yes";
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    
    char x;
    cin >> x;
    if (x >= 'A' && x <= 'Z') cout << "A\n";
    else cout << "a\n";
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), L(N), R(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  L[0] = A[0];
  R[N - 1] = A[N - 1];
  for (int i = 1; i < N; i++) L[i] = gcd(L[i - 1], A[i]);
  for (int i = N - 2; i >= 1; i--) R[i] = gcd(R[i + 1], A[i]);

  vector<ll> ans(N);
  ans[0] = R[1], ans[N - 1] = L[N - 2];
  for (int i = 1; i < N - 1; i++) {
    ans[i] = gcd(L[i - 1], R[i + 1]);
  }

  cout << *max_element(ans.begin(), ans.end()) << endl;
  return 0;
}


Measured memory_bytes: 3328
program main;
var 
    n, i, temp : integer;
    a : array[1..200000] of integer;

begin
    readln(n);

    for i := 1 to n do 
        a[i] := 0;

    for i := 2 to n do begin
        read(temp);
        a[temp] := a[temp] + 1;
    end;

    for i := 1 to n do 
        writeln(a[i]);
end.


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll k, s;
  cin >> k >> s;

  ll cnt = 0;
  for (long long x = 0; x <= k; x++) {
    for (long long y = 0; y <= k; y++) {
      ll z = s - x - y;
      if (z >= 0 && z <= k) {
        cnt++;
      }
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3624
#include<iostream>
 
using namespace std;
 
int main(){
	int n;
  	bool f = false;
  	cin >> n;
  	for(int i = 0; i < n; i++){
    	int t;
      	cin >> t;
      	if(t % 2 == 1)f = true;
    }
  	if(f)cout << "first" << endl;
  	else cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

const int N=200005;

int n,b;
ll ans;
int a[N];

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]),a[i]-=i;
	sort(a+1,a+1+n);
	b=a[(n+1)/2];
	for (i=1;i<=n;i++) ans+=1ll*abs(a[i]-b);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int main()
{
	int n,a = 0,b = 0,k,j;
	char c[200001];
	scanf("%d",&n);
	scanf("%s",c);
	
	for(int i = 0;i < n;i++){
		if(c[i] == '.') b++;
	}
	
	int min = b;
	for(int i = 0;i < n;i++){
		if(c[i] == '#') a++;
		else b--;
		if(a + b < min) min = a + b;
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N; cin >> N;
	bool flag = false;
	for (int i = 1; i <= 9; i++) {
		if (N%i == 0 && 1 <= (N / i) && (N / i) <= 9) flag = true;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
	char s[100001];
	bool isAlphabetExsist[26];
	for (int i = 0; i < 26; i++) {
		isAlphabetExsist[i] = false;
	}
	int len;
	scanf("%s", s);
	len = strlen(s);
	for (int i = 0; i < len; i++) {
		isAlphabetExsist[s[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; i++) {
		if (!isAlphabetExsist[i]) {
			printf("%c\n", 'a' + i);
			return 0;
		}
	}
	printf("None\n");
	return 0;
}

Measured memory_bytes: 256
def ccc(n):
    #c(n,2)
    result = (n * (n-1))//2
    return result



def sortString(a):
    a = list(a)
    a.sort()
    return "".join(a)


def calculate(arr):
    if len(arr) == 0:
        return 0

    dict = {}
    for i in range(len(arr)):
        s = sortString(arr[i])
        if dict.get(s) == None:
            dict.setdefault(s,1)
        else:
            dict.__setitem__(s,dict.get(s) + 1)


    sum = 0
    for v in dict.values():
        sum += ccc(v)

    return sum



arr = []

N = int(input())
for i in range(N):
    arr.append(input())


result = calculate(arr)
print(result)

Measured memory_bytes: 24980
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])


def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)

    cur = []
    nxt = []
    cur.append(S[0])
    nxt.append(S[0])
    
    flag[0] = False

    for i in range(N):
        j = 0
        for k in range(len(S)):
            if flag[k] and S[k]<cur[j]:
                nxt.append(S[k])
                j+=1
                flag[k] = False
                if j==len(cur):
                  break
        else:
            return("No")
        nxt.sort(reverse=True)
        cur = [x for x in nxt]
    return("Yes")

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 118860
s=input()
t=input()

dp=[[-1]*(len(t)+1) for x in range(len(s)+1)]
arr = ""
for i in range(len(s),-1,-1):
    for j in range(len(t),-1,-1):
        if i>=(len(s)) or j>=(len(t)):
            dp[i][j] = 0
        else:
            if s[i] == t[j]:
                dp[i][j] = dp[i+1][j+1] + 1
            else:
                dp[i][j] = max(dp[i+1][j],dp[i][j+1])

l=dp[0][0]
i,j=0,0
while len(arr)!=l:
    if s[i] == t[j]:
        arr=arr+s[i]
        i+=1
        j+=1
    else:
        if dp[i+1][j]>=dp[i][j+1]:
            i+=1
        else:
            j+=1

print(arr)



# def func(i,j):
    # if i>=(len(s)) or j>=(len(t)):
    #     return 0
    # if dp[i][j]!=-1:
    #     return dp[i][j]
    # if s[i]==t[j]:
    #     dp[i][j] = func(i+1,j+1)+1
    #     return dp[i][j]
    # if s[i]!=t[j]:
    #     dp[i][j] = max(func(i+1,j),func(i,j+1))
    #     return dp[i][j]
# l=func(0,0)


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

int n,k;
int a[125252];
int outdeg[125252], indeg[125252];
int po[125252];
bool view[125252];
bool used[125252];

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n)scanf("%d",a+i),a[i]--;
  REP(i,n){
    if(a[i]!=-1){
      outdeg[i]++;
      indeg[a[i]]++;
    }
  }
  REP(i,n)view[i] = (outdeg[i]==0) || (indeg[i]==0);
  stack<int> S;
  REP(i,n)if(indeg[i]==0){
    po[i] = k;
    S.push(i);
  }
  while(!S.empty()){
    int p = S.top(); S.pop();
    used[p] = true;
    int to = a[p];
    po[to] = max(po[to], po[p]-1);
    indeg[to]--;
    if(indeg[to] == 0){
      S.push(to);
    }
  }
  REP(i,n)view[i] = view[i] || (po[i]>0);
  int ans = 0;
  REP(i,n)ans+=view[i];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353
signed main(){
	int n, m, a[1001][3], ans = 0;
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i ++)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	for(int i = 0 ; i <= 7 ; i ++){
		priority_queue<int, vector<int>, greater<int> > pq;
		for(int j = 1 ; j <= n ; j ++){
			int cur = a[j][0]*((i >> 0)&1 ? 1: -1) + a[j][1]*((i >> 1)&1 ? 1: -1) + a[j][2]*((i >> 2)&1 ? 1: -1);
			pq.push(cur);
			if(pq.size() > m) pq.pop();
		}
		int cur = 0;
		while(pq.size()) cur += pq.top(), pq.pop();
		if(cur > ans) ans = cur; 
	}
	cout << ans;
}


Measured memory_bytes: 256
s = list(input())

counter_1 = 0
for i in range(len(s)):
  # 101010...
  if i%2==0:
    if s[i] == '0':counter_1 += 1
  
  if i%2!=0:
    if s[i] == '1':counter_1 += 1
      
counter_2 = 0
for i in range(len(s)):
  # 01010...
  if i%2==0:
    if s[i] == '1':counter_2 += 1
  
  if i%2!=0:
    if s[i] == '0':counter_2 += 1
      
print(min(counter_1, counter_2))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

int main(){
	ll n; cin >> n;
	vector<ll> a(n),b(n);
	rep(i,n) cin >> a[i] >> b[i];
	vector<pair<ll,ll> > s(n);
	rep(i,n){
		s[i] = make_pair(b[i],a[i]);
	}
	sort(all(s));
	ll count = 0;
	rep(i,n){
		count += s[i].second;
		if (s[i].first < count){
			cout <<"No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 6528
N = int(raw_input())
for i in range(N):
    r = raw_input()
    lis = [r[0]]
    a = ''
    for c in r[1:]:
        if c.isalpha():
            lis.append(a)
            lis.append(c)
            a = ''
        else:
            a += c
    
    t = lis[0]
    d = ''
    for v in lis[1:]:
        if v.isalpha():
            if d == '->':
                if not v in t:
                    t = t+v 
            elif d == '<-':
                if not v in t:
                    t = v+t
        else:
            d = v
    else:
        print t

Measured memory_bytes: 4228
R,C,B[10000],i,j,k,o,p;main(m){for(;scanf("%d%d",&R,&C)*R;memset(B,!printf("%d\n",m),4*C)){for(m=R*C;m--;B[m%C]|=k<<m/C)scanf("%d",&k);for(i=1<<R;i--;k>m?m=k:0)for(k=0,j=C;j--;k+=o>R-o?o:R-o)for(o=0,p=B[j]^i;p;p&=p-1)o++;}}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n; cin>>n;

	map<ll,ll> mp;

	rep(i,n){
		int tmp; cin>>tmp;

		mp[tmp]++;
	}

	vector<ll> ans(n+1,0);

	for(auto e : mp){
		if(e.second >=2){
			ans.push_back(e.first);
		}
		if(e.second >=4){
					ans.push_back(e.first);
		}
	}

	sort(ans.begin(),ans.end(),greater<int>());

	writeln((ll)ans[0]*ans[1]);



}


Measured memory_bytes: 8064
#include <cstdio>
using namespace std;
int N,K,mo;
int dp[305][305];
int main(){
	scanf("%d%d%d",&N,&K,&mo);
	dp[0][0]=1;
	for(int i=0;i<=N;i++)
		for(int j=0;j<K;j++)
			for(int k=i;k>=0;k--){
				if(k)dp[j][k-1]=(dp[j][k-1]+dp[j][k])%mo;
				else dp[j+1][i]=(dp[j+1][i]+dp[j][k])%mo;
				dp[j][k]=1ll*dp[j][k]*(k+1)%mo;
			}
	printf("%d\n",dp[K][N]);
	return 0;
}

Measured memory_bytes: 512
#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>;
const ll INF = 1LL<<60;
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; }

const int mod = 1000000007;

int main() {
  int a[3][3];
  int n;
  rep(i, 3){
    rep(j, 3){
      cin >> a[i][j];
    }
  }
  cin >> n;
  int b[n];
  rep(i, n) cin >> b[i];

  rep(i, 3){
    rep(j, 3){
      rep(k, n){
        if(a[i][j] == b[k]) a[i][j] = 0;
      }
    }
  }

  // rep(i, 3){
  //   rep(j, 3){
  //     cout << a[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  rep(i, 3){
    if(a[i][0] == a[i][1] && a[i][1] == a[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
    if(a[0][i] == a[1][i] && a[1][i] == a[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(a[0][0] == a[1][1] && a[1][1] == a[2][2]){
      cout << "Yes" << endl;
      return 0;
  }
  if(a[0][2] == a[1][1] && a[1][1] == a[2][0]){
      cout << "Yes" << endl;
      return 0;
  }

  cout << "No" << endl;
  return 0;
}

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

int main(){
	int R;
	string ans;
	cin >> R;
	if(R < 1200){
		ans = "ABC";
	}else if(R < 2800){
		ans = "ARC";
	}else{
		ans = "AGC";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
x_=input()
px=x_.count("1")
if not px:
    for i in range(n):
        print(1)
    exit()
if px==1:
####[上から] i 桁目
    for i in range(n):
        if int(x_[i]):
            print(0)
        else:
            if i==n-1 or int(x_[-1])==1:###
                print(2)
            else:
                print(1)
    exit()
x=int(x_,2)

pow2=[1]

for i in range(n):
    tmp=pow2[-1]
    tmp*=2
    tmp%=px+1
    pow2.append(tmp)
pow22=[1]
for i in range(n):
    tmp=pow22[-1]
    tmp*=2
    tmp%=px-1
    pow22.append(tmp)
x1=x%(px+1)
x2=x%(px-1)
ans=[]
for i in range(n):
    tmp=0;dv=0
    if int(x_[-i-1]):
        tmp=x2-pow22[i]
        tmp%=(px-1)
        dv=px-1
    else:
        tmp=x1+pow2[i]
        tmp%=(px+1)
        dv=px+1
    
    cnt=1
    while tmp:
        
        dv=bin(tmp).count("1")
        if not dv or not tmp:
            break
        
        tmp%=dv
        cnt+=1
    ans.append(cnt)
for i in ans[::-1]:
    print(i)


Measured memory_bytes: 101276
def main(n500, n100, n50, price):
    count = 0
    for i in range(n500 + 1):
        for j in range(n100 + 1):
            for k in range(n50 + 1):
                p = i * 500 + j * 100 + k * 50
                if p == price:
                    count += 1
    print(count)


if __name__ == "__main__":
    n500 = int(input())
    n100 = int(input())
    n50 = int(input())
    price = int(input())
    main(n500, n100, n50, price)


Measured memory_bytes: 9056
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n;
    vector<int>a;
    int ans;
    int bef;
    while(1){
    cin >>n;
    ans=INF;
    if(n==0){
        return 0;
    }
    rep(i,n){
        cin>>bef;
        a.pb(bef);
    }
    sort(all(a));
    rep(i,n-1){
        chmin(ans,a[i+1]-a[i]);
    }
    cout<<ans<<endl;
    a.clear();
    }
}


Measured memory_bytes: 3112
#>=はmの倍数をまたいだ回数
k,q = map(int, input().split( ))
d = list(map(int, input().split( )))
from collections import Counter
for i in range(q):
    n,x,m=map(int, input().split( ))
    dx = [di%m for di in d]
    ##あまり0をあまりmで処理
    for i in range(k):
        if dx[i]==0:
            dx[i]=m
    sm = x%m+sum(dx)*((n-1)//k)+sum(dx[:(n-1)%k])
    print(n-1 -sm//m)


Measured memory_bytes: 64860
#include<stdio.h>
int main()
{
    int A1 , A2 , A3;
    scanf("%d",&A1);
    scanf("%d",&A2);
    scanf("%d",&A3);
    if(A1+A2+A3>=22){
        printf("bust\n");
    }
    else
        printf("win\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;




int main(){
	int k, a, b;
	cin >> k >> a >> b;
	if ((a+k-a%k>b)&& !(a%k==0))
		cout << "NG";
	else
		cout << "OK	";
	return 0;
}

Measured memory_bytes: 3640
def checkValidity(a, b, c):  
      
    # check condition  
    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
        return False
    else: 
        return True 
n=int(input())
l=list(map(int,input().split()))
count=0
a,b,c=0,0,0
for i in range(n):
    for j in range(i+1,n):
        if l[j]!=l[i]:
            for k in range(j+1,n):
                if (l[k]!=l[j])and (l[k]!=l[i]):
                    a=l[i]
                    b=l[j]
                    c=l[k]
                    if checkValidity(a, b, c):
                        count=count+1
print(count)                


Measured memory_bytes: 9084
def solve(field):
  for i in range(1, h + 1):
    for j in range(1, w + 1):
      if field[i][j] == '.':
        continue
        #それ以後の処理がスキップされ、次のループに。つまり#の場合のみ次に進める。
      if field[i-1][j] == field[i][j-1] == field[i][j+1] == field[i+1][j] == '.':
      #上下左右に黒がない場合（全部白の場合）、黒色にできない（隣も塗らざるを得ないから）。
      #また黒色にできないのはその場合に限る（1つ以上あれば――ダブってても白には戻らないため――べたべた塗ればよい）
        return False
  return True
#インデント注意。任意の#のfieldに対してFalse返らなかったらTrueということなので、最初の条件節を出る（同じインデントかそれより前）。
h, w = list(map(int, input().split()))
field = ['.' + input() + '.' for _ in range(h)]
#左右の端についてもsolve(field)を適用するため、入力に左右を付け加える
field = ['.'*(w+2)] + field + ['.'*(w+2)]
#上下の端についても同様の処理。fieldは例えば['.....', '..#..', '.###.', '..#..', '.....']となる。
#これのi番目のリストのj項が、field[i][j]によって指示される。

print('Yes' if solve(field) else 'No')
#solve(field)だけで、Trueが返ってくるということを意味する。


Measured memory_bytes: 3064
# soundhound2018-summer-qualA - F
def main():
    a, b = map(int, open(0).read().split())
    if a + b == 15:
        print("+")
    elif a * b == 15:
        print("*")
    else:
        print("x")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    if (n < 30)
        cout << "No";
    else
        cout << "Yes";
}

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

int main(){

  int a,input;
  char c;

  cin >> a;

  while(1){

    cin >> c >> input;

    switch(c){

    case '+': a += input;break;

    case '-': a -= input;break;

    case '*': a *= input;break;

    case '/': a /= input;break;

    default : cout << a << endl; return 0;
    
    }

  }

  return 0;
}

Measured memory_bytes: 3108
p, g = 998244353, 3
def convolve(a, b):
    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2
 
    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2
 
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)
    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int cnt[11]={0};
  cnt[a]++;cnt[b]++;cnt[c]++;

  if(cnt[5]==2 && cnt[7]==1)cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
use superslice::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n],
    }
    let mut result = 0;
    for k in 0..30 {
        let t = 2usize.pow(k as u32);
        let mut c = b.iter().map(|&bi| bi % (2 * t)).collect::<Vec<usize>>();
        c.sort();
        let mut count = 0usize;
        for i in 0..n {
            let ai = a[i] % (2 * t);
            let x = c.lower_bound_by_key(&t, |&ci| ai + ci);
            let y = c.lower_bound_by_key(&(2 * t), |&ci| ai + ci);
            let z = c.lower_bound_by_key(&(3 * t), |&ci| ai + ci);
            count += n - z + y - x;
        }
        dbg!(count);
        if count % 2 == 1 {
            result |= 1 << k;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 11212
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int adj [][] = new int[n][n];
        for(int i=0;i<n;i++) Arrays.fill(adj[i],0);
        for(int i=0;i<n;i++){
            int u = sc.nextInt();
            int k = sc.nextInt();
            for(int j=0;j<k;j++){
                int num = sc.nextInt();
                adj[u-1][num-1]=1;
            }
        }
        for(int [] L:adj){
            System.out.print(L[0]);
            for(int i=1;i<n;i++) System.out.print(" "+L[i]);
            System.out.println();
        }
    }
}


Measured memory_bytes: 31976
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3584