akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int p;
int a[3000], s[3000], t[3000], b[3000];

int main()
{
	cin >> p;

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

	for (int i = 0; i < p; i++)
		b[i] = 0;

	s[0] = 1;
	t[0] = 1;

	for (int i = 1; i < p; i++) {
		s[i] = s[i - 1] * i % p;

		int j = s[i], k = 1;

		while (k < (p - 2) / 2) {
			j = j * j % p;
			k *= 2;
		}

		while (k < p - 2) {
			j = j * s[i] % p;
			k++;
		}

		t[i] = j;
	}

	for (int i = 0; i < p; i++) {
		if (a[i] == 1) {
			b[p - 1] = (b[p - 1] - 1 + p) % p;

			if (i == 0)
				b[0] = (b[0] + 1) % p;
			else {				
				int u = i;

				for (int j = 1; j < p - 1; j++) {
					if (j % 2 == 0)
						b[p - 1 - j] = (b[p - 1 - j] - s[p - 1] * t[j] % p * t[p - 1 - j] % p * u + p) % p;
					else
						b[p - 1 - j] = (b[p - 1 - j] + s[p - 1] * t[j] % p * t[p - 1 - j] % p * u) % p;

					u = u * i % p;
				}
			}
		}
	}

	for (int i = 0; i < p - 1; i++)
		cout << b[i] << " ";
	cout << b[p - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


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

    vector<vector<int>> c(3,vector<int>(3));
    rep(i, 3)rep(j, 3) cin >> c[i][j];

    if(c[0][1] - c[0][0] == c[1][1] - c[1][0] && c[1][1] - c[1][0] == c[2][1] - c[2][0]){
        if(c[0][2] - c[0][1] == c[1][2] - c[1][1] && c[1][2] - c[1][1] == c[2][2] - c[2][1]){
            if(c[1][0] - c[0][0] == c[1][1] - c[0][1] && c[1][1] - c[0][1] == c[1][2] - c[0][2]){
                if(c[2][0] - c[1][0] == c[2][1] - c[1][1] && c[2][1] - c[1][1] == c[2][2] - c[1][2]){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

int main(void) {
    int N,M;
    cin>>N>>M;
    double sum = 0;
    
    vector<int> vc;
    for (int i = 0; i < N; i++) {
        int A;
        cin>>A;
        sum += A;
        vc.push_back(A);
    }
    double threshold = sum / (4.0 * M);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (vc.at(i) >= threshold) cnt++;
    }
    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 888
X = int(input())

X_range = int(pow(X, 1/4))+1

for i in range(X_range, -X_range-1, -1):
    for j in range(-X_range, X_range+1):
        if pow(i, 5) - pow(j, 5) == X:
            print(i, j)
            exit()

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

int main(){
	int n,a,b,c,x,y[100],m,turn;
	while(1){
		cin >> n >> a >> b >> c >> x ;
		if((n==0)&&(a==0)&&(b==0)&&(c==0)&&(x==0)){
			return 0;
		}
		for(int i=0;i<n;i++){
			cin >> y[i];
		}
		m=0;
		for(turn=0;turn<=10000;turn++){
			if(y[m]==x){
				m++;
			}
			if(m==n){
				break ;
			}
			x=(a*x+b)%c;
		}
		if(turn==10001){
			cout << "-1\n";
		}
		else{
			cout << turn << "\n";
		}
	}
return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);

}

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

class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int a, b, c;
        cin >> a >> b >> c;
        int g = gcd(a, b);

        for (int i = g, cnt = 0; i >= 1; --i) {
            if (g % i == 0) {
                cnt++;
            }
            if (cnt == c) {
                cout << i << endl;
                return;
            }
        }

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
n,m = gets.chomp.split.map(&:to_i)
ts = m.times.map{gets.chomp.split.map(&:to_i)}
flag = Array.new(n,0)
ans = Array.new(n,0)
ts.each do |s,c|
  if flag[s-1] == 1 && ans[s-1] != c
    ans = [-1]
    break
  end
  if n != 1 && s == 1 && c == 0
    ans = [-1]
    break
  end
  flag[s-1] = 1
  ans[s-1] = c
end

if n !=1 && ans[0] == 0
  ans[0] = 1
end
puts ans.join


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<array>


typedef std::array<int, 6> Dice;

enum Direction {
	Top,
	Bottom,
	North,
	South,
	East,
	West
};

typedef std::array<Direction, 4> RotateDirection;

const RotateDirection north = { {Top, North, Bottom, South } };
const RotateDirection east = { { Top, East, Bottom, West} };
const RotateDirection south = { { Top, South, Bottom, North } };
const RotateDirection west = { { Top, West, Bottom, East } };
const RotateDirection right = { { North, East, South, West } };
const RotateDirection left = { { North, West, South, East } };


void RotateDice(Dice& dice , const RotateDirection& direction) {
	int temp = dice[direction[3]];
	dice[direction[3]] = dice[direction[2]];
	dice[direction[2]] = dice[direction[1]];
	dice[direction[1]] = dice[direction[0]];
	dice[direction[0]] = temp;
}


int main() {

	int n;


	while (true) {
		std::cin >> n;
		if (n == 0) {
			break;
		}

		int sum = 1;
		Dice dice{ { 1, 6, 5, 2, 3, 4 } };

		for (int i = 0; i < n; ++i) {
			std::string dir;
			std::cin >> dir;
			if (dir == "North") {
				RotateDice(dice, north);
			}
			else if (dir == "East") {
				RotateDice(dice, east);
			}
			else if (dir == "West") {
				RotateDice(dice, west);
			}
			else if (dir == "South") {
				RotateDice(dice, south);
			}
			else if (dir == "Right") {
				RotateDice(dice, right);
			}
			else if (dir == "Left") {
				RotateDice(dice, left);
			}
			using std::cout;
			sum += dice[Top];
		}
		std::cout << sum << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1212
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = (int) 2e3;

int n;

char A[MAXN + 5], B[MAXN + 5];

inline void input()
{
	scanf("%s%s", A, B), n = strlen(A);
}

inline int calc()
{
	int ans = INT_MAX;
	for(int k = 0; k < n; ++k)
	{
		static int C[MAXN + 5];

		for(int i = 0; i < n; ++i) C[i] = A[i] != B[(i + k) % n];

		static int lst[MAXN + 5], nxt[MAXN + 5];
		memset(lst, -1, sizeof lst);
		memset(nxt, -1, sizeof nxt);

		int p = -1;
		for(int i = 0; i < n; ++i) if(B[i] == '1') { p = i; break; }

		lst[p] = nxt[p] = p;
		for(int i = (p + 1) % n; i != p; i = (i + 1) % n) lst[i] = B[i] == '1' ? i : lst[(i - 1 + n) % n];
		for(int i = (p - 1 + n) % n; i != p; i = (i - 1 + n) % n) nxt[i] = B[i] == '1' ? i : nxt[(i + 1) % n];

		static int l[MAXN + 5], r[MAXN + 5];

		for(int i = 0; i < n; ++i) if(C[i] && (nxt[i] - i + n) % n > k)
		{
			l[i] = (nxt[i] - i + n) % n - k;
			r[i] = (i - lst[i] + n) % n;
		}
		else l[i] = r[i] = 0;

		static int suf[MAXN + 5];
		for(int i = 0; i < n; ++i) suf[i] = 0;

		for(int i = 0; i < n; ++i) chkmax(suf[l[i]], r[i]);
		for(int i = n - 1; i >= 0; --i) suf[i] = max(suf[i], suf[i + 1]);

		int res = n;
		for(int i = 0; i < n; ++i) chkmin(res, i + suf[i + 1]);

		res = res * 2 + k;
		for(int i = 0; i < n; ++i) res += C[i];
		chkmin(ans, res);
	}
	return ans;
}

inline void solve()
{
	int cntA = 0, cntB = 0;
	for(int i = 0; i < n; ++i)
	{
		cntA += A[i] == '1';
		cntB += B[i] == '1';
	}
	if(cntB == 0) { printf("%d\n", cntA == 0 ? 0 : -1); return; }

	int ans = INT_MAX;

	chkmin(ans, calc());

	reverse(A, A + n);
	reverse(B, B + n);
	chkmin(ans, calc());

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

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pet pair<int,int>
#define one first
#define two second

#ifdef debug
#define cin fin 
#define fileopen fin.open("test.txt");
#else
#define fileopen
#endif

#define int long long
#define big 1000000007
#define all(x) x.begin(),x.end()

using namespace std;

ifstream fin;

vector<vector<int>> primes;

int power(int a,int b,int m=big)
{
	if(b==0)
	return 1;

	int ans=power(a,b/2,m);
	if(b%2==0)
	return ans*ans%m;

	return ((a*ans)%m*ans)%m;
}

int inverse(int a,int m=big)
{
	return power(a,m-2,m);
}

int ceil(int a,int b)
{
	return (a-1)/b+1;
}

void init_prime()
{
	int size=1e6+1;
	primes.resize(1e6);

	for(int i=2;i<size;i++)
	{
		if(primes[i].size()==0)
		{
			for(int j=i;j<size;j+=i)
			primes[j].push_back(i);
		}
	}
}

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


/*_______________________________

			START
			FROM
			BELOW

		  #pragyanc2#
________________________________
*/

void solve()
{
    int n;
    cin >> n;

    int arr[n];

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

    map<int,int> m;
    for(int i=0;i<n;i++)
    m[arr[i]]++;

    int ans=0;

    for(auto itr=m.begin();itr!=m.end();itr++)
    ans+=(itr->second)*(itr->second -1 )/2;

    for(int i=0;i<n;i++)
    {
        if(m[arr[i]]==1)
        {
            cout << ans << endl;
            continue;
        }

        int k = m[arr[i]];
        cout << ans - (k-1) << endl;
    }
}


signed main()
{
	fileopen
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	//init_prime();

	int t=1;
	//cin >> t;

	for(int i=1;i<=1;i++)
	solve();
}

Measured memory_bytes: 11136
module Main where

import Control.Applicative
import Control.Monad
import Data.List (sort)

main :: IO ()
main = do
    [a, b, k] <- fmap read . words <$> getLine :: IO [Int]
    let ls = sort $ take k [a .. b]
    let rs = sort $ take k [b, b - 1 .. (maximum ls + 1)]
    mapM_ print $ ls ++ rs

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; cin>>s;
    map<char,ll> m;
    for(char c: s) m[c]++;
    for(char c='a'; c<='z'; c++){
        if(m[c]==0){
            cout<<c<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll X;
  cin>>X;
  ll m = 100;
  ll y = 0;
  while(m<X){
    m = m*1.01;
    m = floor(m);
    y++;
  }
  cout<<y<<endl;
}


Measured memory_bytes: 3636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
t = 'abcdefghijklmnopqrstuvwxyz'
for i in t:
    if not i in s:
        print(i)
        break
else:
    print('None')

Measured memory_bytes: 39024
#include <stdio.h>
#include <stdlib.h>

typedef long long ll;

int main(void){
    ll A,B,C,K;
    scanf("%lld %lld %lld",&A,&B,&C);
    scanf("%lld",&K);
    while(A>=B&&K>0){
        B*=2;
        K--;
    }
    while(B>=C&&K>0){
        C*=2;
        K--;
    }
    if(A<B&&B<C)printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1624
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,A,B,n,ans=0;
  cin>>N>>A>>B>>n;
  for(int i=1;i<N;i++){
    int a;
    cin>>a;
    ans+=min((a-n)*A,B);
    n=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
li = []
for i in range(n):
    s,t = input().split()
    li.append([s,int(t),i+1])
li = sorted(li,key = lambda x:x[1], reverse = True)
li = sorted(li,key = lambda x:x[0])
for i in range(n):
    print(li[i][2])


Measured memory_bytes: 10200
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,c=0;
    bool a[26],b[26];
    string s,x,y;
    cin>>n>>s;
    
    for(int i=1;i<n;i++){
        x=s.substr(0,i);
        y=s.substr(i);
        for(int j=0;j<26;j++){
            a[j]=false;
            b[j]=false;
        }
        int d=0;
        for(int j=0;j<i;j++){
            a[x[j]-'a']=true;
        }
        for(int j=0;j<n-i;j++){
            b[y[j]-'a']=true;
        }
        for(int j=0;j<26;j++){
            if(a[j]&&b[j])d++;
        }
        
        c=max(c,d);
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
#define endl '\n'
#define SIGMA 128
const ld PI=3.14159265358979;
#define fr(i,n) for(i=1;i<=n;i++)
#define rep(i,k,n) for(i=k;i<=n;i++)
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ps(x,y) cout<<fixed<<setprecision(y)<<x<<endl
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define vvl vector<vll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

ll dp[3003][3003];
vll  v;
ll n;
int main()
{
    IOS

    ll i,j;
    cin>>n;
    v.assign(n+1,0);
    vll pref(n+1,0);
    fr(i,n) 
    {
        cin>>v[i];
        pref[i]=pref[i-1]+v[i];
    }
    

    for(int len=1;len<=n;len++)
    {
        for(int st=1;st+len-1<=n;st++)
        {
            int last=st+len-1;
            if(st==last)
            {
                dp[st][last]=v[st];
                continue;
            }
            ll pre=pref[last]-pref[st-1];
            dp[st][last]=max(pre-dp[st+1][last],pre-dp[st][last-1]);
        }
    }

    cout<<2*dp[1][n]-pref[n]<<endl;

    return 0;  
}



Measured memory_bytes: 49752
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAXN 101
typedef pair<int,int> pii;
 
 
 
int main()
{
    vector <int> digitos;
    map<int,int> check;
    int n, m, s, c;
    cin >> n >> m;
    digitos.resize(n);
    digitos[0] = 3;
    for(int i=1;i<=m;i++)
    {
        cin >> s >> c;
        if(check.find(s) != check.end())
        {
            if(check[s] != c)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        else
        {
            digitos[s-1] = c;
            check.insert(make_pair(s,c));
        }
    }
    if(n == 1 && m == 0)
    {
        cout << 0 << endl;
                return 0;
    }
    if(n > 1 && digitos[0] <= 0)
    {
        cout << -1 << endl;
                return 0;
    }
    else for(int i=0;i<n;i++)
    {
        if(check.find(i+1) == check.end())
        {
            if(i) cout << 0;
            else cout << 1;
        }
        else
        {
            cout << digitos[i];
        }
        
    }
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    char suit;
    int value;
} card;

void DisplayArray(card C[], int N)
{
    int i;
    for (i = 0; i < N; i++) {
        if (i) printf(" ");
        printf("%c%d", C[i].suit, C[i].value);
    }
    printf("\n");
}

void BubbleSort(card C[], int N)
{
    int i, j;
    card temp;

    for (i = 0; i < N-1; i++) {
        for ( j = N-1; j >= 1; j--) {
            if (C[j].value < C[j-1].value) {
                temp = C[j];
                C[j] = C[j-1];
                C[j-1] = temp;
            }
        }
    }
}

void SelectionSort(card C[], int N)
{
    int i, j, minj;
    card temp;

    for (i = 0; i < N; i++) {
        minj = i;
        for (j = i; j < N; j++) {
            if (C[j].value < C[minj].value) minj = j;}
            temp = C[i];
            C[i] = C[minj];
            C[minj] = temp;
    }
}

int IsStable(card cBubble[], card cSelection[], int N)
{
    int i;

    for (i = 0; i < N; i++) {
        if (cBubble[i].suit != cSelection[i].suit) return 0;
    }

    return 1;
}

int main(void)
{
    int N, i;
    scanf("%d%*c", &N);
    card* C1 = (card*)malloc(sizeof(card) * N);
    card* C2 = (card*)malloc(sizeof(card) * N);

    for (i = 0; i < N; i++) {
        scanf("%c%d%*c", &C1[i].suit, &C1[i].value);
        C2[i] = C1[i];
    }

    BubbleSort(C1, N);
    SelectionSort(C2, N);

    DisplayArray(C1, N);
    printf("Stable\n");
    DisplayArray(C2, N);
    if (IsStable(C1, C2, N)) {
        printf("Stable\n");
    } else {
        printf("Not stable\n");
    }

    return 0;
}





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

int main (void){
  int n, k;
  cin >> n >> k;
  int count = 0;
  for(int i = 0; i < n; i++){
    int s;
    cin >> s;
    if(s >= k){
      count++;
    }
  }
  cout << count;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int h, w, res;
const int N = 2005;
string s[N];
int leftc[N][N], rightc[N][N], up[N][N], down[N][N];
int main() {
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < h; ++i) {
        int sum = 0;
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '.') {
                sum++;
            } else {
                sum = 0;
            }
            leftc[i][j] = sum;
        }
    }
    for (int i = 0; i < h; ++i) {
        int sum = 0;
        for (int j = w - 1; j >= 0; --j) {
            if (s[i][j] == '.') {
                sum++;
            } else {
                sum = 0;
            }
            rightc[i][j] = sum;
        }
    }
    for (int i = 0; i < w; ++i) {
        int sum = 0;
        for (int j = 0; j < h; ++j) {
            if (s[j][i] == '.') {
                sum++;
            } else {
                sum = 0;
            }
            up[j][i] = sum;
        }
    }
    for (int i = 0; i < w; ++i) {
        int sum = 0;
        for (int j = h - 1; j >= 0; --j) {
            if (s[j][i] == '.') {
                sum++;
            } else {
                sum = 0;
            }
            down[j][i] = sum;
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            res = max(res, leftc[i][j] + rightc[i][j] + up[i][j] + down[i][j] - 3);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 70240
#abc 147 C
import itertools
n = int(input())
word_g = []
for i in range(n):
    m = int(input())
    part_word = []
    for j in range(m):
        part_word.append(list(map(int, input().split())))
    word_g.append(part_word)
#print(word)       
state = list(itertools.product([0,1], repeat = n))  

def abc147c(n, word, i):
    word_i = []
    
    for j1 in range(n):
        if i[j1]  == 0:
            word_i.append([])
        else:
        	word_i.append(word[j1])
          
    
    check_mujun = [[] for i in range(n)]
    
    for j in word_i:
        for k in j:
            check_mujun[k[0] -1].append(k[1])
    
    
    counter = 0
    
    for x, j in enumerate(check_mujun):
        
        if len(set(j)) == 0  :
            counter += i[x]
            
        elif len(set(j)) == 1 and sum(set(j)) == i[x]:
            counter += i[x]
            
        else:
            return -1
            break
    return counter

output = 0 
for i in state:
    output = max(output, abc147c(n,word_g,list(i) ) )
    #print(i, abc147c(n,word_g,i))
print(output)

Measured memory_bytes: 10868
import math 
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)] 
count = 0

for i in range(n):
  for j in range(i+1, n):
    added = 0
    dis = 0
    for k in range(d): 
      added += (x[i][k] - x[j][k]) ** 2 
      dis = math.sqrt(added)
    if dis % 1 == 0:
      count += 1
print(count)

Measured memory_bytes: 3064
#!/usr/bin/env python3
def divisor_dif_2_over(n):
    if n == 1:
        return []
    res = []
    i = 1
    while i * i <= n:
        if n % i == 0 and (n // i) - i >= 2:
            res.append(n // i - 1)
        i += 1
    return res


n = int(input())
# print(divisor_dif_2_over(n))
print(sum(divisor_dif_2_over(n)))


Measured memory_bytes: 9156
n = int(input())
S = []
for _ in range(n):
    S.append(input())
d = {}

for _ in S:
    d[_]=0

for _ in S:
    d[_]+=1

max_ = max(d.values())

_sorted = sorted(d.items(), key=lambda x:x[0])
for _ in _sorted:
    if _[1]== max_:
        print(_[0])

Measured memory_bytes: 48012
n,m =map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
r=any([r[j:j+m] for r in a[i:i+m]]==b for i in range (n-m+1) for j in range(n-m+1))
print("Yes" if r else "No")

Measured memory_bytes: 3060
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b,c,d;
    bool flag=true;
    cin>>a>>b>>c>>d;
    while(flag==true){
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            flag=false;
            break;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No"<<endl;
            flag=false;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 100 + 1;
ll a[mxN];
ll n;
 
 
int main()
{
FIO
    cin >> n;
    For(n) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    Rep(i,0,n-1)
    {
        Rep(j,i+1,n-1)
        {
            Rep(k,j+1,n-1)
            {
                if(a[i] + a[j] > a[k] && a[i] < a[j] && a[j] < a[k])
                    ans++;
            }
        }
    }
    cout << ans;
    
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	int a=read<int>();
	int b=read<int>();
	int ans=(a-1)/b+1;

	cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 256
class Item(object):
    def __init__(self, value, weight):
        self.v = value
        self.w = weight


n, W = map(int, input().split())
dp = [[-1] * (W + 1) for i in range(n + 1)]
items = [[int(x) for x in input().split()] for j in range(n)]


def rec_dp(i: int, w: int) -> int:
    if dp[i][w] != -1:
        return dp[i][w]

    result = 0
    if i < 0:
        pass
    else:
        item = Item(items[i][0], items[i][1])
        if w - item.w < 0:
            result = rec_dp(i - 1, w)
        else:
            result = max(
                rec_dp(i - 1, w),
                rec_dp(i - 1, w - item.w) + item.v
            )

    dp[i][w] = result
    return result


def main() -> None:
    print(rec_dp(n - 1, W))


if __name__ == "__main__":
    main()



Measured memory_bytes: 24256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  vector<int> vec{1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  int K; cin >>K;
  cout <<vec[K-1] <<endl;
  return 0;
}


Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  
  int cnt = 0;
  for (int i = min(a, b); i > 0; i--) {
    if (a%i == 0 && b%i == 0) {
      cnt++;
      if (cnt == k) {
        cout << i << endl;
        return 0;
      }
    }
  }
}




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

int main(){
  int a,b;
  cin >> a>>b;
  vector<char>vec(a*b);
  for (int i=0;i<(a*b);i++){
    cin >> vec[i];
  }
  for (int j=0;j<(b+2);j++){
    cout<< '#';
  }
  cout << endl;
  for(int m=0;m<a;m++){
    cout <<'#';
    for(int n=0;n<b;n++){
      cout << vec.at(n+m*b) ;
    }
    cout <<'#';
    cout << endl;
  }
  for(int i=0;i<b+2;i++){
    cout <<'#';
  }
  cout << endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int h, w;
  std::cin >> h >> w;
  std::vector<std::vector<char>> c(h, std::vector<char>(w));
  std::cin >> c;

  for (int i = 0; i < 2 * h; i++) {
    for (int j = 0; j < w; j++) {
      std::cout << c[i / 2][j];
    }
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())

AB = [[] for _ in range(N)]

for _ in range(M):
    a,b = map(lambda x: int(x)-1, input().split())
    AB[a].append(b)
    AB[b].append(a)

visited = [0] * N
ans = []
for i in range(N):
    if visited[i]:
        continue
    group = [i]
    d = deque(AB[i])
    while d:
        s = d.popleft()
        if visited[s]:
            continue
        visited[s] = 1
        group.append(s)
        for k in AB[s]:
            d.append(k)
    ans.append(len(group))

print(len(ans)-1)


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

long long f(long long n) {
  long long res = 0;
  while (n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

double g(long long n) {
  return (double)(n)/f(n);
}

int main() {
  vector<long long> res;
  long long base = 1;
  for (int i = 0; i < 15; ++i) {
    for (int j = 1; j < 150; ++j) {
      res.push_back(base * (j+1) - 1);
    }
    base *= 10;
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());

  for (long long i = 0; i < res.size(); ++i) {
    for (long long j = i+1; j < res.size(); ++j) {
      if (g(res[i]) > g(res[j])) {
        res.erase(res.begin() + i--);
        break;
      }
    }
  }

  long long K;
  cin >> K;
  for (long long i = 0; i < K; ++i) {
    cout << res[i] << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long ll;
#define INF 2000000000

static const int MAX = 200001;

int A[MAX];
int L[MAX / 2 + 2], R[MAX / 2 + 2];
int n;

ll merge(int left, int mid, int right);
ll mergeSort(int left, int right);

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    ll cnt = mergeSort(0, n);
    printf("%lld\n", cnt);
}


ll merge(int left, int mid, int right) {
    ll cnt = 0;
    int n1 = mid - left, n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        L[i] = A[i + left];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[i + mid];
    }
    L[n1] = R[n2] = INF;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}


ll mergeSort(int left, int right) {
    int mid;
    ll cnt1, cnt2, cnt3;
    if (left + 1 < right) {
     mid = (left + right) / 2;
     cnt1 = mergeSort(left, mid);
     cnt2 = mergeSort(mid, right);
     cnt3 = merge(left, mid, right);
     return cnt1 + cnt2 + cnt3;
    }
    else return 0;
}



Measured memory_bytes: 4260
import sys
from statistics import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
d, x = na()
ct = 0
for i in range(n):
    a = ni()
    ct += len([1 + a * i for i in range(100) if 1 + a * i <= d])
print(ct + x)

Measured memory_bytes: 5144
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int p = scanner.nextInt();
			int q = scanner.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			list.add(p);
			while (true) {
				p *= 10;
				System.out.print(p / q);
				p = p % q;
				if (p == 0 || list.contains(p)) {
					break;
				}
				list.add(p);
			}

			System.out.println();
			if (p != 0 && list.contains(p)) {
				char a = ' ';
				for (int t : list) {
					if (t == p) {
						a = '^';
					}
					System.out.print(a);
				}
				System.out.println();
			}
		}
	}
}

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

int main() {
  string s;
  cin >> s;
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std; 
int main()
{
    int a;
    scanf("%d\n",&a);
    if(a<2)  {printf("1\n"); return 0;}
    if(a<4)  {printf("2\n"); return 0;}
    if(a<8)  {printf("4\n"); return 0;}
    if(a<16) {printf("8\n"); return 0;}
    if(a<32) {printf("16\n");return 0;}
    if(a<64) {printf("32\n");return 0;}
    if(a<128){printf("64\n");return 0;}
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
long long area[3];
int main(){
  int n,m;scanf("%d%d",&n,&m);
  if(n%3==0||m%3==0)printf("%d\n",0);
  else{
    long long ans=min(n,m);
    long long tmp;
    for(int i=1;i<n;++i){
      area[0]=i*1ll*m;
      area[1]=(m/2)*1ll*(n-i);
      area[2]=(m-m/2)*1ll*(n-i);
      long long Min=1ll<<60,Max=0;
      for(int j=0;j<3;++j)Min=min(Min,area[j]);
      for(int j=0;j<3;++j)Max=max(Max,area[j]);
      ans=min(ans,Max-Min);
    }
    for(int i=1;i<m;++i){
      area[0]=i*1ll*n;
      area[1]=(n/2)*1ll*(m-i);
      area[2]=(n-n/2)*1ll*(m-i);
      long long Min=1ll<<60,Max=0;
      for(int j=0;j<3;++j)Min=min(Min,area[j]);
      for(int j=0;j<3;++j)Max=max(Max,area[j]);
      ans=min(ans,Max-Min);
    }
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
using namespace std;


using vc = vector<char>;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void process(const string& t) {
}

int main() {
  int t, n;
  string s;
  int x, y;
  int ans = 0;
  char c;
  while (cin >> c) {
    if (isupper(c)) cout << "A\n";
    else cout << "a\n";
  }
  return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] T = new int [N];
        int sum=0;
        for(int i=0; i<N; i++){
            T[i]=sc.nextInt();
            sum+=T[i];
        }
        int M = sc.nextInt();
        for(int i=0; i<M; i++){
            int P = sc.nextInt();
            int X = sc.nextInt();
            int ans = sum-T[P-1]+X;
            System.out.println(ans);
        }
        sc.close();
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
#define ll long long
using namespace std;

int main() {
	ll n, time, l[7], min_d, min_n, hoge;
	double j;
	cin >> n;
	min_d = 3000000000000000;
	for (int i = 0; i < 5; i++) {
		cin >> l[i];
		if (min_d > l[i]) {
			min_n = i;
			min_d = l[i];
		}
	}
	hoge = n / l[min_n];
	if (n % l[min_n] != 0)hoge++;
	time = 4 + hoge;
	cout << time << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <array>

using namespace std;

constexpr char WHITE='.';
constexpr char BLACK='#';

class Board{
public:
	Board(){
		for(int i=0; i<MAX_SIZE; ++i){
			fill(_data[i].begin(), _data[i].end(), i < MAX_SIZE/2 ? BLACK : WHITE);
		}
	}

	void add_points(char color, int num){
		int l_max_num = (MAX_SIZE + 1)/2;
		for(int i=0; i<num; ++i){
			int l = (i/l_max_num)*2;
			int r = (i%l_max_num)*2;
			switch(color){
			case WHITE:
				_data[l][r] = WHITE;
				break;
			case BLACK:
				_data[MAX_SIZE - l - 1][r] = BLACK;
				break;
			}
		}
	}

	void output(){
		cout << 100 << " " << 100 << endl;
		for(int l=0; l<MAX_SIZE; ++l){
			for(int r=0; r<MAX_SIZE; ++r){
				cout << _data[l][r];
			}
			cout << endl;
		}
	}
private:
	constexpr static int MAX_SIZE=100;
	array<array<char, MAX_SIZE>, MAX_SIZE> _data;
};

constexpr int Board::MAX_SIZE;

int main() {
	int A, B;
	cin >> A >> B;
	Board board;
	board.add_points(WHITE, A - 1);
	board.add_points(BLACK, B - 1);
	board.output();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    vector<int> ans;
    int i;
    for(i = n - 1; i >= 0; i -= 2) ans.push_back(v[i]);
    if(i == -2)
    {
        for(i = 1; i < n; i+= 2) ans.push_back(v[i]);
    }
    else
    {
        for(i = 0; i < n; i += 2) ans.push_back(v[i]);
    }
    for(i = 0; i < n; i++)
    {
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int INF = 1000;
vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, 1, 0, -1};
int main(){
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    vector<int> x(N), y(N);
    x[0] = 0;
    y[0] = 0;
    for (int i = 1; i < N; i++){
      int n, d;
      cin >> n >> d;
      x[i] = x[n] + dx[d];
      y[i] = y[n] + dy[d];
    }
    int x_max = -INF;
    int x_min = INF;
    int y_max = -INF;
    int y_min = INF;
    for (int i = 0; i < N; i++){
      x_max = max(x_max, x[i]);
      x_min = min(x_min, x[i]);
      y_max = max(y_max, y[i]);
      y_min = min(y_min, y[i]);
    }
    cout << x_max - x_min + 1 << ' ' << y_max - y_min + 1 << endl;
  }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main() {
  int x;
  int y;
  int z;
  cin >> x;
  if (x %1000 == 0){
    y = (x+1000)/1000-1;
  }
  else {
     y = (x+1000)/1000;
  }
  z = 1000*y-x;
  cout << z << endl;
}


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

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

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  vector<ll> t(n);
  REP(i,n)cin>>t[i];

  ll ans=0;
  FOR(i,1,n){
    if(t[i]-t[i-1] >= T){
      ans += T;
    }else{
      ans += t[i]-t[i-1];
    }
  }
  ans += T;

  cout << ans << endl;

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  int n,m;
  cin >> n >> m;
  string s="";
  rep(i,n) s[i]='*';
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    if(s[x-1]!='*'&&s[x-1]-'0'!=y) {
      pr(-1);
      return;
    }
    s[x-1]=(char)(y+'0');
  }
  reverse(all(s));
  if(n>1&&s[0]=='0') {
    pr(-1);
    return;
  }
  string ans="{";
  rep(x,1000) {
    stringstream ss;
    string t;
    ss << x;
    ss >> t;
    if(t.size()==n) {
      rep(i,n) {
        if(s[i]!='*'&&s[i]!=t[i]) goto next;
      }
      ans=min(ans,t);
    }
  next:;
  }
  if(ans=="{") ans="-1";
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
import java.util.*;

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

        if(X<A) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 25044
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }
using namespace std;

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

    }
    return 0;
}


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

    }
    return 0;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
using namespace std;
ll n, m;
ll a[100000];
vector<pair<ll, ll> > cb;
ll b, c;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if (a.first != b.first) {
        return a.first > b.first;
    } else {
        return a.second > b.second;
    }
}

int main() {
    cin >> n >> m;
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, m) {
        cin >> b >> c;
        cb.push_back(make_pair(c, b));
    }
    sort(a, a + n);
    sort(cb.begin(), cb.end(), compare_by_b);
    int i = 0;
    for (auto e : cb) {
        if (e.first > a[i]) {
            int j = 0;
            while (i < n && j < e.second && e.first > a[i]) {
                a[i] = e.first;
                i++;
                j++;
            }
        } else {
            break;
        }

    }
    ll ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == B.at(i) && A.at(i) == C.at(i)) ans += 0;
    else if (A.at(i) == B.at(i) || B.at(i) == C.at(i) || C.at(i) == A.at(i)) ans++;
    else ans += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define _USE_MATH_DEFINENS
#include <cmath>

using namespace std;

#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

    cout << ((a + b >= c) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int N=sc.nextInt();
	long A[]=new long[N];
	long sum=0;
	for(int i=0;i<N;i++) {
		A[i]=sc.nextLong();
		sum+=A[i];
	}
	long karisum=0;
	long ans=0;
	for(int i=0;i<N;i++) {
		karisum+=A[i];
		if(karisum>=(double)sum/2) {
			if(karisum-A[i]>sum-karisum)
			karisum-=A[i];
			ans=Math.abs(sum-2*karisum);
			break;
		}

	}
	System.out.println(ans);

}
}

Measured memory_bytes: 94080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		for(int i = 0;i<n;i++) {
			x[i] = sc.nextInt();
		}
		int min =1000000;
		for(int i=0;i<=100;i++) {
			int temp = 0;
			for(int j=0;j<n;j++) {
				temp += Math.pow(x[j]-i, 2);
			}
			min = Math.min(min, temp);
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define mp       make_pair
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{	//pre();
	//case
	{	int n, m;
		cin >> n >> m;
		string s[n + 2];
		for (int i = 0; i < n; i++)
			cin >> s[i];
		int dp[n][m];
		for (int i = 0; i < n; i++)
		{	for (int j = 0; j < m; j++)
			{	if (i == 0 && j == 0)
					dp[i][j] = 1;
				else if (s[i][j] == '#')
					dp[i][j] = 0;
				else if (i == 0)
					dp[i][j] = dp[i][j - 1];
				else if (j == 0)
					dp[i][j] = dp[i - 1][j];
				else
					dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] %= MOD;
			}
		}
		cout << dp[n - 1][m - 1];

	}
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;

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

  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i, m) cin >> x[i];
  sort(ALL(x));
  vector<ll> y(m-1);
  for (int i = 0; i < m-1; i++) {
    y[i] = x[i+1] - x[i];
  }

  sort(ALL(y));

  ll ans = 0;
  for (int i = 0; i < max(0, m-n); i++) {
    ans += y[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408