akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys

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

def lcm(a,b):
    return a*b/gcd(a,b)

for s in sys.stdin:
    a,b = map(int,s.split())
    a,b = max(a,b),min(a,b)
    print gcd(a,b),lcm(a,b)

Measured memory_bytes: 4208
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

L = [A, B, C, D, E]
S = [10]
for l in L:
    if l % 10 != 0:
        S.append(l % 10)
min_s = min(S)

s = 0
flag = True
for l in L:
    if flag and min_s == l % 10:
        s += l
        flag = False
    elif 0 == l % 10:
        s += l
    else:
        s += 10 * (l // 10) + 10
print(s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define show(x) cerr << #x << " = " << (x) << endl
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
class DisjointSets
{
public:
    DisjointSets(const int v) : parent(v), rank(v, 0) { iota(parent.begin(), parent.end(), 0); }
    bool same(const int a, const int b) { return find(a) == find(b); }
    int find(const int a) { return parent[a] == a ? a : parent[a] = find(parent[a]); }
    void unite(int a, int b)
    {
        a = find(a), b = find(b);
        if (a == b) { return; }
        if (rank[a] < rank[b]) { swap(a, b); }
        rank[a] += rank[b], parent[b] = a;
    }

private:
    vector<int> parent, rank;
};
int main()
{
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<char> v(M);
    vector<int> u(M);
    int maximum = 1;
    for (int i = 0; i < M; i++, maximum *= 3) { cin >> v[i] >> u[i]; }
    map<char, int> mp;
    for (int i = 0; i < M; i++) { mp[v[i]] = i; }
    ll ans = 0;
    for (int i = 0; i < maximum; i++) {
        int num = i;
        vector<string> st(M);
        using Set = bitset<10>;
        vector<Set> cand;
        for (int i = 0; i < M; i++, num /= 3) {
            const int c = num % 3;
            if (c == 0) {
                st[i].push_back('a' + cand.size()), cand.push_back(Set((1 << min(u[i] + 1, 10)) - 1));
            } else if (c == 1) {
                st[i].push_back('a' + cand.size()), u[i] >= 20 ? cand.push_back(Set((1 << (u[i] / 10)) - 2)) : cand.push_back(Set(0));
                st[i].push_back('a' + cand.size()), cand.push_back(Set((1 << 10) - 1));
            } else {
                st[i].push_back('a' + cand.size()), u[i] >= 10 ? cand.push_back(Set(1 << (u[i] / 10))) : cand.push_back(Set(0));
                st[i].push_back('a' + cand.size()), cand.push_back(Set((1 << (1 + u[i] % 10)) - 1));
            }
        }
        for (int i = 0; i < 10; i++) { cand.push_back(Set(1 << i)); }
        string s;
        for (const char c : S) {
            if (isdigit(c)) {
                s.push_back(c);
            } else {
                s += st[mp[c]];
            }
        }
        const int l = cand.size();
        auto enc = [&](const char c) { return isdigit(c) ? l - 10 + c - '0' : c - 'a'; };
        DisjointSets uf(l);
        for (int i = 0; i < s.size() / 2; i++) { uf.unite(enc(s[i]), enc(s[s.size() - i - 1])); }
        vector<Set> v(l, Set((1 << 10) - 1));
        vector<bool> used(l, false);
        for (int i = 0; i < l; i++) { used[uf.find(i)] = true, v[uf.find(i)] &= cand[i]; }
        ll sub = 1;
        for (int i = 0; i < l; i++) { (sub *= not used[i] ? 1 : v[i].count()) %= MOD; }
        (ans += sub) %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3228
using System;

public class candy
{
    public static void Main()
    {
        while (true)
        {
            string aa = Console.ReadLine();
            if (aa == null)
            {
                break;
            }
            else
            {
                int n = int.Parse(aa);

                int amari = n % 39;
                if (amari == 0)
                {
                    amari = 39;
                }
                string ama = amari.ToString();
                if (amari == 1 || amari == 2 || amari == 3 || amari == 4 || amari == 5 || amari == 6 || amari == 7 || amari == 8 || amari == 9)
                {
                    Console.WriteLine("3C0{0}", ama);
                }
                else
                {
                    Console.WriteLine("3C{0}", ama);
                }
            }

        }
    }
}

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

using namespace std;
int main(){
  int n;
  cin>>n;
  
  for(int i=1;i<=9;i++){
for(int j=0;j<=9;j++){
if(i*j==n){
  cout<<"Yes"<<endl;
  return 0;
}
}
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
blue = {}
i = 0
while i < n:
    temp = input()
    if temp in blue:
        blue[temp] += 1
    else:
        blue[temp] = 1
    i += 1
#print(blue)

m = int(input())
red = {}
i = 0
while i < m:
    temp = input()
    if temp in red:
        red[temp] += 1
    else:
        red[temp] = 1
    i += 1
#print(red)

max_score = 0
score = 0
for key in blue.keys():
    if key not in red:
        score = blue[key]
    else:
        score = blue[key] - red[key]
    max_score = max(max_score, score)
    
if max_score < 0:
    print(0)
else:
    print(max_score)

Measured memory_bytes: 3064
N = int(input())

ac, wa, tle, re = 0, 0, 0, 0
for i in range(N):
    tmp = input()
    if tmp == "AC":
        ac += 1
    elif tmp == "WA":
        wa += 1
    elif tmp == "TLE":
        tle += 1
    elif tmp == "RE":
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))


Measured memory_bytes: 74892
#include <iostream>

using namespace std;

int main(){
    int h,w;
    
    
    
    while(1){
        cin >> h >> w;
        if(h==0 && w==0)break;
        
        for(int i=0; i <h; i++){
            for(int j=0; j<w; j++){
                cout << "#";
            }
            cout <<endl;
        }
        cout <<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3084
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define N 100100
#define LL long long

using namespace std;

int a[N],b[N],c[N];
LL A[N],B[N];

int main()
{
	int n;
	scanf ("%d",&n);
	for (int i=1;i<=n;i++)
		scanf ("%d",&a[i]);
	for (int i=1;i<=n;i++)
		scanf ("%d",&b[i]);
	for (int i=1;i<=n;i++)
		scanf ("%d",&c[i]);
	
	sort (a+1,a+n+1);
	sort (b+1,b+n+1);
	sort (c+1,c+n+1);
	
	int loc = 1;
	for (int i=1;i<=n;i++)
	{
		while (loc <= n && b[i]>a[loc])
			loc ++;
		B[i] = loc-1;
	}
	
	loc = 1;
	LL ans = 0,tmp = 0;
	for (int i=1;i<=n;i++)
	{
		while (loc <= n && c[i]>b[loc])
			tmp += B[loc++];
		ans += tmp;
	}
	
	printf ("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2304
# 2020/03/07
# AtCoder Beginner Contest 108 - A

# Input
k = int(input())

# Calc
if k % 2 == 0:
    ans = (k // 2) ** 2
else:
    ans = (k // 2) * ((k // 2) + 1)

# Output
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> cnt(M+1, 0);
    
    int K;
    for(int i = 0; i < N; i++){
        cin >> K;
        for(int j = 0; j < K; j++){
            int a;
            cin >> a;
            cnt[a]++;
        }
    }
    
    int ans = 0;
    for(int i = 1; i <= M; i++){
        if(cnt[i] == N){
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			double a = sc.nextInt();
			double b = sc.nextInt();
			double c = sc.nextInt();
			double d = sc.nextInt();
			double e = sc.nextInt();
			double f = sc.nextInt();
			
			/*クラメルの公式*/
			double x = ((c * e) - (b * f)) / ((a * e) - (b * d));
			double y = ((a * f) - (c * d)) / ((a * e) - (b * d));
			
			BigDecimal x_bd = new BigDecimal(x);
			BigDecimal y_bd = new BigDecimal(y);
			
			x_bd = x_bd.setScale(3, BigDecimal.ROUND_HALF_UP);
			y_bd = y_bd.setScale(3, BigDecimal.ROUND_HALF_UP);
			
			String x_ans = x_bd.toString().format("%.3f", x_bd);
			String y_ans = y_bd.toString().format("%.3f", y_bd);
			
			System.out.println(x_ans+" "+y_ans);
		}
	}
}

Measured memory_bytes: 18224
#再起関数を使ったのが以下のもの、defで定義して漸化式を使う
#レベル N バーガーの下から X 層に含まれるパティの枚数」を f(N,X)とおく
n,x = gets.strip.split.map(&:to_i)
def f(n,x)
  if n==0
    return 1
  else
    if x==1
      return 0
    elsif 2<=x && x<=2**(n+1)-2
      return f(n-1,x-1)
    elsif x==2**(n+1)-1
      return f(n-1,x-2)+1
    elsif 2**(n+1)<=x && x<=2**(n+2)-4
      return f(n-1,2**(n+1)-3)+1+f(n-1,x-2**(n+1)+1)
    else
      return 2*f(n-1,2**(n+1)-3)+1
    end
  end
end
puts f(n,x)

Measured memory_bytes: 14272
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    a, b, c = rli()
    k = ri()
    for i in range(k):
        if a >= b:
            b *= 2
            continue
        if b >= c:
            c *= 2
    if a < b and b < c:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <iostream>
#include <list>
#include <vector>

using namespace std;

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

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

    list<int> b;
    for (int i = 0; i < n; i++) {
        if (n % 2 == 0) {
            if (i % 2 == 0) b.push_back(a[i]);
            else b.push_front(a[i]);
        } else {
            if (i % 2 == 0) b.push_front(a[i]);
            else b.push_back(a[i]);
        }
    }

    int c = 0;
    for (auto itr = b.begin(); itr != b.end(); ++itr, ++c) {
        if (c == n-1) cout << *itr << endl;
        else cout << *itr << " ";
    }

    return 0;
}
        


Measured memory_bytes: 9216
import math

N = int(input())
XY_list = []
for i in range(N):
    x, y = map(int, input().split())
    XY_list.append([x, y])


def distance(x1, y1, x2, y2):
    return math.sqrt((x1 - x2)**2 + (y1 - y2)**2)


ans = 0
for i in range(N):
    start = XY_list[i]
    for j in range(i+1, N):
        node = XY_list[j]
        ans += distance(start[0], start[1], node[0], node[1])

print(ans * 2 / N)

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

using namespace std;

int main(){
    string s;
    int k;
    cin >> k >> s;
    if (s.size() <= k)
    {
        cout << s << endl;
    }
    else
    {
        s = s.substr(0, k)+"...";
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
def check_RGB(c1, c2, c3):
    l = [c1, c2, c3]
    return ("R" in l) and ("G" in l) and ("B" in l)
    
N = int(input())
S = input()

R, G, B = 0, 0, 0
for i, s in enumerate(S):
    if s == "R":
        R += 1
    elif s == "G":
        G += 1
    else:
        B += 1

result = R * G * B

width = 1
while width * 2 < N:
    i = 0
    first = i
    mid = i + width
    last = i + width*2

    while last < N:
        if check_RGB(S[first], S[mid], S[last]):
            result -= 1

        i += 1
        first = i
        mid = i + width
        last = i + width*2

    width += 1

print(result)


Measured memory_bytes: 74216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc088b
{
    class abc088b
    {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().ToList().ConvertAll(int.Parse).OrderByDescending(x => x).ToList();

            int scoreAlice = 0, scoreBob = 0;
            for (var i = 1; i <= n; ++i) {
                if (i % 2 == 1)
                    scoreAlice += a[0];
                else
                    scoreBob += a[0];
                a.RemoveAt(0);
            }
            Console.WriteLine(scoreAlice - scoreBob);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); ++i)
#define all(a) (a).begin(),(a).end()
#define debug(x) cerr<<(#x)<<": "<<(x)<<endl;
typedef long long ll;
#define print(v) {cerr<<#v<<": ["; for(auto x : v){cerr<<x<<", "; } cerr<<"]"<<endl;}


bool is_op(char c){
    return c=='+' || c=='-' || c=='*' || c=='/';
}

int operate(int &e1,int &e2,char &op){
    if(op == '+') return e1+e2;
    if(op == '-') return e1-e2;
    if(op == '*') return e1*e2;
    if(op == '/') return e1/e2;
    assert(false);
}

set<int> calc(vector<set<int>> Es, vector<char> &ops, vector<int> &perm){
    int n = perm.size();
    if(n == 0){
        return Es[0];
    }
    vector<bool> done(n);
    rep(i,n){
        int p = perm[i];
        set<int> E;
        char op = ops[p];
        for(int e1 : Es[p]){
            for(int e2 : Es[p+1]){
                if(op == '/' && e2 == 0) continue;
                E.insert(operate(e1,e2,op));
            }
        }
        done[p] = true;
        // debug(p);
        Es[p] = E;
        Es[p+1] = E;
        int l = p-1, r = p+1;
        while(l>=0 && done[l]){
            Es[l] = E;
            l--;
        }
        while(r<n && done[r]){
            Es[r+1] = E;
            r++;
        }
        // cerr<<"----------"<<endl;
        // rep(k,n){
        //     // print(Es[k]);
        //     cerr<<ops[k]<<endl;
        // }
        // print(Es[n]);
        if(i == n-1){
            return E;
        }
    }
    assert(false);
}

set<int> all_check(vector<set<int>> &Es, vector<char> &ops){
    int n = ops.size();
    vector<int> perm(n);
    rep(i,n){
        perm[i] = i;
    }

    set<int> res;
    do{
        set<int> tmp = calc(Es,ops,perm);
        for(int t : tmp){
            res.insert(t);
        }
    }while(next_permutation(all(perm)));
    return res;
}


set<int> eval(string &s, int &i){

    vector<set<int>> Es;
    vector<char> ops;
    while(1){
        if(isdigit(s[i])){
            set<int> res;
            int num = 0;
            while(isdigit(s[i])){
                num = num*10 + s[i]-'0';
                i++;
            }
            res.insert(num);
            Es.push_back(res);
        }else if(s[i] == '('){
            i++; // (
            Es.push_back(eval(s,i));
            i++; // )
        }else{
            assert(false);
            Es.push_back(eval(s,i));
        }

        if(i == (int)s.size()) break;
        if(is_op(s[i])){
            ops.push_back(s[i]);
            i++;
        }else{
            break;
        }
    }
    set<int> res = all_check(Es,ops);
    // print(Es);
    // print(ops);
    // print(res);
    return res;

}

int main(){
    string s;
    while(cin>>s, s!="#"){
        // debug(s);
        int index = 0;
        set<int> st = eval(s, index);
        cout<<st.size()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3232
#include<stdio.h>
    #include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
    int r,g,b;
     scanf("%d %d %d",&r,&g,&b);
     int a=(10*g)+b;
     if(a%4==0)
      printf("YES\n");
     else printf("NO\n");
     return 0;
    }

Measured memory_bytes: 256
import sys
raw_input = sys.stdin.readline
N,K = map(int,raw_input().split())
nums = list(map(int,raw_input().split()))
dp = [10000000000 for x in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(K):
        if i+j+1 < N:
            dp[i+j+1] = min(dp[i]+abs(nums[i]-nums[i+j+1]),dp[i+j+1])
print dp[N-1]

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a == b)
    cout << "Draw" << endl;
  else if (a == 1 || ( b != 1 && a > b))
    cout << "Alice" << endl;
  else
    cout << "Bob" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int first = Integer.parseInt(scan.next());
        int second = Integer.parseInt(scan.next());
        int third = Integer.parseInt(scan.next());

        //long input = scan.nextLong();
//        String first = scan.next();
//        String second = scan.next();
        //for (int i = 1; i <=input; i++) {
        //}
        if(first+second+third >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}


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

int main()
{
	
	int a, b, i;
	char op;
	
	while(1)
	{
		cin >> a >> op >> b;
		if(op == '+'){
			cout << a + b  << endl;
		}else if(op == '-'){
			cout << a - b  << endl;
		}else if(op == '*'){
			cout << a * b  << endl;
		}else if(op == '/'){
			cout << a / b  << endl;
		}else{ if(op == '?')
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
namespace my_std{
	using namespace std;
	#define reg register
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
	#define FORit(templ,arr,i,a,b) for(register templ *i=(arr)+(a);i!=(arr)+(b)+1;++i)
	#define ROFit(templ,arr,i,a,b) for(register templ *i=(arr)+(b);i!=(arr)+(a)-1;--i)
	#define GO(x,p,e,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define MEM(x,v) memset(x,v,sizeof(x))
	#define fir first
	#define sec second
	#define pq priority_queue
	#define PII pair<int,int>
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	inline int read(){
		int ans=0,f=1;char c=getchar();
		while(!isdigit(c)){ f^=(c=='-'); c=getchar(); }
		for(;isdigit(c);c=getchar()) ans=ans*10+c-'0'; return f?ans:-ans;
	}
	const int mod = 1e9+7;
	inline void inc(int &x,const int &y){ x+=y; if(x>=mod) x-=mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res;}
	inline int gcd(int x,int y){ if(x<y) swap(x,y); return y?gcd(y,x%y):x; }
	#define FILE(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
}
using namespace my_std;

char S[100];

int main(){
	scanf("%s",S+1);
	int l = strlen(S+1) , ans = 0;
	FOR(i,1,l) ans += (S[i] == 'o');
	FOR(i,l + 1,15) ans += 1;
	puts(ans > 7?"YES":"NO");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int N;
vector<string> S;
vector<vector<int>> G;
vector<int> v;
bool ok;

int main(){
    cin >> N;
    S.resize(N);
    G.resize(N);
    v.resize(N);
    REP(i, N) cin >> S[i];
    REP(i, N) REP(j, N)
        if(S[i][j]=='1')
            G[i].push_back(j);

    int ans = 0;
    REP(i, N){
        ok = true;
        fill(v.begin(), v.end(), 0);
        v[i] = 1;
        queue<int> que;
        que.push(i);
        while(!que.empty()){
            int cur = que.front();
            que.pop();
            for(auto nxt : G[cur]){
                if(v[nxt] != 0 && v[nxt]%2 == v[cur]%2){
                    ok = false;
                    break;
                }
                if(v[nxt] != 0) continue;
                v[nxt] = v[cur] + 1;
                que.push(nxt);
            }
            if(!ok) break;
        }
        if(ok) ans = max(ans, *max_element(v.begin(), v.end()));
    }
    if(ans==0) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main(void)
{
    int n;      // [^
    int r;      // [^Ô
    int k;      // Ú±
    int t;      // Ú±[^Ô
    int p;      // pPbg
    int s, d, v;// pPbgîñ
    int connect[101][101];
    int i, j;
    int steps, step[101];
    int flag;
    
    memset(connect, 0, sizeof(connect));

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &r);
        scanf("%d", &k);
        for (j = 0; j < k; j++){
            scanf("%d", &t);
            connect[r][t] = 1;
        }
    }
    
    scanf("%d", &p);
    for (i = 0; i < p; i++){
        memset(step, 0, sizeof(step));
    
        scanf("%d%d%d", &s, &d, &v);
        step[s] = 1;
        steps = 1;
        do {
            flag = 0;
            for (j = 1; j <= n; j++){
                if (step[j] == steps){
                    for (k = 1; k <= n; k++){
                        if (connect[j][k] == 1){
                            if (step[k] == 0){
                                step[k] = steps + 1;
                                flag = 1;
                            }
                        }
                    }
                }
            }
            steps++;
        } while (flag == 1);
//    printf("<%d, %d=%d>\n", step[d], i, p);
        if (step[d] == 0 || step[d] > v){
            printf("NA\n");
        }
        else {
            printf("%d\n", step[d]);
        }
    }
    return (0);
}

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

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

        vector<stack<int> > q(n);
        vector<int> sum(n, 0);
        for(int i=0; i<n; ++i){
            int m;
            cin >> m;
            while(--m >= 0){
                int a;
                cin >> a;
                q[i].push(a);
                sum[i] += a;
            }
        }

        multiset<int> ms;
        for(int i=0; i<n; ++i)
            ms.insert(sum[i]);

        bool ng;
        while(*ms.rbegin() != 0){
            ng = true;
            for(int i=0; i<n; ++i){
                if(sum[i] == 0)
                    continue;

                ms.erase(ms.find(sum[i]));
                int x = sum[i] - q[i].top();
                if(abs(*ms.begin() - x) <= d && abs(*ms.rbegin() - x) <= d){
                    q[i].pop();
                    sum[i] = x;
                    ng = false;
                }
                ms.insert(sum[i]);
            }
            if(ng)
                break;
        }

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

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

#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast

int main()
{
	JJ;
	string str; cin >> str;
	int n = str.length();
	FOR(i, 0, n)
	if(str[i] == '7')
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;



	return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize "03"
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

multiset<int, greater<int> > s; 
vector<int> v[N];

signed main() {
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	IOS;
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		int a, b;
		cin >> a >> b;
		if(m-a+1 >= 1)
			v[m-a+1].push_back(b);
	}	
	int ans = 0;
	for(int i = m; i >= 1; i--){
		for(auto j: v[i])
			s.insert(j);
		if(!s.empty()){
			ans += *s.begin();
			s.erase(s.begin());
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8320
#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<ll,ll>;

int main() {
    ll K;
    cin>>K;
    ll ai=7;
    for(int i=1;i<=K;i++)
    {
      if(ai%K==0)
      {
        cout<<i<<endl;
        return 0;
      }
      ai=(ai*10+7)%K;
      //cout<<ai<<endl;
    }
    
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 3620
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;string s;
    cin >> n >> s;
    string ans="Yes";
    if(n%2==1) ans="No";
    REP(i,n/2){
        if(s[i]!=s[i+n/2]) ans="No";
    }
    cout << ans;
    return 0;
}

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

typedef long long ll;

int A[100002];

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A, A + n);
    int mx = A[n - 1];
    int mid = mx / 2;
    int diff = 1e9, id = 0;
    for(int i = 0; i < n - 1; i++) {
        if(abs(mid - A[i]) <= diff) {
            diff  = abs(mid - A[i]);
            id = A[i];
        }
    }
    cout << mx << " " << id << endl;
}

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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    cout << min(n, k) * x + max(0, n - k) * y << endl;

    return 0;
}


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


int main() {
    int N, K;
    cin >> N >> K;
    int64_t h[110000];
    for (int64_t i = 0; i < N; ++i) {
        cin >> h[i];
    }
    int64_t dp[110000];
    for (int64_t i = 0; i < 110000; ++i) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int64_t i = 0; i < N; ++i) {
        for (int64_t j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1920
#include <stdio.h>
#define N 100
#define INFTY 100000000

int min(int a,int b){
        if(a<b) {return a;}
        else return b;
}
int main (){
        int i,j,n,l,k;
        int m[N+1][N+1];
        int p[N+1];
        scanf("%d",&n);
        for (i=1; i<=n; i++) {
                scanf("%d%d",&p[i-1],&p[i]);
        }
        for(i=1; i<=n; i++) {
                m[i][i]=0;
        }
        for(l=2; l<=n; l++) {
                for(i=1; i<=n-l+1;i++) {
                        j=i+l-1;
                        m[i][j]=INFTY;
                                 for(k=i; k<=j-1; k++) {
                                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
                        }
                }

        }
      //  for (i=0; i<=n; i++) {
      //          printf("%d \n",p[i]);
      //   }
        printf("%d\n",m[1][n]);
        return 0;
}



Measured memory_bytes: 2048
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,i,j,a,b;
  int d[1010][1010],m[1010][1010];
  while(scanf("%d",&n),n){
    for(i=0;i<1010*1010;i++)d[i/1010][i%1010]=m[i/1010][i%1010]=0;
    while(n--){
      scanf("%d %d",&a,&b);
      m[a][b]=1;
    }
    scanf("%d",&n);
    while(n--){
      scanf("%d %d",&a,&b);
      m[a][b]=1;
    }
    for(i=1;i<1010;i++){
      for(j=1;j<1010;j++){
	d[i][j]=MAX(MAX(d[i-1][j],d[i][j-1]),d[i-1][j-1]+m[i][j]);
      }
    }
    printf("%d\n",d[1009][1009]);
  }
  return 0;
}

Measured memory_bytes: 8568
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

S = str(input())
ans = 0
if(S[len(S)-1]=="s"):
    print(S+"es")
else:
    print(S+"s")

#print(ans)


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

typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;

int add(ll a, ll b){
    return (a+b)%MOD;
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, k;
    cin >> n >> k;
    int res = 0;
    for(int i=k; i<=n+1; i++){
        ll l = 1LL*i*(i-1)/2;
        l %= MOD;
        l = add(l, MOD-1);
        ll r = 1LL*i*n - 1LL*i*(i-1)/2;
        r = add(r, MOD-l);
        res = add(res, r);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3640
/*
    ASEEN AAN 
            PINDAN AALE JATT!!!
                                */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1000000007;   
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,y,k,m;
const double pi1=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
//lli tot=0;
vector<lli> pf(string s) {
    int n = (int)s.length();
    vector<lli> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//map<ll,lli> dp;
//set<lli> s[100005];
lli dp[100005][3];
lli x[3][100005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x[0][i]>>x[1][i]>>x[2][i];
    }
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+x[0][i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+x[1][i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+x[2][i];
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
}

Measured memory_bytes: 4992
from collections import deque
n = int(input())
num753 = set()
q = deque([3,5,7])

#753数(準753も含む)の全列挙
while q:

    #右端の値を取り出す
    x = q.pop()

    #xが10**9以上になったら終了
    if x <= 10**9:

        #集合型のnum753にxを追加
        num753.add(x)

        #xを10倍して7,5,3をそれぞれ足した数をキューに追加
        q.append(x*10+3)
        q.append(x*10+5)
        q.append(x*10+7)
count = 0

#num753に格納してある値からn以下の753数を判定
for i in num753:
    if i <= n:
        lst = list(str(i))
        if "3" in lst and "5" in lst and "7" in lst:
            count += 1

print(count)

Measured memory_bytes: 6640
def main():
    # 行先、上限、逆辺
    def add_edge(From, to, cap):
        g[From][to] = cap
        g[to][-From-1] = 0

    def max_flow(s, t):
        flow = 0
        while True:
            used = [False]*n
            used2 = [0]*n
            q = [(s, 10**6)]
            ans = [0]
            while q:
                v, f = q[-1]
                a = ans[0]
                if a == 0:
                    if v == t:
                        ans[0] = f
                        continue
                    gkv, gv = gkey[v], g[v]
                    l, used[v] = len(gkv), True
                    while True:
                        i = used2[v]
                        used2[v] += 1
                        if i < l:
                            to = gkv[i]
                            cap, to2 = gv[to], [to, -to-1][to < 0]
                            if (not used[to2]) and cap:
                                q.append((to2, min(f, cap)))
                                break
                        else:
                            q.pop()
                            ans[0] = 0
                            break
                else:
                    q.pop()
                    if q:
                        v = q[-1][0]
                        i = used2[v]-1
                        to = gkey[v][i]
                        g[v][to] -= a
                        g[[to, -to-1][to < 0]][-v-1] += a
            if not ans[0]:
                return flow
            flow += ans[0]

    h, w = map(int, input().split())
    n = h+w+2
    g = [dict() for _ in range(n)]
    for i in range(h):
        A = input()
        for j in range(w):
            if A[j] == "o":
                add_edge(i, j+h, 1)
                add_edge(j+h, i, 1)
            elif A[j] == "S":
                add_edge(h+w, i, 10**6)
                add_edge(h+w, j+h, 10**6)
            elif A[j] == "T":
                add_edge(i, h+w+1, 10**6)
                add_edge(j+h, h+w+1, 10**6)
    gkey = [list(i.keys()) for i in g]

    ans = max_flow(h+w, h+w+1)
    if ans >= 10**6:
        print(-1)
    else:
        print(ans)


main()


Measured memory_bytes: 8436
#include<stdio.h>

 long long int w[100000];
 long long int P,n,truck;

 long long int count(int P){
          long long int i,sum;
          i=0;
          for(long long int j=0;j<truck;j++){
                          sum=0;
                          while(sum+w[i]<=P){
                                   sum+=w[i];
                                   i++;
                                   if(i==n)return n;
                                   }
                          }
          return i;
          }
          

 long long int solve(){
          int mid,right,left,v;
          left=0;
          right=100000*10000;

          while(right-left>1){
                   mid=(left+right)/2;
                   v=count(mid);
                   if(v>=n)right=mid;
                   else left=mid;
                   }
         return right;
         }
                  


 int main(){
       int i,ans;
       scanf("%d%d",&n,&truck);
       for(i=0;i<n;i++){
                  scanf("%d",&w[i]);
                  }
       ans=solve();
       printf("%d\n",ans);
       return 0;
       }
       


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

int main() {
    string S ;
    cin >> S ; // S is 'Sunny', 'Cloudy', or 'Rainy'.
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
         else cout << "Sunny" << endl;
	return 0;
}

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

int main(){
    
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        cin >> s.at(i);
        sort(s.at(i).begin(), s.at(i).end());
        mp[s.at(i)]++;
    }
    
    long long pattern = 0;
    
    for(auto x: mp){
        pattern += x.second * (long long)(x.second - 1) / 2;
    }
    
    cout << pattern << endl;
    
}


Measured memory_bytes: 18176
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}


// ----------------------------------------------------------------------------
int main(){
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<ll>> a(n,vector<ll> (m));
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin >> a[i][j];
    }
  }
  vector<vector<ll>> b(m,vector<ll> (l));
  for(int i=0; i<m; i++){
    for(int j=0; j<l; j++){
      cin >> b[i][j];
    }
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      ll sum=0;
      for(int k=0; k<m; k++){
        sum += a[i][k] * b[k][j];
      }
      if(j){
        cout << " ";
      }
      cout << sum;
    }
    cout << endl;
  }
  return 0;
}



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

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

    int n, m, k;
    cin >> n >> m >> k;
    REP(i, n + 1){
        REP(j, m + 1){
            if((i * (m - j) + j * (n - i)) == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, a, b, num[5007], dp[5007][5007], res = 1e18;
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
signed main()
{
	n = read();
	a = read();
	b = read();
	for (int i = 1; i <= n; i++)
		num[i] = read();
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= n; j++)
			if (num[i] > j)
			{
				dp[i][j] = min(dp[i][j], dp[i - 1][j] + a);
				dp[i][num[i]] = min(dp[i][num[i]], dp[i - 1][j]);
			}
			else dp[i][j] = min(dp[i][j], dp[i - 1][j] + b);
	for (int i = 0; i <= n; i++)
		res = min(res, dp[n][i]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 196096
N, M, Q = map(int, input().split())

a = []
b = []
c = []
d = []

ans = 0


def dfs(A):
    global ans
    if len(A) == N:
        now = 0
        for i in range(Q):
            if A[b[i]] - A[a[i]] == c[i]:
                now += d[i]
        ans = max(now, ans)
        return

    if not A:  # Aが空リストのとき
        tmp = 1
    else:
        tmp = A[-1]

    while tmp <= M:
        dfs(A + [tmp])
        tmp += 1


for i in range(Q):
    o, p, q, r = map(int, input().split())
    o -= 1
    p -= 1
    a.append(o)
    b.append(p)
    c.append(q)
    d.append(r)
dfs([])
print(ans)


Measured memory_bytes: 9216
def pow(x, n):
    if n == 0:
        return 1
    res = pow(x * x % MOD, n//2)
    if n % 2 == 1:
        res = res * x % MOD
    return res

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
 
MOD = 998244353
N, M, K = map(int, input().split())

fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 2):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

ans = 0
Mm1 = M-1
Nm1 = N-1
Mm1pow = pow(Mm1, (N-K-1))
for k in range(K, -1, -1):
    ans = (ans + (M * cmb(Nm1, k, MOD) * Mm1pow)) % MOD
    Mm1pow = (Mm1pow * Mm1) % MOD
print(ans)


Measured memory_bytes: 117448
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> v(n);
        for(int i=0; i<n; ++i) {
            cin >> v[i];
        }
        sort(v.begin(), v.end());
        cout << accumulate(v.begin()+1, v.end()-1, 0) / (v.size()-2) << endl;
    }
}

Measured memory_bytes: 3068
"""
author : halo2halo
date : 19,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

a = int(readline())
s = readline()

if a >= 3200:
    print(s)
else:
    print('red')


Measured memory_bytes: 2940
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<int> vl;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) {cout<<n<<"\n" ; return ;}
#define po(n) cout << n <<"\n " 
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
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");}
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...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#ifndef ONLINE_JUDGE
//#ifndef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
//#else
//#define debug(x...)
//#endif
//#define int ll 
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
long const M=1e9+7;
const long mxN =1e5+2 ;
const ll INF =1e18;
void solve(){ 
  char a ;cin >> a ;
  if(a<='Z' &&a>='A')pf("A")
  else pf("a")
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  // ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}


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

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

    vector<int> a(N);
    for (auto& x : a) cin >> x;

    int idx = 0;
    vector<vector<int>> vvi(H, vector<int> (W));
    for (int i = 0; i < H; i++) {
        if (i % 2) {
            for (int j = W - 1; j >= 0; j--) {
                vvi[i][j] = idx + 1;
                a[idx]--;
                if (!a[idx]) {
                    idx++;
                }
            }
        }
        else {
            for (int j = 0; j < W; j++) {
                vvi[i][j] = idx + 1;
                a[idx]--;
                if (!a[idx]) {
                    idx++;
                }
            }
        }
    }

    for (auto vi : vvi) {
        for (auto x : vi) {
            cout << x << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
def main():
    K = int(input())

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
    
main()

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second

const int MAXN = 100005;
long long a[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n, l;
    cin >> n >> l;
    int pos = -1;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
        if (i)
        {
            if ((a[i] + a[i-1]) >= l)
            {
                pos = i;
            }
        }
    }

    if (pos == -1)
    {
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;
    for (int i=0;i<pos-1;i++)
    {
        cout << i + 1 << endl;
    }

    for (int i=n-1;i>pos;i--)
    {
        cout << i << endl;
    }

    cout << pos << endl;
    return 0;
}



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

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

    for(int i=1; i<=9; i++) {
        if(N%i==0 && N/i<10) {
            printf("Yes");
            return 0;
        }
    };
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  vector<long long>v(n);
  for(int i = 0; i < n; i++)
  {
      cin>>v[i];
  }
  long long mi = INT_MAX, total;
  for(int j = 1; j <= 100; j++)
  {
    total = 0;
    for(int i = 0; i < n; i++)
    {
        total += (v[i] - j)*(v[i] - j);    
    }
    if(mi > total) mi = total;
  }
  cout<<mi;
}   

Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int n,m,i,j;
		char a[50][51],b[50][51];
		scanf("%d%d",&n,&m);
		for(i=0;i<n;i++)scanf("%s",a[i]);
		for(i=0;i<m;i++)scanf("%s",b[i]);
		for(i=0;i<=n-m;i++){
				for(j=0;j<=n-m;j++){
						int k,l,f=0;
						for(k=0;k<m;k++){
								for(l=0;l<m;l++){
										if(a[i+k][j+l]!=b[k][l]){
												f=1;
												break;
										}
								}
								if(f==1)break;
						}
						if(f==0){
								puts("Yes");
								return 0;
						}
				}
		}
		puts("No");
		return 0;
}


Measured memory_bytes: 128
const val MOD = (1e9 + 7).toLong()

var fact = Array(200001) { 1L }
var finv = Array(200001) { 1L }

fun comb(n: Int, k: Int): Long {
    if (n < k || k < 0) return 0L
    return fact[n] * finv[n - k] % MOD * finv[k] % MOD
}

fun pow(x: Long, n: Long): Long {
    if (n == 0L) return 1L
    var res = pow(x * x % MOD, n / 2)
    if (n % 2 == 1L) res = res * x % MOD
    return res
}

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    for (i in 1..200000) {
        fact[i] = fact[i - 1] * i % MOD
    }
    for (i in 1..200000) {
        finv[i] = pow(fact[i], MOD - 2)
    }

    var rem = m
    var ans = 1L
    for (i in 2..Math.sqrt(m.toDouble()).toInt()) {
        var cnt = 0
        while (rem % i == 0) {
            cnt++
            rem /= i
        }
        ans = ans * comb(cnt + n - 1, cnt) % MOD
    }
    if (rem != 1) ans = ans * comb(n, 1) % MOD

    println(ans)
}

Measured memory_bytes: 54844