akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int N;cin >> N;
    map<string,int> mp;
    for (int i = 0; i< N;i++){
        string s;cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for (auto p : mp) mx = max(mx,p.second);
    for (auto p : mp){
        if (p.second != mx) continue;
        cout << p.first << endl;
    }
}

Measured memory_bytes: 25216
# 10-Structured_Program_I-Print_a_Frame.py

# ?????¬???????????????
# ??\????????????????????????H cm ?????? W cm ???????????????????????°?????????????????????????????????
# ##########
# #........#
# #........#
# #........#
# #........#
# ##########
# ?????????????????? 6 cm ?????? 10 cm ???????????¨??????????????????

# Input
# ??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
# H W
# H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????
# ????????????????????¨??????????????\???????????¶??????3 ??? H, W ??? 100 ??§??????

# Output
# ?????????????????????????????????????????? H cm ?????? W cm ?????????????????????????????????
# ?????????????????????????????????????????????????????\??????????????????

# Constraints
# H, W ??? 300

# Sample Input
# 3 4
# 5 6
# 3 3
# 0 0
# Sample Output
# ####
# #..#
# ####

# ######
# #....#
# #....#
# #....#
# ######

# ###
# #.#
# ###


# a = []
# a = [ *map(int,input().split() ) ]
H=[]
W=[]

while 1:
	temp = input().split()
	H.append( int(temp[0]) )
	W.append( int(temp[1]) )
	if H[-1]==0 and W[-1]==0:
		break;

for i in range( len(H) ):
	for j in range( H[i] ):
		#???????¨???°????§?
		if j==0 or j==H[i]-1: 		#?????????????????????????????????
			for k in range( W[i] ):
				print("#",end="")
		else:
			print("#",end="")
			for k in range(W[i]-2):
				print(".",end="")
			print("#",end="")

		print("")
		#???????¨???°?????????

	if i !=len(H)-1:
		print("")

Measured memory_bytes: 9024
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    int ans=0;
    cin>>a>>b>>c;
    if(a!=b)
        ans+=2;
    else 
        ans++;
    if(a!=c&&b!=c)
        ans++;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

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

const int maxn = 2*1000+10;
const ll  mod = 1e9+7;
ll dp[maxn][maxn];
ll a[maxn], b[maxn];

int main()
{_
    int n, m;   cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= m; i++)
        cin >> b[i];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m;j ++){
            if(a[i] == b[j])
                dp[i][j] = 1+dp[i-1][j-1] + dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + mod;
            else
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + mod;
            dp[i][j] %= mod;
        }
    }
    cout << (dp[n][m]+1+mod) % mod;
    return 0;
}


Measured memory_bytes: 31744
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Data[] datas = IntStream.range(0, n).mapToObj(i -> new Data(scanner.next(), scanner.nextInt(), i)).sorted()
					.toArray(Data[]::new);
			int[] result = new int[n];
			IntStream.range(0, n).forEach(i -> result[i] = datas[i].index + 1);
			Arrays.stream(result).forEach(System.out::println);
		}
	}

	/**
	 * sとpとindexを表すクラス
	 */
	private static class Data implements Comparable<Data> {
		String s;
		int p, index;

		Data(String s, int p, int index) {
			super();
			this.s = s;
			this.p = p;
			this.index = index;
		}

		@Override
		public int compareTo(Data data) {
			if (s.equals(data.s)) {
				return Integer.compare(data.p, p);
			}
			return s.compareTo(data.s);
		}
	}
}


Measured memory_bytes: 36452
n,m = gets.chomp.split.map(&:to_i)

class UnionFind
	def initialize n
		@parent = Array.new(n,&:itself)
		@rank = Array.new(n,0)
		@size = n
	end

	def get_parent n
		@parent[n] == n ? n : get_parent(@parent[n])
	end

	def unite x,y
		x = get_parent(x)
		y = get_parent(y)
		if x != y
			if @rank[x] < @rank[y]
				@parent[x] = y
			else
				@parent[y] = x
				@rank[x] += 1 if @rank[x] == @rank[y]
			end
			@size -= 1
		end
	end

	def size
		@size
	end
end

union = UnionFind.new(n)
m.times do
	x,y,z = gets.chomp.split.map(&:to_i)
	union.unite(x-1,y-1)
end

puts union.size

Measured memory_bytes: 3324
sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy
ans = []
ans.append("U" * y)
ans.append("R" * x)
ans.append("D" * y)
ans.append("L" * (x + 1))
ans.append("U" * (y + 1))
ans.append("R" * (x + 1))
ans.append("D")
ans.append("R")
ans.append("D" * (y + 1))
ans.append("L" * (x + 1))
ans.append("U")
print("".join(ans))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int

	fmt.Scan(&n)

	mochi := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&mochi[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(mochi)))

	kasane := 1
	for i := 0; i < n-1; i++ {
		if mochi[i] > mochi[i+1] {
			kasane++
		}
	}
	fmt.Println(kasane)
}


Measured memory_bytes: 1844
import numpy as np
rest = {}
N = int(input())
for i in range(N):
    s,p = input().split()
    if(s not in rest.keys()):
        rest[s] = [[int(p)],[i+1]]
    else:
        rest[s][0].append(int(p))
        rest[s][1].append(i+1)

sort_rest = sorted(rest.keys())
for r in sort_rest:
    argsort_ = np.argsort(np.array(rest[r][0]))[::-1]
    for i in argsort_:
        
        #pdb.set_trace()
        print(rest[r][1][i])

Measured memory_bytes: 12488
# dpA - Frog 1
# 配るDP
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    dp = [float("inf")] * n
    dp[0] = 0
    for i in range(n):
        if i + 1 < n:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(A[i + 1] - A[i]))
        if i + 2 < n:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(A[i + 2] - A[i]))
    print(dp[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 14108
#include<iostream>

using namespace std;

int main(){

        int H,W;
        char S[50][50];
        int i,j;
        int FLG=0;

        cin >> H >> W;

        for(i =0 ; i < H; i++){
                for(j =0 ; j < W; j++){
                        cin >> S[i][j];
                }
        }

        for(i =0 ; i < H; i++){
                for(j =0 ; j < W; j++){
                        if(S[i][j] == '#'){
                                if(S[i-1][j] == '.' && S[i][j-1] == '.' && S[i+1][j] == '.' && S[i][j+1] == '.'){
                                        FLG++;
                                }
                        }
                }
        }

        if(FLG > 0){
                cout << "No" << endl;
        }else{
                cout << "Yes" << endl;
        }

        return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int d = 1;

int power(int D){ 
  if( D == 0){return  d;}
  d *= 100; 
  return power(D - 1); }

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

 int c = power(D);
if(N <= 99){ cout << c * N;}
 else{ cout << c* 101;}
 
 return 0;
}


Measured memory_bytes: 256
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))


if __name__ == "__main__":
    w, h, n = iparse()
    xmax = w
    xmin = 0
    ymin = 0
    ymax = h
    for i in range(n):
        x, y, a = iparse()
        
        if a == 1:
            xmin = max(xmin,x)
        if a == 2:
            xmax = min(xmax,x)
        if a == 3:
            ymin = max(ymin,y)
        if a == 4:
            ymax = min(ymax,y)
        
    print((max(xmax-xmin,0)*(max(0,ymax-ymin))))

Measured memory_bytes: 9112
import Foundation

/*
// 1
let N = Int(readLine()!)!

// 1 2
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let S = Int(split[1])!

// 1 2 3 4 5
let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }

func pow(_ number: Int, multiplier: Int) -> Int {
  var answer = 1
  for _ in 0 ..< multiplier {
    answer *= number 
  }
  return answer
}


*/
let N = readLine()!
let A = "AAA"
let B = "BBB"
if N == A || N == B{
  print("No")
} else {
print("Yes")
}

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b;  a <= c; ++a)
#define pb push_back
#define int long long
typedef pair<int, int> ii;
const int N = 2e5 + 10;
const int oo = 1e16;

int n, m;
int f[N], it[4 * N], la[4 * N], L[N], R[N], C[N];
vector<ii> vi[N];
struct line {
    int l, r, v;
} t[N];

void true_val(int i, int l, int r)  {
    if(!la[i]) return;
    it[i] += la[i];
    if(l != r)  {
        la[2 * i] += la[i];
        la[2*i + 1] += la[i];
    }
    la[i] = 0;
}
void upd(int i, int l, int r, int ql, int qr, int val, int ti)   {
    true_val(i, l, r);
    if(l > qr || ql > r) return;
    if(ql <= l && r <= qr)  {
        if(ti == 0) {
            la[i] += val; true_val(i, l, r);
        } else {
            it[i] = val;
        }
        return;
    }
    int mid = (l + r) / 2;
    upd(2*i, l, mid, ql, qr, val, ti); upd(2*i + 1, mid + 1, r, ql, qr, val, ti);
    it[i] = max(it[2*i], it[2*i + 1]);
}
int get(int i, int l, int r, int ql, int qr)    {
    true_val(i, l, r);
    if(ql > r || l > qr) return -oo;
    if(ql <= l && r <= qr) return it[i];
    int mid = (l + r) / 2;
    return max(get(2*i, l, mid, ql, qr), get(2*i + 1, mid + 1, r, ql, qr));
}
signed main()
{
    scanf("%lld%lld", &n, &m);
    FOR(i, 0, 4 * n) it[i] = -oo;
    upd(1, 0, n, 0, 0, 0, 1);
    FOR(i, 1, m)    {
        scanf("%lld%lld%lld", &L[i], &R[i], &C[i]);
        vi[L[i]].pb(ii(i, 0)); vi[R[i] + 1].pb(ii(i, 1));
    }
    int ans = 0;
    FOR(i, 1, n)    {
        for(auto v: vi[i])  {
            if(v.se == 0) upd(1, 0, n, 0, i - 1, C[v.fi], 0);
            else upd(1, 0, n, 0, L[v.fi] - 1, -C[v.fi], 0);
        }
        int val = get(1, 0, n, 0, i - 1);
        ans = max(ans, val);
        upd(1, 0, n, i, i, val, 1);
    }
    printf("%lld", ans);
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    long long s = 0;
    for (int i = 1; i < n; ++i)
    {
        if (a[i] - a[i - 1] <= t)
            s += a[i] - a[i - 1];
        if (a[i] - a[i - 1] > t)
            s += t;
    }
    s += t;
    cout << s;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int n,m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = a.copy()

if set(a) <= {0,1}:
    for i in range(N//2, -1, -1):
        ball_sum = sum(b[i::i+1])
        if ball_sum % 2 == a[i]:
            continue
        else:
            b[i] = int(not(b[i]))
        
    print(sum(b))
    for j in range(N-1, -1, -1):
        if b[j]: print(j+1)

else: print(-1)

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

const int MOD = 1e9+7;
const int MAX_N = 10006;
string K;
int N, D;
ll dp[MAX_N][102];

ll dfs(int at, int rem, bool zero, bool less)
{
	if(at == N){
		if(!rem) return 1;
		else return 0;
	}
	if(!zero && less){
		ll res = dp[at][rem];
		if(res != -1) return res;
	}
	ll res = 0;
	for(int i=0;i<=(less?9:K[at]-'0');++i){
		(res += dfs(at+1, (rem+i)%D, (zero&&!i), (less||(i<(K[at]-'0')))))%=MOD;
	}
	if(!zero && less) dp[at][rem]=res%MOD;
	return res;
}

void solve()
{
	N = K.length();
	memset(dp, -1, sizeof(dp));
	int ans = dfs(0,0,true,false);
	cout << (ans-1+MOD)%MOD << '\n';
}

int main()
{
	cin >> K >> D;
	solve();
	return 0;
}

Measured memory_bytes: 9088
#include <cstdio>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

const int INF=1e9;
const int N=1000001;
int mem[N],memo[N];


int tetra(int x)
{
    return x*(x+1)*(x+2)/6;
}
int main()
{
    REP(i,N)
    {
        mem[i]=INF;
        memo[i]=INF;
    }
    mem[0]=0;
    memo[0]=0;
    for(int j=200;j>=1;j--)
    {
        int c = tetra(j);
        REP(i,N)
        {
            if(i+c>=N) continue;
            if(c%2==1)
            {
                memo[i+c]=min(memo[i+c], memo[i]+1);
            }

            mem[i+c]=min(mem[i+c], mem[i]+1);
        }
    }

    /*
    REP(i,30)
        cout<<mem[i]<<" \n"[i==29];
    REP(i,30)
        cout<<memo[i]<<" \n"[i==29];
        */

    int n;
    while(cin>>n,n)
    {
        cout<<mem[n]<<" "<<memo[n]<<endl;
    }
}

Measured memory_bytes: 10816
a, b, c, k = map(int, input().split())
def main():
    ans = 0
    if k < a:
        ans += k
        return ans
    elif k < a+b:
        ans += a
        return ans
    elif k < a+b+c:
        ans += a
        ans -= k-a-b
        return ans
    else:
        ans += a
        ans -= c
        return ans

print(main())

Measured memory_bytes: 61788
import collections
 
n = int(input())
s = [input() for i in range(n)]
 
counter = collections.Counter(s)
most = counter.most_common()
ans = []
for i in range(len(counter.keys())):
    if most[i][1] == most[0][1]:
        ans.append(most[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 47740
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;

int main()
{
    //freopen("C:\\Users\\Administrator\\Desktop\\in.txt" , "r" , stdin);
    int n,a,b;
    int num;
    scanf("%d",&n);
    while(n--)
    {
        num=0;
        scanf("%d%d",&a,&b);
        for(int i=-142;i<=142;i++)
        {
            for(int j=-142;j<=142;j++)
            {
               // __int64 k1=i*i+j*j,k2=i*a+j*b,k3=i*b-j*a;
                long long  k1=i*i+j*j,k2=i*a+j*b,k3=i*b-j*a;
                if(k1&&(k2%k1==0)&&(k3%k1==0))
                {
                    num++;
                }
            }
        }
        if(num==8)cout<<"P"<<endl;
        else cout<<"C"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n>>h;
    vl a(n+1),b(n+1);
    fo(i,n)cin>>b[i+1]>>a[i+1];
    vvl dp(n+1,vl(100001,inf*inf));
    dp[0][0]=0;
    fo(i,n+1){
        fo(j,100001){
            if(i==0){continue;}
            dp[i][j]=dp[i-1][j];
            if(j>=a[i]){
                dp[i][j]=min(dp[i][j],dp[i-1][j-a[i]]+b[i]);
            }
            //cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
        }
    }
    fo(i,100001)if(dp[n][i]<=h&&i>kv)kv=i;
    cout<<kv;
    return 0;
}


Measured memory_bytes: 80256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll A[1010][1010];
ll cnt[1010];
bool done[1010];

int main() {
  cin >> N;
  repe(i, 1, N) {
    rep(j, 0, N - 1) { cin >> A[i][j]; }
    A[i][N - 1] = INF;
  }

  ll ans = 0;
  vector<ll> updated;
  repe(i, 1, N) { updated.push_back(i); }
  while (true) {
    repe(i, 1, N) { done[i] = false; }
    bool ok = false;
    vector<ll> updated_next;
    for (auto i : updated) {
      if (done[i]) continue;

      ll op = A[i][cnt[i]];
      if (op == INF) continue;
      if (done[op]) continue;

      if (A[op][cnt[op]] == i) {
        done[i] = true;
        done[op] = true;
        ++cnt[i];
        ++cnt[op];
        ok = true;
        updated_next.push_back(i);
        updated_next.push_back(op);
      }
    }
    if (!ok) {
      repe(i, 1, N) {
        if (cnt[i] != N - 1) {
          cout << -1;
          return 0;
        }
      }
      cout << ans;
      return 0;
    }
    updated = updated_next;
    ++ans;
  }
}


Measured memory_bytes: 11472
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  
 ll n,i,j=0,sm1=0,sm2=0,k;
 
 cin>>n;
 int a[n];
 for(i=0;i<n;i++)
 {
     cin>>a[i];
     j+=a[i];
 }
 k=j/n;
 j=ceil(j/(float)n);
 for(i=0;i<n;i++)
 {
     sm1+=(j-a[i])*(j-a[i]);
     sm2+=(k-a[i])*(k-a[i]);
 }
 cout<<min(sm1,sm2);
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const ll INF = 1e15;
int N, W;
int v[111], w[111];
ll dp[111][111111];

void print() {
   for (int i = 0; i <= N; i++) { // i個選ぶ
      for (int j = 0; j <= W; j++) { // 重さjまで
         printf(" %3lld", dp[i][j]);
      }
      puts("");
   }
}

int main() {
   cin >> N >> W;
   rep (i, N) {
      cin >> v[i] >> w[i];
   }

   // DPテーブル初期化
   for (int j = 0; j <= W; j++) {
      dp[0][0] = 0;
   }
   // DP本体
   for (int i = 0; i < N; i++) { // i個選ぶ
      for (int j = 0; j <= W; j++) { // 重さjの時
         // 選ぶ
         dp[i+1][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i]);
         // 選ばない
         dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
      }
   }

   cout << dp[N][W] << endl;

   // print();

   return 0;
}


Measured memory_bytes: 12040
n = int(input())
l = len(str(n))
ns = n//(10**(l-1))
nt = n-ns*10**(l-1)
ans = 0
if l>1:
  ans += (ns-1)*(ns-1)*10**(2*l-4)
  for i in range(2, l):
    ans += 2*(ns-1)*9*10**(l+i-4)
  ans += 2*(ns-1)*10**(l-2)
  if ns<=nt:
    ans += ((nt-ns)//10+1)*((nt-ns)//10+1)
    for i in range(1, ns):
      ans += 2*((nt-i)//10+1)*10**(l-2)
    for i in range(2, l):
      for j in range(1, min(nt+1, 10)):
        ans += 2*((nt-j)//10+1)*10**(i-2)
    ans += 2*((nt-ns)//10+1)
  else:
    ans += nt
    for i in range(2, l):
      ans += 2*nt*10**(i-2)
  for i in range(2, l):
    for j in range(2, l):
      ans += 9*9*10**(i-2+j-2)
    ans += 2*9*10**(i-2)
  ans += 9
else:
  ans += n
print(ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
INF = 10 ** 10
MOD = 10 ** 9 + 7
from heapq import heapify,heappop,heappush
input = sys.stdin.readline

def main():
    x,y,a,b,c = map(int,input().split())
    R = list(map(int,input().split()))
    G = list(map(int,input().split()))
    M = list(map(int,input().split()))
    R.sort(reverse = True)
    G.sort(reverse = True)
    M.sort(reverse = True)
    apple = R[:x] + G[:y] + M
    apple.sort(reverse = True)
    ans = sum(apple[:x + y])
    print(ans)
if __name__=='__main__':
    main()

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

ll dp[60][60][2600];

int main(){
    int n,a;
    cin>>n>>a;
    vector<int>x(n);
    rep(i,n)cin>>x[i];
    //dp
    dp[0][0][0]=1;
    for(int i=0; i<n; ++i){
        for(int j=0; j<=n; ++j){
            for(int k=0; k<=n*50; ++k){
                dp[i+1][j][k]+=dp[i][j][k];
                dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
            }
        }
    }
    ll ans=0;
    for(int i=1; i<=n; ++i){
        ans+=dp[n][i][i*a];
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    int view = 0,maior = 0;
    cin >> N;
    for (int i = 0 ; i < N ; i++)
    {
        int tam;
        cin >> tam;
        if(tam >= maior)
        {
            maior = tam;
            view++;
        }
    }
    cout << view << endl;
    return 0;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  var C = one[2];
  if(A == B && A == C && B == C){
     if(A % 2 == 0){
        myout(-1);
     }else{
        myout(0);
     }
  }else{
     var count = 0;
    while(count < 100){
      if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1 ){
        myout(count);
        return;
      }
      var tmpA = (B + C) / 2;
      var tmpB = (A + C) / 2;
      var tmpC = (A + B) / 2;
      count++;
      A = tmpA;
      B = tmpB;
      C = tmpC;
    }
    myout(-1);
  }
}


Measured memory_bytes: 7372
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>b(n);
	int flag = 0;
	rep(i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			flag = 1;
		}
	}
	if (flag == 1) {
		cout << 0 << endl;
		return 0;
	}
	else {
		b[0] = a[0];
		for (int i = 1; i < n; i++) {
			b[i] = b[i - 1] * a[i];
			if (b[i] / a[i] != b[i - 1]) {
				cout << -1 << endl;
				return 0;
			}
		}
		if (b[n - 1] > 1000000000000000000) {
			cout << -1 << endl;
			return 0;
		}
		else {
			cout << b[n - 1] << endl;
		}
	}

	return 0;
}



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

int main() {
	long long int A, B,ans;
	ans = 0;
		cin>> A >> B;
		ans = max(A, B);
		if (ans > min(A, B)) ans = ans + ans - 1;
		else ans = ans + min(A, B);

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000009LL

double dp[305][305][305];//dp[i][j][k]:１個の寿司がi個，２個の寿司がj個，３個の寿司がk個あるときすべて食べ終わるまでの試行回数の期待値
int N;

double dfs(int i, int j, int k) {
    if (dp[i][j][k] > -1) return dp[i][j][k];

    double res = 1.0 * N / (i + j + k);
    if (i > 0) res += 1.0 * i / (i + j + k) * dfs(i-1, j, k);
    if (j > 0) res += 1.0 * j / (i + j + k) * dfs(i+1, j-1, k);
    if (k > 0) res += 1.0 * k / (i + j + k) * dfs(i, j+1, k-1);

    return dp[i][j][k] = res;
}

int main() {
    cin >> N;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a == 1) one++;
        else if (a == 2) two++;
        else three++;
    }

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= N; k++) {
                dp[i][j][k] = -1;
            }
        }
    }

    dp[0][0][0] = 0;
    cout << fixed;
    cout << setprecision(10) << dfs(one, two, three) << endl;

    return 0;
}



Measured memory_bytes: 219392
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define BUF_SIZE 15

int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, (a%b));
}

void print_YES_NO(int flag) {
  printf("%s\n", flag ? "YES" : "NO");
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int a, b, c;
  sscanf(line, "%d %d %d", &a, &b, &c);
  int rem = c % gcd(a, b);

  print_YES_NO(!rem);
  return 0;
}

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

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int cntdigits(int n)
{
    int cnt = 0;
    while (n)
        cnt++, n /= 10;
    return cnt;
}

int32_t main()
{
    fast;
    int n;cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(cntdigits(i)&1)
            cnt++;
    }
    cout<<cnt;
}

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

int main() {
  char S;
  cin >> S;
  int count = 0;
  string T = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int i = 0; i < 26; i++) {
    if (T.at(i) == S)
      count++;
  }
  if (count == 0)
    cout << "a" << endl;
  else
    cout << "A" << endl;
}


Measured memory_bytes: 3576
N,X =map(int,input().split())
Z =[]
ALL =0
for i in range(N):
    Y = int(input())
    ALL+=Y
    Z.append(Y)

ANS = (X- ALL)//(min(Z))
if ANS ==0:
    print(len(Z))
else:
    print(ANS+len(Z))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=-1e12;
const double pi=acos(-1);



void solve(int T){
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


Measured memory_bytes: 3652
using System;
using System.Linq;

namespace ABC147
{
    class B
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int res = 0;
            for (int i = 0; i < S.Length / 2; i++)
            {
                if (S[i] != S[S.Length - 1 - i]) res++;
            }

            Console.WriteLine(res);

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
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;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

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

class unionFind {
public:
  vector<ll> data;
  
  unionFind(ll size) {
    data.assign(size, -1);
  }
  
  bool same(ll x, ll y) {
    return find(x)==find(y);
  }
  
  void unite(ll x, ll y) {
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(data[x]>data[y]) swap(x, y);
    data[x]+=data[y];
    data[y]=x;
  }
  
  ll find(ll k) {
    if(data[k]<0) return k;
    return data[k]=find(data[k]);
  }
  
  ll size(ll k) {
    return -data[find(k)];
  }
  
};


int main(void) {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  ll P[5555], C[5555];
  for(i=0; i<N; i++) {
    cin >> P[i];
    P[i]--;
  }
  for(i=0; i<N; i++) cin >> C[i];
  
  unionFind uf=unionFind(N);
  map<ll, set<ll>> mp;
  
  for(i=0; i<N; i++) uf.unite(i, P[i]);
  
  for(i=0; i<N; i++) {
    ll u=uf.find(i);
    if(mp[u].empty()) mp[u]=set<ll>();
    mp[u].insert(i);
  }
  
  ll ans=-INF;
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    set<ll> st=it->sc;
    ll n=st.size();
    ll c=0;
    for(auto ptr=st.begin(); ptr!=st.end(); ptr++) c+=C[*ptr];
    
    ll tK=K;
    ll t=0;
    if(c>0) {
      t=tK/n*c;
      tK%=st.size();
      
      if(tK==0) {
        t-=c;
        tK=n;
      }
      
    }else {
      chmin(tK, n);
    }
    
    vector<ll> v;
    ll now=*st.begin();
    v.push_back(now);
    for(i=1; i<n; i++) {
      now=P[now];
      v.push_back(now);
    }
    for(i=0; i<n; i++) v.push_back(v[i]);
    
    ll sum[v.size()+10];
    for(i=0; i<v.size(); i++) sum[i+1]=sum[i]+C[v[i]];
    
    ll S=-INF;
    for(k=1; k<=tK; k++) for(i=1; i<=(ll)v.size()-k+1; i++) chmax(S, sum[i+k-1]-sum[i-1]);
    
    t+=S;
    chmax(ans, t);
    
  }
  
  pt(ans);
  
}
 
 




Measured memory_bytes: 4396
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# Author:   bebebe
# Created:  2019-10-27
#


import math

def divisor(M):
    maxX = int(math.sqrt(M))
    for x in range(2, maxX + 1):
        if M % x == 0:
            return x, M // x
    return 1, M


N = int(input().strip())
N_sqrt = int(math.sqrt(N))

ret_list = []
for a in range(1, N_sqrt + 1):
    if N % a == 0:
        ret_list.append(a + N // a - 2)

print(min(ret_list))



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

public class Main {


    public Main(FastScanner in, PrintWriter out) {
        int X = in.nextInt();
        for (long a = 120; a >= 0; a--) {
            for (long b = a - 1; b >= -119; b--) {
                long c = a * a * a * a * a - b * b * b * b * b;
                if (c == X) {
                    out.printf("%d %d%n", a, b);
                    return;
                } else if (c > X)
                    break;
            }
        }
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        Main sol = new Main(in, out);

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

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

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 33904
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a, b;
	int c;

	while (cin >> a >> b) {
		c = a + b;
		if (c / 10 > 0) {
			if (c / 100 > 0) {
				if (c / 1000 > 0) {
					if(c / 10000 > 0) {
						if(c / 100000 > 0) {
							if(c / 1000000 > 0) {
								printf("7\n");
							} else {
								printf("6\n");
							}
						} else {
							printf("5\n");
						}
					} else {
						printf("4\n");
					}
				} else {
					printf("3\n");
				}
			} else {
				printf("2\n");
			}
		} else {
			printf("1\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
using namespace std;
int mp[100];
vector<char>Q;
int main(){
	char str[5];
	cin>>str;
	int ans=0;
	for(int i=0; i<strlen(str); i++){
		if(!mp[str[i]]) Q.push_back(str[i]);
		mp[str[i]]++;
	}
	if(Q.size()==2 && mp[Q[0]]==2 && mp[Q[1]]==2) puts("Yes");
	else puts("No");
	return 0;
}

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

signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int i = 0; i + 2 <= s.size(); ++i) {
    if (s.substr(i, 2) == "AC") {
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n, k;
	char s[51];
	
	scanf("%d %d ", &n, &k);
	
	for(int i=1; i<=n; i++)
	    scanf("%c", &s[i]);
	
	s[k]=s[k]+32;
	
	for(int i=1; i<=n; i++)
		printf("%c", s[i]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k;cin >> h >> w >> k;
  vector<vector<char>> c(h,vector<char>(w));
  vector<vector<int>> ans(h,vector<int>(w,-1));
  int cnt=0;
  vector<bool> f(h);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
      if(c[i][j]=='#'){
        f[i]=true;
        cnt++;
        ans[i][j]=cnt;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(f[i]){
      for(int j=1;j<w;j++){
        if(ans[i][j-1]!=-1&&ans[i][j]==-1){
          ans[i][j]=ans[i][j-1];
        }
      }
      for(int j=w-2;j>=0;j--){
        if(ans[i][j+1]!=-1&&ans[i][j]==-1){
          ans[i][j]=ans[i][j+1];
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    if(i){
      for(int j=0;j<w;j++){
        if(ans[i][j]==-1){
          ans[i][j]=ans[i-1][j];
        }
      }
    }
  }
  for(int i=h-1;i>=0;i--){
    if(i!=h-1){
      for(int j=0;j<w;j++){
        if(ans[i][j]==-1){
          ans[i][j]=ans[i+1][j];
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
#include <string>
#include <iostream>
#include <algorithm>
#define INF 1000000007
using namespace std;
int N, a[1000]; string s;
int main() {
	while (cin >> N, N) {
		for (int i = 0; i < N; i++) {
			cin >> s;
			a[i] = s[0] != 'x' ? stoi(s) : INF;
		}
		int f = 1;
		for (int i = 0; i < N; i += 2) {
			if (a[i] == INF) continue;
			if (i && a[i - 1] != INF && a[i - 1] <= a[i]) f = 0;
			if (i + 1 != N && a[i + 1] != INF && a[i] >= a[i + 1]) f = 0;
		}
		for (int i = 1; i < N; i += 2) {
			if (a[i] == INF) continue;
			if (a[i - 1] != INF && a[i - 1] >= a[i]) f = 0;
			if (i + 1 != N && a[i + 1] != INF && a[i] <= a[i + 1]) f = 0;
		}
		for (int i = 1; i < N; i++) {
			if (a[i - 1] == a[i]) f = 0;
		}
		if (!f) cout << "none" << endl;
		else if (find(a, a + N, INF) == a + N) cout << "ambiguous" << endl;
		else {
			int l = -INF, r = INF;
			for (int i = 0; i < N; i += 2) {
				if (a[i] != INF) continue;
				if (i) r = min(r, a[i - 1] - 1);
				if (i + 1 != N) r = min(r, a[i + 1] - 1);
			}
			for (int i = 1; i < N; i += 2) {
				if (a[i] != INF) continue;
				l = max(l, a[i - 1] + 1);
				if (i + 1 != N) l = max(l, a[i + 1] + 1);
			}
			if (r - l < 0) cout << "none" << endl;
			else if (r - l > 0) cout << "ambiguous" << endl;
			else cout << l << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3000
N,M=map(int,input().split())
stu=[]
for i in range(N):
  a,b=map(int,input().split())
  stu.append([a,b])
pl=[]
for j in range(M):
  c,d=map(int,input().split())
  pl.append([c,d])
for k in range(N):
  met=4*(10**8)+1
  pr=0
  for l in range(M):
    if abs(pl[l][0]-stu[k][0])+abs(pl[l][1]-stu[k][1])<met:
      met=abs(pl[l][0]-stu[k][0])+abs(pl[l][1]-stu[k][1])
      pr=l+1
  print(pr)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define sort(v) sort(v.begin(),v.end());
const ll mod = 1E9+7;

int main()
{
   // ll n;
   // cin>>n;
   // string ans;
   // while(n!=0){
   //    ll r = n%26 - 1;
   //    char x = char(r+97);
   //    ans+=x;
   //    n = (n-r)/26;
   // }
   // reverse(ans.begin(),ans.end());
   // cout<<ans<<endl;
   char x;
   cin>>x;
   ll n = x;
   if(n < 97){
      cout<<"A";
   }
   else{
      cout<<"a";
   }
  
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] array = Console.ReadLine().Split(' ').Select(x => x).ToArray();
            HashSet<string> hsTable = new HashSet<string>();

            //var num = int.Parse(Console.ReadLine());
            //var num2 = Console.ReadLine().Split(' ').GroupBy(a => a).ToArray().Length;
            //if (num == num2)
            //    Console.Write("YES");
            //else
            //    Console.Write("NO");



            string message = "";
            for (long j = 0; j < N; j++)
                hsTable.Add(array[j]);
            if (N == hsTable.Count)
                message = "YES";
            else
                message = "NO";
            Console.WriteLine(message);






           
        }
    }
}

//24579 =  hon
//0168 = pon
//3 = bon
//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


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

int main() {
	int a, b, k;
	while ( cin >> a >> b >> k ) {
		vector<int> ans;
		
		for (int i = min(a,b); i >= 1; --i) {
			if ( a % i or b % i );
			else ans.push_back(i);
		}
		
		cout << ans[ k-1 ] << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline long long read()
{
	long long ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
inline long long read_l()
{
	long long ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
long long n;
long long m;
long long a[100010];
long long s[100010];
long long ans=0;
bool check(long long x)
{
	long long tot=0;
	for(long long i=1;i<=n;i++) tot+=lower_bound(a+1,a+n+1,x-a[i])-a-1;
	if(n*n-tot<m) return 1;
	else return 0;
}
int main()
{
	n=read(),m=read_l();
	for(long long i=1;i<=n;i++) a[i]=read_l();
	sort(a+1,a+n+1);
	for(long long i=1;i<=n;i++) s[i]=s[i-1]+a[i];
	long long l=1,r=999999999;
	while(l+1<r)
	{
		long long mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid;
	}
	for(long long i=1;i<=n;i++) 
	{
		long long x=lower_bound(a+1,a+n+1,l-a[i])-a;
		ans+=s[n]-s[x-1];
		ans+=a[i]*(n-x+1);
	}
	long long tot=0;
	for(long long i=1;i<=n;i++) tot+=lower_bound(a+1,a+n+1,l-a[i])-a-1;
	if(n*n-tot>m) ans-=(n*n-tot-m)*l;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int a,b,c,k,i;
  string s;

    cin >> a >> s;
  
  
    if(s.length()>a){
      for(i=0;i<a;i++){
        cout << s[i];
      }
      cout << "..." << endl;
    }
  	
    else cout << s << endl;
}

Measured memory_bytes: 3624
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(k, x) = in.readLine().split("\\s+").map(_.toInt)

    out.println(
      if (500 * k >= x) {
        "Yes"
      } else {
        "No"
      }
    )

    out.flush()
  }
}


Measured memory_bytes: 25548