akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	int neg = 0;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(a[i] < 0)neg++;
	}
	//0以上を作れるかそうでないか.
	//非負に出来る->負から偶数個選ぶような場合が存在する.

	bool flag = false;
	for(int i = 0;i <= min(neg,k);i+=2){
		if(k - i <= n - neg){
			flag = true;
		}
	}

	if(flag == false){
		 sort(a.begin(), a.end(), [](int i, int j) -> bool {
			return abs(i) < abs(j);
		});

		ll ans = 1;
		for(int i = 0;i < k;i++){
			if(a[i] < 0){
				ans *= (MOD + a[i]);
			}
			else ans *= a[i];

			ans %= MOD;
		}
		cout << ans << endl;
	}
	else{
		//最大限正の数から取って,うしろ2つの積を比較.
		vector<ll> narr;
		vector<ll> parr;
		for(int i = 0;i < n;i++){
			if(a[i] < 0)narr.push_back(a[i]);
			else parr.push_back(a[i]);
		}

		int p = parr.size();
		int q = narr.size();

		sort(parr.begin(),parr.end(),greater<ll>());
		sort(narr.begin(),narr.end());

		int neg_num;
		for(int i = 0;i <= min(q,k);i+= 2)neg_num = i;//negを取る個数
		int pos_num = k - neg_num;//posを取る個数

		while(neg_num && pos_num < p){
			//neg_numを2ずつ減らしてpos_numを2ずつ増やすとき,
			if(narr[neg_num-1] * narr[neg_num-2] >= parr[pos_num] * parr[pos_num+1])break;
			neg_num-=2;
			pos_num += 2;
		}

		ll ans = 1;
		for(int i = 0;i < neg_num;i++){
			ans *= (MOD + narr[i]);
			ans %= MOD;
		}
		for(int i = 0;i < pos_num;i++){
			ans *= parr[i];
			ans %= MOD;
		}

		cout << ans << endl;
	}
}


Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
  os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
  is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}
void fastio(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);
}
int N,M;
int main(){
  cin >> N >> M;
  int X = 100*N+1800*M;
  cout << (X<<M) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
string s;
map<char,int> mp;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	for(int i=0;i<4;i++)
		mp[s[i]]++;
	if(mp.size()==2){
		if(mp.begin()->second==2){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    rep(i,1001)
    {
        //cout << (int)((i+1) * 0.08) << " " << (int)((i+1) * 0.1) << endl; 
        if( (int)((i+1) * 0.08) == A && (int)((i+1) * 0.1) == B )
        {
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
long long int ans[55][5050];
int n,ave;
int x[55];


long long int dp(int m,int sum){
    if(ans[m][sum]!=-1){
        return ans[m][sum];
    }else if(m==0){
        if(sum==2500 && sum==2500-x[0])ans[0][sum]=2;
        else if(sum==2500 || sum==2500-x[0])ans[0][sum]=1;
        else ans[0][sum]=0;
    }else{
        ans[m][sum]=dp(m-1,sum)+dp(m-1,sum+x[m]);
    }
    return ans[m][sum];
}

int main(){
    scanf("%d %d",&n,&ave);
    int q,i,j;
    for(i=0;i<=n-1;i++){
        scanf("%d",&q);
        x[i]=q-ave;
    }
    for(i=0;i<=53;i++)for(j=0;j<=5048;j++)ans[i][j]=-1;
    
    
    long long int count=dp(n-1,2500);
    printf("%lld",count-1);
    
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    cout << (N-1)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(i) ((i)&(-i))
#define ls (p << 1)
#define rs (p << 1 | 1)
using namespace std;

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

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MAXN =  + 15;

int main() {
#ifdef CitricAcid
    freopen ("input.txt", "rt", stdin);
#endif

    int n;
    scanf("%d", &n);
    ll res = 7, tmp = 7;
    bool legal = false;
    for(int i = 1; i <= 50000000; i++) {
        // cout << res << endl;
        if(res % n == 0) {
            legal = true;
            printf("%d\n", i);
            break;
        }
        tmp = tmp * 10 % n;
        res = (res + tmp) % n;
    }
    if(!legal) printf("-1\n");

#ifdef CitricAcid
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
/*
# author : CitricAcid
# date : 2020/08/03
*/

Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

signed main(){
	int N,H,M;
	cin>>N;
	for(int i=0;i<N;i++){
		scanf("%d:%d",&H,&M);
		double d;
		d = abs(360.0*((H%12)*60+M)/(12.0*60.0)-360.0*M/60.0);
		if(d>180.0) d = 360.0-d;
		if(d<30) puts("alert");
		else if(90<=d && d<=180) puts("safe");
		else puts("warning");
	}
	return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
using namespace std;

int main(){
	int n,m,c,totl=0;
	int b[30],a;
	scanf("%d%d%d",&n,&m,&c);
	for(int i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(int i=0;i<n;i++){
		int sum=0;
		for(int j=0;j<m;j++){
			scanf("%d",&a);
			sum+=a*b[j];
		}
		sum+=c;
		if(sum>0){
			totl++;
		}
	}
	printf("%d\n",totl);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() { 
  int64_t n, d;
  cin >> n >> d;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int64_t x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

def dfs(v):
    global ct
    visit[v][0] = True
    for next in g[v]:
        if visit[next][0]:
            continue
        else:
            visit[next][1] = visit[v][1] + 1
            if visit[next][1] >= 3:
                continue
            dfs(next)
n, m = na()
g = [[] for i in range(n)]
for i in range(m):
    a, b = na()
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

visit = [[False, 0] for i in range(n)]
ct = 0
dfs(0)
print('POSSIBLE' if visit[n - 1][0] and visit[n - 1][1] <= 2 else 'IMPOSSIBLE')

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

namespace ConsoleApp32 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //初めに、全ての経路の和を計算する
            int total_len = Math.Abs(A[0]);
            for (int i = 0; i < N - 1; i++) {
                total_len += Math.Abs(A[i + 1] - A[i]);
            }
            total_len += Math.Abs(A[N - 1]);
            
            for (int i = 0; i < N; i++) {
                if (i == 0) {
                    if ((A[i + 1] - A[i]) * (A[i] - 0) >= 0) {
                        Console.WriteLine(total_len);
                    } else if ((A[i] - A[i + 1]) * (A[i + 1] - 0) >= 0) {
                        Console.WriteLine(total_len - 2 * Math.Abs(A[i] - A[i + 1]));
                    } else if ((A[i] - 0) * (0 - A[i + 1]) >= 0) {
                        Console.WriteLine(total_len - 2 * Math.Abs(A[i] - 0));
                    }
                    continue;
                }

                if (i == N - 1) {
                    if ((0 - A[i]) * (A[i] - A[i - 1]) >= 0) {
                        Console.WriteLine(total_len);
                    } else if ((A[i] - 0) * (0 - A[i - 1]) >= 0) {
                        Console.WriteLine(total_len - 2 * Math.Abs(A[i] - 0));
                    } else if ((A[i] - A[i - 1]) * (A[i - 1] - 0) >= 0) {
                        Console.WriteLine(total_len - 2 * Math.Abs(A[i] - A[i - 1]));
                    }
                    continue;
                }

                if ((A[i + 1] - A[i]) * (A[i] - A[i - 1]) >= 0) {
                    Console.WriteLine(total_len);
                } else if ((A[i] - A[i + 1]) * (A[i + 1] - A[i - 1]) >= 0) {
                    Console.WriteLine(total_len - 2 * Math.Abs(A[i] - A[i + 1]));
                } else if ((A[i] - A[i - 1]) * (A[i - 1] - A[i + 1]) >= 0) {
                    Console.WriteLine(total_len - 2 * Math.Abs(A[i] - A[i - 1]));
                }

                
            }
        }
    }
}

Measured memory_bytes: 28124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char[] cs;
    int w;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        w = sc.nextInt();
        solve();
    }

    void solve() {
        for (int i = 0; i < cs.length; i += w) {
            System.out.print(cs[i]);
        }
        System.out.println();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n;
	cin >> n;
	vector<pair<ll, ll>> cnt(n, {0, 0}); // {cnt2, cnt5}
	for (ll i = 0; i < n; i++) {
		string s;
		cin >> s;
		ll m = s.size();
		for (ll j = 0; j < m; j++) {
			if (s[j] == '.') {
				cnt[i] = {9 - (m - 1 - j), 9 - (m - 1 - j)};
				s.erase(s.begin() + j);
				m--;
				break;
			}
			if (j == m - 1) cnt[i] = {9, 9};
		}
		ll x = stoll(s);
		while (x % 2 == 0) {
			cnt[i].first++;
			x /= 2;
		}
		while (x % 5 == 0) {
			cnt[i].second++;
			x /= 5;
		}
	}

	ll ans = 0;
	vector<vector<ll>> v(19, vector<ll>(19, 0));
	for (ll i = 0; i < n; i++) {
		auto [a, b] = cnt[i];
		ans += v[max(0ll, 18 - a)][max(0ll, 18 - b)];
		for (ll j = 0; j <= min(18ll, a); j++) {
			for (ll k = 0; k <= min(18ll, b); k++) {
				v[j][k]++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 6372
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <sstream>
#include <fstream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
#ifdef IDE
    freopen("C:\\file.in", "r", stdin);
    //    freopen("C:\\n.in", "w", stdout);
#endif

    int n;
    string s, t;
    cin >> n >> s >> t;
    int res = 0;
    for (int st = 0; st < n; ++st) {
        bool ok = true;
        for (int i = st; i < n; ++i) {
            if (s[i] != t[i-st]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            printf("%d\n", 2*n-(n-st));
            return false;
        }
    }
    printf("%d\n", s.size() + t.size());
    return true & false;
}

Measured memory_bytes: 256
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-05-10(Sun)
   note   
**********************************************************************/

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  // 1. k == a 
  if (a >= k) {
    ans = k;
  }
  // 2. k == b
  else if (b >= k && a == 0) {
    ans = 0;
  }
  // 3. k == c
  else if (c >= k && a == 0 && b == 0) {
    ans = -k;
  }
  // 4. a < k && a + b >= k
  else if (a < k && a + b >= k) {
    ans = a;
  }
  // 5. a < k && a + c >= k
  else if (a < k && a + c >= k && b == 0) {
    ans = 2*a - k;
  }
  // 
  else if (a == 0 && b < k && b + c >= k) {
    ans = b - k;
  }
  //
  else if (a + b < k && a + b + c >= k) {
    ans = 2*a + b - k;
  }

  cout << ans << endl;
}

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

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

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


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

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

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

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

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

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

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

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

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

    if arr==[]:
        arr.append([n, 1])
    return arr

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

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

N = inputI()

if N%2 == 1:
  print(0)
  exit()
  
ans = 0
for i in range(1,28):
  ans += (N//2)//pow(5,i)
  
print(ans)

Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
int main() {
    int q,d,ans=0; cin >> q >> d;
    long double x,y;
    while(q--){
        cin >> x >> y;
        if(sqrt(x*x+y*y) <= d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3844
<?php

fscanf(STDIN, "%d%d",$D, $G);
$list = [];
$max_p = 0;
for($i=1;$i<=$D;$i++){
    fscanf(STDIN, "%d%d", $n,$bonus);
    $list[$i] = [$i*100, $n, $bonus];
    $max_p = max($max_p, $n);
}
$ans = PHP_INT_MAX;
for($i=0;$i<(2**$D);$i++){
    $t_now = $G;
    $t_ans = 0;
    for($j=1;$j<=($D);$j++){

        if(($i & (2**($j-1))) > 0){
            $t_now -= ($list[$j][0] * $list[$j][1] + $list[$j][2]);
            $t_ans += $list[$j][1];
        }
    }
    for($j=$D;$j>0;$j--){
        if ($t_now <= 0) {
            break;
        }
        if(($i & (2**($j-1))) === 0) {

            if ($t_now >= ($list[$j][0] * ($list[$j][1] - 1))) {
                $t_now -= ($list[$j][0] * ($list[$j][1] - 1));
                $t_ans += ($list[$j][1] - 1);
            } else {
                while ($t_now > 0) {
                    $t_now -= $list[$j][0];
                    $t_ans++;
                }
            }
        }
    }
    if($t_now > 0){
        continue;
    }
    $ans = min($ans, $t_ans);
}
echo $ans.PHP_EOL;


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

int main(){
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if(b >= 0 && d >= 0){
    if(a <= 0 && c <= 0)
      cout << max(a*c, b*d) << endl;
    else
      cout << b * d << endl;
  }
  else if(a >= 0 && d <= 0)
    cout << a * d << endl;
  else if(b <= 0 && c >= 0)
    cout << b * c << endl;
  else if(a <= 0 && c <= 0)
    cout << a * c << endl;
  
  return 0;
}

Measured memory_bytes: 3632
n, m = [0] * 2
a = []

def format_input(filename = None):
	global n, m
	global a
	if filename == None:
		n, m = list(map(int, input().split()))
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(1, 10**6)
		m = rng(1, 10**4)
		a = [rng(1, 10**4) for i in range(m)]
		print(n, m)
		print(' '.join(list(map(str, a))))

def get_answer():
	answer = max(n - sum(a), -1)
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)


Measured memory_bytes: 10116
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
int main()
{
    ll H;
    cin >> H;
    ll X = 2;
    while(H >= X)X *= 2;
    cout << X-1 << endl;
    return 0;
}

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

int main() {
	vector<int> a(5);
	for (int& i : a) cin >> i;
	sort(a.begin(), a.end(), [](int& a, int& b)->bool {
		if (a % 10 == 0) return false;
		if (b % 10 == 0) return false;
		return a % 10 < b % 10;
	});
	//for (int& i : a) cout << i << endl;
	vector<double> b(5);
	double ans = 0.0;
	for (int i = 1; i < 5; ++i) {
		b[i] = a[i];
		b[i] /= 10.0;
		b[i] = ceil(b[i]);
		b[i] *= 10.0;
		ans += b[i];
	}
	ans += a[0];
	cout << ans;
}

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

class UnionFind
{
  vector<int> parents;

public:
  UnionFind(int N) : parents(N, -1) {}

  int find(int x)
  {
    if (this->parents[x] < 0)
      return x;
    return this->parents[x] = this->find(this->parents[x]);
  }

  int size(int x)
  {
    return -this->parents[this->find(x)];
  }

  void marge(int x, int y)
  {
    x = this->find(x);
    y = this->find(y);
    if (x == y)
      return;
    if (this->parents[x] > this->parents[y])
      swap(this->parents[x], this->parents[y]);
    this->parents[x] += this->parents[y];
    this->parents[y] = x;
  }

  bool is_same(int x, int y)
  {
    return this->find(x) == this->find(y);
  }

  int count()
  {
    int ans = 0;
    for (auto &p : this->parents)
    {
      if (p < 0)
        ans++;
    }
    return ans;
  }
};

int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (auto &a : A)
  {
    int x, y;
    cin >> x >> y;
    a = {x, y};
  }

  sort(A.begin(), A.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
    if (a.first == b.first)
    {
      return a.second < b.second;
    }
    return a.first < b.first;
  });

  int ans = N;
  for (int ii = 0; ii < N - 1; ii++)
  {
    for (int jj = ii + 1; jj < N; jj++)
    {
      int p = A[jj].first - A[ii].first;
      int q = A[jj].second - A[ii].second;

      UnionFind uf(N);
      for (int kk = 0; kk < N - 1; kk++)
      {
        for (int ll = kk + 1; ll < N; ll++)
        {
          if (A[ll].first - A[kk].first == p && A[ll].second - A[kk].second == q)
          {
            uf.marge(kk, ll);
            break;
          }
        }
      }
      ans = min(ans, uf.count());
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
let n = read_int ()
let ss =
  let rec read i ls = 
    if i = n then ls else read (i + 1) (read_int () :: ls)
  in
  read 0 []
let rec find_min tmp = function
  | [] -> (if tmp = max_int then 0 else tmp)
  | h :: tl ->
    if h mod 10 = 0 then find_min tmp tl else find_min (min tmp h) tl
let () =
  let sum = List.fold_left ( + ) 0 ss in
  ( if sum mod 10 <> 0 then sum
    else
      let new_sum = sum - find_min max_int ss in
      if new_sum mod 10 <> 0 then new_sum else 0 )
  |> Printf.printf "%d\n"

Measured memory_bytes: 384
#!/usr/bin/env python3


def solve(n, x):
    if x == 1 or x == 2 * n - 1:
        return None
    ans = [0 for _ in range(2 * n - 1)]
    ans[n - 1] = x
    ans[n - 2] = x - 1
    ans[n] = x + 1
    rest = set(range(1, 2 * n)) - {x - 1, x, x + 1}
    for i in range(2 * n - 1):
        if ans[i] == 0:
            ans[i] = rest.pop()
    return ans


def main():
    n, x = (int(y) for y in input().split())
    ans = solve(n, x)
    if ans is None:
        print("No")
    else:
        print("Yes")
        print(*ans, sep="\n")


if __name__ == '__main__':
    main()


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

int main() {
	int n, p;
	while (cin >> n >> p, n || p) {
		int mayor[n];
		fill(mayor, mayor + n, 0);
		int stone = p;
		for (int i = 0;; i = (i + 1) % n) {
			if (stone) {
				stone--;
				mayor[i]++;
				if (mayor[i] == p) {
					cout << i << endl;
					break;
				}
			}
			else {
				stone = mayor[i];
				mayor[i] = 0;
			}
		}
	}
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n;  cin >> n;   vector<double> vec(n+1);
    vector< vector<double> > dp(n+1, vector<double>(n+1));
    for(int i=1;n+1>i;i++){
        cin >> vec[i];
    }
    double bir=1.0;
    dp[1][0]=bir-vec[1];
    dp[1][1]=vec[1];
    //cout << dp[1][0] << " " << dp[1][1] << "\n";
    for(int i=2;n>=i;i++){
        for(int j=0;i>=j;j++){
            dp[i][j]=dp[i-1][j-1]*vec[i]+dp[i-1][j]*(bir-vec[i]);
            //cout << dp[i][j] << " ";
        }
        //cout << "\n";
    }
    double ans=0.0;
    for(int i=n/2+1;n>=i;i++){
        ans+=dp[n][i];
    }
    cout << setprecision(12) << ans;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    std::string s;
    std::cin >> s;
    bool ok = true;
    ok &= (s[3 - 1] == s[4 - 1]);
    ok &= (s[5 - 1] == s[6 - 1]);
    std::cout << (ok ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, A, B;
  cin >> N >> A >> B;

  ll ans = 0;
  REP(i, 1, N+1) {
    string c = to_string(i);
    ll sum = 0;
    REP(j, 0, c.size()) {
      sum += stol(c.substr(j, 1));
    }
    if (A <= sum && sum <= B) {
      ans += i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
H = list(map(int, input().split()))
 
dp = [0 for _ in range(N)]
for i in range(1, N):
    min_v = 1050000000
    for j in range(1, K+1):
        if i - j >= 0:
            min_v = min(min_v, dp[i - j] + abs(H[i] - H[i - j]))
    dp[i] = min_v
print(dp[N-1])

Measured memory_bytes: 56032
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NM_MAX = 500002;

const int MOD = 1e9+7;

int pwr(int a, int b)
{
    if(b == 0)
        return 1;
    if(b & 1)
        return 1LL * a * pwr(a, (b ^ 1)) % MOD;
    int aux = pwr(a, (b >> 1));
    return 1LL * aux * aux % MOD;
}

int inv (int a)
{
    return pwr(a, MOD - 2);
}

int n, m;

int fact[NM_MAX], ifact[NM_MAX];

int comb (int a, int b)
{
    return 1LL * fact[a] * ifact[b] % MOD * ifact[a - b] % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    fact[0] = ifact[0] = 1;
    for(int i = 1; i < NM_MAX; i++)
    {
        fact[i] = 1LL * fact[i - 1] * i % MOD;
        ifact[i] = inv(fact[i]);
    }
    int ans = 0;
    for(int i = 0; i <= n; i++)
    {
        int val = 1LL * comb(m - i, n - i) * fact[n - i] % MOD * comb(n, i) % MOD;
        if(i & 1)
            ans = (ans - val + MOD) % MOD;
        else
            ans = (ans + val) % MOD;
    }
    cout << 1LL * ans * comb(m, n) % MOD * fact[n] % MOD << "\n";
    return 0;
}


Measured memory_bytes: 7556
#include <stdio.h>

int main(void)
{
	int n, s, cnt;
	int i, j, k, l, a, b, c, d, e;
	
	while (scanf("%d %d", &n, &s), n != 0 || s != 0){
		cnt = 0;
		for (i = 0; i <= 9; i++){
			if (1 < n){
				for (j = i + 1; j <= 9; j++){
					if (2 < n){
						for (k = j + 1; k <= 9; k++){
							if (3 < n){
								for (l = k + 1; l <= 9; l++){
									if (4 < n){
										for (a = l + 1; a <= 9; a++){
											if (5 < n){
												for (b = a + 1; b <= 9; b++){
													if (6 < n){
														for (c = b + 1; c <= 9; c++){
															if (7 < n){
																for (d = c + 1; d <= 9; d++){
																	if (8 < n){
																		for (e = d + 1; e <= 9; e++){
																			if (i + j + k + l + a + b + c + d + e == s){
																				cnt++;
																			}
																		}
																	}
																	else if (i + j + k + l + a + b + c + d == s){
																		cnt++;
																	}
																}
															}
															else if (i + j + k + l + a + b + c == s){
																cnt++;
															}
														}
													}
													else if (i + j + k + l + a + b == s){
														cnt++;
													}
												}
											}
											else if (i + j + k + l + a == s){
												cnt++;
											}
										}
									}
									else if (i + j + k + l == s){
										cnt++;
									}
								}
							}
							else if (i + j + k == s){
								cnt++;
							}
						}
					}
					else if (i + j == s){
						cnt++;
					}
				}
			}
			else if (i == s){
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
	return (0);
}

Measured memory_bytes: 596
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
p = [0 for i in range(n)]
for a_ in a:
  p[a_ - 1] += 1
for p_ in p:
  if k - q + p_ <= 0:
    print('No')
  else:
    print('Yes')

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;

int main(){
 int M1,D1,M2,D2;cin >> M1 >> D1 >> M2 >> D2;
 if(M1 != M2){
     cout << 1 << endl;
 }else{
     cout << 0 << endl;
 }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}


class Program
{
    public static void Main()
    {
	var t = ReadIntArray();
	int n = t[0], k = t[1];
	var h = new int[n];

	for (int i = 0; i < n; i++)
	{
	    h[i] = int.Parse(ReadLine());
	}

	Array.Sort(h);

	int ans = 2000000000;
	for (int i = 0; i + k - 1 < n; i++)
	{
	    int hMax = h[i+k-1];
	    int hMin = h[i];
	    ans = Math.Min(ans, hMax - hMin);
	}

	WriteLine(ans);
    }
}


Measured memory_bytes: 17632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl;
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll h, w; cin >> h >> w;
    ll ans;

    if(w %2 == 0) if(h %2 == 0) {ans = (h/2) * (w);}
    if(w %2 == 0) if(h %2 == 1) {ans =(h) * (w/2);}
    if(w %2 == 1) if(h %2 == 0) {ans =(h/2) * ((w));}
    if(w %2 == 1) if(h %2 == 1) {ans =(h) * ((w/2))+(h+1)/2;}

    if(w == 1 || h == 1) ans = 1;

    dunk(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long int 
using namespace std;
int main() {
    ll a,b,c,d; 
    cin >> a >> b >> c >> d ; 
    if(a+b< c+d) cout << "Right"; 
    else if(a+b == c+d) cout << "Balanced"; 
    else cout << "Left"; 
    return 0;
}


Measured memory_bytes: 3600
fn gcd(a:i64, b:i64) -> i64 {
    if a > b {
        gcd(b, a);
    }
    return if a == 0 { b } else { gcd(b % a, a) };
}

fn lcm(a:i64, b:i64) -> i64 {
    a * b / gcd(a,b)
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn num_of_not_multiple(n: i64, c:i64, d:i64) -> i64 {
    let common_multiple = lcm(c, d);
    n - (n / c) - (n / d) + (n / common_multiple)
}

fn main() {
    let input_vec = read_vec::<i64>();
    let a = input_vec[0];
    let b = input_vec[1];
    let c = input_vec[2];
    let d = input_vec[3];
    println!("{}", num_of_not_multiple(b, c, d) - num_of_not_multiple(a-1, c, d));
}


Measured memory_bytes: 4352
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll X, an = 1;
	cin >> X;
	ll t = X;
	while (t % 360 != 0) {
		t += X;
		an++;
	}
	cout << an << endl;

}


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

const int SIZE = 200000;
using ll = long long;
ll N;
ll all = 0;
vector<ll> colors(SIZE), cnt(SIZE, 0), sub(SIZE, 0), ans(SIZE, 0);
vector<vector<ll>> T(SIZE);

ll f(ll x){
    return x * (x-1) / 2;
}

ll dfs(int node = 0, int p = -1){
    sub[node] = 1;
    ll bfr = cnt[colors[node]];
    for (ll i : T[node]){
        if (i == p) continue;
        ll pre = all - cnt[colors[node]];
        sub[node] += dfs(i, node);
        ll next = all - cnt[colors[node]];
        ans[colors[node]] -= f(next - pre);
    }
    cnt[colors[node]] = bfr + sub[node];
    all++;
    return sub[node];
}

int main(){
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> colors[i];
        colors[i]--;
        ans[i] += f(N);
    }

    for (int i = 0; i < N-1; i++){
        int a, b; cin >> a >> b;
        a--;b--;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    dfs();
    for (int color = 0; color < N; color++)
        ans[color] -= f(N-cnt[color]);
    for (int i = 0; i < N; i++) ans[colors[i]]++;
    for (int i = 0; i < N; i++) cout << ans[i] << endl;
    
}

Measured memory_bytes: 35920
#include<bits/stdc++.h>
using namespace std;
int dp[6030];
struct node{
    int w,v;
}da[4000];
int cmp(node a,node b){
    return a.w<b.w;
}
int main()
{

    int bagV;
    int n;
    cin>>n>>bagV;
    memset(dp,0,sizeof(dp));
    for(int i=1; i<=n; i++)
        cin>>da[i].w>>da[i].v;
    sort(da+1,da+n+1,cmp);
    for (int i = 1; i <= n; i++)
    {
        for (int j = bagV+3010; j>0 ; j--)
        {
            if(j>=da[i].w&&j-da[i].w<bagV)
            {
                dp[j]=max(dp[j],dp[j-da[i].w]+da[i].v);
            }
        }
    }

    int res=0;
	for(int i=bagV;i<=bagV+3000;i++){
            res=max(res,dp[i]);
	}
	cout<<res<<endl;

    return 0;
}


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

int main() {
	int H, W, D, A, Q, L, R;
	cin >> H >> W >> D;
	vector<pair<int, int>> a(H * W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A;
			a[A - 1] = { i, j };
		}
	}
	cin >> Q;
	vector<int> b(H * W);
	for (int i = D; i < H * W; i++) b[i] = abs(a[i - D].first - a[i].first) + abs(a[i - D].second - a[i].second) + b[i - D];
	for (int i = 0; i < Q; i++) {
		cin >> L >> R;
		cout << b[R - 1] - b[L - 1] << endl;
	}
}

Measured memory_bytes: 2176
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    int m;
    cin >> n >> m;
    int ans=1900*m+100*(n-m);
    for(int i=0; i<m; i++){
        ans*=2;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
using System;
namespace ABC052 {
    class Program {
        static void Main(string[] args) {
            int x = 0;
            int max = 0;
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            for(int i = 0; i < s.Length; i++) {
                if (s[i] == 'I') {
                    x++;
                    if (max < x) {
                        max = x;
                    }
                }else if (s[i] == 'D') {
                    x--;
                }
            }
            Console.WriteLine(max);
        }
    }
}


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

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    // S -> T
    rep(i, dx) cout << 'R';
    rep(i, dy) cout << 'U';

    // T -> S
    rep(i, dx) cout << 'L';
    rep(i, dy) cout << 'D';

    // S -> T
    cout << 'D';
    rep(i, dx + 1) cout << 'R';
    rep(i, dy + 1) cout << 'U';
    cout << 'L';

    // T -> S
    cout << 'U';
    rep(i, dx + 1) cout << 'L';
    rep(i, dy + 1) cout << 'D';
    cout << 'R';

    cout << endl;

    return 0;
}


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

using namespace std;

struct Node{
    int a;
    int b;
    int in=0;
    int out=0;
    vector<int> nextidx;
};

Node node_list[1010000];

int n;
queue<int> q;
map<int, int> record;

int main(){
    cin>>n;
    int index;
    int temp_a;
    for(int i=1;i<=n;i++){
        int flag = 0;
        int pre_index = -1;

        for(int j=1;j<=n-1;j++){
            cin>>temp_a;
            if(temp_a < i) index=temp_a+1000*i;
            else index=i+1000*temp_a;

            node_list[index].a = min(temp_a, i);
            node_list[index].b = max(temp_a, i);
            node_list[index].out++;
            if(flag==1) node_list[index].in++;
            if(pre_index!=-1) node_list[pre_index].nextidx.push_back(index);

            flag = 1;
            record[index] = 1;
            pre_index = index;
        }
    }

    for(map<int, int>::iterator iter=record.begin(); iter!=record.end();iter++)
    {
        if(node_list[iter->first].in==0) q.push((iter->first));
    }
    int flag = 0;
    int ans = 0;
    int temp;

    int t = q.size();

    queue<int> delete_q;

    while(!q.empty()){
        ans++;
        int q_size = q.size();
        int temp;
        for(int i=0;i<q_size;i++){
            temp = q.front();
            q.pop();
            for(int m=0; m<node_list[temp].nextidx.size();m++){
                node_list[node_list[temp].nextidx[m]].in --;
                if(node_list[node_list[temp].nextidx[m]].in==0){
                    q.push(node_list[temp].nextidx[m]);
                    t++;
                }
            }
        }
    }
    if(t==(n*(n-1)/2))cout<<ans<<endl;
    else cout<<-1<<endl;

    return 0;

}


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

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

	for( int i = 1; i <= n; i++){
		if( i % 3 == 0){
			cout << " " << i;
		}  else{
			for( int j = i; j > 0; j /= 10){
				if( j % 10 == 3){
					cout << " " << i;
					break;
				}
			}
		}
	}	
	cout << endl;

	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if(((s[0] == s[1]) && (s[0] == s[2])) || ((s[1] == s[2]) && (s[1] == s[3]))) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main()
{

  int X;

  cin >> X;

  int result = 0;

  while (X >= 0)
  {
    if (X >= 500)
    {
      result += 1000;
      X -= 500;
    }
    else if (X >= 5)
    {
      result += 5;
      X -= 5;
    }
    else
    {
      break;
    }
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, std::string S, long long K){
    char tmp = S.at(K-1);
    rep(i, N){
        if(S.at(i)!= tmp)
            S.at(i) = '*';
    }
    cout << S << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    long long K;
    scanf("%lld",&K);
    solve(N, S, K);
    return 0;
}


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

bool c[128][128];

int main(void) {

  int n;
  int u;
  int k;
  int v;

  std::cin >> n;
  for(int i = 1; i <= n; ++i) {
    std::cin >> u >> k;
    for(int j = 1; j <= k; ++j) {
      std::cin >> v;
      c[u][v] = true;
    }
  }

  for(int i = 1; i <= n; ++i) {
    for(int j = 1; j <= n-1; ++j) {
      if( c[i][j] ) {
        std::cout << "1 ";
      }
      else {
        std::cout << "0 ";
      }
    }
    if( c[i][n] ) {
      std::cout << "1" << std::endl;
    }
    else {
      std::cout << "0" << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 200010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

int A[N],buc[N],pre[N];
ll dp[N];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,i,j,k,x,q;
    int t=1;
    cin>>n;
    memset(buc,-1,sizeof(buc));
    rep(i,1,n){
        cin>>A[i];
        pre[i]= buc[A[i]];
        buc[A[i]]=i;
    }
    dp[0]=1;
    rep(i,1,n){
        dp[i]= (dp[i]+ dp[i-1])%mod;
        if(pre[i]==-1 || pre[i]==i-1)continue;
        dp[i] = (dp[i]+dp[pre[i]])%mod;
    }
    cout<<dp[n]<<"\n";


    
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int N;
int F[100][14];
int P[100][15];

int main() {
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++) scanf("%d",&F[i][j]);
  }

  for(int i=0;i<N;i++) for(int j=0;j<11;j++) cin >> P[i][j]; 
  
  int res = -(1<<30);
  
  for(int b=1;b<(1<<10);b++){
    int cc = 0;
    for(int i=0;i<N;i++){
      int c=0;
      for(int j=0;j<10;j++){
        if((b>>j &  1)&& F[i][j]) c++;  
      }
      cc+=P[i][c];
     
    }
     if(res<cc) res=cc;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int GCD(int a, int b){
    if(a % b == 0)
        return (b);
    else return(GCD(b,a%b));
}
int main(){
    int N;
    cin >> N;
    int A[100010];
    int ans;
    cin >> A[1];ans = A[1];
    for(int i = 2;i <= N;i++){
        cin >> A[i];
        ans = GCD(ans, A[i]);
    }
    cout << ans;
}


Measured memory_bytes: 640
a, b, c = map(int, input().split())
k = int(input())
cnt = 0

while not (a < b < c):
    cnt += 1
    if a >= b:
        b *= 2
    elif b >= c:
        c *= 2
    if cnt > k:
        print("No")
        exit(0)

print("Yes")

Measured memory_bytes: 61804