akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int sx,sy,tx,ty,i;
	cin>>sx>>sy>>tx>>ty;
	for(i=1;i<=ty-sy;i++) cout<<"U";
	for(i=1;i<=tx-sx;i++) cout<<"R";
	for(i=1;i<=ty-sy;i++) cout<<"D";
	for(i=1;i<=tx-sx;i++) cout<<"L";
	cout<<"L";
	for(i=1;i<=ty-sy+1;i++) cout<<"U";
	for(i=1;i<=tx-sx+1;i++) cout<<"R";
	cout<<"D";
	cout<<"R";
	for(i=1;i<=ty-sy+1;i++) cout<<"D";
	for(i=1;i<=tx-sx+1;i++) cout<<"L";
	cout<<"U";
	return 0;
}

Measured memory_bytes: 764
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

A,B,C = inputIL()

for i in range(1,B+1):
  if A*i % B == C:
    print("YES")
    exit()
print("NO")

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

int main() {
    ull K;
    cin >> K;
    ull amari = 7 % K;
    if ((K == 7) || (K == 1)) {
        cout << 1 << endl;
    }
    else if ((K % 2 == 0) || (K % 5 == 0)) {
        cout << -1 << endl;
    }
    else {
        ull cnt = 1;
        while (amari != 0) {
            amari = (amari * 10 + 7) % K;
            cnt ++;
            if (amari == 0) {
                cout << cnt << endl;
                break;
            }
            else if (cnt > K) {
                cout << -1 << endl;
                break;
            }
        }
    }
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()


int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i,n)
		cin>>a[i];
	vector<vector<int>> g(n);
	REP(i,n-1)
	{
		int s,t;
		cin>>s>>t;
		s--;t--;
		g[s].push_back(t);
		g[t].push_back(s);

	}
	if(n==2)
	{
		if(a[0]==a[1])
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		return 0;
	}

	int root=0;
	while(g[root].size()<=1) root++;
	//cout<<"root:"<<root<<endl;
	function<int(int,int)> dfs=[&](int v,int vs)
	{
		if(g[v].size()==1) return a[v];

		int cnt=0;
		vector<int> c;
		int cmax=0;
		for(auto&& e:g[v])
		{
			if(e==vs)continue;
			int tmp=dfs(e,v);
			if(tmp<0) return -1;
			cnt+=tmp;
			c.push_back(tmp);
			if(tmp>cmax) cmax=tmp;
		}


		/*if(g[v].size()==2)
		{
			if(a[v]!=cnt) return -1;
		}*/
		if(a[v]>cnt) return -1;

		int pair=cnt-a[v];
		if(cnt-cmax < pair) return -1;

		return a[v]*2-cnt;
	};

	if(dfs(root,-1)==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}


Measured memory_bytes: 16768
// AOJ 1024 Cleaning Robot 2.0
// 2018.2.4 bal4u

#include <stdio.h>
#include <string.h>

char map[65][65];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char ch[2] = {'.', 'E' };

int main()
{
    int n, n1, i, r, c, nr, nc;
    long long k;

	while (scanf("%d%lld", &n, &k) && n) {
		k--, n1 = n-1;
        if ((n & 1) || k >= (1LL<<(n/2))) { puts("No\n"); continue; }

		memset(map, -1, sizeof(map));
        for (c = 0; c < n; c++) map[0][c] = (k >> ((n1-c) >> 1)) & 1;
        for (r = 0; r < n1; r++) for (c = 0; c < n; c++) {
			int f = 0, t = map[r][c];
			for (i = 0; i < 4; i++){
				nr = r + mv[i][0], nc = c + mv[i][1];
				if (nr >= 0 && nr < n && nc >= 0 && nc < n && map[nr][nc] == t) f++;
			}
			map[r+1][c] = (f==2)? 1-t: t;
        }
        for (r = 0; r < n; r++) {
			for (c = 0; c < n; c++) putchar(ch[map[r][c]]);
            putchar('\n');
        }
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 1972
n=int(input())
x=str(n)
keta=len(str(n))

l=[[0]*10 for i in range(10)]
for i in range(n+1):
    num=str(i)
    sento=int(num[0])
    matsubi=int(num[-1])
    if matsubi==0:
        continue
    l[sento][matsubi]+=1

sm=0
for i in range(n+1):
    num=str(i)
    sento=int(num[0])
    matsubi=int(num[-1])
    if matsubi==0:
        continue
    sm+=l[matsubi][sento]

print(sm)

Measured memory_bytes: 9128
#include <cstdio>

int main(){
	int a, b, c, d, e, f;
	double x, y;
	while(scanf("%d %d %d %d %d %d\n", &a, &b, &c, &d, &e, &f) != EOF){
		y = (double)(a * f - c * d) / (double)(a * e - b * d);
		x = ((double)c - (double)b * y) / (double)a;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    vector<pair<int,int>> o(100001);
    vector<pair<int,int>> e(100001);

    for(int i=1;i<=n/2;i++){
        int tmp_o,tmp_e;
        cin >> tmp_o >> tmp_e;
        o[tmp_o].first++;
        o[tmp_o].second=tmp_o;
        e[tmp_e].first++;
        e[tmp_e].second=tmp_e;
    }
    sort(o.begin(),o.end(),greater<>());
    sort(e.begin(),e.end(),greater<>());

    if(o[0].second!=e[0].second){
        p(n-o[0].first-e[0].first)
    } else {
        p(min(n-o[1].first-e[0].first,n-o[0].first-e[1].first))
    }

}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n;
    multiset<ll> pres;
    rep(i,1,n){
        ll v;cin>>v;
        pres.insert(v);
    }
    cin>>m;
    rep(i,1,m){
        ll v;cin>>v;
        if(pres.find(v) == pres.end()){
            cout<<"NO\n";
            return 0;
        }
        pres.erase(pres.find(v));
    }
    cout<<"YES\n";
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
vector<int> vec, vec1;
vector<pair<int, int>> ans;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a >= 0) {
			vec.emplace_back(a);
		}
		else {
			vec1.emplace_back(a);
		}
	}
	if (vec.empty()) {
		sort(vec1.rbegin(), vec1.rend());
		for (int i = 1; i < n; i++) {
			ans.emplace_back(make_pair(vec1[0], vec1[i]));
			vec1[0] -= vec1[i];
		}
		cout << vec1[0] << endl;
		for (int i = 0; i < ans.size(); i++) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}
		return 0;
	}
	if (vec1.empty()) {
		sort(vec.begin(), vec.end());
		for (int i = 1; i < n - 1; i++) {
			ans.emplace_back(make_pair(vec[0], vec[i]));
			vec[0] -= vec[i];
		}
		ans.emplace_back(make_pair(vec[n - 1], vec[0]));
		vec[n - 1] -= vec[0];
		cout << vec[n - 1] << endl;
		for (int i = 0; i < ans.size(); i++) {
			cout << ans[i].first << " " << ans[i].second << endl;
		}
		return 0;
	}
	sort(vec.begin(), vec.end());
	sort(vec1.begin(), vec1.begin());
	for (int i = 0; i < vec.size() - 1; i++) {
		ans.emplace_back(make_pair(vec1[0], vec[i]));
		vec1[0] -= vec[i];
	}
	for (int i = 0; i < vec1.size(); i++) {
		ans.emplace_back(make_pair(vec[vec.size() - 1], vec1[i]));
		vec[vec.size() - 1] -= vec1[i];
	}
	cout << vec[vec.size() - 1] << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}

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

int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

const int N = 100010;
const int INF = 1e9;

typedef long long ll;

ll a[N];

ll p,q;

void cal(ll l,ll r,int k)
{
	p = ((l - 1) / a[k] + 1) * a[k], q = r / a[k] * a[k];
}

int main()
{
	int n = read();
	for (int i = 1; i <= n; i++)
		scanf("%lld",&a[i]);
	ll needMax = 2, needMin = 2;
	for (int k = n; k >= 1; k--)
	{
		cal(needMin, needMax, k);
		if (p < needMin || p > needMax)
		{
			printf("-1\n");
			return 0;
		}
		needMin = p;
		needMax = q + a[k] - 1;
	}
	printf("%lld %lld\n", needMin, needMax);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    int n;
    cin >> n;
    int ans = 0, c = 0;
    for (int i = 1; i <= n; i = i + 2) {
        c = 0;
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) ++c;
        }
        if (c == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

const double dINF = 1e11;

typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef pair<double,PP> PPP;

int main ()
{
    int n, m;
    while (cin >> n >> m, n + m) {
        int s, g;
        cin >> s >> g;
        vector<vector<PP> > e(n + 1);

        for (int i = 0; i < m; i++) {
            int sx, sy, d, c;
            cin >> sx >> sy >> d >> c;
            e[sx].push_back(PP(sy, P(d, c) ));
            e[sy].push_back(PP(sx, P(d, c) ));
        }

        priority_queue<PPP, vector<PPP>, greater<PPP> > pq;
//        vector<vector<double> > dp(31, vector<double>(n + 1, dINF));
        vector<vector<vector<double> > > dp(31, vector<vector<double> >(n + 1, vector<double>(n + 1, dINF)));
        // dp[0][0][s] = 0.;
        double res = dINF;

        for (int j = 0; j < e[s].size(); j++) {
            int dir = e[s][j].first;
            int dis = e[s][j].second.first;
            int limit = e[s][j].second.second;

            dp[1][s][dir] = (double)dis;
            pq.push(PPP((double)dis, PP(1, P(dir, s)) ));
        }

        while (pq.size()) {
            PPP ppp = pq.top(); pq.pop();
            double cost = ppp.first;
            int v = ppp.second.first;
            int now = ppp.second.second.first;
            int pre = ppp.second.second.second;

            if (dp[v][pre][now] < cost) continue;
            // if (now == g && v == 1 && dp) break;

            // cout << now << " " << pre  << " " << v << endl;

            for (int i = 0; i < e[now].size(); i++) {
                if (e[now][i].first == pre) continue;

                for (int j = -1; j <= 1; j++) {
                    if (v + j <=  0 || v + j > e[now][i].second.second) continue;
                    double cost_ = cost + (double)e[now][i].second.first / (double)(v + j);
                    int to_ = e[now][i].first;
                    if (dp[v + j][now][to_] > cost_) {
                        dp[v + j][now][to_] = cost_;
                        pq.push(PPP(cost_, PP(v + j, P(to_, now))) );
                        if (to_ == g && v + j == 1)
                        {
                            res = min(res, cost_);
                            // cout << "DBG > cost : " << cost_ << " v : " << v + j << " to : " << to_ << endl;
                        }
                    }
                }
            }
        }

        for (int i = 1; i <= n; i++) {
            res = min(res, dp[1][i][g]);
        }
        // if (dp[1][g] == dINF) cout << "unreachable" << endl;
        // else printf("%.12f\n", dp[1][g]);
        if (res == dINF) cout << "unreachable" << endl;
        else printf("%.12f\n", res);
    }

    return 0;
}

Measured memory_bytes: 2132
import java.io.*;
import java.math.*;
import java.util.*;


public class Main{
    static long MOD = 998244353 ;
    static long [] fac;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            long x = 100l;
            long k = sc.nextLong();
            int cnt = 0;
            while(x < k)
            {
                x = x + x / 100;
                cnt++;
            }
            out.println(cnt);
        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 32704
dic = {0:"0111111", 1:"0000110", 2:"1011011", 3:"1001111", 4:"1100110",
       5:"1101101", 6:"1111101", 7:"0100111", 8:"1111111", 9:"1101111"}

while True:
  n = int(input())
  if n == -1:
    break
  dig = "0" * 7
  for _ in range(n):
    d = dic[int(input())]
    put = ""
    for i in range(7):
      if dig[i] != d[i]:
        put += "1"
      else:
        put += "0"
    print(put)
    dig = d


Measured memory_bytes: 5600
(defun average (n &rest numbers)
  (/ (reduce #'+ numbers) n))

(defun solve (n xs)
  (let ((p (round (apply #'average n xs))))
    (loop for x in xs
          sum (expt (- x p) 2))))

#-swank
(let* ((n (read))
       (xs (loop repeat n collect (read))))
  (format t "~A~%" (solve n xs)))


Measured memory_bytes: 16864
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int a[3];
    for(int i = 0;i <3;i++)
        scanf("%d",&a[i]);
    sort(a,a+3);
    int ans = a[1]-a[0] + a[2]-a[1];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

transit = []
transit_ = []

for a,b in (map(int, input().split()) for _ in range(m)):
    if a == 1:
        transit.append(b)
    if b == n:
        transit_.append(a)

if set(transit)&set(transit_):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> p(N), q(N);
    for (int i = 0; i < N; ++i) cin >> p[i];
    for (int i = 0; i < N; ++i) cin >> q[i];
    vector<int> v;
    for (int i = 1; i <=N; ++i) v.push_back(i);

    int cnt = 0;
    int a = 0;
    int b = 0;
    do {
       if (v == p) a = cnt;
       if (v == q) b = cnt;
       ++cnt;
    } while (std::next_permutation(v.begin(), v.end()));
    cout << abs(a - b) << endl;
}


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

int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    double ans = 0;
    if (d == 0) ans += 1.0 / n;
    else {
        ans += 2.0 * double(n - d) / double(n * n);
    }
    ans *= double(m - 1);
    printf("%.9f\n", ans);
}

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

using namespace std;
typedef long long ll;
const int N=30;

int main()
{
    int a[3];
    int maxx=-1;
    int id,k;
    for(int i=0; i<3; i++)
    {
        cin>>a[i];
        if(maxx<a[i])
        {
            id=i;
            maxx=a[i];
        }
    }
    cin>>k;
    ll ans=0;
    for(int i=0; i<3; i++)
    {
        if(id!=i)
        {
            ans+=a[i];
        }
        else ans+=pow(2,k)*maxx;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=get_i.sort.join("")
puts yn_judge(N=="1479","YES","NO")

Measured memory_bytes: 1788
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a = sc.read_chars();

    let mut counts = BTreeMap::new();
    for &c in a.iter() {
        counts.entry(c).and_modify(|x| *x += 1).or_insert(1_usize);
    }

    let ans = a.len() * (a.len() - 1) / 2 + 1
        - counts
            .into_iter()
            .map(|(_, v)| v * (v - 1) / 2)
            .sum::<usize>();
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, K;
    ll count;
    cin >> N >> K;
    count = K;
    for(ll i = 1;i < N;i++) count *= K - 1;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
//	freopen("C.in", "r", stdin);
//	freopen("C.out", "w", stdout);
	int n;
	cin >> n;
	int lastT=0, lastX=0, lastY=0;
	while(n--)
	{
		int t, x, y;
		cin >> t >> x >> y;
		int deltaT = t - lastT;
		int minT = std::abs(lastX - x) + std::abs(lastY - y);
		if(deltaT < minT || (deltaT & 1) != (minT & 1))
		{
			cout << "No" << endl;
			return 0;
		}
		lastT = t, lastX = x, lastY = y;
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N, K, C;
  in<string> S;
  
  vector<ll> dpl(N), dpr(N);

  dpl[0] = (S[0] == 'o') ? 1 : 0;
  dpr.back() = (S.back() == 'o') ? 1 : 0;
  
  for (int i = 1; i < dpl.size(); i++) {
    if (S[i] == 'o') {
      ll tmp = 1;
      if (i > C)
        tmp += dpl[i-C-1];
      dpl[i] = max(dpl[i-1], tmp);
    }
    else
      dpl[i] = dpl[i-1];
  }
  for (int i = dpr.size()-2; i >= 0; i--) {
    if (S[i] == 'o') {
      ll tmp = 1;
      if (i < dpr.size()-1-C)
        tmp += dpr[i+C+1];
      dpr[i] = max(dpr[i+1], tmp);
    }
    else
      dpr[i] = dpr[i+1];
  }


  REP(i, N) {
    ll left = ((i > 0) ? dpl[i-1] : 0);
    ll right = ((i < dpl.size()-1) ? dpr[i+1] : 0);
    if (left+right <= K - 1)
      cout << i + 1 << endl;
  }
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 4996
#include<bits/stdc++.h>
using namespace std;
static const int MMAX=20;
static const int NMAX=500000;
static const int INFTY=2000000000;
int main(){
    int n,m;
    int C[MMAX+1],T[NMAX+1];
    cin>>n>>m;
    for(int i=1;i<=m;i++)
        cin>>C[i];
    for(int i=0;i<NMAX;i++) T[i]=INFTY;
    T[0]=0;
    for(int i=1;i<=m;i++){
        for(int j=C[i];j<=n;j++)
            T[j]=min(T[j],T[j-C[i]]+1);
    }
    cout<<T[n]<<"\n";
    return 0;
}


Measured memory_bytes: 5036
#include <stdio.h>

int n;
int a[30];

void output(int num, int sum, int i)
{
	int j;
	
	if (sum == n){
		printf("%d", a[0]);
		for (j = 1; j < i; j++){
			printf(" %d", a[j]);
		}
		printf("\n");
	}
	else if (sum < n){
		for (j = num; j >= 1; j--){
			output(a[i] = j, sum + j, i + 1);
		}
	}
}

int main(void)
{
	int i;
	
	while (1){
		scanf("%d", &n);
		if (!n){
			break;
		}
		
		for (i = n; i >= 1; i--){
			output(a[0] = i, i, 1);
		}
	}
	
	return (0);
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for (int a = 0; a <= N; ++a) {
    for (int b = 0; b + a <= N; ++b) {
      int c = N - a - b;
      int total = 10000 * a + 5000 * b + 1000 * c;
      if (total == Y) {
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


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

int main() {
    bool zero_flg=false, over_flg =false;
    int n;
    long long a,ans = 1, anstmp;

    cin >> n;

    rep(i,n){
        cin >> a;
        if(a == 0){
            zero_flg = true;
            break;
        }
        anstmp = ans * a;
        if(anstmp>1000000000000000000 || anstmp < ans){
            over_flg = true;
        }
        ans = anstmp;
    }

    if(zero_flg == true){
        ans = 0;
    }else if(over_flg == true){
        ans = -1;
    }

    out(ans);
}

Measured memory_bytes: 3636
let a, b, c, x, y = Scanf.scanf " %d %d %d %d %d" @@ fun a b c d e -> a, b, c, d, e
let r, z = if x > y then x - y, a else y - x, b
let _ = Printf.printf "%d\n" @@ min x y * min (a + b) (2 * c) + r * min z (2 * c)

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

int main(int argc, char const *argv[]) {
  double a,b,c,ans=0;
  cin>>a>>b>>c;
  c+=0.5;
  while(c>a){
    ans+=b;
    c-=a;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0] << endl;

	return 0;
}


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


public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));       
		try {
			String line;
			while((line = br.readLine())!=null){
				int n = Integer.parseInt(line.split(" ")[0]), r = Integer.parseInt(line.split(" ")[1]);

				//input shuffle numbers
				int[] c = new int[r];
				line = br.readLine();
				String[] l = line.split(" ");
				for(int i=0;i<r;i++){
					c[i] = Integer.parseInt(l[i]);
				}
				
				//prepare deck
				ArrayList<Integer> A = new ArrayList<Integer>();
				ArrayList<Integer> B = new ArrayList<Integer>();
				ArrayList<Integer> C = new ArrayList<Integer>();
				int k;
				for(k=0;k<n;k++){
					C.add(k);
				}
				
				//shuffle
				for(int i=0;i<r;i++){
					//split deck
					for(k=0;k<n/2;k++){
						B.add(C.get(0));
						C.remove(0);
					}
					for(;k<n;k++){
						A.add(C.get(0));
						C.remove(0);
					}					
					
					while(A.size()>0||B.size()>0){
						for(int j=0;j<c[i]&&A.size()>0;j++){
							C.add(A.get(0));
							A.remove(0);
						}
						for(int j=0;j<c[i]&&B.size()>0;j++){
							C.add(B.get(0));
							B.remove(0);
						}
					}
				}
				
				System.out.println(C.get(C.size()-1));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 26284
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

using Graph = vector<vector<pair<int,long long>>>;
vector<int> color;

void dfs(int p,const Graph &e) {
  for(int i = 0;i < e.at(p).size();i++) {
    pair<int,long long> c = e.at(p).at(i);

    if(color.at(c.first) != -1) continue;
    if(c.second % 2 == 0) color.at(c.first) = color.at(p);
    else color.at(c.first) = 1^color.at(p);

    dfs(c.first,e);
  }
}


int main() {

  int N;
  cin >> N;

  Graph e(N,vector<pair<int,long long>>(0));

  for(int i = 0;i < N-1;i++) {
    int u,v;
    long long w;
    cin >> u >> v >> w;
    u--; v--;
    e.at(u).push_back(make_pair(v,w));
    e.at(v).push_back(make_pair(u,w));
  }

  color.assign(N,-1);
  color.at(0) = 0;
  dfs(0,e);

  for(int i = 0;i < N;i++) {
    cout << color.at(i) << endl;
  }
}








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

using namespace std;

typedef long long ll;

int n , p , a[101], odd, even;

ll C[101][101];

int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d", &n, &p);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		if (a[i] % 2 == 0)
			even++;
		if (a[i] % 2 == 1)
			odd++;
	}
	for (int i = 0; i <= 50; i++){
		for (int j = 0; j <= i; j++){
			if (j == 0 || j == i)
				C[i][j] = 1;
			else
				C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
		}
	}
	if (p == 0) {
		ll sum = 0;
		for (int i = 0 ; i <= even ; i++) {
			for (int j = 0 ; j <= odd ; j += 2) {
				sum += C[even][i] * C[odd][j];
			}
		}
		printf("%lld\n", sum);
	} else {
		ll sum = 0;
		for (int i = 0 ; i <= even ; i++) {
			for (int j = 1 ; j <= odd ; j += 2) {
				sum += C[even][i] * C[odd][j];
			}
		}
		printf("%lld\n", sum);
	}

	return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N = int(input())
    res = 0

    def div2(num):
        if num == 1:
            return 0
        else:
            cnt = 0
            while True:
                if num % 2 == 0:
                    num //= 2
                    cnt += 1
                else:
                    return cnt


    res_max_cnt = 0
    res = 1
    for i in range(N):
        tepm_cnt = div2(i+1)
        if res_max_cnt < tepm_cnt:
            res_max_cnt = tepm_cnt
            res = i+1
    print(res)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9120
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		List <String>LA=new ArrayList<String>();//LastA
		List <String>FB=new ArrayList<String>();//FirstB
		List <String>FBLA=new ArrayList<String>();//FirstALastA
		List <String>O=new ArrayList<String>();//Other
		for(int i=0;i<a;i++) {
			String s=scan.next();
			if(s.charAt(0)=='B') {
				if(s.charAt(s.length()-1)=='A') {
					FBLA.add(s);
				}
				else {
					FB.add(s);
				}
			}
			else if(s.charAt(s.length()-1)=='A') {
				LA.add(s);
			}
			else {
				O.add(s);
			}
		}
		String ans="";
		if(LA.size()!=0) {
			ans+=LA.get(0);
			LA.remove(0);
		}
		for(;FBLA.size()!=0;) {
			ans+=FBLA.get(0);
			FBLA.remove(0);
		}
		for(;FB.size()!=0&&LA.size()!=0;) {
			ans+=FB.get(0);
			FB.remove(0);
			ans+=LA.get(0);
			LA.remove(0);
		}
		for(;LA.size()!=0;) {
			ans+=LA.get(0);
			LA.remove(0);
		}
		for(;FB.size()!=0;) {
			ans+=FB.get(0);
			FB.remove(0);
		}
		for(;O.size()!=0;) {
			ans+=O.get(0);
			O.remove(0);
		}
		int ANS=0;
		for(int i=1;i<ans.length();i++) {
			char ch=ans.charAt(i-1);
			char ch2=ans.charAt(i);
			if(ch=='A'&&ch2=='B') {
				ANS++;
			}
		}
		System.out.println(ANS);
	}
}

Measured memory_bytes: 349876
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

/// Bismillahir Rahmanir Rahim


int main(void)
{
    int n, m, j, i, count_ac = 0, count_wa = 0;
    char s[3], s_ac[3] = "AC";
    bool *ara;
    int *count_wa_bucket;

    scanf("%d %d", &n, &m);

    ara = (bool *) calloc(n, sizeof(bool));
    count_wa_bucket = (int *) calloc(n, sizeof(int));

    for(i = 0; i < m; ++i) {
        scanf("%d %s", &j, s);
        if (!ara[j-1]) {
            if (!strcmp(s, s_ac)) {
                count_ac++;
                count_wa += count_wa_bucket[j-1];
                ara[j-1] = true;
            }
            else count_wa_bucket[j-1]++;
        }
    }

    free(ara);
    free(count_wa_bucket);

    printf("%d %d\n", count_ac, count_wa);

    return 0;
}



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

#define rep(i, n) for(int i = 0; i < n; i++)
#define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i]));

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    if((a % 2 == 0) || (b % 2 == 0)){
        printf("Even\n");
    }else{
        printf("Odd\n");
    }
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < s.length;i++){
			list.add(Integer.parseInt(s[i]));
		}
		Collections.sort(list);
		Collections.reverse(list);
		for(int i = 0;i<list.size();i++){
			if(i ==list.size()-1){
				System.out.println(list.get(i));
			}else{
				System.out.print(list.get(i)+" ");
			}
		}
	}

}

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

int n, m;

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

int main() {
	n = read(), m = read();
	printf("%d\n", n - 2 * m < 0 ? 0 : n - 2 * m);
	return 0;
}

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

// ------ disjoint set ------ //
struct UnionFind {
    vector<int> data;
    int __size;
    UnionFind(int size) : data(size, -1), __size(size) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) != (y = root(y))) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x; __size--;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return __size; }
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n + m);            // i: [0, n) + l: [n, n + m)
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        while (k--) {
            int l; cin >> l; l--;
            uf.unionSet(i, l + n);
        }
    }
    int size = uf.size();
    int cnt = 0;
    for (int l = n; l < n + m; l++) {
        if (uf.size(l) == 1) cnt++;
    }
    if (size - cnt == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = na()

max_a = max(a)
diff = inf
ans = 0
for i in range(n):
    if a[i] != max_a:
        d = abs(a[i] - max_a // 2)
        if diff > d:
            diff = d
            ans = a[i]

print(max_a, ans)

Measured memory_bytes: 14260
n = int(input())
A = [int(x) for x in input().split()]
m = int(input())
B = [int(x) for x in input().split()]
 
ans = 0
 
for i in range(min(len(A), len(B))):
    if A[i] < B[i]:
        ans = 1
        break
    elif A[i] > B[i]:
        break
else:
    if len(A) < len(B):
        ans = 1
 
print(ans)


Measured memory_bytes: 5632
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define tc int t;cin>>t;while(t--)


int main()

{
   ll sum=0;
   string n;
   cin>>n;
   for(ll i=0;i<n.length();i++){
          sum+=n[i]-'0';
   }
   if(sum%9==0)cout<<"Yes";
   else cout<<"No";

}


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

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


Measured memory_bytes: 3984
#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;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll mod = 1e9 + 7;
ll num[10][10], dp[101][10];

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

    int w = W-1;
    for (int bit=0; bit<(1<<w); ++bit) {
        bool ok = true;
        for (int i=0; i<w-1; ++i) {
            if (bit&(1<<i) and bit&(1<<(i+1))) {
                ok = false;
                break;
            }
        }
        if (!ok) continue;

        vector<int> P(W, 0);
        iota(P.begin(), P.end(), 0);
        for (int i=0; i<W-1; ++i) {
            if (bit&(1<<i)) swap(P[i], P[i+1]);
        }
        for (int i=0; i<W; ++i) num[i][P[i]]++;
    }

    dp[0][0] = 1;
    for (int i=0; i<H; ++i) {
        for (int k=0; k<W; ++k) {
            for (int j=0; j<W; ++j) {
                dp[i+1][k] += (dp[i][j] * num[j][k] % mod);
            }
        }
    }
    cout << dp[H][K-1]%mod << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

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

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, K;
	cin >> N >> K;
	vector<int64> A(N), F(N);
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> F[i];
	sort(all(A));
	sort(all(F), greater<int64>());
	int64 l = -1, r = INF_LL, m;
	while (r - l > 1) {
	  m = (l + r) >> 1;
	  int64 cnt = 0;
	  REP(i, N) {
	    if (m < A[i]*F[i]) {
        cnt += (A[i]*F[i]-m+F[i]-1) / F[i];
      }
	  }
	  if (cnt <= K) {
	    r = m;
	  } else {
	    l = m;
	  }
	}
	cout << r << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>/
// #include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 100000007LL
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 500005
vector <int >divisor ;

int a[maxn] ;

int main()
{
    int n , k ;

    scanf("%d %d",&n,&k) ;

    for(int i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;

    int sum = 0 ;

    for(int i=1 ; i<=n ; i++) sum += a[i] ;

    for(int i=1 ; i*i<=sum ; i++)
    {
        if( sum%i == 0 )
        {
            divisor.pb(i) ;
            divisor.pb(sum/i) ;
        }
    }

    int ans = 1 ;

    for( auto d:divisor )
    {
     //   printf("%d\n",d) ;
        i64 x = 0 ;
        vector <i64> v ;
        for(int i=1 ; i<=n ; i++)
        {
            x += ((( a[i]+d-1 )/d)*d - a[i]) ;
            v.pb( ((( a[i]+d-1 )/d)*d - a[i]) ) ;
        }

        sort( v.begin() , v.end() ) ;

        i64 res = x ;

        for(int i=(int)v.size() - 1 ; x !=0 ; i--, x -=d )
        {
            res = res - v[i] + (d-v[i]) ;
        }

        if( res/2 <= k ) ans = max(ans,d) ;
    }

    printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);
        char c = sc.next().charAt(0);
        System.out.println((char)(a-'a'+'A') +""+ (char)(b-'a'+'A') +""+ (char)(c-'a'+'A'));
    }
}

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

int main( void ) {
	char str1[ 100000 ], str2[ 100000 ], fig, tmp;
	int i, n, idx1, idx2, sum;

	while ( scanf( "%d", &n ), n ) {
		scanf( "%s", str1 );

		while ( n-- ) {
			idx1 = idx2 = 0;
			while ( sscanf( str1 + idx1, "%c", &fig ) != EOF ) {
				sum = 1;
				while ( sscanf( str1 + ++idx1, "%c", &tmp ) != EOF && fig == tmp )
					sum++;
				sprintf( str2 + idx2++, "%d%c", sum, fig );

				do {
					idx2++;
				} while ( sum /= 10 );
			}

			strcpy( str1, str2 );
		}

		printf( "%s\n", str1 );
	}

	return 0;
}

Measured memory_bytes: 716
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vi v(n);
		REP(i, n) {
			string s;
			cin >> s;
			v[i] = s.size();
		}
		vi a = { 5,7,5,7,7 };
		REP(i, n) {
			int k = 0,sum = 0;
			FOR(j, i, n) {
				while (k < 5) {
					while (j < n&&sum < a[k]) {
						sum += v[j];
						j++;
					}
					if (sum == a[k]) {
						sum = 0;
						k++;
						if (k == 5) {
							cout << i + 1 << endl;
							goto ok;
						}
					}
					else break;
				}
			}
		
		}
	ok:;
	}
	return 0;
}

Measured memory_bytes: 3160
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
z=min(al)+min(bl)
for i in range(m):
  x,y,c=map(int,input().split())
  t=al[x-1]+bl[y-1]-c
  z=min(z,t)
print(z)

Measured memory_bytes: 18736
#include<bits/stdc++.h>
using namespace std;
int a,b,ans;
void dfs(int n,int s,int bit,int bef);
int main(){

  cin >> a >> b;
  while(a!=0||b!=0){
    
    ans = 0;
    dfs(0,0,0,-1);
    cout << ans << endl;
    cin >> a >> b;
  }

  return (0);
}

void dfs(int n,int s,int bit,int bef){
  
  if(n == a){
    if(s == b) ans++;
  }

  else {
    
    for(int i=0;i<=9;i++){
      if( ((1<<i)&bit)==0 && bef<i){
	dfs(n+1,s+i,bit|(1<<i),i);
      }
    }
  }
  
}

Measured memory_bytes: 3100