akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
//-------------------------------------------------------------------------------

intl n,m,x;
intl c[12];
intl a[12][12];
bool flag = false;
intl mi = INF;

void input_var(){
    cin >> n >> m >> x;
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }
}
//-------------------------------------------------------------------------------


void dfs(vector<bool> &v) {
    if (v.size() == n){
        intl b[m];
        intl d = 0;
        m0(b);
        rep(i,n){
            if(v[i]){
                rep(j,m){
                    b[j] += a[i][j];
                }
                d += c[i];
            }
        }
        //rdebug(i,b);
        bool f = true;
        rep(i,m)if(b[i] < x)f = false;
        if(f){
            flag = f;
            mi = min(mi,d);
        }
        return;
    }
    for (intl i = 0;i < 2; i++) {
        v.push_back((bool)i);
        dfs(v);
        v.pop_back();
    }
}

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    vector<bool> v;
    dfs(v);
    if(!flag)mi = -1;
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
int dp[105][105];
int main() 
{

   
    fast();
    int r,c;
    cin>>r>>c;
    string s[105];
    for(int i=0;i<r;i++)
    	cin>>s[i];
    if(s[0][0]=='#')
    	dp[0][0]=1;
    else
    	dp[0][0]=0;
    for(int i=1;i<c;i++)
    {
    	if(s[0][i]=='.')
    	{
    		dp[0][i]=dp[0][i-1];
    	}
    	else
    	{
    		if(s[0][i-1]=='#')
    			dp[0][i]=dp[0][i-1];
    		else
    			dp[0][i]=dp[0][i-1]+1;
    	}
    }
    for(int i=1;i<r;i++)
    {
    	if(s[i][0]=='.')
    	{
    		dp[i][0]=dp[i-1][0];
    	}
    	else
    	{
    		if(s[i-1][0]=='#')
    			dp[i][0]=dp[i-1][0];
    		else
    			dp[i][0]=dp[i-1][0]+1;
    	}
    }
    for(int i=1;i<r;i++)
    {
    	for(int j=1;j<c;j++)
    	{
    		if(s[i][j]=='#')
    		{
    			if(s[i-1][j]=='#')
    			{
    				if(s[i][j-1]=='#')
    				{
    					dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
    				}
    				else
    				{
    					dp[i][j]=min(dp[i-1][j],dp[i][j-1]+1);	
    				}
    			}
    			else
    			{
    				if(s[i][j-1]=='#')
    				{
    					dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]);
    				}
    				else
    				{
    					dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1);	
    				}
    			}
    		}
    		else
    		{
    			dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
    		}
    	}
    }
    cout<<dp[r-1][c-1];
  
}

Measured memory_bytes: 384
n = int(input())
s = [input() for _ in range(n)]
s2 = [0 for _ in s]
# l = [0 for _ in range(1<<(26*4))]
s2 = {}

for j, si in enumerate(s):
    counter = [0 for _ in range(26)]
    for c in si:
        i = ord(c) - 0x61
        counter[i] += 1
    rep = 0
    for i in range(26):
        rep += counter[i] * (1<<(i*4))
    # s2[j] = rep
    # l[rep] += 1
    if rep not in s2.keys():
        s2[rep] = 1
    else:
        s2[rep] += 1

pair = 0
"""
for i in range(n):
    for j in range(i+1, n):
        if s2[i] == s2[j]:
            pair += 1
"""
from math import factorial
for i in s2.values():
    if i > 1:
        pair += i * (i-1) // 2 

print(pair)


Measured memory_bytes: 23440
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int64_t gcd(int64_t a, int64_t b){
    while(b > 0){
        int64_t tmp = a;
        a = b;
        b = tmp % b;
    }
    return a;
}

void solve(){
    int64_t k, ans = 0;
    cin >> k;
    for(int64_t i = 1; i <= k; i++){
        for(int64_t j = 1; j <= k; j++){
            for(int64_t l = 1; l <= k; l++){
                ans += gcd(gcd(i, j), l);
            }
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
}

Measured memory_bytes: 3636
n = int(input())
A = [[] for _ in range(n)]
for i in range(n):
    a_i = int(input())
    for j in range(a_i):
        x,y = map(int, input().split())
        A[i].append((x-1,y))

ans = 0
for i in range(2**n):
    flag = True
    for j in range(n):
        if (i >> j) & 1:
            for x,y in A[j]:
                if (i >> x) & 1 != y:
                    flag = False
                    break
    if flag:
        ans = max(ans, bin(i)[2:].count("1"))

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String t = in.next();
        int a = in.nextInt();
        int b = in.nextInt();
        String u = in.next();
        if(u.equals(s)) {
            a--;
        }
        else {
            b--;
        }
        System.out.print(a);
        System.out.print(' ');
        System.out.println(b);
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();

    sc.close();

    int count = 0;

    for (int i = 0; i <= A; i++) {
      for (int j = 0; j <= B; j++) {
        for (int k = 0; k <= C; k++) {
          if (i * 500 + j * 100 + k * 50 == X) {
            count++;
          }
        }
      }
    }

    System.out.println(count);

  }

}

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

int main(){

  int n, x=0, mn=0;
  char c;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>c;
    if(c=='I') x++;
    else x--;
    mn=max(mn, x);
  }

  cout<<mn<<endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))

mini = float('inf')

for i in range(n):
    s1 = sum(w[0:i+1])
    s2 = sum(w[i+1:n])
    
    mini = min(abs(s2-s1),mini)
        
print(mini)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

struct list {
    string handle;
    int    position;
    int    rank;
};

//  文字列を置換する
string Replace( string String1, string String2, string String3 )
{
    string::size_type  Pos( String1.find( String2 ) );

    while( Pos != string::npos )
    {
        String1.replace( Pos, String2.length(), String3 );
        Pos = String1.find( String2, Pos + String3.length() );
    }
    return String1;
}

int main()
{
    int N;

    if (scanf("%d", &N) < 1) return 0;

    char tmp[21];

    vector<list> va;
    vector<list> vz;
    for (int i = 0; i <= N; i++)
    {
        if (scanf("%s", tmp) < 1) return 0;

        string tmpa = Replace(tmp, "?", "a");

        list a = {tmpa, i, 0};
        va.push_back(a);

        string tmpz = Replace(tmp, "?", "z");

        list z = {tmpz, i, 0};
        vz.push_back(z);
    }

    // a置換 handleをキーに昇順でソート
    stable_sort(va.begin(), va.end(),
        [](const list &x, const list &y) { return x.handle < y.handle; });

    for (int i = 0; i < va.size(); i++)
    {
        va[i].rank = i + 1;
    }

    // a置換 positionをキーに昇順でソート
    sort(va.begin(), va.end(),
        [](const list &x, const list &y) { return x.position < y.position; });

    int endrank = va[N].rank;

    // z置換 handleをキーに昇順でソート
    stable_sort(vz.begin(), vz.end(),
        [](const list &x, const list &y) { return x.handle < y.handle; });

    int samerank = -1;
    for (int i = 0; i < vz.size(); i++)
    {
        vz[i].rank = i + 1;
        if (vz[i].position == N)
        {
            string tmphandle = vz[i].handle;
            samerank = vz[i].rank;
            for (int j = i - 1; 0 <= j; j--)
            {
                if (vz[j].handle == tmphandle) samerank = vz[j].rank;
                else break;
            }
        }
    }

    int startrank = samerank > 0 ? samerank : endrank;

    string str = "";
    for (int i = startrank; i <= endrank; i++)
    {
        printf("%s", str.c_str());
        str = " ";
        printf("%d", i);
    }

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


Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


static const int N = 100;
static const long long INFTY = (1LL << 32);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

long long m[N][N], n;


void Floyd()
{
	for (int k = 0; k < n; ++k){
		for (int i = 0; i < n; ++i){
			if (m[i][k] == INFTY) continue;
			for (int j = 0; j < n; ++j){
				if (m[k][j] == INFTY) continue;
				m[i][j] = std::min(m[i][j], m[i][k] + m[k][j]);
			}
		}
	}
}


int main()
{
	int x; cin >> n >> x;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			m[i][j] = (i == j) ? 0 : INFTY;
		}
	}
	for (int i = 0; i < x; ++i)
	{
		int u, v, d;
		cin >> u >> v >> d;
		m[u][v] = d;
	}

	Floyd();

	bool neg = false;
	for (int i = 0; !neg && i < n; ++i){
			if (m[i][i] < 0) neg = true;
	}

	if (neg) cout << "NEGATIVE CYCLE" << endl;
	else{
		for (int i = 0; i < n; ++i)	{
			for (int j = 0; j < n; ++j) {
				if (j) cout << " ";
				if (m[i][j] == INFTY) cout << "INF";
				else cout << m[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define all(x) x.begin(),x.end()
#define LB(V,x) lower_bound(all(V),x)-V.begin()

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vll = vector<int64>;
using ll = int64;

ll gcd(ll A, ll B){
    if(A<B) swap(A, B);
    if(B==0) return A;
    gcd(B,A%B);
}
ll gcd(vll& V){
    ll ans=V[0],i=V.size();
    while(i--) ans = gcd(ans,V[i]);
    return ans;
}

void Main(){
    int32 N;
    cin >> N;
    vll A(N);
    for(auto &a:A) cin >> a;
    cout << gcd(A) << endl;
}

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

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
# A

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N = int(input())

if N % 2 == 0:
    print(0.5)
else:
    a = N//2
    b = N - a
    print(b/N)



Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

struct rest {
    int n;
    string s;
    int p;

    rest(int n, string s, int p) :n(n), s(s), p(p) {};

    bool operator<( const rest& r ) const{
        return s==r.s ? p>r.p : s<r.s;
    }
};

int N;
vector<rest> V;
int main(void){
    cin >> N;
    string s;
    int p;
    REP(i,N){
        cin >> s >> p;
        V.emplace_back(i+1, s, p);
    }
    sort(V.begin(), V.end());
    REP(i,N) cout << V[i].n << endl;
    return 0;
}



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

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

using namespace std;

int main(){
	int h,w; scanf("%d%d",&h,&w);
	int a[500][500];
	rep(i,h) rep(j,w) scanf("%d",a[i]+j);

	vector<tuple<int,int,int,int>> Op;
	rep(i,h-1) rep(j,w) if(a[i][j]%2==1) {
		a[i+1][j]++;
		Op.emplace_back(i,j,i+1,j);
	}
	rep(j,w-1) if(a[h-1][j]%2==1) {
		a[h-1][j+1]++;
		Op.emplace_back(h-1,j,h-1,j+1);
	}

	printf("%d\n",Op.size());
	for(auto o:Op) printf("%d %d %d %d\n",get<0>(o)+1,get<1>(o)+1,get<2>(o)+1,get<3>(o)+1);

	return 0;
}


Measured memory_bytes: 5104
from collections import Counter

N = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for k, v in c.items():
    tmp = v + c.get(k - 1, 0) + c.get(k + 1, 0)
    if tmp > ans:
        ans = tmp

print(ans)


Measured memory_bytes: 14564
/**
*    author:  boutarou
*    created: 15.06.2020 09:41:54
**/

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

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

const double PI = 3.1415926535897932;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int X, Y;
	cin >> X >> Y;
	int A = (Y - 2 * X) % 2;
	int B = (Y - 2 * X) / 2;

	if (A == 0 && B <= X && B >= 0) {
	    cout << "Yes" << endl;
	}

	else {
	    cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

static const int N = 1000;

int lcs(string X, string Y){
  int c[N+1][N+1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;

  X = ' ' + X;
  Y = ' ' + Y;



  for(int i = 0; i <= m; i++) c[i][0] = 0;
  for(int j = 0; j <= n; j++) c[0][j] = 0;

  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= n; j++){
      if(X[i] == Y[j]){
	c[i][j] = c[i - 1][j - 1] + 1;
      }
      else {
	c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string s1, s2;
  int n; cin >> n;
  int a[N];
  
  for(int i = 0; i < n; i++){
    cin >> s1 >> s2;
    a[i] = lcs(s1, s2);
  }
  for(int i = 0; i < n; i++){
    cout << a[i] << endl;
  }
  
  return 0;
}
 

      
    
   



Measured memory_bytes: 7068
#include <stdio.h>
#define INF 1000000000

int main()
{
    int m = 0, n, max = -INF, min2, min1, x = -INF, y = -1, i, j = 0, k , l = -INF;
    int s[200000] = {0};
    
    scanf ("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }
    
    min1 = INF;
    min2 = INF;
    
    for (i = 0; i < n; i++) {
        if (s[i] < min1) {
            min2 = min1;
            min1 = s[i];
            k = min1 - min2;
            if (k > l) {
                l = k;
            }
            m = i;
            max = min1;
            for ( j = m + 1; j < n; j++) {
                if (max <= s[j]) {
                    max = s[j];
                    y = max - min1;
                }
            }
            if (y > x) {
                x = y;
            }
        }
    }
    
    if (x < 0) {
        x = l;
    }
    
    printf ("%d\n", x);
    
    return 0;
}

Measured memory_bytes: 1388
from collections import deque

class UnionFind:
    def __init__(self, n):
        self.rank = [0]*n
        self.parent = [i for i in range(n)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        elif self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)



n = int(input())
s = [input() for _ in range(n)]

min_i = 0
min_count = n + 1
for i in range(n):
    count = 0
    for j in range(n):
        if s[i][j]:
            count += 1
    if count < min_count:
        min_count = count
        min_i = i

uf = UnionFind(n)

INF = 1001001001
ans = 0

for min_i in range(n):
    dist = [INF] * n
    dist[min_i] = 0
    q = deque([(min_i, 0, -1)])

    while q:
        v, d, p = q.popleft()
        box = []
        for nv in range(n):
            if s[v][nv] == '1':
                if nv == p:
                    continue
                if uf.same(v, nv):
                    print(-1)
                    exit()
                if d + 1 < dist[nv]:
                    dist[nv] = d + 1
                    q.append((nv, d + 1, v))
                    box.append(nv)
        for i in range(len(box) - 1):
            uf.merge(box[i], box[i + 1])
    ans = max(ans, max(dist) + 1)

print(ans)


Measured memory_bytes: 53212
from collections import Counter

while 1:
    try:
        hand = map(int, raw_input().split(','))
    except EOFError:
        break
    count = Counter(hand).most_common()

    ret = ''
    if count[0][1] >= 4:
        ret = 'four card'
    elif len(count) >= 2 and count[0][1] == 3 and count[1][1] == 2:
        ret = 'full house'
    elif len(count) == 5:
        sort_hand = sorted(hand)
        for i in xrange(4):
            if sort_hand[i] + 1 != sort_hand[i + 1]:
                break
        else:
            ret = 'straight'
        if sort_hand == [1, 10, 11, 12, 13]:
            ret = 'straight'
    elif len(count) == 3 and count[0][1] == 3:
        ret = 'three card'
    elif len(count) == 3 and count[0][1] == count[1][1] == 2:
        ret = 'two pair'
    elif len(count) == 4:
        ret = 'one pair'
    if ret:
        print ret
    else:
        print 'null'

Measured memory_bytes: 4600
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    int ar[11][1001],n,m;
    int ans;

    vector<int> v;

    void func(int x,int K)
    {
        if(x==n+1)
        {
            int ans2=v.size()-1;
            v.pb(n);
            int ar2[21],i,j,ct,k,nxt;
            for(i=0;i<=20;++i)
                ar2[i]=0;
            for(j=1;j<=m;++j)
            {
                for(i=1;i<v.size();++i)
                {
                    for(k=v[i-1]+1;k<=v[i];++k)
                    {

                        ar2[i]=ar2[i]+ar[k][j];
                    }
                    if(ar2[i]>K)
                    {
                        ++ans2;
                        goto end2;
                    }
                }
                continue;
                end2:
                for(i=0;i<=20;++i)
                    ar2[i]=0;
                for(i=1;i<v.size();++i)
                {
                    for(k=v[i-1]+1;k<=v[i];++k)
                    {
                        // cout<<k<<" "<<j<<"..."<<ar[k][j]<<endl;
                        ar2[i]=ar2[i]+ar[k][j];
                    }
                    if(ar2[i]>K)
                    {
                        // cout<<j<<" "<<i<<" "<<k<<" "<<ar2[i]<<" "<<endl;
                        goto end;
                    }
                }
            }
            //  cout<<v.size()<<" "<<ans2<<endl;
            ans=min(ans,ans2);
            end:
            v.pop_back();
            return;
        }
        func(x+1,K);
        v.pb(x);
        func(x+1,K);
        v.pop_back();
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int h,w,i,j,k;
            cin>>h>>w>>k;
            n=h,m=w;
            ans=h+w+1;
            char ch;
            for(i=1;i<=h;++i)
            {
                for(j=1;j<=w;++j)
                {
                    cin>>ch;
                    ar[i][j]=(ch-'0');
                }
            }
            v.pb(0);
            func(1,k);
            cout<<ans<<endl;
        }
        return 0;
    }


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

#define ll unsigned long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll S[555], T[555];
ll U[555], V[555];
ll  mks[555],mkt[555];
ll A[555][555];
ll i, j, k;

void outpt(){
    fornum(i,0,N){
        ll a = A[i][0];
        fornum(j,1,N){
            if(S[i]==0){
                a &= A[i][j];
            }else{
                a |= A[i][j];
            }
        }
        if(a!=U[i]){
            break;
        }
        a = A[0][i];
        fornum(j,1,N){
            if(T[i]==0){
                a &= A[j][i];
            }else{
                a |= A[j][i];
            }
        }
        if(a!=V[i])
            break;
    }
    if(i<N){
        printf("-1\n");
        return;
    }
    fornum(i,0,N){
        fornum(j,0,N){
            cout << A[i][j]<<" ";
        }
        cout << endl;
    }
}


int main(){
    cin>>N;
    fornum(i,0,N){
        cin>>S[i];
    }
    fornum(i,0,N){
        cin>>T[i];
    }
    fornum(i,0,N){
        cin>>U[i];
    }
    fornum(i,0,N){
        cin >> V[i];
    }
    //r&
    fornum(i,0,N){
        if(S[i]==1)
            continue;
        fornum(j,0,N){
            A[i][j] |= U[i];
        }
    }
    //c&
    fornum(i,0,N){
        if(T[i]==1)
            continue;
        fornum(j,0,N){
            A[j][i] |= V[i];
        }
    }
    //r|
    k = 0;
    fornum(i,0,N){
        if(S[i]==0)
            continue;
        fornum(j,0,N){
            if(T[j]==1){
                A[i][j] = U[i] & V[j];
            }
        }
        ll aa = 0;
        fornum(j,0,N){
            aa |= A[i][j];
        }
        if((aa&U[i])!=U[i]){
            ll a = 1e9, b = 1e9;
            fornum(j,0,N){
                if(T[j]==0){
                    if(a==1e9)
                        a = j;
                    b = j;
                }
            }
            if(a==1e9)
                continue;
            ll c = (aa & U[i]) ^ U[i];
            if(k%2==0){
                A[i][a] |= c;
            }else{
                A[i][b] |= c;
            }
        }
        ++k;
    }
    k = 0;
    fornum(i,0,N){
        if(T[i]==0)
            continue;
        ll aa = 0;
        fornum(j,0,N){
            aa |= A[j][i];
        }
        if((aa&V[i])!=V[i]){
            ll a = 1e9, b = 1e9;
            fornum(j,0,N){
                if(S[j]==0){
                    if(a==1e9)
                        a = j;
                    b = j;
                }
            }
            if(a==1e9)
                continue;
            ll c = (aa & V[i]) ^ V[i];
            if(k%2==0){
                A[a][i] |= c;
            }else{
                A[b][i] |= c;
            }
        }
        ++k;
    }

    outpt();

    return 0;
}

Measured memory_bytes: 7776
n = int(input())

class Node:
	def __init__(self, index, parent, children):
		self.parent = parent
		self.children = children
		self.depth = -1
		self.index = index
	
	def type(self):
		if self.parent == -1:
			return "root"
		elif len(self.children) == 0:
			return "leaf"
		else:
			return "internal node"
		
nodes = [Node(i, -1,[]) for i in range(n)]

for _ in range(n):
	l = list(map(int, input().split()))
	if l[1] > 0:
		children = l[2:]
		nodes[l[0]].children = children
		for child in children:
			nodes[child].parent = l[0]

def dfs(thisIndex, thisDepth):
	nodes[thisIndex].depth = thisDepth
	for child in nodes[thisIndex].children:
		dfs(child, thisDepth+1)
	

for node in nodes:
	if node.parent == -1:
		depth = 0
		dfs(node.index, 0)
		break
		
for node in nodes:
	print("node {}: parent = {}, depth = {}, {}, {}".format(node.index, node.parent, node.depth, node.type(), node.children))	


Measured memory_bytes: 43156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    int ans=0;
    FOR(i,1,n){
        if(vec[i]==vec[i-1]){
            ans++;
            vec[i]=-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N = ii()
    L = sorted(il())
    return "Yes" if L[-1] < sum(L[:-1]) else "No"


if __name__ == "__main__":
    print(solve())


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S.back() == 's') cout << S << "es\n";
    else cout << S << "s\n";
    return 0;
}

Measured memory_bytes: 3652
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S[]=sc.next().split("");
		String T[]=sc.next().split("");

		Arrays.sort(S);
		Arrays.sort(T, Collections.reverseOrder());

		String sortedS=String.join("",S);
		String sortedT=String.join("",T);

		if(sortedS.equals(sortedT)) {
			System.out.println("No");
			return;
		}

		String judge[]= {sortedS,sortedT};
		Arrays.sort(judge);

		System.out.println((judge[0]==sortedS) ? "Yes":"No");
	}
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    V w(n);rep(i,n)cin>>w[i];
    V right(n+1,0);
    V left(n+1,0);
    right[0]=w[0];
    for(int i=1;i<n;i++){
        right[i]=right[i-1]+w[i];
    }
    for(int i=n-1;i>=0;i--){
        left[i]=left[i+1]+w[i];
    }
    /*rep(i,n){
        printf("%d ",right[i]);
    }
    cout<<endl;
    rep(i,n){
        printf("%d ",left[i]);
    }
    cout<<endl;
    */
    int ans=inf;
    rep(i,n-1){
        int tmp=abs(right[i]-left[i+1]);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import string
from itertools import permutations

S = input()
if len(S) == 26:
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
    else:
        for i in range(25, -1, -1):
            j = 0
            while chr(ord(S[i]) + j + 1) <= "z":
                j += 1
                if chr(ord(S[i]) + j) not in set(S[:i]):
                    print(S[:i] + chr(ord(S[i]) + j))
                    exit()
else:
    for c in string.ascii_lowercase:
        if c not in S:
            print(S + c)
            exit()


Measured memory_bytes: 74496
N = int(input())
multi4 = range(0,101,4)
multi7 = range(0,101,7)
bigmulti = set()
for i in multi4:
    for j in multi7:
        bigmulti.add(i+j)
if N in bigmulti:
    print("Yes")
else:
    print("No")

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

int main()
{
    double a, v, b, w, t, dist, sp;
    cin >> a >> v >> b >> w >> t;
    dist = abs(a - b);
    sp = v - w;
    if (sp <= 0) {
        cout << "NO" << endl;
        return 0;
    }
    if (ceil(dist / sp) <= t) cout << "YES" << endl;
    else cout << "NO" << endl; 
    return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,sum=0;
  string N;
  cin>>A>>B;
  for(int i=0;i<B-A+1;i++){
    N=std::to_string(A+i);
 	if(N.at(0)==N.at(4)&&N.at(1)==N.at(3)){
      sum++;
    }
  }
  cout<<sum<<endl;
}

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

//SET PRECIOSION   cout << fixed ;  cout << setprecision(n) << ans << endl;
#define ll long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector <ll> v,w;
ll x,y,z,a,b,c,sum,ans,total,t,cnt,n,m,k,p,kase;
ll dp[101][100009];
string s1,s2;
map<ll,ll> mp;
set<ll> s;
map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;
ll coinChange(ll i, ll amount)
{
    if(amount==0)
        return 0;
    if(i>=n)
    {
            return INT_MAX;
    }
    if(dp[i][amount]!=-1)
        return dp[i][amount];
    ll ret1 = INT_MAX, ret2 = INT_MAX;
    if(amount-v[i]>=0)
        ret1 = coinChange(i+1, amount-v[i])+w[i];
    ret2 = coinChange(i+1, amount);
    dp[i][amount]= min(ret1,ret2);
    return dp[i][amount];
}
int main()
{
	FAST;
	cin>>n>>k;
	memset(dp,-1,sizeof(dp));
	v.resize(n+1);
	w.resize(n+1);
	for(int i=0; i<n; i++)
    {
           cin>>w[i]>>v[i];
           sum+=v[i];
    }
    while(sum--)
    {

        if(coinChange(0,sum+1)<=k)
        {
            cout<<sum+1<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
	//clear vectors and maps you idiot
	// check array size dumb
	// use long long instead of int too
	return 0;
}


Measured memory_bytes: 79360
parseint(x) = parse(Int, x)
readlist() = map(parseint, readline() |> split)

function main()
    k, x = readlist()
    l = [x+i for i = -k+1:k-1]
    ans = ""
    for e in l
        print(e, " ")
    end
    println()
end

main()

Measured memory_bytes: 112760
#include<stdio.h>
int main(void)
{
	int r,c,a[1000][1000]={0},i,j;
	
	scanf("%d %d",&r,&c);
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
			a[i][c]+=a[i][j];
			a[r][j]+=a[i][j];
		}
		a[r][c]+=a[i][c];
	}
	
	
	for(i=0;i<r+1;i++){
		for(j=0;j<c+1;j++){
			printf("%d",a[i][j]);
			if(j!=c){
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll n,x;
    cin >> n >> x;
    ll ans = n;
    ll mx = max(x, n - x), mn = min(x, n - x);
    while(mx % mn != 0){
        ans += (mx / mn) * mn * 2;
        ll k = mx % mn;
        mx = mn;
        mn = k;
    }
    ans += (mx / mn) * mn * 2 - mn;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
  
  int size1 = S.size();
  int size2 = T.size();
  
  for(int i = 0; i < size1; i++){
    if(S.at(i) != T.at(i)){
      cout << "No" << endl;
      return 0;
    }
    
  }
  
  if(size2 - size1 == 1){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3644
#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int q;
    cin >> q;
    REP(k,q){
        string X,Y;
        cin >> X;
        cin >> Y;
        int m,n;
        m = X.length();
        n = Y.length();

        vector<vector<int>> dp(m+1, vector<int>(n+1,0));

        REP(i,m){
            REP(j,n){
                if(X[i] == Y[j]){
                    dp[i+1][j+1] = max({dp[i+1][j+1], dp[i][j]+1});
                }
                dp[i+1][j+1] = max({dp[i+1][j+1], dp[i+1][j], dp[i][j+1]});
            }
        }
        cout << dp[m][n] << endl;
    }
    return 0;
}



Measured memory_bytes: 6864
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()
    a = []
    t = s[0]
    u = 1
    for c in s[1:]:
        if t == c:
            u += 1
        else:
            t = c
            a.append(u)
            u = 1
    a.append(u)
    f = False
    r = 0
    for c in a:
        if f:
            r += 1
            c -= 1
        f = False
        if c == 0:
            continue
        if c == 1:
            r += 1
            continue
        if c == 2:
            r += 1
            f = True
            continue
        r += c // 3 * 2
        if c % 3 > 0:
            r += 1
        if c % 3 == 2:
            f = True

    return r


print(main())





Measured memory_bytes: 7368
import sys
input = sys.stdin.readline
#N, K = (int(i) for i in input().split())
#B = [int(x) for x in stdin.readline().rstrip().split()]
#A = [[int(i) for i in input().split()] for i in range(N)]
S = input()
T = input()

for i in range(len(S)-1):
    if S[i] != T[i]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 61816
import sys

a = 0
b = 0
c = 0
d = 0
pw = dict()

def minCost(n):
	if n == 0:
		return 0
	if n == 1:
		return d
	if n in pw:
		return pw[n]
	else:
		ns = dict()
		ns[(n // 2) * 2] = 1
		ns[((n + 1) // 2) * 2] = 1
		ns[(n // 3) * 3] = 1
		ns[((n + 2) // 3) * 3] = 1
		ns[(n // 5) * 5] = 1
		ns[((n + 4) // 5) * 5] = 1
		_min = n * d
		for key in ns:
			if key % 2 == 0:
				_min = min(_min, a + int(minCost(key // 2)) + d * abs(n - key))
			if key % 3 == 0:
				_min = min(_min, b + int(minCost(key // 3)) + d * abs(n - key))
			if key % 5 == 0:
				_min = min(_min, c + int(minCost(key // 5)) + d * abs(n - key))
		pw[n] = _min
		return pw[n]

t = int(sys.stdin.readline())
for i in range(0, t):
	line = sys.stdin.readline().split()
	n = int(line[0])
	a = int(line[1])
	b = int(line[2])
	c = int(line[3])
	d = int(line[4])
	pw = dict()
	print(int(minCost(n)))

Measured memory_bytes: 13052
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
  
ll h,a;
cin>>h>>a;
ll cnt=0;
while(h>0)
{
    h=h-a;
    cnt++;
}
cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{
	
	
	public static void main(String[] args) throws Exception {
		
		Scanner s=new Scanner(System.in);
		
		int h=s.nextInt();
		int n=s.nextInt();
		int[] hel=new int[n];
		int [] cost=new int[n];
		for(int i=0;i<n;i++) {
			hel[i]=s.nextInt();
			cost[i]=s.nextInt();
		}
		
		int[][] dp=new int[n+1][h+1];
		
		for(int i=0;i<h+1;i++) {
			dp[0][i]=Integer.MAX_VALUE;
			
		}
		
		for(int i=1;i<n+1;i++) {
			for(int j=1;j<h+1;j++) {
				
				if(j<=hel[i-1]) {
					dp[i][j]=Math.min(dp[i-1][j],cost[i-1]);
					
				}else {
					dp[i][j]=Math.min(dp[i-1][j], cost[i-1]+dp[i][j-hel[i-1]]);
				}
				
			
				
				
			}
		}
		
		
//		for(int i=0;i<n+1;i++) {
//			for(int j=0;j<h+1;j++) {
//				System.out.print(dp[i][j]+" ");
//			}
//			System.out.println();
//		}
//		
		
		System.out.println(dp[n][h]);
		
		
		
	}
}

Measured memory_bytes: 82404
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	char s[52][52];
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>s[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(s[i][j]=='.')s[i][j]='0';
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(s[i][j]!='#'){
			if(s[i-1][j-1]=='#')s[i][j]++;
			if(s[i-1][j]=='#')s[i][j]++;
			if(s[i-1][j+1]=='#')s[i][j]++;
			if(s[i][j-1]=='#')s[i][j]++;
			if(s[i][j+1]=='#')s[i][j]++;
			if(s[i+1][j-1]=='#')s[i][j]++;
			if(s[i+1][j]=='#')s[i][j]++;
			if(s[i+1][j+1]=='#')s[i][j]++;
		}
	}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)cout<<s[i][j];
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

#define X_MIN (0.0)
#define X_MAX (1000.0)
#define Y_MIN (0.0)
#define Y_MAX (1000.0)

int n;
vector<pair<int, int>> points;

// 中心座標を(x,y)としたときに必要な半径
ld r(ld x, ld y) {
	ld res = 0;
	for (int i = 0; i < n; ++i) {
		ld xi = points[i].first;
		ld yi = points[i].second;
		res = max(res, sqrt(pow(x - xi, 2.0) + pow(y - yi, 2.0)));
	}
	return res;
}

ld solve() {
	const ld e = 1e-10;
	ld res = 0.0;
	ld x_mn = X_MIN, x_mx = X_MAX;
	while (x_mx - x_mn > e) {
		ld x_mid_l = (x_mx / 3) + ((2 * x_mn) / 3);
		ld x_mid_r = ((2 * x_mx) / 3) + (x_mn / 3);
		// xをx_mid_lに固定したときの最小値を求める
		ld y_mn = Y_MIN, y_mx = Y_MAX;
		while (y_mx - y_mn > e) {
			ld y_mid_l = (y_mx / 3) + ((2 * y_mn) / 3);
			ld y_mid_r = ((2 * y_mx) / 3) + (y_mn / 3);
			if (r(x_mid_l, y_mid_l) >= r(x_mid_l, y_mid_r))
				y_mn = y_mid_l;
			else
				y_mx = y_mid_r;
		}
		ld tmp1 = r(x_mid_l, y_mx);
		// xをx_mid_rに固定したときの最小値を求める
		y_mn = Y_MIN, y_mx = Y_MAX;
		while (y_mx - y_mn > e) {
			ld y_mid_l = (y_mx / 3) + ((2 * y_mn) / 3);
			ld y_mid_r = ((2 * y_mx) / 3) + (y_mn / 3);
			if (r(x_mid_r, y_mid_l) >= r(x_mid_r, y_mid_r))
				y_mn = y_mid_l;
			else
				y_mx = y_mid_r;
		}
		ld tmp2 = r(x_mid_r, y_mx); res = tmp2;
		// x_mn, x_mxの更新
		if (tmp1 >= tmp2) x_mn = x_mid_l;
		else x_mx = x_mid_r;
	}
	return res;
}

signed main() {
	cin >> n;
	points.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> points[i].first >> points[i].second;
	cout << setprecision(15) << solve() << endl;
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  bool ans=false;
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    if(c=='Y'){
      ans=true;
    }
  }
  if(ans){
    cout<<"Four"<<endl;
  }
  else{
    cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long N,K,i,j;
    string S;
    cin>>N>>K>>S;
    long long A[N],B[N];
    j=0;
    for(i=0;i<N;i++){
        if(S[i]=='1'){
            if(i==0){
                A[j]=i;
            }else if(i==N-1){
                B[j]=i;
                j++;
            }else{
                if(S[i-1]=='0'){
                    A[j]=i;
                }
                if(S[i+1]=='0'){
                    B[j]=i;
                    j++;
                }
            }
        }
    }
    if(K>j){
        cout<<N<<endl;
        return 0;
    }
    long long ans;
    ans=max(B[K-1]+1,N-A[j-K]);
    for(i=0;i+K<j;i++){
        ans=max(ans,B[i+K]-A[i]+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1280
#[allow(unused_imports)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
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()
}

type Work = (i64, i64); // A, B

fn main() {
    let n = read::<usize>();
    let mut works: Vec<Work> = Vec::with_capacity(n);
    for _i in 0..n {
        let ab: Vec<i64> = read_vec();
        let a = ab[0];
        let b = ab[1];
        let w: Work = (a, b);
        works.push(w);
    }


    let answer = solve(&mut works);
    let msg = if answer {
        "Yes"
    } else {
        "No"
    };
    println!("{}", msg);
}

fn solve(works: &mut [Work]) -> bool {
    // 1. Sort
    works.sort_by(|a, b| a.1.cmp(&b.1));

    // 2. Check
    let mut prev : i64 = 0;
    for w in works {
        let current : i64 = w.0 + prev;
        if current > w.1 {
            return false;
        }
        prev = current;
    }
    return true;
}


Measured memory_bytes: 6544
// -*- coding:utf-8-unix -*-

use proconio::input;

// v[i] >= k を満たす最小の i を返す
fn lower_bound(v: &[u32], k: u32) -> usize {
    let mut low: isize = -1;
    let mut high = v.len() as isize;

    while high - low > 1 {
        let mid = (low + high) / 2;
        if v[mid as usize] >= k {
            high = mid;
        } else {
            low = mid;
        }
    }
    high as usize
}

fn main() {
    input! {
        n: usize,
        mut l: [u32; n],
    }

    l.sort();
    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            let k = lower_bound(&l[j + 1..], l[i] + l[j]);
            ans += k;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2120
gomi = gets
input = gets.split(" ").map{|k|k.to_i}
count =0
input.each{|item|
if item<0 then
count +=1
end
}
ans = 0
input.map!{|item|item.abs}
if count%2==0 then
    input.each{|item|
        ans = ans + item
    }
else
    t = input.min
    input.each{|item|
        ans = ans + item
    }
    ans -= t*2
end
print ans

Measured memory_bytes: 8580
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int a, b;
  cin >> a >> b;
  if (b >= a) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}


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

int main(){
    int x,n; cin >> x >> n;
    vector<int> p(101,0);
    for(int i=0; i<n; i++){
        int j; cin >> j;
        p[j] = 1;
    }

    int left = x;
    int right = x;
    while(true){
        if(left > 0){
            if(p[left] == 0){
                cout << left << endl;
                break;
            }else{
                left--;
            }
        }else{
            cout << "0" << endl;
            break;
        }

        if(right < 101){
            if(p[right] == 0){
                cout << right << endl;
                break;
            }else{
                right++;
            }
        }else{
            cout << "101" << endl;
            break;
        }
    }
}

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

using namespace std;
using ll = long long int;

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

    auto p = [&](ll x) {
        ll t = x *x;
        return t*t*x;
    };
    ll x;
    cin >> x;
    for(ll b=-1000; b<=1000; b++) {
        // a^5 - b^5 >= x
        ll ok = 1e3, ng = -1e3;
        while(abs(ok - ng) > 1) {
            ll m = (ok + ng) /2;
            (p(m) - p(b) >= x ? ok : ng) = m;
        }
        if(p(ok) - p(b) == x) {
            cout << ok << ' ' << b << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3640