akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int c[10][1005];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = INF;
  rep(div, 1 << (h - 1)) {
    int g = 0;
    vector<int> id(h);
    rep(i, h) {
      id[i] = g;
      if (div >> i & 1) ++g;
    }
    ++g;
    rep(i, g) rep(j, w) c[i][j] = 0;
    rep(i, h) rep(j, w) c[id[i]][j] += (s[i][j] - '0');

    int num = g - 1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i, g) now[i] += c[i][j];
      rep(i, g) if (now[i] > k) return false;
      return true;
    };
    rep(j, w) {
      if (!add(j)) {
        num++;
        now = vector<int>(g);
        if (!add(j)) {
          num = INF;
          break;
        }
      }
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}


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

#define ull unsigned long long
#define ll long long
#define imei(...)   "[ "<< #__VA_ARGS__ <<" = "<< __VA_ARGS__ <<" ] "

using namespace std;

class BIT {
public:
        BIT(int _n): n(_n) {
            bit.clear();
            bit.resize(n+1, 0);
        }

        void add(int x, int v) {
            while(x <= n) {
                bit[x]+=v;
                x += x&-x;
            }
        }

        int sum(int x) {
            int s = 0;
            while(x > 0) {
                s += bit[x];
                x -= x&-x;
            }
            return s;
        }

        int query(int l, int r) {
            return sum(r) - sum(l-1);
        }
private:
    int n;
    vector<int> bit;
};

const int MAX_N = 5e5+50;
int n, q;
vector<pair<int, int>> queries, ori;
map<pair<int, int>, int> mp;
vector<int> occurence;
vector<int> c;
vector<int> ans;

int main(int argc, char *argv[])
{
    cin >> n >> q;
    occurence.resize(MAX_N, -1);
    c.resize(MAX_N);
    queries.resize(q);
    ori.resize(q);

    BIT bit(MAX_N);

    for (int i = 0; i < n; i++) {
        cin >> c[i+1];
    }

    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        queries[i] = {l, r};
        ori[i] = queries[i];
    }

    sort(queries.begin(), queries.end(), [&](auto& p1, auto& p2) {
            if (p1.second == p2.second) return p1.first < p2.first;
            return p1.second < p2.second;
        });

    int cur = 1;
    for (int i = 0; i < q; i++) {
        int l = queries[i].first;
        int r = queries[i].second;
        for (; cur <= r; cur++) {
            if (occurence[c[cur]] != -1)
                bit.add(occurence[c[cur]], -1);
            occurence[c[cur]] = cur;
            bit.add(cur, 1);
        }
        cur--;
        mp[make_pair(l, r)] = bit.query(l, r);
    }

    for (int i = 0; i < q; i++)
        cout << mp[ori[i]]<<endl;

    return 0;
}


Measured memory_bytes: 48768
#include <stdio.h>
#include <string.h>

int main () {
	char buff[64];
	char result[64];
	int length;
	
	fgets (buff, 64, stdin);
	length = strlen(buff);

	int i, j;
	for (i = length - 2, j = 0; i >= 0; i--, j++) {
		result[j] = buff[i];
	}
	result[j] = '\0';
	printf ("%s\n", result);
	
	return 0;
}



Measured memory_bytes: 2080
from itertools import combinations, count

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)
ans = next(i for i in count(n, - 1) for x in map(set, combinations(r, i))
           if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x))
print(ans)


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        size = max((int) sqrt(size) + 1, 101010);
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

string s;
ll N, K;

int main() {
    cin >> K >> N;
    ll sum = 0;
    REP(i, N) {
        int a;
        cin >> a;
        sum += a;
    }
    if (K <= sum)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int kiriste(double x){
    return x/1;
}

int main() {
  int A, B;
  cin >> A >> B;
  bool Possible = false;
  for(int p =1; p <= 2000; p++){
    if(kiriste(p*0.08)== A && kiriste(p*0.1)==B){
      Possible = true;
      cout << p << endl;
      break;
    }
  }
  if(!Possible) cout << "-1" << endl;
}

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

int main(){
	string s;cin>>s;
  map<char,int>cnt;
  for(auto&& u:s)cnt[u]++;
  if(cnt['a']==1&&cnt['b']==1&&cnt['c']==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13

G = [[INF] * (N + 1) for _ in range(N + 1)]
for a, b, c in egdes:
    G[a][b] = -c
dist = [INF] * (N + 1)
dist[1] = 0
for _ in range(N - 1):
    for a, b, c in egdes:
        dist[b] = min(dist[b], dist[a] - c)
ans = dist[N]
for a, b, c in egdes:
    dist[b] = min(dist[b], dist[a] - c)
print(-ans if ans == dist[N] else 'inf')

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;

int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall


        
    ini(n);
    ini(n1);
    double tmp = 0;
    double a[n];
    FOR(i,0,n){
        in(a[i]);
        tmp+=a[i];
    }
    double tmp1 = tmp/(4*n1);
    int tmp_ = 0;
    FOR(i,0,n){
        if(a[i]>=tmp1){
            tmp_++;
        }
    }
    if(tmp_ >= n1)out("Yes");
    else out("No");
    


    return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7

def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs

def getCombKs(n, k, invs, MOD):
    combKs = [0] * (n+1)
    combKs[k] = 1
    for x in range(k+1, n+1):
        combKs[x] = (combKs[x-1] * x * invs[x-k]) % MOD
    return combKs

N, K = map(int, input().split())
As = list(map(int, input().split()))

As.sort()

invs = getInvs(N, MOD)
combKs = getCombKs(N, K-1, invs, MOD)

ans = 0
for i, A in enumerate(As):
    numMax = combKs[i]
    numMin = combKs[N-1-i]
    ans += A * (numMax - numMin) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 14416
{-# LANGUAGE FlexibleContexts #-}
import Data.Array
import Data.Array.ST

type CountVect=(Int,Int,Int,Int)

case_ee::CountVect->(Int,Int)->Bool
case_ee (a,b,c,d) _     = (b,c,d)==(0,0,0)

case_eo::CountVect->(Int,Int)->Bool
case_eo (a,b,c,d) (e,o) = let limit = div e 2 in ((b,d)==(0,0)) && (c <= limit)

case_oo::CountVect->(Int,Int)->Bool
case_oo (a,b,c,d) (h,w) = case (b,d) of
                          (1,0) -> (c <= ((div (h-1) 2) + (div (w-1) 2))   )
                          (0,1) -> (c <= ((div (h-1) 2) + (div (w-1) 2))-1 )
                          otherwise -> False

preproc1::String->Array Char Int
preproc1 str = runSTArray $ do
                  ar<-newArray ('a','z') 0
                  mapM_ (count ar) str
                  return ar
                        where count ar x = do
                                v<-(readArray ar x)
                                writeArray ar x (v+1)

preproc2::Array Char Int->CountVect
preproc2 ar = let ls = elems ar in
              let  a = length (filter (\x->mod x 4 == 0) ls) in
              let  b = length (filter (\x->mod x 4 == 1) ls) in
              let  c = length (filter (\x->mod x 4 == 2) ls) in
              let  d = length (filter (\x->mod x 4 == 3) ls) in
              (a,b,c,d)

solver::String->(Int,Int)->Bool
solver str (h,w)=let vec = (preproc2 (preproc1 str)) in
                  case (mod h 2,mod w 2) of
                  (0,0) -> case_ee vec (h,w)
                  (1,0) -> case_eo vec (w,h)
                  (0,1) -> case_eo vec (h,w)
                  (1,1) -> case_oo vec (h,w)


main::IO()
main=do
  size<-getLine
  let h:w:[]= map read (words size)
  str<-getdat h
  putStr (if (solver str (h,w)) then "Yes" else "No")
  putStr "\n"

getdat::Int->IO String
getdat 0 = return []
getdat n = do
  str<-getLine
  rest<-getdat (n-1)
  return (str++rest)

Measured memory_bytes: 1532
using System;

class Program
{
    static void Main()
    {
        var nm = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        long ans = 0;
        if (nm[0] <= nm[1] * 2)
        {
            ans = nm[0];
            nm[1] -= nm[0] * 2;
            ans += nm[1] > 0 ? nm[1] / 4 : (long)Math.Floor((double)nm[1] / 2);
        }
        else ans = nm[1] / 2;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, M;
  cin >> N >> M;
  int l = 1, r = N;
  for (int i = 1; i <= M; ++i) {
    int a, b;
    cin >> a >> b;
    l = max(l, a);
    r = min(r, b);
  }
  cout << max(0, r-l+1) << endl;
  return 0;
}

Measured memory_bytes: 3148
from collections import deque

k = int(input())
limit = 10#最大桁数

start = [i for i in range(1, 10)]#最初にスタートする数
ans = []
q=deque(start)
while q:
	num=q.popleft()
	if len(str(num))>11:#処理終了
		continue#次のQへ
	ans.append(num)
	last=str(num)[-1]
	if last == "0":
		add = ['0', '1']
	elif last == '9':
		add = ['8',"9"] 
	else:
		add = [str(int(last) - 1), str(int(last)), str(int(last) + 1)]
	for i in add:
		q.append(int(str(num)+i))

ans = sorted(ans)
print(ans[k - 1])#k番目の答えを創出


Measured memory_bytes: 153428
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#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 llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

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

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

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};

int main(){
    int A[22],B[22],C[22];
    int N,score=0,idx;
    cin >> N;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }
    rep(i,N-1){
        cin >> C[i];
    }
    rep(i,N){
        idx = A[i]-1;
        score += B[idx];
        if (i<N-1 && (A[i] + 1 == A[i+1]) ){
            score += C[idx];
        }
    }
    cout << score << endl;
    return 0;
}


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

int MOD = 1000000007;

int main() {
	int N;
	char d[2][52] = { '\0' };
	vector<int> v;
	long long ans = 0;

	cin >> N;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> d[i][j];
		}
	}

	for (int i = 0; i < N; i++) {
		if (i + 1 < N && d[0][i] == d[0][i + 1]) {
			v.push_back(2);
			i++;
		}
		else {
			v.push_back(1);
		}
	}

	if (v[0] == 1) {
		ans = 3;
	}
	else {
		ans = 6;
	}

	for (int i = 0; i < v.size() - 1; i++) {
		if (v[i] == 1) {
			ans = ans * 2 % MOD;
		}
		else {
			if (v[i + 1] == 2) {
				ans = ans * 3 % MOD;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <iostream>
# include <string>
using namespace std;
int main ()
{
	string s;
	int n,a=0,flag=1;
	cin>>s;
	n=s.length();
	for (int i=0;i<n;++i)
	   {
	   	 if (isupper(s[i]))
	         a++;
	   }
	if (s[0]=='A'&&s[1]!='C'&&s[n-1]!='C'&&a==2)
	  printf ("AC\n");
	else
	printf ("WA\n");	   
}

Measured memory_bytes: 256
n=int(input())
w_list=list(map(int,input().split()))
Sum=sum(w_list)
ans=10**10
for i in range(1,n):
    s_1=sum(w_list[:i])
    s_2=Sum-s_1
    d=abs(s_1-s_2)
    if d<ans:
        ans=d
print(ans)



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

using namespace std;

int main() {

	int n;
	int a[200000] = {0};
	int sort_a[200000] = {0};
		
	cin >> n;
	
	for(int i = 0; i < n; i++){
		int num;
		cin >> num;
		a[i] = sort_a[i] = num;
	}
	
	sort(sort_a, sort_a+n);
	
	for(int i = 0; i < n; i++){
		if(a[i] != sort_a[n - 1]){
			cout << sort_a[n-1] << endl;
		}
		else{
			cout << sort_a[n-2] << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#define SIZE 200005

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

int A[SIZE],B[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	bool up=true;
	for(int i=0;i<n;i++)
	{
		scanf("%d %d",&A[i],&B[i]);
		if(A[i]!=B[i]) up=false;
	}
	if(up)
	{
		puts("0");
		return 0;
	}
	int mn=-1;
	for(int i=0;i<n;i++)
	{
		if(A[i]>B[i])
		{
			if(mn==-1) mn=B[i];
			else mn=min(mn,B[i]);
		}
	}
	ll ret=-mn;
	for(int i=0;i<n;i++) ret+=B[i];
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;

public class MainApp
{
    static public void Main(string[] args)
    {
        var read = Console.ReadLine();
        var split = read.Split(' ');
        int H = int.Parse(split[0]);
        int W = int.Parse(split[1]);
        string outputsharp = "";
        for (int c = 0; c < W + 2; c++)
        {
            outputsharp += "#";
        }
        Console.WriteLine(outputsharp);
        for (int c = 0; c < H; c++)
        {
            read = Console.ReadLine();
            string output = "#" + read + "#";
            Console.WriteLine(output);
        }
        Console.WriteLine(outputsharp);
    }

}

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

struct UnionFind{
	vector<int> par,gsize;
	int sz;
	
	UnionFind(int N) : par(N) ,gsize(N), sz(N) {
		for(int i=0;i<N;i++) {
			par[i]=i;
			gsize[i]=1;
		}
	}
	
    //root:子xの根を返す
	int root(int x){
		if(par[x]==x) return x;
		else{
			return par[x]=root(par[x]); 
		}
	}
	
    //unite:要素xとyを結ぶ
	void unite(int x,int y){
		int rx=root(x);
		int ry=root(y);
		if(rx==ry) return;
		else {
			if(gsi(rx)>gsi(ry))swap(rx,ry);
			par[ry]=rx; sz--; 
			gsize[rx]+=gsize[ry];
		}
	}
	
    //same:要素xとyの親が同じか判定する
	bool same(int x,int y){
		int rx=root(x);
		int ry=root(y);
		return rx==ry;
	}
	
    //size:全体のグループの数を返す
	int size() { return sz; }

	//gsize:要素xが属するグループの大きさを返す
	int gsi(int x) {return gsize[root(x)]; }
};

signed main(){
	int N,M; cin>>N>>M;
	vector<int> p(N);
	for(int i=0;i<N;i++){cin>>p[i]; p[i]--;}
	UnionFind tree(N);
	for(int i=0;i<M;i++){
		int x,y; cin>>x>>y; x--; y--;
		tree.unite(x,y);
	}
	int ans=0;
	for(int i=0;i<N;i++){
		ans+=tree.same(i,p[i]);
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] atk = new int[n];
        int[] mgc = new int[n];
        //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i = 0; i < n; i++){
            atk[i] = sc.nextInt();
            mgc[i] = sc.nextInt();
            //map.put(k,v);
        }
        long[] dp = new long[h+1];
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i = 1; i <= h; i++){
            //for(Map.Entry<Integer,Integer> entry :map.entrySet()){
            for(int j = 0; j < n; j++){
                int k = atk[j];
                int v = mgc[j];
                if(i < k){
                    dp[i] = Math.min(dp[i], v);
                }else{
                    dp[i] = Math.min(dp[i], dp[i-k] + v);
                }
            }
        }
        System.out.println(dp[h]);
    }
}

Measured memory_bytes: 27908
#include <cmath>
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
inline char nc()
{
    return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
typedef long long ll;
ll S;
void solve()
{
    int x = ceil(sqrt(S));
    int a = 1;
    int b = (ll)x * x - S;
    printf("%d %d %d %d %d %d\n", 0, 0, x, a, b, x);
}
int main()
{
    read(S);
    solve();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(x int, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func max(x int, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	v := make([]int, n)
	for i := range v {
		v[i] = nextInt()
	}
	//fmt.Printf("v: %v\n", v)

	//minK := min(n, k)
	minK := k
	if n < minK {
		minK = n
	}

	ans := 0
	for r := 0; r <= minK; r++ {
		for l := 0; l <= minK-r; l++ {
			t := make([]int, 0, r+l)
			t = append(t, v[0:l]...)
			t = append(t, v[len(v)-r:len(v)]...)
			sort.Ints(t)
			//fmt.Printf("t: %v\n", t)

			remainingK := k - r - l
			sum := 0
			for _, v := range t {
				if v < 0 && remainingK > 0 {
					remainingK--
					continue
				}
				sum += v
			}
			if sum > ans {
				ans = sum
			}
		}
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool ok = true;
    if(s[a] != '-'){
        ok = false;
    }

    rep(i, a){
        if(s[i] < '0' || s[i] > '9'){
            ok = false;
        }
    }

    for (int i = a+1; i < a+b+1; ++i) {
        if(s[i] < '0' || s[i] > '9'){
            ok = false;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

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


int main() {
  string  S;
  cin >> S;
  if (S == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;
  vint cnt(N, 1);
  vint col(N, 0);
  col[0] = 1;
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y; --x, --y;
    cnt[x]--;
    cnt[y]++;
    col[y] |= col[x];
    if(cnt[x] == 0) col[x] = 0;
  }
  int ans = 0;
  for(int i = 0; i < N; i++) ans += col[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS


//FUNCTIONS
int n,m; 
vector<vector<int>> gr;
vector<int> dist;
vector<int> indegree;
vector<bool> visited;
void dfs(int i){
	visited[i] = true;
	for(auto ra: gr[i]){
		dist[ra] = max(dist[ra],dist[i]+1);
		indegree[ra]--;
		if(indegree[ra] == 0){
			dfs(ra);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	gr.resize(n+1);
	dist.resize(n+1,0);
	indegree.resize(n+1,0);
	visited.resize(n+1,0);
	for(int i = 0; i < m; i++){
		int x,y; cin >> x >> y;
		gr[x].push_back(y);
		indegree[y]++;
	}
	for(int i = 1; i < n; i++){
		gr[0].push_back(i);
	}
	indegree[0] = -1;
	for(int i = 0; i < n+1; i++){
		if(indegree[i] == 0 and visited[i] == false){
			dfs(i);
		}
	}
	int mx = 0;
	for(auto ra: dist){
		mx = max(ra,mx);
	}
	cout << mx << endl;
	return 0;
}


Measured memory_bytes: 10232
INF = 10**10

def solve(n, x):
    best = INF
    for p in range(min(x), max(x)+1):
        cost = sum((xi-p)**2 for xi in x)
        best = min(best, cost)
    return best

n = int(input())
x = list(map(int, input().split()))
print(solve(n, x))

Measured memory_bytes: 3060
v = sorted(list(map(int,input().split())))
cnt = 0
while v[0]!=v[2]:
    if v[2]-v[0]>=2:
        cnt += (v[2]-v[0])//2
        v[0]+=((v[2]-v[0])//2)*2
    elif v[2]-v[0]==1:
        v[0]+=1
        v[1]+=1
        cnt+=1
    v.sort()
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  for(int i = 0; i < A + B + 1; i++) {
    if (((S.at(i) - '0' < 0 || S.at(i) - '0' > 9) && i != A) || (i == A && S.at(i) != '-')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<unistd.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")

struct Bipartite_Matching
{
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;
 
  Bipartite_Matching(int n)
  {
    timestamp = 0;
    graph.resize(n);
    alive.assign(n, 1);
    used.assign(n, 0);
    match.assign(n, -1);
  }
 
  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
 
  bool dfs(int v)
  {
    used[v] = timestamp;
    for(int i = 0; i < graph[v].size(); i++) {
      int u = graph[v][i], w = match[u];
      if(alive[u] == 0) continue;
      if(w == -1 || (used[w] != timestamp && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return (true);
      }
    }
    return (false);
  }
 
  int bipartite_matching()
  {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return (ret);
  } 
};


signed main(){
    int x,y,e;
    cin >> x >> y >> e;
    Bipartite_Matching graph(x+y);
    REP(i,e){
        int a,b;
        cin >> a >> b;
        graph.add_edge(a, b + x);
    }
    cout << graph.bipartite_matching() << endl;

    return 0;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
string ans;
int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

k, x = Is()
if k*500 >= x:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 63340
#include <stdio.h>
#include <inttypes.h>
 
int N, K;
int H[512];
 
/* [最初, 2番目) */
int64_t sakugenTable[512][512];
 
int64_t memo[512][512];
 
int64_t search(int pos, int stock) {
	int64_t answer;
	int i;
	if (pos > N) return 0;
	if (memo[pos][stock]) return ~memo[pos][stock];
 
	/* 使わない */
	answer = search(pos + 1, stock);
	/* 使う */
	for(i = 1; i <= stock && pos + i <= N + 1; i++) {
		int64_t candidate = search(pos + i + 1, stock - i) + sakugenTable[pos][pos + i];
		if (candidate > answer) answer = candidate;
	}
 
	return ~(memo[pos][stock] = ~answer);
}
 
int main(void) {
	int i, j;
	int64_t all_cost;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &H[i]) != 1) return 1;
	}
	H[0] = H[N + 1] = 0;
	for (i = 1; i <= N; i++) {
		int64_t sum = 0;
		for (j = i; j <= N + 1; j++) {
			if (H[j] < H[j - 1]) sum += H[j - 1] - H[j];
			sakugenTable[i][j] = sum + H[j];
		}
	}
	all_cost = sakugenTable[1][N + 1];
	for (i = 1; i <= N; i++) {
		for (j = i; j <= N + 1; j++) {
			int64_t after_cost = (H[i - 1] >= H[j]) ? H[i - 1] : H[j];
			sakugenTable[i][j] -= after_cost;
		}
	}
	printf("%" PRId64 "\n", all_cost - search(1, K));
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    if(x<600){
        cout<<"8\n";
    }else if(x<800){
        cout<<"7\n";
    }else if(x<1000){
        cout<<"6\n";
    }else if(x<1200){
        cout<<"5\n";
    }else if(x<1400){
        cout<<"4\n";
    }else if(x<1600){
        cout<<"3\n";
    }else if(x<1800){
        cout<<"2\n";
    }else{
        cout<<"1\n";
    }
    return 0;

}

//      *   *  *****  *   *  *   *   ****  ****    ****     **  ***
//     *   *  *      **  *  *   *  *      *   *  *        * *  *  *
//    *****  *****  * * *  *   *  *      ****   *       *  *    *
//   *   *      *  *  **  *   *  *      *  *   *       *****  *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   ****

//     ****  *   *  *   *   ***   *   *  *****  *   *
//    *     *   *  *   *  *   *  *   *  *      *   *
//    ***  *****  *   *  *****  * * *  ****   *   *
//      *   *    *   *  *   *  * * *  *      *   *
//  ****   *     ***   *   *   * *   *****   ***


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

int main(){
  int N;
  std::cin >> N;
  vector<int> A(N+1);
  A[0] = 0;
  for(int i=1;i<N+1;i++) std::cin >> A[i];
  A.push_back(0);
  int sum=0;
  for(int i=0;i<N+1;i++){
    sum += abs(A[i+1] - A[i]);
  }
  for(int i=1;i<=N;i++){
    if((A[i]-A[i-1]) * (A[i+1]-A[i]) >= 0) std::cout << sum << '\n';
    else if((A[i+1] == A[i-1])) std::cout << sum - abs(A[i] - A[i-1])*2 << '\n';
    else if((A[i-1]<A[i+1] && A[i+1]<A[i]) || (A[i]<A[i+1] && A[i+1]<A[i-1])) std::cout << sum - abs(A[i+1]-A[i])*2 << '\n';
    else if((A[i+1]<A[i-1] && A[i-1]<A[i]) || (A[i]<A[i-1] && A[i-1]<A[i+1])) std::cout << sum- abs(A[i-1]-A[i])*2 << '\n';
  }
  return 0;
}


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

#define int long long
#define pb push_back

signed main(){
    int n;
    cin>>n;
    vector<int> A(n);
    vector<int> B(n);
    vector<int> C(n-1);
    
    for(int i=0; i<n; i++) cin>>A[i];
    for(int i=0; i<n; i++) cin>>B[i];
    for(int i=0; i<n-1; i++) cin>>C[i];

    int res = B[A[0]-1];
    for(int i=1; i<n; i++){
        res += B[A[i]-1];
        if(A[i] == A[i-1]+1){
            res += C[A[i-1]-1];
        }
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 0; i < N - 1; i++) cin >> C[i];
    ll sum = 0;
    for(int i = 0; i < N; i++) sum += B[i];

    for(int i = 0; i < N-1; i++){
        if(A[i] + 1 == A[i + 1]){
            sum+=C[A[i]-1];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3592
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int gcd(int x, int y)
{
     if(y == 0) return x;
     if(x < y)      return gcd(y,x);
     else        return gcd(y, x%y);
}

int main()
{
    int N;
    scanf("%d",&N);
    int h,n,ansh,ansn,answ;
    long long fenmu,fenzi1,fenzi2,fenzi3;
    for(h=1;h<=3500;h++)
    {
        for(n=1;n<=3500;n++)
        {
            int rgcd=gcd(N,gcd(h,n));
            fenmu=N;
            fenmu*=h;
            fenmu/=rgcd;
            fenmu*=n;
            fenmu/=rgcd;
            fenzi1=4;fenzi1*=h;fenzi1*=n;fenzi1/=rgcd;fenzi1/=rgcd;
            fenzi2=1;fenzi2*=N;fenzi2*=n;fenzi2/=rgcd;fenzi2/=rgcd;
            fenzi3=1;fenzi3*=h;fenzi3*=N;fenzi3/=rgcd;fenzi3/=rgcd;
            long long fenzi4=fenzi1-fenzi2-fenzi3;
            if(fenzi4>0&&fenmu%fenzi4==0)
            {
                printf("%d %d %lld",h,n,fenmu/fenzi4);
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
	int N, W; cin >> N >> W;
	vector<int>w(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	long long x = w[0];
	for (int i = 0; i < N; i++) {
		w[i] -= x;
	}
	vector<vector<vector<long long>>>dp(N + 1, vector<vector<long long>>(200, vector<long long>(N + 1, 0)));
	for (int i = 0; i < N; i++) for (int j = 0; j < 200; j++) for (int k = 0; k < i + 1; k++) {
		dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
		if (j >= w[i]) {
			dp[i + 1][j][k + 1] = max(dp[i + 1][j][k + 1], dp[i][j - w[i]][k] + v[i]);
		}
	}
	long long ans = 0;
	for (int i = 0; i < 200; i++)for (int j = 0; j < N + 1; j++) {
		if (i + j * x <= W) {
			ans = max(ans, dp[N][i][j]);
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
	vector<int> vec(3); int n; cin >> n; int temp;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> temp; vec[j] = pow(temp, 2);
		}
		sort(vec.begin(), vec.end());
		if (vec[0] + vec[1] == vec[2]) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 2968
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int cnt = 1;
    int min = sc.nextInt();
    for (int i = 0; i < N - 1; i++) {
      int next = sc.nextInt();
      if (min > next) {
        cnt++;
      }
      min = Math.min(min, next);
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 64768
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
    string a;
    int b,c,d=0;
    cin>>a;
    for(int i=0;i<4;i++){
    b=a[i];
    for(int j=i+1;j<4;j++){
    c=a[j];
    if(b==c){
    d++;
    }
    }
    }
    if(d==2){
    cout<<"Yes"<<"\n";
    }
    else{
    cout<<"No"<<"\n";
    }
    return(0);
    }

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int [][] data;
	int h,w;
	int [] vx = {0,1,0,-1};
	int [] vy = {1,0,-1,0};
	boolean [][] used;
	class C{
		int step;
		String state;
		public C(int step, String state) {
			this.step = step;
			this.state = state;
		}
	}

	private void doit(){
		while(sc.hasNext()){
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h) == 0) break;
			data = new int[h][w];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					char c = sc.next().charAt(0);
					if(c == 'R'){
						data[i][j] = 0;
					}
					else if(c == 'G'){
						data[i][j] = 1;
					}
					else{
						data[i][j] = 2;
					}
				}
			}
			int res = solve();
			System.out.println(res);
		}
	}

	private int solve() {
		LinkedList<C> open = new LinkedList<Main.C>();
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				sb.append(data[i][j]);
			}
		}
		open.add(new C(0, sb.toString()));
		HashSet<String> close = new HashSet<String>();
		close.add(sb.toString());
		int ans = -1;
		while(! open.isEmpty()){
			C now = open.poll();
			if(isGoal(now.state)){
				ans = now.step;
				break;
			}
			used = new boolean[h][w];
			count(now.state,now.state.charAt(0), 0, 0);
			for(int i = 0; i < 3; i++){
				String nextstate = paint(i, now.state);
				if(! close.contains(nextstate)){
					open.add(new C(now.step + 1, nextstate));
					close.add(nextstate);
				}
			}
		}
		return ans;
	}

	private String paint(int color, String state) {
		StringBuilder sb = new StringBuilder(state);
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(used[i][j]){
					int pos = i * w + j;
					sb.setCharAt(pos, (char)(color + '0'));
				}
			}
		}
		return sb.toString();
	}

	private void count(String state, char color, int x, int y) {
		used[y][x] = true;
		for(int i = 0; i < 4; i++){
			int xx = x + vx[i];
			int yy = y + vy[i];
			if(!isOK(xx, yy)) continue;
			if(used[yy][xx]) continue;
			int pos = yy * w + xx;
			if(state.charAt(pos) == color){
				count(state, color, xx, yy);
			}
		}
	}

	private boolean isGoal(String state) {
		char c = state.charAt(0);
		for(int i = 1; i < state.length(); i++){
			if(state.charAt(i) != c){
				return false;
			}
		}
		return true;
	}

	private boolean isOK(int xx, int yy) {
		if(0<= xx && xx < w && 0<= yy && yy < h) return true;
		return false;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 44128
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;
typedef vector<char> vech;

int main(){
    ll N,T,A;cin>>N>>T>>A;
    vector<pair<double,ll>> data(N);
    rep0(i,N){
        ll h;cin>>h;
        double t=(double)(T-h*0.006);
        t=(double)(abs(A-t));
        data[i]=make_pair(t,i+1);
    }
    sort(all(data));
    cout<<data[0].second<<endl;
}
      

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

int main() {
    long long a;
    long long b = 0;
    string s;
    cin >> a;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '.') continue;
        b = b*10 + s[i] - '0';
    }
    cout << a * b / 100;
  //  system("pause");
}

Measured memory_bytes: 3164
s=gets.chomp
mods=[0]*2019
digit=1
sum=0

s.reverse.chars do |ch|
  sum=(sum+digit*ch.to_i)%2019
  mods[sum]+=1
  digit=(digit*10)%2019
end

puts  mods.sum{|m| m*(m-1)/2}+mods[0]


Measured memory_bytes: 14764
#include <stdio.h>
int main(void){
    // Your code here!
    char str[201] = {};
    char tmp[402];
    int i,j,m,p;
    int num = 0;
    int pos;

    while(1){
        scanf( "%s" , str );
        if( str[0] == '-' ){ break; }
        scanf( "%d " , &m );
        
        for( i = 0 , num = 0 ; str[i] != '\0' ; i++ ){
            num++;
        }
        
        for( i = 0 ; i < m ; i++ ){//シャッフル回数
            scanf( "%d " , &p );//ずらす文字位置
        
            for( j = 0 ; j < num ; j++ ){
                tmp[j] = str[j];
                tmp[ j + num ] = str[j];
            }
        
            for( j = 0 ; j < num ; j++ ){
                str[j] = tmp[ j + p ];
                
               //printf("%c = %c\n" , str[j] , tmp[ j + p ]);
                
            }
            //printf( "%s\n" , str );
            
            
        }
        
        printf( "%s\n" , str );//xyzvw
        
    }    

}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read(), ans = 0;
  REP(i, n) {
    int l, r;
    std::cin >> l >> r;
    ans += r - l + 1;
  }
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#ifndef ONLINE_JUDGE
#define debarr(a,n)cerr<<#a<<":";for(int i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const set<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>ostream &operator<<(ostream &os,const map<S,T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){int idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
const int N = 5001;
ll dp[N][N];
int n;
string s;
ll func(ll used,ll match)
{
    if(used==n)
    {
        return match==s.length();
    }
    ll &ret = dp[used][match];
    if(ret!=-1)
        return ret;
    ret = 0;
    if(match)
        ret = func(used+1,match+1)+func(used+1,match-1)*2;
    else
        ret = func(used+1,match+1)+func(used+1,match);
    ret%=mod;
    return ret;
}
signed main()
{
    fast;
    cin>>n>>s;
    mem(dp,-1);
    cout<<func(0,0);
    
}


Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	bool flag=true;
	for(char i='a';i<='z';i++)
	{
		if(s+i==t)
		{
			cout<<"Yes"<<endl;
			flag=false;
			break;
		}
	}
	if(flag) cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
package main

import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  w, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  h, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  x, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  y, _ := strconv.Atoi(sc.Text())

  a := 0
  if x * 2 == w && y * 2 == h {
    a = 1
  }

  s := float64(w * h) / 2
  fmt.Println(s, a)

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector <int> a[100010];
int vis[100010];
int dfs(int x){
    if(vis[x]!=-1)
        return vis[x];
    vis[x]=0;
    for(int i=0; i<a[x].size(); ++i){
        vis[x]=max(vis[x], 1+dfs(a[x][i]));
    }
    return vis[x];
}
int main(){
    int n, m;
    while(cin>>n>>m){
        int ans=0;
        int x, y;
        for(int i=0; i<m; ++i){
            scanf("%d%d",&x,&y);
            a[x].push_back(y);
        }
        int tmp;
        memset(vis, -1, sizeof vis);
        for(int i=1; i<=n; ++i){
            tmp=dfs(i);
            ans=max(ans, tmp);
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 8192
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int i,n,a[100005],temp=1;
	long long sum;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	 scanf("%d",&a[i]);
	sort(a,a+n);
	sum=(long long)a[0];
	for(i=1;i<n;i++)
	{
		if(sum*2<(long long)a[i])
		{
		   temp=1;
		   sum+=(long long)a[i];
		}
		else
		{
			temp++;
			sum+=(long long)a[i];
		}	
	}
   printf("%d\n",temp);
}

Measured memory_bytes: 512