akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    vector<long long> num(1100000, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        auto pf = prime_factorize(A[i]);
        for (auto p : pf) num[p.first] = max(num[p.first], p.second);
    }

    mint LCM = 1;
    for (int v = 2; v < 1100000; ++v) {
        LCM *= modpow(mint(v), num[v]);
    }

    mint res = 0;
    for (auto a : A) {
        res += LCM / a;
    }
    cout << res << endl;
}

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

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        System.out.println(n*n*n);

    }


    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N,M,X,Y;
	vector<llong> x,y;

	cin >> N >> M >> X >> Y;
	x.resize(N);
	y.resize(M);
	for(int i = 0; i < N; i++)
		cin >> x[i];
	for(int i = 0; i < M; i++)
		cin >> y[i];

	sort(BE(x), greater<llong>());
	sort(BE(y));

	int zl = x[0]+1;
	int zu = y[0];

	bool check = false;
	for(int i = zl; i <= zu; i++)
		if(X < i && i <= Y)
			check = true;

	if(check)
		cout << "No War" << endl;
	else
		cout << "War" << endl;

	return 0;
}

Measured memory_bytes: 256
//B-81
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >>N;
    for(int i=1;i<10;i++){
        if(N/i<10 && N%i==0){
            cout<< "Yes";
          	return 0;
        }        
    }
	cout <<"No";

}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int k = Integer.parseInt(br.readLine());
      
      int val=0;
      int ans = -1;
      
      for(int i = 1 ; i <= 1e6 ; i++){
       	val = val * 10 + 7;
        
        if(val % k == 0){
         	ans = i;
          break;
        }
        
        val = val%k;
      }
      
      System.out.println(ans);
    }
}

Measured memory_bytes: 32676
#include <iostream>
using namespace std;
bool prime(int n){
	for (int i=2;i<n;i++){
		if (n%i==0){
			return false;
		}
	}
	return true;
}
int main() {
	int n;
	cin>>n;
	int arr[n];
	int p=2;
	for (int i=0; i<n; i++){
		p++;
		while(!prime(p) or p%5!=1){
			p++;
		}
		arr[i]=p;
	}
	for (int i=0; i<n; i++){
		cout<< arr[i] << " ";
	}cout<<endl;
}

Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {

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

		int a = Integer.parseInt(sc.next());
		
		a = a % 10;
		
		if(a == 3) {
			System.out.println("bon");
		}
		else if(a == 0 || a == 1 || a == 6 || a == 8) {
			System.out.println("pon");
		}
		else {
			System.out.println("hon");
		}
	}

}


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

using namespace std;

string solve(vector<int>& xs, int k)
{
    for (int i = 0; i < 5; ++i)
        for (int j = i + 1; j < 5; ++j)
            if (xs[j] - xs[i] > k)
                return ":(";

    return "Yay!";
}

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

    vector<int> xs(5);

    for (int i = 0; i < 5; ++i)
        cin >> xs[i];

    int k;
    cin >> k;

    auto ans = solve(xs, k);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (data) {
  let sum = 0
  for (let i = 1; i < Number(data) + 1; i++) {
    if(i % 3 !== 0 && i % 5 !== 0){
      sum = sum + i
    }
  }
  console.log(sum)
});

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 3005;

int a[N];
ll dp[N][N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i=1; i<=n; i++) cin >> a[i];
	for (int i=1; i<=n; i++) {
		if (n & 1) dp[i][i] = a[i];
		else dp[i][i] = -a[i];
	}
	for (int s=2; s<=n; s++) {
		for (int i=1; i<=n-s+1; i++) {
			if ((n - s + 1) & 1) {
				dp[i][i+s-1] = max(dp[i][i+s-2] + a[i+s-1], dp[i+1][i+s-1] + a[i]);
			}
			else {
				dp[i][i+s-1] = min(dp[i][i+s-2] - a[i+s-1], dp[i+1][i+s-1] - a[i]);
			}
		}
	}
	cout << dp[1][n] << "\n";
    return 0;
}


Measured memory_bytes: 70016
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
#define out(a) printf("%d",a)
#define ln printf("\n")
const int N=1e5+50;
const int MOD=1e9+7;
const int inf=0x7f7f7f7f;
using namespace std;
int n,x,num,l;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
	  scanf("%d",&x);
	  if (i==1) num=x;
	  else num^=x;
	}
	if (!num) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int func();
string s;
int p;

int main(){
  getline(cin,s);
  reverse(s.begin(),s.end());
  cout<<func()<<endl;
}

int func(){
  int res;
  if('0'<=s[p]&&s[p]<='9'){
    int num=s[p]-'0'; p++;
    int k=10;
    while('0'<=s[p]&&s[p]<='9') num=num+(s[p]-'0')*k,p++,k*=10;
    p++;
    return num;
  }
  else{
    char c=s[p++];
    p++;
    int a=func(),b=func();
    if(c=='+') return b+a;
    if(c=='-') return b-a;
    return b*a;
  }
}

Measured memory_bytes: 1176
def segfunc(x,y):
    return x|y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
n=int(input())
S=input()
Q=int(input())

num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
alphabet={key:alphabetlist.index(key)  for key in alphabetlist}

data=[0 for i in range(0,n)]
for i in range(0,n):
    data[i]=2**(alphabet[S[i]])

init(data)

ans=[]
for i in range(0,Q):
    q,a,b=input().split()
    if q=='1':
        update(int(a)-1,2**(alphabet[b]))
    else:
        a=int(a)
        b=int(b)
        ans.append(query(a-1,b))

for i in range(len(ans)):
    x=ans[i]
    print(bin(x).count('1'))

Measured memory_bytes: 85452
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int ans=max({a*c,a*d,b*c,b*d});
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 3608
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d

N = int(input())
S = input()

ans = 0
for i in range(1000):
    key = str(i).zfill(3)
    first = S.find(key[0])
    if first == -1:
        continue
    second = S[first + 1:].find(key[1])
    if second == -1:
        continue
    third = S[first + second + 2:].find(key[2])
    if not third == -1:
        #print(key, first, second, third)
        ans += 1
print(ans)


Measured memory_bytes: 72528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll N, M; cin >> N >> M;
    UnionFind Tree(M);
    bool L[M];
    memset(L, false, sizeof(L));
    for(int i = 0; i < N; i++){
        int k; cin >> k;
        int x ; cin >> x; x--; L[x] = true;
        for(int j = 1; j < k; j++){
            int y; cin >> y; y--; L[y] = true;
            Tree.unite(x, y);
        } 
    }
    int parent[M];
    for(int i = 0; i < M; i++) parent[i] = Tree.root(i);
    for(int i = 0; i < M-1; i++){
        if( (L[i] && L[i+1]) &&  parent[i] != parent[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;





    /*
    vector<set<int>> Tree(M);
    for(int i = 0; i < N; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int x; cin >> x;
            Tree[x].insert(i);
        }
    }
    set<int> ST; ST = Tree[0];
    for(int i = 1; i < M; i++){
        for(auto )
    }*/
}


Measured memory_bytes: 1152
# coding: utf-8

import math

def get_primenumber(number):
    prime_list = []
    
    search_list = list(range(2,number+1))
    while True:
      
      if search_list[0] > math.sqrt(number):
        
        prime_list.extend(search_list)
        break
      else:
        
        head_num = search_list[0]
        prime_list.append(head_num)
        
        search_list.pop(0)
        
        search_list = [num for num in search_list if num % head_num != 0]
    return max(prime_list)

    
a = int(input())
r_before = get_primenumber(a)
s_after = get_primenumber(a)
count = a + 1
if a != r_before:
    while r_before == s_after:
        s_after = get_primenumber(count)
        count += 1
    
print(s_after)






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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  string ans = "No";
  for(int i=0; i<n/4+1; i++){
    int tmp = n - 4*i;
    if(tmp%7==0) ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    vector<bool> flg(n);
    rep(i, n) flg[i] = 0;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        switch(t[i]) {
            case 'r':
                if(i - k >= 0 && t[i - k] == 'r') {
                    if(flg[i - k] == 0) {
                        ans += p;
                        flg[i] = 1;
                    }
                } else {
                    ans += p;
                    flg[i] = 1;
                }
                break;
            case 's':
                if(i - k >= 0 && t[i - k] == 's') {
                    if(flg[i - k] == 0) {
                        ans += r;
                        flg[i] = 1;
                    }
                } else {
                    ans += r;
                    flg[i] = 1;
                }
                break;
            case 'p':
                if(i - k >= 0 && t[i - k] == 'p') {
                    if(flg[i - k] == 0) {
                        ans += s;
                        flg[i] = 1;
                    }
                } else {
                    ans += s;
                    flg[i] = 1;
                }
                break;
        }
        /*cout << 'i' << i << ' ' << ans << endl;
        rep(i, n) cout << flg[i];
        cout << endl;*/
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class BitSum:
    def __init__(self, n):
        self.n = n + 1
        self.table = [0] * self.n

    def add(self, i, x):
        i += 1
        while i < self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

n,q=MI()
cc=LI()
lri=[]
mx=500005
#mx=10
for i in range(q):
    l,r=MI()
    l-=1
    lri.append((l,r-1,i))

lri.sort(key=lambda x:x[1])

#print(lri)
last=[-1]*mx
st=BitSum(mx)
ans=[0]*q
now=0
for l,r,i in lri:
    for j in range(now,r+1):
        c=cc[j]
        pre=last[c]
        if pre!=-1:st.add(pre,-1)
        last[c]=j
        st.add(j,1)
    #print(l,r,st.tree,last)
    now=r+1
    ans[i]=st.sum(r)-st.sum(l-1)
print(*ans,sep="\n")



Measured memory_bytes: 190572
#include <iostream>

using namespace std;

int count_prime(int n)
{
    int c = 0;
    bool ps[n+1];

    ps[0] = false;
    ps[1] = false;

    for(int i = 2; i <= n; ++i)
        ps[i] = true;

    for(int i = 2; i <= n; ++i){
        if(ps[i]){
            for(int j = i * 2; j <= n; j += i)
                ps[j] = false;
        }
    }

    for(int i = 1; i <= n; ++i){
        if(ps[i])
            ++c;
    }
    return c;
}

int main()
{
    int n;
    int c;

    while(cin >> n){
        c = count_prime(n);
        cout << c << endl;
    }
    return 0;
}

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

int x(double a) {
  if(a<35.5) return 7;
  if(a<37.5) return 6;
  if(a<40) return 5;
  if(a<43) return 4;
  if(a<50) return 3;
  if(a<55) return 2;
  if(a<70) return 1;
  return 0;
}

int y(double a) {
  if(a<71) return 7;
  if(a<77) return 6;
  if(a<83) return 5;
  if(a<89) return 4;
  if(a<105) return 3;
  if(a<116) return 2;
  if(a<148) return 1;
  return 0;
}

int main() {
  double a,b;
  while(cin >> a >> b) {
    int s=x(a),t=y(b);
    int z=min(s,t);
    if(z==7) cout << "AAA" << endl;
    if(z==6) cout << "AA" << endl;
    if(z==5) cout << "A" << endl;
    if(z==4) cout << "B" << endl;
    if(z==3) cout << "C" << endl;
    if(z==2) cout << "D" << endl;
    if(z==1) cout << "E" << endl;
    if(z==0) cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 1216
#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;
typedef long long ll;

int N;
int P[15];

int main(){
  cin >> N;
  rep(i, N) cin >> P[i];

  sort(P, P+N);
  int ans = 0;
  rep(i, N-1) ans += P[i];
  ans += (P[N-1] / 2);

  cout << ans << endl;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int a,b; cin >> a >> b;

	cout << max(a+b,max(a-b,a*b)) << endl;

	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n, k;
    cin >> n >> k;
    vector<ll> h;
    REP(i, n) {
        ll input;
        cin >> input;
        h.push_back(input);
    }

    SORT(h);

    ll min_diff = INF;
    REP(i, h.size()-(k-1)) {
        min_diff = min(min_diff, h[i+k-1] - h[i]);
    }
    P(min_diff);

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int n, m;
  cin>>n>>m;
  vvi u(n);
  REP(i, m) {
    int a,b;
    cin>>a>>b;
    a--; b--;
    u[a].push_back(b);
    u[b].push_back(a);
  }
  vi dist(n, -1);
  queue<int> q;
  q.push(0);
  dist[0] = 0;

  while (!q.empty()) {
    int now = q.front(); q.pop();
    REP(i, u[now].size()) {
      int nxt = u[now][i];
      if (dist[nxt] != -1) continue;
      dist[nxt] = now;
      q.push(nxt);
    }
  }
  bool ok = true;
  REP(i, n) {
    if(dist[i]==-1) {
      ok = false;
      break;
    }
  }
  if(ok) {
    cout << "Yes" << endl;
    FOR(i, 1, n) cout << dist[i]+1 << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
#define INF lli(1e19)

#define forz(i, n) for (lli i = 0; i < n; i++)
#define fore(i, m, n) for (lli i = m; i < n; i++)
#define rforz(i, n) for (lli i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (lli i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define newline cout<<endl;
//#define endl "\n"



inline lli power(lli x, lli y, lli p = mod)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

inline lli modadd(lli a, lli b, lli m = mod)
{
    a += b;
    if (a >= m)
        a -= m;
    return a;
}

inline lli modmul(lli a, lli b, lli m = mod)
{
    return ((a % m) * (b % m)) % m;
}

inline lli modi(lli a, lli m = mod) { return power(a, m - 2, m); }
inline lli md(lli x) {if(x>=0)return x; return -x;}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
const lli mxN = 2e5;
lli n,m,k,r[mxN],p[mxN];
//lli u, v;
//bool vis[mxN];
//vector<lli> adj[mxN];
//void init()
//{
//    forz(i,n) vis[i]=0, adj[i].clear();
//}
lli gP(lli x)
{
    if(x==p[x]) return x;
    return p[x]=gP(p[x]);
}

void jC(lli x, lli y)
{
    x = gP(x);
    y = gP(y);
    if(x!=y)
    {
        if(r[x]<r[y])
            p[x]=y;
        else if(r[x]>r[y])
            p[y]=x;
        else
            p[x]=y,r[y]++;
    }
}

int32_t main()
{
    kira;

    lli T=1;
    //cin>>T;

    while(T--)
    {
        cin>>n>>m;
        forz(i,n) p[i]=i,r[i]=1;
        forz(i,m)
        {
            lli t,x,y;
            cin>>t;
                cin>>x>>y;
            if(t)
            {
                if(gP(x)==gP(y)) cout<<1<<endl;
                else cout<<0<<endl;
            }
            else jC(x,y);

        }
    }

    return 0;

}


Measured memory_bytes: 6600
main = interact $ unlines . map (today2004 . map read) . takeWhile (notElem "0") . map words . lines
today2004 [m,d] = case (mod days 7) of {0->"Wednesday";1->"Thursday";2->"Friday";3->"Saturday";4->"Sunday";5->"Monday";6->"Tuesday"}
 where days = (sum $ take (m-1) [31,29,31,30,31,30,31,31,30,31,30,31]) + d

Measured memory_bytes: 4060
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        a: [usize; n]
    }

    let mut res = 0;
    let mut right = 0;
    let mut sum = 0;

    for left in 0..n {
        while right < n && (sum ^ a[right]) == (sum + a[right]) {
            sum += a[right];
            right += 1;
        }

        res += right - left;
        if left == right { right += 1 } else {sum -= a[left]}
    }

    println!("{}", res);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


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

using namespace std;

int main(void) {
	int num, i, a, t = 0;
	vector<int> d(100001, 0);
	cin >> num;
	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		d[a]++;
	}
	for (i = 1; i <= 100000; i++) {
		if (d[i] & 1)
			num -= d[i] - 1;
		else if (d[i] > 0) {
			t++;
			num -= d[i] - 2;
		}
	}
	num -= t + (t & 1);
	cout << num << "\n";
	return 0;
}

Measured memory_bytes: 640
n = int(input())
lis = [0]*n
for i in range(1, n+1):
    j = 1
    while i*j <= n:
        lis[i*j-1] += 1
        j += 1
lis[0] = 1
ans = 0
for i in range(len(lis)):
    ans += (i+1)*lis[i]
print(ans)

Measured memory_bytes: 145640
<?php
list($h,$w) = explode(" ",trim(fgets(STDIN)));
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));

$i = 0;
while($i < $h){
$j = 0;
while($j < $w){
$g[$i][$j] = 0;
++$j;
}
++$i;
}


$f = 0;
$o = 0;
$i = 0;
while($i < $n){
$j = 0;
while($j < $a[$i]){
if($f % 2 == 0){
if($o < $w){
$g[$f][$o] = $i + 1;
++$o;
}else{
++$f;
$o = $w - 1;
$g[$f][$o] = $i + 1;
--$o;
}
}else{
if($o >= 0){
$g[$f][$o] = $i + 1;
--$o;
}else{
++$f;
$o = 0;
$g[$f][$o] = $i + 1;
++$o;
}
}
++$j;
}
++$i;
}

foreach($g as $v){
echo implode(" ",$v) . PHP_EOL;
}

Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n;cin>>n;
    pair<ll,ll> p;
    ll tmp = INF;
    rep(a,1,sqrt(n)+1){
        if(n % a == 0){
            ll b = n/a;
            if(tmp > abs(a-b)){
                tmp = abs(a-b);
                p = mp(a,b);
            }
        }
    }
    cout << p.fi-1 + p.se-1 << ednl;
}

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

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int

#define M_DEBUG 1
#define PI 3.141592653589793

#define DEBUG 1

int main(void) {
    int n, i;

    cin >> n;

    vector<int> a(n);

    for (i = 0; i < n; ++i) cin >> a[i];

    vector<int> b;

    for (i = n - 1; i >= 0; --i)
        if ((n % 2 && !(i % 2)) || (!(n % 2) && (i % 2))) b.push_back(a[i]);

    for (i = 0; i < n; ++i)
        if ((n % 2 && (i % 2)) || (!(n % 2) && !(i % 2))) b.push_back(a[i]);

    for (i = 0; i < n; ++i) cout << b[i] << ' ';
    cout << endl;

    return 0;
}

Measured memory_bytes: 3828
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toLong() }.toLongArray()
    val b = readLine()!!.split(' ').map { it.toLong() }.toLongArray()

    val max = b.sum() - a.sum()
    var x = 0L

    for (i in 0 until n) {
        if (a[i] < b[i]) {
            x += (b[i] - a[i] + 1) / 2
        }
    }

    println(if (x <= max) "Yes" else "No")
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
template <class T = int>
T in() {
  T x;
  std::cin >> x;
  return (x);
}

using namespace std;
typedef long long ll;

int main() {
  int n = in();
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i, n) { a[i] = in(); }
  rep(i, n) { b[i] = in(); }
  rep(i, n) { c[i] = in(); }
  sort(all(a));
  sort(all(b));
  sort(all(c));
  ll ans = 0;
  rep(i, n) {
    ll tmp = lower_bound(all(a), b[i]) - a.begin();
    tmp *= c.end() - upper_bound(all(c), b[i]);

    ans += tmp;
  }

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


Measured memory_bytes: 1408
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

int main(){
    long long a,n,num,ans=100000000000;
    cin>>n;
    for (int i=1;i<=sqrt(n);i++){
        if (n%i==0){
            a=n/i;
            num=0;
            while(a!=0)num++,a/=10;
            ans=min(ans,num);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3680
import sys
from operator import itemgetter

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


def main():
    N = int(readline())
    A = [0] * N
    for i in range(N):
        s, p = readline().strip().split()
        p = int(p)
        A[i] = (s, p, i + 1)

    A.sort(key=itemgetter(1), reverse=True)
    A.sort(key=itemgetter(0))
    for s, p, i in A:
        print(i)

    return


if __name__ == '__main__':
    main()


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

int main(){
  long N,X,all=0;
  cin >> N >> X;
  vector<long> A(N);
  for(long i=0;i<N;i++){
    cin >> A.at(i);
    all += A.at(i);
  }
  sort(A.begin(),A.end());
  if(X > all){
    cout << N-1 << endl;
  }else if(X<all){
    int sum = 0;
 	while(X>-1){
      X = X - A.at(sum);
      sum++;
    }
  	cout << sum-1 << endl;
  }else{
    cout << N << endl;
  }
  return 0;
}

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

#define rep(i,a,b) for (auto i = (a); i < (b); i++)
typedef long long ll;
const ll INF = 1000000000000000000;

int h[100100];
ll mn[100100];
int n;

ll dp(int at) {
    if (at == n-1) {
        return 0;
    }
    if (mn[at] != -1) {
        return mn[at];
    }

    mn[at] = INF;
    rep(i,1,3) {
        if (at + i <= n-1) {
            mn[at] = min(mn[at], abs(h[at] - h[at+i]) + dp(at+i));
        }
    }
    return mn[at];
}

int main() {
    cin >> n;

    rep(i,0,n) {
        cin >> h[i];
    }

    memset(mn, -1, sizeof(mn));
    cout << dp(0) << endl;

    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N; cin >> N;
	vector<double> A(N);
	rep(i,N) cin >> A[i];
	double sum = 0;
	rep(i,N) {
		sum += (1 / A[i]);
	}
	cout << 1 / sum << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
S=str(input())
length=0
longest=0

for i in range(len(S)):
    if S[i]!='A' and S[i]!='C' and S[i]!='G' and S[i]!='T':
        length=0
    else:
        length+=1
    if length>longest:
        longest=length
print(longest)

Measured memory_bytes: 3060
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

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

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

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    for(int i = 1; i <= 100000; i++){
        if((a * i) % b == c % b){
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using namespace std;
#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const ll MOD = 1e9 + 7;
const int MAX = 5000010;
int lastInc[MAX] = {};

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (auto &x : a)
        cin >> x;
    int curr_max = a[0];
    int cnt = 1;
    for (size_t i = 1; i < n; i++)
    {
        if (a[i] >= curr_max)
            cnt++;
        curr_max = max(curr_max, a[i]);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
from queue import Queue

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

D = [a - b for a, b in zip(A, B)]
Dm = [d for d in D if d < 0]
sum_Dm = abs(sum(Dm))

if sum_Dm == 0:
    print(0)
    exit(0)

Dp = [d for d in D if d > 0]
Dp.sort(reverse=True)

que = Queue()
for d in Dp:
    que.put(d)

cnt = 0
while not que.empty():
    p = que.get()
    cnt += 1
    sum_Dm -= p
    if sum_Dm <= 0:
        print(len(Dm) + cnt)
        exit(0)

print(-1)


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

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> pos(N);
    rep(i, N) cin >> pos[i].first >> pos[i].second;

    int par = (abs(pos[0].first) + abs(pos[0].second)) % 2;
    bool no = false;
    rep(i, N) {
        int par2 = (abs(pos[i].first) + abs(pos[i].second)) % 2;
        pos[i] = {pos[i].first + pos[i].second, pos[i].first - pos[i].second};
        if (par2 != par) {
            no = true;
        }
    }

    if (no) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> d;
    for (int i=30; i>=0; --i) d.push_back(1LL<<i);
    if (par%2 == 0) d.push_back(1);
    cout << d.size() << endl;
    rep(i, d.size()) cout << d[i] << " ";
    cout << endl;

    rep(i, N) {
        int xdir, ydir;
        ll xsum = 0, ysum = 0;
        rep(j, d.size()) {
            if (xsum <= pos[i].first) xdir = 1, xsum += d[j];
            else xdir = -1, xsum -= d[j];
            if (ysum <= pos[i].second) ydir = 1, ysum += d[j];
            else ydir = -1, ysum -= d[j];

            if (xdir == 1 and ydir == 1) cout << "R";
            else if (xdir == 1 and ydir == -1) cout << "U";
            else if (xdir == -1 and ydir == -1) cout << "L";
            else cout << "D";
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

string ans;
ll DP[3100][3100];
pair<ll, ll> DPrev[3100][3100];
string S, T;

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

    int SL = S.size();
    int TL = T.size();

    REP(i,SL+1){
        REP(j,TL+1){
            DP[i][j] = 0;
        }
    }

    REP(i,SL+1){
        REP(j,TL+1){
            DPrev[i][j] = make_pair(-1, -1);
        }
    }

    REPi(i,1,SL+1){
        REPi(j,1,TL+1){
            char x = S[i-1];
            char y = T[j-1];
            ll tmp = 0;
            if(x == y){
                DPrev[i][j] = make_pair(i-1, j-1);
                chmax(tmp, DP[i-1][j-1] + 1);
            }

            if(tmp < DP[i-1][j]){
                DPrev[i][j] = make_pair(i-1, j);
                chmax(tmp, DP[i-1][j]);
            }

            if(tmp < DP[i][j-1]){
                DPrev[i][j] = make_pair(i, j-1);
                chmax(tmp, DP[i][j-1]);
            }
            DP[i][j] = tmp;
        }
    }

    //REP(i,SL+1){
    //    REP(j,TL+1){
    //        printf("%lld ", DP[i][j]);
    //    }
    //    printf("\n");
    //}

    ll num = DP[SL][TL];

    string ans = "";
    int y = SL;
    int x = TL;
    while(1){
        auto next = DPrev[y][x];
        if(-1 == next.first && -1 == next.second) 
            break;
        if(y-1 == next.first && x-1 == next.second)
            ans += S[y-1];
        y = next.first;
        x = next.second;
    }

    reverse(ans.begin(), ans.end());

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


Measured memory_bytes: 219392
#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 || (A > B && B != 1)){
  	cout << "Alice" << endl;
  }
  
  else {
  	cout << "Bob" << endl;
  }
  
 
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val count = LongArray(5)
    repeat(N){
        val S = readLine()!!
        when(S[0]){
            'M' -> count[0]++
            'A' -> count[1]++
            'R' -> count[2]++
            'C' -> count[3]++
            'H' -> count[4]++
        }
    }

    val list = mutableListOf<String>()
    fun comGenerate(index: Int, s: String){
        if(index == 5){
            if(s.length == 3){
                list.add(s)
            }
            return
        }
        comGenerate(index + 1, s + index)
        comGenerate(index + 1, s)
    }
    comGenerate(0, "")

    list.map { s ->
        s.map { c ->
            count[c.toString().toInt()]
        }.reduce { acc, l -> acc * l }
    }.sum().let { println(it) }
}

Measured memory_bytes: 38576
#include <iostream>

using namespace std;

int main()
{
  int N,T;
  cin >> N >> T;
  pair<int, int> route[N];

  //    cout << "checkkkk" << "\n";
  for(int i = 0; i < N; i++){
    int c,t;
    cin >> c >> t;
    route[i].first = t;
    route[i].second = c;
    //    cout << "check" << "\n";
    //    route.push_back(make_pair(t, c));
    //    route[i] = make_pair(t, c);
  }
  
  //  sort(route.begin(), route.end());

  int mincost = route[0].second;;
  bool flag = false;
  for(int i = 0; i < N; i++){
    if(route[i].first <= T){
      flag = true;
      if(mincost > route[i].second) mincost = route[i].second;
    }
  }

  if(flag == false) cout << "TLE" << "\n";
  else cout << mincost << "\n";

  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left


def solve(string):
    a, b, q, *stx = map(int, string.split())
    bignum = 3 * 10**10
    s = [-bignum] + stx[:a] + [bignum]
    t = [-bignum] + stx[a:a + b] + [bignum]
    ans = []
    for _x in stx[-q:]:
        i_s, i_t = bisect_left(s, _x), bisect_left(t, _x)
        ls, rs = _x - s[i_s - 1], s[i_s] - _x
        lt, rt = _x - t[i_t - 1], t[i_t] - _x
        ans.append(str(min(max(rs, rt), max(ls, lt), rt + ls + min(rt, ls),
                           rs + lt + min(rs, lt))))
    return "\n".join(ans)


if __name__ == '__main__':
    n, m, l = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, l) + '\n'.join([input() for _ in range(n + m + l)])))


Measured memory_bytes: 39492