akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = 1 << 28;

int main() {
    int N;
    cin >> N;
    vi V(N), C(N);
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }
    int ret = 0;
    for (int i = 0; i < N; ++i) {
        ret += max(V[i] - C[i], 0);
    }
    cout << ret << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        System.out.println(s.charAt(0) + "" + (s.length() - 2) + s.charAt(s.length() - 1));
    }
}

Measured memory_bytes: 22868
s = int(input())
a = [0] * (1000000+7)
a[0] = s
for i in range(1,1000001):
    if a[i-1] % 2 == 0:
        a[i] = a[i-1] // 2
    else:
        a[i] = a[i-1] * 3 + 1
for i in range(1,1000001):
    for j in range(0,i):
        if a[i] == a[j]:
            print(i+1)
            break
    else:
        continue
    break

Measured memory_bytes: 48236
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;
  for(int i = 1; i < n; i++){
    set< char > x;
    for(int j = 0; j < i; j++){
      x.insert(s[j]);
    }
    set< char > y;
    for(int j = i; j < n; j++){
      y.insert(s[j]);
    }
    int count = 0;
    for(char ch: x){
      if(y.find(ch) != y.end()){
        ++count;
      }
    }
    ans = max(ans, count);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [x, y, z] <- fmap read . words <$> getLine :: IO [Int]
    let f n = y * n + z * (n + 1)
    let ans = takeWhile (<= x) $ fmap f [1 ..]
    print $ length ans

Measured memory_bytes: 508
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();

    let mut is_prime = vec![true; 1000001];
    is_prime[0] = false;
    is_prime[1] = false;
    let mut primes = Vec::new();
    for i in 2..=1000000 {
        if is_prime[i] {
            primes.push(i);

            for x in (2..).map(|j| i * j).take_while(|&x| x <= 1000000) {
                is_prime[x] = false;
            }
        }
    }

    let mut m = HashMap::<usize, usize>::new();
    for &aa in a.iter() {
        let mut aa = aa;
        for p in primes.iter() {
            if p * p > aa {
                break;
            }
            if aa % p == 0 {
                *m.entry(*p).or_insert(0) += 1;

                while aa % p == 0 {
                    aa /= p;
                }
            }
        }

        if is_prime[aa] {
            *m.entry(aa).or_insert(0) += 1;
        }
    }

    if m.values().all(|&v| v <= 1) {
        println!("pairwise coprime");
    } else if m.values().all(|&v| v < n) {
        println!("setwise coprime");
    } else {
        println!("not coprime");
    }
}

Measured memory_bytes: 17880
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            s = string.Join("", s.OrderBy(x => x));
            t = string.Join("", t.OrderByDescending(x => x));
            if (s == t)
            {
                Console.WriteLine("No");
                return;
            }
            var tmp = new string[] { s, t };
            Array.Sort(tmp);
            Console.WriteLine(tmp[0] == s ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27104
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
  int n; 
  cin >> n;
  vector<int> curr;
  for (int i = 0; i < n; i++){
    int x; cin >> x;
    if (x % 2 == 0) 
      curr.push_back(x);
  }
  int ret = 0;
  for (auto it : curr)
    ret += it % 3 == 0 || it % 5 == 0;
  bool ok = ret == (int)curr.size();
  if (ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long> card;
	for (int i = 0; i < N; i++) {
		long long t;
		cin >> t;
		if (i != 0) {
			card.push_back(t + card[i - 1]);
		}
		else {
			card.push_back(t);
		}
	}
	long long total = card[N - 1];

	int count = 0;
	long long min = numeric_limits<long long>::max() - 1;
	for (int i = 0; i < N - 1; i++) {
		long long x, y, z;
		x = card[i];
		y = total - card[i];
		z = abs(x - y);
		if (min > z) {
			min = z;
		}
	}
	cout << min << endl;
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, ans = 0;
  cin >> n;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
  	ans = __gcd(ans, x);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();

        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();
        StringBuilder U = new StringBuilder();

        for (int i = 0; i < N; i++) {
            U.append(S[i]);
            U.append(T[i]);
        }

        System.out.println(U);
    }
}

Measured memory_bytes: 23636
def topologicalSort(g: list, deg: list):
	ret = []
	q = []
	for i, d in enumerate(deg):
		if not d:
			ret.append(i)
			q.append(i)
	while q:
		cur = q.pop(0)
		for nxt in g[cur]:
			deg[nxt] -= 1
			if not deg[nxt]:
				ret.append(nxt)
				q.append(nxt)
	return ret

def main():
	v, e, *L = map(int, open(0).read().split())
	g = [[] for _ in range(v)]
	deg = [0] * v
	for s, t in zip(*[iter(L)] * 2):
		g[s].append(t)
		deg[t] += 1
	print("\n".join(map(str, topologicalSort(g, deg))))

if __name__ == "__main__":
	main()



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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

typedef pair<int, int> P;
#define INF 1e9
#define INF_LL 1LL<<60
#define ll long long
int result[15]; /* 1:正直者、-1:うそつき */
vector<P> youso[15];

#define MAX_V       (301)

int main() {
    int n;
    cin >> n;
    int pattern = 1 << n;
    int ans = 0;

    REP(i, n) {
        int tmp;
        cin >> tmp;
        REP(j, tmp) {
            int x, y;
            cin >> x >> y;
            x--;
            youso[i].push_back(make_pair(x, y));
        }
    }

    REP(i, pattern) {
        int tmp = 0;
        bool seikou = true;
        REP(j, n) {
            if((i >> j) & 1) {
                result[j] = 1;
                tmp++;
            } else {
                result[j] = 0;
            }
        }
        //cout << tmp << endl;
        REP(j, n) {
            if((i >> j) & 1) {
                REP(k, youso[j].size()) {
                    if(youso[j][k].second != result[youso[j][k].first]) {
                        seikou = false;
                        break;
                    }
                }
            }
        }
        if(seikou) {
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
def abc():
    n = int(input())
    odd = [x for x in range(1, n + 1) if x % 2]
    cnt = 0
    for o in odd:
        divisor = [x for x in range(1, o + 1) if o % x == 0]
        if len(divisor) == 8:
            cnt += 1
    print(cnt)


abc()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 200000 + 10;

int X, K, Q;
int r[MAXN];

struct Fun {
    int a,b,c;
};

Fun f[MAXN+1];

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin >> X >> K;

    vector<pair<int, bool>> ev;
    r[0] = 0;
    ev.push_back({0, true});
    for (int i = 0; i < K; i++) {
        cin >> r[i+1];
        ev.push_back({r[i+1], true});
    }

    cin >> Q;

    vector<pair<int,int>> queries;
    queries.resize(Q);
    for (int i = 0; i < Q; i++) {
        cin >> queries[i].first >> queries[i].second;
        ev.push_back({queries[i].first, false});
    }

    sort(begin(ev)+1, end(ev));

    f[0] = Fun({0, X, 0});

    bool dec = true;

    
    for (int i = 1; i < ev.size(); i++) {
        int a, b, c;
        tie(a, b, c) = make_tuple(f[i-1].a, f[i-1].b, f[i-1].c);
        int d = ev[i].first - ev[i-1].first;
        if (dec) {
            int m = min(a + c, d);
            c -= m;
            d -= m;

            d = min(d, b-a);

            c -= d;
            a += d;
        } else {
            int m = min(X - (b + c), d);
            c += m;
            d -= m;

            d = min(d, b-a);

            c += d;
            b -= d;
        }
        if (ev[i].second) dec = !dec;
        f[i] = {a, b, c};
    }

    /*cerr << "events\n";
    for (int i = 0; i < ev.size(); i++) {
        cerr << ev[i].first << " " << ev[i].second << " " <<  "\n";
    }*/

    for (auto q: queries) {
        int t = q.first;
        int a = q.second;
        Fun fun = f[(lower_bound(begin(ev), end(ev), make_pair(t, false)) - begin(ev))];
        int res;
        if (a <= fun.a) res = fun.a + fun.c;
        else if (a <= fun.b) res = a + fun.c;
        else res = fun.b + fun.c;

        cout << res << "\n";
        
    }

    return 0;
}


Measured memory_bytes: 12396
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int s1, s2, s3;
	int re = 0, rh = 0;

	while (scanf("%d,%d,%d", &s1, &s2, &s3) != EOF)
	{
		if (s1*s1 + s2*s2 == s3*s3) re++;
		if (s1 == s2) rh++;
	}

	cout << re << "\n" << rh << endl;

	return 0;
}

Measured memory_bytes: 1212
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 1021
void build(){

}
char c[ N ];
int len;
void init(){
  scanf( "%s" , c );
  len = strlen( c );
}
char cc[ N ];
LL cal( int msk ){
  int ptr = 0;
  for( int i = 0 ; i < len ; i ++ ){
    cc[ ptr ++ ] = c[ i ];
    if( ( msk >> i ) & 1 )
      cc[ ptr ++ ] = '+';
  }
  cc[ ptr ] = '\0';
  LL tsum = 0 , ta = 0;
  for( int i = 0 ; i <= ptr ; i ++ )
    if( i == ptr || cc[ i ] == '+' ){
      tsum += ta; ta = 0;
    }else
      ta = ( ta * 10 ) + cc[ i ] - '0';
  // puts( cc );
  // printf( "%d %lld\n" , msk , tsum );
  return tsum;
}
void solve(){
  if( len == 1 ){
    printf( "%d\n" , c[ 0 ] - '0' );
    exit( 0 );
  }
  int x = len - 1;
  long long ans = 0;
  for( int i = 0 ; i < ( 1 << x ) ; i ++ )
    ans += cal( i );
  printf( "%lld\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))


Measured memory_bytes: 23328
import math
n,a,b = [int(i) for i in input().split()]
mod = 10**9+7
  
def comb(n,k):
  ans = 1
  for i in range(k):
    ans = ans*(n-i)%mod
  for i in range(1,k+1):
    ans = ans*pow(i,mod-2,mod)%mod
  return ans

print((pow(2,n,mod)-1-comb(n,a)-comb(n,b))%mod)
# print(comb(n,a))


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

#define N 200

int pop(void);
void push(int);

int top=0;
int stack[100];

int main(){
    char s[N];
    int a,b;

    while(1){
        if(scanf("%s",s) == EOF) break;
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        } 
        else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        }
        else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }
        else push(atoi(s));
    }
    printf("%d\n",pop());
    return 0;
}

int pop(){
    top--;
    return stack[top+1];
}

void push(int a){
    top++;
    stack[top] = a;
}


Measured memory_bytes: 2120
list = input().split()
a = int(list[0])#体力
b = int(list[1]) #攻撃力
c = int(list[2])#体力
d = int(list[3])#攻撃力

#最初
while c>0 and a>0:
    c = c - b
    if c <= 0:
        print("Yes")
        break
    else:
        pass

    a = a -d
    if a<= 0:
        print("No")
        break
    else:
        pass


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

string s;

int si(int&);
int fi(int&);
int so(int&);

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		int pos = 0;
		cout << so(pos) << endl;
	}

	return 0;
}
int so(int& pos){
	int ans = fi(pos);
	while (s[pos] != '=' && s[pos] != ')'){
		if (s[pos] == '+'){
			ans += fi(++pos);
		}
		else if (s[pos] == '-'){
			ans -= fi(++pos);
		}
	}
	pos++;
	return ans;
}
int fi(int& pos){
	int ans = si(pos);
	while (1){
		if (s[pos] == '*'){
			ans *= si(++pos);
		}
		else if (s[pos] == '/'){
			ans /= si(++pos);
		}
		else {
			return ans;
		}
	}
}

int si(int& pos){
	if (s[pos] != '('){
		int ans = 0;
		while ('0' <= s[pos] && s[pos] <= '9'){
			ans *= 10;
			ans += s[pos] - 48;
			pos++;
		}
		return ans;
	}
	else{
		return so(++pos);
	}
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 5001;
const int mod = 1e9 + 7;
inline int add(ll x, ll y) {return (x + y) % mod;}
inline int mul(ll x, ll y) {return x * y % mod;}
inline int sub(ll x, ll y) {return (x - y + mod) % mod;}
int dp[N][N];
char s[N];
int main()
{
    int n; scanf("%d", &n);
    scanf("%s", s); int m = strlen(s);
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= n; j++)
        {
            dp[i + 1][j + 1] = add(dp[i + 1][j + 1], dp[i][j]); // match
            if (j > 0) dp[i + 1][j - 1] = add(dp[i + 1][j - 1], mul(dp[i][j], 2)); // back
            else dp[i + 1][j] = add(dp[i + 1][j], dp[i][j]); 
        }
    printf("%d\n", dp[n][m]);
    return 0;
}

Measured memory_bytes: 97920
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
bool h[100];
signed main() {
	int a, b, ans = 0;
	cin >> a >> b;
	f(i, b) {
		int c;
		cin >> c;
		f(i, c) {
			int d;
			cin >> d;
			h[d - 1] = true;
		}
	}
	f(i, a) {
		if (!h[i])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1173&lang=jp*/
 
#include <iostream>
#include <stack>
 
using namespace std;

int main()
{
    string s;
 
    while(getline(cin,s) && s!="."){
    	bool is_yes=true;
    	stack<char> stack;
    	
    	for(int i=0;is_yes && i<s.length();i++){
    		if(s[i]=='(' || s[i]=='['){
    			stack.push(s[i]);
    		}else if(s[i]==')' || s[i]==']'){
    			if((s[i]==')' && 0<stack.size() && stack.top()=='(') || (s[i]==']' && 0<stack.size() && stack.top()=='[')){
    				stack.pop();
    			}else{
    				is_yes=false;
    			}
    		}
    	}
    	if(is_yes && stack.size()==0){
    		cout<<"yes"<<endl;
    	}else{
    		cout<<"no"<<endl;
    	}
     }
    return 0;
}

Measured memory_bytes: 1176
input_list = list(map(int, input().split(" ")))

n = input_list[0]
m = input_list[1]
a_i_list = list(map(int, input().split(" ")))


a_i_sum = sum(a_i_list)

result = n - a_i_sum

if result < 0:
    result = -1

print(result)

Measured memory_bytes: 9884
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int n;
    cin >> n;
    vector<vector<int>> f(n, vector<int>(10));
    vector<vector<int>> p(n, vector<int>(11));
    
    REP(i, n) REP(j, 10) cin >> f[i][j];
    REP(i, n) REP(j, 11) cin >> p[i][j];
   
    int ans = -INF;
    for(int mask = 1; mask < (1 << 10); mask++){
        int sum = 0;
        REP(i, n){
            int cnt = 0;
            REP(j, 10) if(mask & (1 << j) && f[i][j]) {
                cnt++;
            }
            
            sum += p[i][cnt];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s, t;
    cin >> s >> t;
    string ans = "UNRESTORABLE";
    for (int i = 0; i + t.size() <= s.size(); i++)
    {
        string tmp = s;
        bool f = true;
        for (int j = 0; j < t.size(); j++)
        {
            if (s[i + j] != '?' && s[i + j] != t[j])
                f = false;
            else
                tmp[i + j] = t[j];
        }
        if (!f)
            continue;
        for (int j = 0; j < tmp.size(); j++)
            if (tmp[j] == '?')
                tmp[j] = 'a';
        if (ans == "UNRESTORABLE" || ans > tmp)
            ans = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
int main() {
	// your code goes here
	char c;
	lli n,k,i,s=0;
	cin>>n>>k;
	vector<lli> v(n);
	for(auto &i:v)
	cin>>i;
	sort(v.begin(),v.end());
	for(i=0;i<k;i++)
	s=s+v[i];
	cout<<s;
	
	return 0;
}

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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int A, B; cin >> A >> B;
	double inf, sup;

	inf = max((double)A / 0.08, (double)B / 0.1);
	sup = min((double)(A + 1) / 0.08, (double)(B + 1) / 0.1);

	int ans = ceil(inf);
	if (ans >= sup)cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3604
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  string s;
  int i;
  cin >> s;
  for(i=0;i<s.size();i=i+2){
    if(s[i]=='h' && s[i+1]=='i'){
    }
    else{
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    int mx = 1e9, ans = 0;
    forn(i, n) {
        if (a[i] <= mx) {
            ans++, mx = a[i];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
#define LL long long int
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL r1,c1,r2,c2;

mint ans = 0;

void solve(){
	vector<mint> pow2(2000001,1);
	for(int i=1;i<=2000000;i++) pow2[i] = pow2[i-1]*mint(2);

	combination c(2000001);

	auto square = [&](LL x,LL y){
		return c(x+y+1,y)+c(x+y+1,y+1)-mint(1);
	};

	ans = square(r2,c2)-(square(r1-1,c2)+square(c1-1,r2)-square(r1-1,c1-1));
}

int main(){
    cin >> r1 >> c1 >> r2 >> c2;

    solve();

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

Measured memory_bytes: 47104
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    }
  long long ma,mi;
  ma=mi=2;
  for(int i=n-1;i>=0;i--){
    if(mi%a[i]!=0&&ma/a[i]==mi/a[i]){
      cout<<"-1"<<endl;
      return 0;
      }
    mi=((mi-1)/a[i])*a[i]+a[i];
    ma=(ma/a[i])*a[i]+a[i]-1;
    }
  cout<<mi<<" "<<ma<<endl;
  return 0;
  }


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b;
	int i;
	int sum;
	cin>>a>>b;
	i=0;
	while(1){
		sum=(a-i)+i*a;
		if(sum>=b)	break;
		i++;
	}
	if(b==1)	cout<<0<<endl;
	else 		cout<<i+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,i,j,k,rows,cols;
    for(a=0;;a++)
    {
        scanf("%d %d",&rows,&cols);
        if(rows==0 && cols==0)
            break;
        else
      {

    k = 1;

    for(i=1; i<=rows; i++)
    {
        for(j=1; j<=cols; j++)
        {
            if(k == 1)
            {
                printf("#");
            }
            else
            {
                printf(".");
            }
            k *= -1;
        }

        if(cols % 2 == 0)
        {
            k *= -1;
        }

        printf("\n");
    }
    printf("\n");
    }
    }

    return 0;
}



Measured memory_bytes: 2060
//PLUS ULTRA
//one who sits atop all the clans : Lion's Sin Escanor 

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;


void solve(){

	int n ,m ; cin >> n >> m;
	std::vector<int> obs[n+1];

	int h[n+1];
	forn(i,1,n+1)cin >> h[i];

	int u  , v;

	forn(i,0,m){
		cin >> u >> v;
		obs[u].pb(v);
		obs[v].pb(u);

	}

	int ans = 0;
	bool flag ;

	forn(i,1,n + 1){
		// bool flag = true;

		flag = true;
		int siz = obs[i].size();
		forn(j,0,siz){
			
			if(h[i] <= h[obs[i][j] ] ){
				flag = false;
				break;
			}
		}

		// if(flag)cout << i << "\n";

		if(flag)ans++;

	}


	cout << ans << "\n";
    
        


}

int main(){
    SPEED;

    solve();


    return 0;
}
      
       


Measured memory_bytes: 9120
class Main{

	public static void main(String[] a){
		int j = 1;
		int i = 1;

		for(int count = 1; count < 10; count++){
			System.out.println(i +"x" +  j + "=" + i * j);
			j++;
			if( j == 10){
				i++;
				j = 1;
				count = 0;
				if(i == 10){
					count = 10;
				}
			}
		}
	}
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

ll a, b, c;

bool ok() {
	if(a & 1 || b & 1 || c & 1)
		return 0;
	return 1;
}

int main() {
	megaRandom();
	cin >> a >> b >> c;
	int cnt = 0;
	while(ok() && cnt <= (int)5e7) {
		//cout << a << ' ' << b << ' ' << c << "\n";
		ll sum_a = b / 2 + c / 2;
		ll sum_b = a / 2 + c / 2;
		ll sum_c = a / 2 + b / 2;	
		a = sum_a , b = sum_b, c = sum_c;
		cnt ++;
		
	}
	if(cnt > (int)5e7) 
		cout << "-1";
	else   
		cout << cnt;
	
	return 0;         
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
    
    long long N;
    cin >> N;
    long long cnt[10][10]={};
    for(int i = 1; i <= N; i++){
        string s = to_string(i);
        cnt[s.front()-'0'][s.back()-'0']++;
    }
    
    long long ans = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct LazySegmentTree{
private:
   int n;
   vector<ll> node,lazy;
public:
   LazySegmentTree(int sz,ll init=0){
      n=1;
      while(n<sz)n*=2;
      node.resize(2*n-1,init);
      lazy.resize(2*n-1,0);
   }

   void eval(int k,int l,int r){
      if(lazy[k]!=0)node[k]+=lazy[k];
      if(r-l>1){
          lazy[2*k+1]+=lazy[k];
          lazy[2*k+2]+=lazy[k];
      }
      lazy[k]=0;
   }
      //[a,b)にxを加算
   void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
       if(r<0)r=n;
       eval(k,l,r);
       if(r<=a||b<=l)return;
       if(a<=l&&r<=b){
          lazy[k]+=x;
          eval(k,l,r);
       }
       else {
          add(a,b,x,2*k+1,l,(l+r)/2);
          add(a,b,x,2*k+2,(l+r)/2,r);
          node[k]=min(node[2*k+1],node[2*k+2]);
        }
   }
   //[a,b)でのminを返す
   ll get(int a,int b,int k=0,int l=0,int r=-1){
      if(r<0)r=n;
      eval(k,l,r);
      if(r<=a||b<=l)return longinf;
      if(a<=l&&r<=b)return node[k];
      ll xl=get(a,b,2*k+1,l,(l+r)/2);
      ll xr=get(a,b,2*k+2,(l+r)/2,r);
      return min(xl,xr);
   }
};

ll dp[202020];


int main(){
    int n,m;
    cin>>n>>m;
    vector<pll> a[n+1];
    ll ans=0;
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        ans+=z;
        a[y].emplace_back(x,z);
    }
    rep(i,n+1)dp[i]=longinf;
    LazySegmentTree sg(n+1,0);
    dp[0]=0;
    rep(i,n){
        dp[i+1]=dp[i];
        sg.add(i+1,i+2,dp[i+1]);
        for(auto p:a[i+1])sg.add(0,p.first,p.second);
        dp[i+1]=min(dp[i+1],sg.get(0,i+1));
    }
    cout<<ans-dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> a;
int main() {
  cin >> N;
  a.resize(N);
  rep(i, N) cin >> a[i];

  int c = 1;

  rep(i, N) if (a[i] == c)++ c;

  cout << (c == 1 ? -1 : N - c + 1) << endl;

  return 0;
}


Measured memory_bytes: 1024
import math
N = int(input())
S = input()

w = [0]*N
e = [0]*N
if S[0] == 'W':
    w[0] += 1
if S[N-1] == 'E':
    e[N-1] += 1
for i in range(1,N):
    w[i] = w[i-1]
    e[N-i-1] = e[N-i]
    if S[i] == 'W':
        w[i] += 1
    if S[N-i-1] == 'E':
        e[N-i-1] += 1

m = float("inf")
for i in range(N):
    cnt = w[i] + e[i] - 1
    if cnt < m:
        m = cnt
print(m)


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

int main() {
  int height[10];
  for (int i = 0; i < 10; ++i) {
    cin >> height[i];
  }
  int maxHight[3] = {0, 0, 0};
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (maxHight[j] < height[i]) {
	for (int k = 2; k > j; --k) { // 入れ替える
	  maxHight[k] = maxHight[k-1];
	}
	maxHight[j] = height[i];
	break;
      }
    }
  }
  for (int i = 0; i < 3; ++i) {
    cout << maxHight[i] << endl;
  }
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <iomanip>
#include <deque>
#include <list>
#include <cassert>
#include <complex>
#include <bitset>
#include <deque>


using namespace std;
typedef long long ll;
//#define int ll
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
#define mmin(a, b) a = min(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;


const int N = 1 << 10, K = 101, oo = 1e9 + 10, A = 201, B = 400, psz = 20;
const ll M = 1e9 + 9, x = 100019;
const ld pi = atan2(1, 0) * 2;


int skip[N], num[N], n, m;;
vvi mp;


int count()
{
	fill(num, num + N, 0);
	int ans = 1;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			if (!skip[mp[i][j]])
			{
				num[mp[i][j]]++;
				
				if (num[ans] < num[mp[i][j]])
					ans = mp[i][j];

				break;
			}
		}

	skip[ans] = 1;
	return num[ans];
}


signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> n >> m;
	
	mp.resize(n);
	for (int i = 0; i < n; ++i)
	{
		mp[i].resize(m);
		for (int j = 0; j < m; ++j)
			cin >> mp[i][j];
	}
	
	int ans = n;
	for (int i = 0; i + 1 < m; ++i)
		ans = min(ans, count());
	
	cout << ans << '\n';
}

Measured memory_bytes: 640
n, k  = map(int, input().split())
w = []
def check(ptest):
    tk=1
    p=0
    global k
    global w
    global n
    i=0
    
    while i<n:
        p+=w[i]
        if p<=ptest:
            i+=1
        else:
            tk+=1
            p=0
            
        if tk>k:
            return 0
            #break   
    
    return 1
for i in range(n):
    w.append(int(input()))
pmax = sum(w)
pmin = pmax//k - 1


while (pmax - pmin) > 1:
    pmid = (pmax + pmin)//2
    if check(pmid) == 1:
        pmax = pmid
    else:
        pmin = pmid
print(pmax)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 367
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int p,q,r;
    cin>>p>>q>>r;
    OUT(p+q+r-max({p,q,r}));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;
 
int n;
int main()
{
        int m,d;
 
        cin>>m>>d;
 
        int ans = 0;
        for(int i=1;i<=m;i++){
            for(int j=20;j<=min(d,99);j++){
                if(j%10 < 2)continue;
                if((j/10) * (j%10)  == i){
                    ans++;
                }
            }
        }

     cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<cstdlib>



using namespace std;

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

vector<string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};



int main(){
    string s;
    cin >> s;
    int n = 7;
    int ans;
    rep(i,n){
        //cout << v[i] << endl;
        if(s == v[i]){
            // cout << v[i] << endl;
            ans = n - i;
        }
    }
    cout << ans << endl;
    



    return 0;
}

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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    
    int i;
    vector<int> aa, bb, common;
    for(i=1; i<=a; i++) {
        if( a % i == 0 ) aa.push_back(i); 
    }

    for(i=1; i<=b; i++) {
        if( b % i == 0 ) bb.push_back(i); 
    }

    set_intersection(aa.begin(), aa.end(), bb.begin(), bb.end(), back_inserter(common));
    sort(common.begin(), common.end(), greater<int>());
    cout << common[k-1] << "\n";

    return 0;
}

Measured memory_bytes: 256
n,t[999],a;
int main(i){for(;n*=scanf("%d",&n);puts("")){
    for(i=999;t[--i]=i;);
    for(;n--;t[i]=*t)scanf(" %c %c",&i,t);
    for(scanf("%d",&n);n--;putchar(t[a]))scanf(" %c",&a);
  }
}

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

int main()
{
  int n, l;
  cin >> n >> l;
  vector<string> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int i = 0; i < n; i++) {
    cout << vec.at(i);
  }
  
  return 0;
}

Measured memory_bytes: 256
from math import ceil
n = int(input())
A = []
B = []
for i in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A = A[::-1]
B = B[::-1]
cnt = 0
for i in range(n):
    a = A[i]+cnt
    b = B[i]
    cnt += b*ceil(a/b)-a
print(cnt)    

Measured memory_bytes: 11844
#include<bits/stdc++.h>
#include<vector>
using namespace std;
const int maxn=1e5+5;
int fa[maxn]; int sz[maxn]; int c[maxn]; int res[maxn];
inline int find(int x) { return x==fa[x]?x:fa[x]=find(fa[x]); }
void merge(int x,int y)
{
	x=find(x); y=find(y);
	if(x==y) return ;
	fa[x]=y;
	sz[y]+=sz[x];
}
int main(void)
{
	int n,m,k; scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1;
	for(int i=1;i<=m;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		c[x]++; c[y]++;
		merge(x,y);
	}
	for(int i=1;i<=n;i++) res[i]=sz[find(i)]-1-c[i];
	for(int i=1;i<=k;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		if(find(x)==find(y))
		{
			res[x]--;
			res[y]--;
		}
	}
	for(int i=1;i<=n;i++) printf("%d%c",res[i],(i==n)?'\n':' ');
	return 0;
}



Measured memory_bytes: 2816
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

n = n_in()

from itertools import product
from collections import Counter
c = Counter()

for x,y, z in list(product(range(1, 101), repeat=3)):
       c[x*x+y*y+z*z+x*y+y*z+z*x] += 1

for i in range(1,n+1):
    print(c[i])
           




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

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

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{
    ll N, M;
    cin >> N >> M;
    vec A(M+1), C(M+1, 0);
    REP(i,1,M+1) {
        ll b;
        cin >> A[i] >> b;
        REP(j,1,b+1) {
            ll c;
            cin >> c;
            C[i] += 1 << (c - 1);
        }
    }

    mat dp(M+1, vec(1<<N, INF));
    dp[0][0] = 0;
    REP(i,1,M+1) {
        REP(j,0,1<<N) {
            dp[i][j] = MIN(dp[i][j],dp[i-1][j]);
            dp[i][j|C[i]] = MIN(dp[i][j|C[i]],dp[i-1][j]+A[i]);
            dp[i][j|C[i]] = MIN(dp[i][j|C[i]],dp[i-1][j|C[i]]);
        }
    }

    ll ans = dp[M][(1<<N)-1] < INF ? dp[M][(1<<N)-1] : -1;
    PR(ans);

    return 0;
}

/*



*/

Measured memory_bytes: 35440
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static long mod = (long)(Math.Pow(10, 9) + 7);
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int n=Read.Int();
        int[] a = Read.ints();
        Array.Sort(a);
        Array.Reverse(a);
        int ans = 0;
        int[] answer = new int[2];
        for (int i = 0; i < a.Length; i++)
        {
            answer[i % 2] += a[i];
        }
        Console.WriteLine(answer[0]-answer[1]);
    }
    public static long gcd(long a, long b)
    {
        if (b == 0) { return a; }
        return gcd(b, a % b);
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static string Reverse(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
def main():
    n = input()
    h = list(map(int, input().split()))[::-1]
    low = h[0]
    for i in h:
        if low > i:
            low = i
        elif i - low > 1:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 14396
n = int(input())
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)

    # divisors.sort()
    return divisors
  
x = make_divisors(n)
div = sorted(x)[len(x)//2]
print(n // div + div - 2)

Measured memory_bytes: 3296
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int buka[n];
    for (int i = 0; i < n; i++) {
        buka[i] = 0;
    }
    for (int i = 1; i < n; i++) {
        int boss;
        cin >> boss;
        boss -= 1;
        if (boss >= 0) buka[boss]++;
    }
    for (int i = 0; i < n; i++) {
        cout << buka[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4392
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] s = scanner.next().toCharArray();

    StringBuilder sb = new StringBuilder();
    for (char c : s) sb.append((char) ((c - 'A' + N) % 26 + 'A'));
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 21972
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	if(c - a - b < 0)
		cout << "No";
	else {
		if((4 * a * b) < (c - a - b) * (c - a - b))
			cout << "Yes";
		else
			cout << "No";
	}
	return 0;
}


Measured memory_bytes: 3660
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
mini = 10**15
for _ in range(5):
    temp = inp()
    if temp < mini: mini = temp

ans = n//mini + (n%mini != 0)+4
print(ans)

Measured memory_bytes: 12528
from collections import Counter
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())
count1 = Counter(s)
count2 = Counter(t)
ans = -1 * M
for key in count1.keys():
    ans = max(ans, count1[key] - count2[key])
ans = max(ans, 0)
print(ans)

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

int main()
{
	long long N, A, B;
	cin >> N >> A >> B;

	long long d = abs( A - B );
	long long ans = d / 2;
	if( d % 2 ) {
		long long h = max( abs(A - 1), abs( B - 1 ) );
		long long l = max( abs(N - A), abs( N - B ) );
		ans = min( h, l );
		h = min( A - 1, B - 1 );
		l = min( N - A, N - B );
		ans = min( ans, min( d / 2 + h + 1, d / 2 + l + 1 ) );
	}

	cout << ans << endl;
}


Measured memory_bytes: 256