akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

ll N;
ll a[201010];
ll csum[201010];

int main() {
  cin >> N;
  repe(i, 1, N) {
    cin >> a[i];
    csum[i] = csum[i - 1] + a[i];
  }

  ll ans = INF;

  for (int i = 1; i < N; ++i) {
    ll x = csum[i];
    ll y = csum[N] - x;
    chmin(ans, abs(x - y));
  }

  cout << ans;
}


Measured memory_bytes: 6752
#include <cstdint>
#include <iostream>

int main(void)
{
    uint32_t a, b, c, d;

    std::cin >> a >> b >> c >> d;

    uint32_t train = a < b ? a : b;
    uint32_t bus = c < d ? c : d;

    std::cout << train + bus << std::endl;

    return 0;
}


Measured memory_bytes: 256
import sys

# H行、W列
h, w = map(int, input().split())

# マス
goal = ["#" * (w + 2)]

for ii in range(h):
    st = input()
    goal.append("#" + st + "#")
    
goal.append("#####")

ng = 0
for i in range(1, h):
    for j in range(1, w):
        if goal[i][j] == "#":
            if goal[i-1][j] == "." and \
               goal[i+1][j] == "." and \
               goal[i][j-1] == "." and \
               goal[i][j+1] == ".":
                    print("No")
                    ng = 1
                    break
    if ng == 1:
        break
else:
    print("Yes")

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if(a.substring(0,a.length()-1).equals(b) || b.substring(0,b.length()-1).equals(a)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35696
<?php
while(true)
   {
       $stdin = trim(fgets(STDIN));
       if ($stdin === '0 0')
       {
         $height = 0;
         $width = 0;
         for ($i=0; $i < count($stdins); $i++) {
             $hw = explode(" ",$stdins[$i]);
             $height = $hw[0];
             $width = $hw[1];
             for ($j=0; $j < $height ; $j++) {
               for ($k=0; $k < $width; $k++) {
                 echo "#";
               }
               echo "\n";
             }
            echo "\n";
         }
           return;
       }
       $stdins[] = $stdin;
   }
//
// function printRectangle($dateSet){
//   echo count($dataSet)."\n";
//   var_dump($dataSet);
//
// }
?>

Measured memory_bytes: 15308
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = input()
bl = [0] * (n+1)
wr = [0] * (n+1)
for i in range(n):
    bl[i] = bl[i-1] + (1 if s[i]=='#' else 0)
for i in range(n-1,-1,-1):
    wr[i] = wr[i+1] + (1 if s[i]=='.' else 0)
mn = wr[0]
for i in range(n):
    x = bl[i] + wr[i+1]
    if x < mn:
        mn = x
print(mn)


Measured memory_bytes: 45568
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long N;
    cin >> N;

    vector<vector<long long>> AT;
    for(long long i = 0; i < N; i++){
      long long a, t;
      cin >> a >> t;
      AT.push_back(vector<long long>{a, t});
    }

    vector<long long> c{AT[0][0], AT[0][1]};
    for(long long i = 1; i < N; i++){
      if((long double)c[0] / AT[i][0] > 1.0 || (long double)c[1] / AT[i][1] > 1.0){
        long long t = (long long)ceil(max((long double)c[0] / AT[i][0], (long double)c[1] / AT[i][1]));
        c[0] = AT[i][0] * t;
        c[1] = AT[i][1] * t;
      }
      else{
        c[0] = AT[i][0];
        c[1] = AT[i][1];
      }
    }

    cout << c[0] + c[1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

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

    vector<ll> a(n);

    for (ll i=0; i<n; i++)
           cin >> a[i]; 

    double denm(0);

    for (ll i=0; i<n; i++)
        denm += (1.0 / a[i]);

    cout << 1.0 / denm << endl;


    return 0;
}


Measured memory_bytes: 256
import sys


def main():
    args = sys.stdin.readline().split()
    H = int(args[0])
    W = int(args[1])
    args = sys.stdin.readline().split()
    N = int(args[0])
    A = list(map(int, input().split()))

    color_matrix = [[0 for i in range(W)] for j in range(H)]

    switch = True
    num_of_cells = 0
    color_num = 1
    index = 0
    for row in range(H):
        for col in range(W):
            if switch:
                color_matrix[row][col] = color_num
            else:
                color_matrix[row][(W - 1) - col] = color_num
            num_of_cells += 1
            if num_of_cells == A[index]:
                num_of_cells = 0
                color_num += 1
                index += 1

        switch = not switch

    # answer
    for array in color_matrix:
        print(' '.join(map(str, array)))

main()


Measured memory_bytes: 3572
field = [['#']*100 for _ in range(50)] + [['.']*100 for _ in range(50)]

a, b = map(int, input().split())
a-=1
b-=1
x = 0
y = 0
for _ in range(a):
    field[x][y] = '.'
    y += 2
    if y >= 100:
        y = 0
        x += 2

x = 99
y = 0
for _ in range(b):
    field[x][y] = '#'
    y += 2
    if y >= 100:
        y = 0
        x -= 2

print(100,100)
        
for row in field:
    print("".join(row))

        


Measured memory_bytes: 9232
#16D8101014F Kurume Ryunosuke 久留米竜之介 2018/5/16 Python3
n = int(input())
box = set()

for _ in range(n):
    tmp,mozi= input().split()
    
    if tmp == "find":
        if mozi in box:
            print("yes")
        else:
            print("no")
    else:
        box.add(mozi)


Measured memory_bytes: 30988
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> l;
int main() {
  cin >> n;
  read_n(l, n);

  sort(begin(l), end(l));

  i64 ans = 0;
  for (i64 i = 0; i < n - 2; ++i) {
    for (i64 j = i + 1; j < n - 1; ++j) {
      i64 x = l[i], y = l[j];
      ans += n
        - (j + 1)
        - (end(l) - lower_bound(begin(l) + j + 1, end(l), x + y));
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define fastio ios::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define fi first
#define se second
#define maxn 100001
#define mp make_pair

const int mod = 1e9+7 ;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

vii AdjList[maxn];
bool visited[maxn];
map<pii, int> ma;
bool check;

void dfs(int start, int root)
{
	visited[start] = true;
	if (check)	return;
	for (int i = 0; i < AdjList[start].size(); i++)
	{
		pii u = AdjList[start][i];
		if (!visited[u.fi])
		{
			ma[mp(root, u.fi)] = ma[mp(root, start)] + u.se;
			dfs(u.fi, root);
		}
		else
		{
			if (ma[mp(root, u.fi)] != ma[mp(root, start)] + u.se)
			{
				check = true;
				return;
			}
		}
	}
}

signed main()
{
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	fastio;
	int n, m;	cin >> n >> m;
	while (m--)
	{
		int a, b, d;	cin >> a >> b >> d;
		AdjList[a].pb({b, d});
		AdjList[b].pb({a, -d});
	}
	for (int i = 1; i <= n; i++)
	{
		if (!visited[i])
		{
			ma[{i, i}] = 0;
			dfs(i, i);
		}
	}
	if (check)	cout << "No";
	else cout << "Yes";
}




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

using namespace std;

#define S second
#define F first

typedef long long ll;

const int maxn = 100;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct matrix
{
    int n;
    ll ar[maxn][maxn];

    matrix(int x)
    {
        memset(ar, 0, sizeof ar);
        n = x;
    }

    matrix operator * (const matrix T)
    {
        matrix R(n);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                for(int x = 0; x < n; x++)
                    (R.ar[i][j] += (ar[i][x] * T.ar[x][j]) % mod) %= mod;
        return R;
    }

    matrix operator ^ (ll power)
    {
        matrix T = *this;
        matrix R = *this;
        power--;
        while(power)
        {
            if(power & 1)
                R = (R * T);
            T = (T * T);
            power >>= 1;
        }
        return R;
    }
};

int n;
ll k;

int main()
{
//    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>> n >> k;
    matrix mat(n);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin>> mat.ar[i][j];
    mat = mat^(k);
    ll ans = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            (ans += mat.ar[i][j]) %= mod;
    cout<< ans;
}





Measured memory_bytes: 768
import sys
from copy import deepcopy
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row_list(N): return [i_list() for _ in range(N)]
sys.setrecursionlimit(10 ** 6)
INF = float('inf')

def main():
    d = i_input()
    c_list = i_list()
    s_list = i_row_list(d)

    output_list = []

    last_list = [0] * 26

    for day in range(1,d+1):
        result = 0
        max_point = -INF
        for i in range(26):
            plus_point = s_list[day-1][i]
            minus_point = 0
            for j in range(26):
                if i == j:
                    continue
                minus_point += c_list[j] * (day - last_list[j])
            sum_point = plus_point - minus_point

            if day != d:
                last_list2 = deepcopy(last_list)
                last_list2[i] = day
                result2 = 0
                max_point2 = -INF
                for k in range(26):
                    plus_point2 = s_list[day][k]
                    minus_point2 = 0
                    for h in range(26):
                        if k == h:
                            continue
                        minus_point2 = c_list[h] * (day+1 - last_list2[h])
                    sum_point2 = plus_point2 - minus_point2
                    if sum_point2 > max_point2:
                        result2 = k + 1
                        max_point2 = sum_point2
                    last_list2[result2-1] = day + 1
            else:
                max_point2 = 0

            if sum_point + max_point2 > max_point:
                result = i + 1
                max_point = sum_point + max_point2
        output_list.append(result)
        last_list[result-1] = day

    for out in output_list:
        print(out)

if __name__ == '__main__':
    main()


Measured memory_bytes: 70580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define rep(n) for(ll j=1;j<=n;j++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define loopne(i,a,b) for(ll i=a;i<b;i++)
vector < ll > graph[100005];
ll visited[100005] = {0};
ll a[100005]={0};
ll maxi[100005]={0};
ll paths[100005]={0};
vector<ll> rev[100005];
ll maxp(ll node)
{
     ll ans=0;
  if(visited[node]==1)
  {
  ans=maxi[node];
  }
    else
    {
    if(rev[node].empty())
    ans=0;
    for(auto x:rev[node])
    {
        ans=max(ans,maxp(x)+1);
    }
    visited[node]=1;
    maxi[node]=ans;
    }
    return ans;
}
int main()
{
    ll n,m;

    
    cin>>n>>m;
    rep(m)
    {
        ll x;ll y;
        cin>>x;
        cin>>y;
        graph[x].pb(y);
        rev[y].pb(x);
        a[y]++;
    }
    ll ans=0;
     rep(n)
     {
         ll alpha=maxp(j);
     }
       rep(n)
     {
         ll alpha=maxp(j);
         ans=max(ans,maxi[j]);
     }
     cout<<ans<<endl;
     return 0;
}

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

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    rr = []

    while True:
        n,m = LI()
        b = LI()
        p = LI()
        r = inf
        t = []
        for i in range(m):
            t += [i % 2] * p[i]
        if sorted(collections.Counter(t).items()) == sorted(collections.Counter(b).items()):
            tr = 0
            pi = 0
            for i in range(n):
                if t[i] != 1:
                    continue
                while b[pi] != 1:
                    pi += 1
                tr += abs(i-pi)
                pi += 1
            r = tr

        t = []
        for i in range(m):
            t += [(i+1) % 2] * p[i]
        if sorted(collections.Counter(t).items()) == sorted(collections.Counter(b).items()):
            tr = 0
            pi = 0
            for i in range(n):
                if t[i] != 1:
                    continue
                while b[pi] != 1:
                    pi += 1
                tr += abs(i-pi)
                pi += 1
            if r > tr:
                r = tr
        rr.append(r)
        break

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9040
m, d = map(int, input().split())

ans = 0


for i in range(1,m+1):
    for j in range(1, d+1):
        if len(str(j)) == 1:
            continue
        d1 = j%10
        d2 = j//10
        if d1 >= 2 and d2 >= 2 and d1*d2==i:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long a, b;
int main () {
	cin >> a >> b;
	
	if(a < 0 && 0 < b) {
		cout << "Zero";
	}
	else if(0 < a && 0 < b) {
		cout << "Positive";
	}
	else if(a < 0 && b < 0 &&(b - a) % 2 == 0) {
		cout << "Negative";
	}
	else if(a < 0 && b < 0 &&(b - a) % 2 != 0) {
		cout << "Positive";
	}
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> posi, nega;
    posi.push_back(0);
    nega.push_back(0);
    rep(i, n)
    {
        int x;
        cin >> x;
        if (x > 0)
            posi.push_back(x);
        else
            nega.push_back(abs(x));
    }    
    sort(nega.begin(), nega.end());

    ll ans = -1;
    rep(num_p, k + 1)
    {
        int cost_p, cost_n;
        int num_n = k - num_p;

        if (num_n > nega.size() - 1 or num_p > posi.size() - 1) continue;
        cost_p = posi[num_p];
        cost_n = nega[num_n];

        int cost = cost_p + cost_n + min(cost_p, cost_n);
        if (ans == -1 or cost < ans)
            ans = cost;

        // cout << cost_p << ' ' << cost_n << ' ' << num_p << ' ' << num_n << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n; long long int d; cin >> n >> d;
  d = d*d;
  int ans = 0;
  for(int i = 0; i < n; ++i)
  {
    long long int x;
    long long int y;
    cin >> x >> y;
    long long int total = x*x + y*y;
    if(total <= d) ++ans;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3632
A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = 10 ** 10
for x, y, c in xyc:
  t = a[x - 1] + b[y - 1] - c
  ans = min(ans, t)

a.sort()
b.sort()
ans = min(ans, a[0] + b[0])

print(ans)



Measured memory_bytes: 38956
N=int(input())
ng = 0
S = set()
pre_we = ""
for i in range(N):
    W=input()
    if W in S:
        ng = 1
    S.add(W)
    if (i != 0) and (pre_we != W[0]):
        ng = 1
    pre_we = W[-1]
if ng == 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MAX 1e9
#define ll long long int
int main(){
  ll h,n;
  cin>>h>>n;
  ll a[n],b[n];
  
  for(ll i=0;i<n;i++) cin>>a[i]>>b[i];
  ll dp[h+1];
  for(ll i=0;i<=h;i++) dp[i]=MAX;
  dp[0]=0;
  for(ll i=0;i<=h;i++){
    for(ll j=0;j<n;j++)
      dp[i]=min(dp[max((ll)0,i-a[j])]+b[j],dp[i]);
  
  }
  cout<<dp[h];
}

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


int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    int cnt = 0;
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        b[i]=abs(a[i]);
        sum += b[i];
        if(a[i]<0) cnt++;
    }
    sort(b.begin(),b.end());
    if(cnt%2){
        cout<<sum-b[0]*2<<endl;
    }else{
        cout<<sum<<endl;
    }
    
    return 0;
}


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

using namespace std;

#define endl '\n'

const int maxn = 1e5 + 5;
const int oo = 0x3f3f3f3f;

int n;
int dp[2][maxn];
int w[maxn], v[maxn], W;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> W;
	
	int mx = 0;
	
	for(int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
		mx += v[i];
	}
		
	for(int i = 0; i < 2; i++)
		for(int j = 0; j < maxn; j++)
			dp[i][j] = oo;

	int ans = 0;
	
	dp[1][0] = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= mx; j++){
			dp[i % 2][j] = (dp[(i + 1) % 2][j]);
			if(j - v[i] >= 0)
				dp[i % 2][j] = min(dp[i % 2][j], dp[(i + 1) % 2][j - v[i]] + w[i]);
		}
	}
	
	for(int i = 0; i <= mx; i++)
		if(dp[(n + 1) % 2][i] <= W)
			ans = i;
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <algorithm>

using std::cout;
using std::cin;
using std::endl;


void funcA() {
	int X, Y;
	cin >> X;
	cin >> Y;
	cout << X + (int)(Y / 2) << endl;

}

int main() {
	funcA();

}





Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		List<Set<Integer>> bs = new ArrayList<Set<Integer>>();
		int size = 0;
		for (int bt = 0; bt < n; bt += size) {
			Set<Integer> set = new HashSet<Integer>();
			size = in.nextInt();
			for (int i = 0; i < size; i++) {
				set.add(in.nextInt());
			}
			bs.add(set);
		}
		Set<Integer> a = new HashSet<Integer>();
		Set<Integer> pear = new HashSet<Integer>();
		int r = in.nextInt();
		for (int p = 0; p < r; p++) {
			pear.clear();
			pear.add(in.nextInt());
			pear.add(in.nextInt());
			for (Set<Integer> check : bs) {
				if (check.containsAll(pear)) {
					a.addAll(pear);
				}
			}
		}
		System.out.println(a.size());
	}
}

Measured memory_bytes: 12000
#include<stdio.h>

static const int N=100;

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


int main(){
  int n,p[N+1],m[N+1][N+1],i=0,j,k=0,l=0;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }
  

  for(i=1;i<=n;i++)m[i][i]=0;
  for(k=2;k<=n;k++){
    for(i=1;i<=n-k+1;i++){
j=i+k-1;
m[i][j]=(1 << 21);
for(l=i;l<=j-1;l++){
  m[i][j]=min(m[i][j],m[i][l]+m[l+1][j]+p[i-1]*p[l]*p[j]);
}
}
}
     


  printf("%d\n",m[1][n]);

  return 0;
}



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 073_arc_b / Link: https://arc073.contest.atcoder.jp/tasks/arc073_b?lang=en  ----- */
/* ------問題------

あなたは N 個の物と、強度 W のバッグを持っています。 i 個目の物は、重さが wi で価値が vi です。
あなたは、物のうちいくつかを選び、バッグに入れます。 ただし、選んだ物の重さの和は W 以下でなくてはいけません。
あなたは、バッグに入れた物の価値の総和を最大化したいです。

-----問題ここまで----- */
/* -----解説等-----

昔はDPを気合で解いていたけど、これはw[0] からの値が4種類しかないのでどれを何個使うかで全探索できる。
dpのときはdp(i,j,k):=i個目まで見てj個選択し,余計な重さがkのときの最大値として、
O(N^3)で解ける。

----解説ここまで---- */

LL N, W;

LL ans = 0LL;

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

	cin >> N >> W;
	VL w(N), v(N);

	VVL s(4,VL());
	LL baseW;
	FOR(i, 0, N) {
		cin >> w[i] >> v[i];
		if (i == 0)baseW = w[i];
		int id = w[i] - baseW;
		s[id].push_back(v[i]);
	}
	FOR(i, 0, 4)RSORT(s[i]);


	FOR(i, 0, SZ(s[0])+1) {
		FOR(j, 0, SZ(s[1])+1) {
			FOR(k, 0, SZ(s[2])+1) {
				FOR(l, 0, SZ(s[3])+1) {

					LL Vs = 0;
					LL Ws = 0;
					FOR(a, 0, i) {
						Ws += baseW;
						Vs += s[0][a];
					}FOR(a, 0, j) {
						Ws += baseW+1;
						Vs += s[1][a];
					}FOR(a, 0, k) {
						Ws += baseW+2;
						Vs += s[2][a];
					}FOR(a, 0, l) {
						Ws += baseW+3;
						Vs += s[3][a];
					}
					if (W >= Ws) {
						ans = max(ans, Vs);
					}

				}
			}
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))

int a[100010];
int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	for(int i=0;i<n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		a[l]++;
		a[r]--;
	}
	for(int i=0;i<t;i++)a[i+1]+=a[i];
	int ans=0;
	for(int i=0;i<t;i++)ans=max(ans,a[i]);
	printf("%d\n",ans);
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}



Measured memory_bytes: 25156
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        boolean f = true;
        for (int i = 0 ; i < n ; i++) {
            if (a[i] % 2 == 0) {
                if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                    f = false;
                }
            }
        }

        System.out.println(f ? "APPROVED" : "DENIED");
    }

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
static const ll mod = 1000000007;
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

ll C[2001][2001];
void pascal_shower(){
    for(int i=0; i<=2000; i++){
        C[i][0] = 1;
        C[i][i] = 1;
    }
    for(int i=2; i<=2000; i++){
        for(int j=1; j<=i-1; j++){
            C[i][j] = (C[i-1][j-1] + C[i-1][j])%mod;
        }
    }
}

int main(void){
    int n,k;
    cin >> n >> k;
    pascal_shower();
    for(int i=1; i<=k; i++){
        ll tmp_1 = C[n-k+1][i]%mod;
        ll tmp_2 = C[k-1][i-1]%mod;
        ll ans = (tmp_1)*(tmp_2)%mod;
        cout << ans << "\n";
    }
    return 0;
}
// 並べる方法色々あるね(順列、数え上げの考え方に慣れたい)

Measured memory_bytes: 30208
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    string s,t;
    cin>>s>>t;
    int cnts[26]={};
    int cntt[26]={};
    for(int i=0;i<s.size();i++)cnts[s[i]-'a']++;
    for(int i=0;i<t.size();i++)cntt[t[i]-'a']++;
    sort(cnts,cnts+26);
    sort(cntt,cntt+26);
    int ans=true;
    for(int i=0;i<26;i++){
        if(cnts[i]!=cntt[i])ans=false;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;

int main(){
    ll N, K;
    cin >> N >> K;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];
    int X[N] = {}, Y[N] = {};
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(A[i] > A[j]) X[i] += 1;
            else if (A[i] < A[j]) Y[j] += 1;
        }
    }
    ll mod = 1e9+7, ans = 0;
    for(int i=0;i<N;i++){
        ans += (K*(K+1)/2%mod)*X[i]%mod + (K*(K-1)/2%mod)*Y[i]%mod;
        ans %= mod;
    }
    cout << ans << endl;
}

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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

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

	if (a == b && b == c)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N, A, B, ans=0;
  cin >> N>> A>> B;
  if((A%2==0 && B%2==1)||(A%2==1 && B%2==0)){
    long long a,b;
    ans=min(A-1, N-B);
    ans++;
    ans+=(B-A-1)/2;
  }
  else{
    ans=(B-A)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
int copy(int x){return x;}
int main(){
	int h,w,k;cin>>h>>w>>k;
	vector<vector<int>> s(h,vector<int>(w));
	vector<vector<int>> sum(h + 1,vector<int>(w + 1,0));
	for(int i = 0; i < h; i++) {
		string st;cin>>st;
		for(int j = 0; j < w; j++) {
			s[i][j] = st[j] - '0';
			sum[i + 1][j + 1] = sum[i + 1][j] + s[i][j];
		}
	}

	for(int i = 0; i < h; i++) {
		for(int j = 0; j <= w; j++) {
			sum[i + 1][j] += sum[i][j];
		}
	}
	int res = INF;
	for(int bit = 0; bit < (1 << (h - 1)); bit++) {
		vector<int> war;
		vector<bool> used(w + 1,false);
		int ans = 0;
		for(int j = 0; j < h - 1; j++) {
			if ((bit >> j) & 1){
				war.pb(j);
				ans++;
				// cout << "ans" << ans << endl;
			}	
		}
		war.pb(h - 1);
		// for(int i = 0; i < war.size(); i++) {
		// 	cout << war[i];
		// }
		// cout << endl;
		vector<vector<int>> x(war.size(),vector<int>(w + 1));
		int index = 0;
		for(int i = 0; i < war.size(); i++) {
			for(int j = 0; j <= w; j++) {
				x[i][j] = sum[war[i] + 1][j] - sum[index][j];
			}
			index = war[i] + 1;
		}
		int l = 0;
		for(int r = 1; r <= w; r++) {
			bool flag = false;
			if (!flag){
				for(int j = 0; j < war.size(); j++) {
				if (x[j][r] - x[j][l] > k){
					if (r == l + 1){
						flag = true;
						break;
					}
					// cout << "j " << j << " r " << r << endl; 
					l = copy(r - 1);
					ans++;
					break;
				}
			}
			}
			if(flag){
				ans = INF;
			}
			
		}

		// for(int i = 0; i < war.size(); i++) {
		// 	for(int j = 0; j <= w; j++) {
		// 		cout << x[i][j] << " ";
		// 	}
		// 	cout << endl;
		// }
		// cout << ans << endl;
		res = min(res,ans);
	}
	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 200010
/*------------------------------------------------------------*/
int n,m;
ll a[maxn];
int main(){
	in(n);
	a[0]=2,a[1]=1;
	FOR(i,2,n)a[i]=a[i-1]+a[i-2];
	outl(a[n]);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a<c){
if(c<b)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
else{
if(c>b)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}



Measured memory_bytes: 256
import copy

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if int(A[j][2:]) <= int(x[2:]):
            i = i + 1
            y = A[i]
            A[i] = A[j]
            A[j] = y
    z = A[i+1]
    A[i+1] = A[r]
    A[r] = z
    return i + 1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)

n = int(input())
A = []
for i in range(n):
    A.append(str(input()))

B = copy.deepcopy(A)
B.sort(key = lambda x: int(x[2:]))

quickSort(A, 0, n-1)

if A == B:
    print('Stable')
else:
    print('Not stable')

for i in range(n):
    print(A[i])


Measured memory_bytes: 17920
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	var a string
  	buf := make([]byte, 1000000)
  	sc.Buffer(buf, 1000000000)
  
	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}
	if sc.Scan() {
		a = sc.Text()
	}
	count_subordinate := make([]int, n)
	for _, i := range strings.Fields(a) {
		index, _  := strconv.Atoi(i)
		count_subordinate[index - 1]++
	}
	for _,j := range count_subordinate {  // 1 1 1 1 1 1 0
		fmt.Println(j)
	}
}

Measured memory_bytes: 10468
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	a = Array{Int}(n)
	mo = 0
	mt = 0
	for i in 1:n
		a[i] = readline() |> parseInt
		if a[i] > mo
			mt = mo
			mo = a[i]
		elseif a[i]>mt
			mt = a[i]
		end
	end
	for i in 1:n
		println(a[i]==mo?mt:mo)
	end
end

main()

Measured memory_bytes: 164400
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn lower_bound<T: Ord>(xs: &[T], y: &T) -> usize {
    let mut l = 0;
    let mut r = xs.len() + 1;

    while r - l > 1 {
        let m = l + (r - l) / 2;
        if &xs[m - 1] < y {
            l = m;
        } else {
            r = m;
        }
    }

    l
}

fn main() {
    let N = read!(usize);
    let mut L = read![[i64]];

    L.sort();
    debug!(L);

    let mut count = 0;

    for a in (0..N).rev() {
        for b in (a + 1..N).rev() {
            let u = lower_bound(&L, &(L[a] + L[b]));
            debug!((a, b, u, L[a], L[b]));
            count += u - min(u, b + 1);
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        out.println(in.next().replaceAll("0", "").length());
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 22996
/*
Author : N_o_o_B
Created : April 22 2020 22:44:32 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vi t(n);
    ll sum = 0;
    fori(i,n) cin >> t[i],sum += t[i];
    int m;
    cin >> m;
    while(m--){
        int p,x;
        cin >> p >> x;
        --p;
        cout << sum + x - t[p] << endl;
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 256
data = input().split(" ")

N = int(data[0])
Y = int(data[1])

# not found
errmsg = "-1 -1 -1"
# break flg
is_ok = False

#各お札の取りうる最大値
max_x = int(Y/10000)
max_y = int(Y/5000)
max_z = int(Y/1000)

if max_x > N:
    max_x = N
if max_y > N:
    max_y = N
if max_z > N:
    max_z = N

for z in range(0,max_z+1):
    for y in range(0,max_y+1):
        if z + y > N:
            continue
        x = N - y - z
        if x * 10000 + y * 5000 + z * 1000 == Y:
            print(str(x) + " " + str(y) + " " + str(z))
            is_ok = True
            break
    if is_ok:
        break

if not is_ok:
    print(errmsg)
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if((i+1)%2){
            if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D') ;
            else {cout << "No" << "\n"; return 0;}
        }
        else{
            if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D') ;
            else {cout << "No" << "\n"; return 0;}
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define max(a,b) (a > b ? a : b)

int main(void){
    int x = 0;
    int n;
    char s[100];
    int i;
    int max = 0;
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<100;i++){
        if(s[i] == 'I'){
            x++;
            max = max(x,max);
        }
        else if(s[i] == 'D'){
            x--;
            max = max(x,max);
        }
    }
    printf("%d\n",max);
}

Measured memory_bytes: 128
def gi; gets.to_i end
def gs; gets.chomp end
def gli; gets.split(' ').map(&:to_i) end
def d(n); Math.log10(n).to_i + 1 end
class Integer
  # 約数の組み合わせを列挙する
  def divisor_combinations
    (1..Math.sqrt(self).to_i).
      select { |i| self % i == 0 }.
      map { |i| [i, self / i] }
  end
end

N = gi

all = (1..N).to_a
odds = all.select(&:odd?)
puts odds.length.to_f / all.length


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

template <class T> int streamvar(std::istream& in, T& var)
{
    if (!in) {
        return 1;
    }
    in >> var;
    if (in.fail()) {
        return 1;
    }
    return 0;
}
template <class T> int streamvec(std::istream& in, std::vector<T> &v)
{
    v.clear();
    string s;

    if (!in) {
        return 1;
    }
    getline(in, s);
    if (in.fail()) {
        return 1;
    }
    istringstream is(s);
    while (1) {
        T tmp;
        is >> tmp;
        if (is.fail())
            break;
        v.push_back(tmp);
    }
    return 0;
}

int main(void)
{
    for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
        cout << i << "x" << j << "=" << i*j << endl;
    }
    }
    return 0;
}

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

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

int main(void){

	ll X, Y; cin >> X >> Y;

	int nr=0;
	while(X<=Y){
		nr++;
		X*=2;
	}
	cout << nr << endl;

	return 0;
}


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

using namespace std;

main(){
    int n,l,b=-1e16;
    scanf("%d",&n);
    int sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&l);
        sum += l;
        b=max(b,l);
    }
    if(b >= sum-b) printf("No\n");
    else printf("Yes\n");
}

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

int main()
{
    int s;
    cin>>s;
    int x=s%3600;
    int y=x%60;
    int z=(x-y)/60;
    int a=(s-z)/3600;
    
    cout<<a<<":"<<z<<":"<<y<<endl;
    
    
    return 0;
}

Measured memory_bytes: 1168
using System;
class A
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int x = int.Parse(str[0]);
        int a = int.Parse(str[1]);
        if (x<a){
            System.Console.WriteLine(0);
        }
        else {
            System.Console.WriteLine(10);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long int
#define double long double
#define pb push_back
#define endl '\n'
#define er erase
#define sz size
#define in insert
using namespace std;

ll n, W, w[105], v[105], dp[105][100005], ans;

int main(){
    cin>>n>>W;
    for(ll i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for(ll i=0;i<=n;i++) dp[i][0]=0;
    for(ll i=1;i<=n;i++)
        for(ll j=0;j<=W;j++)
        {
            if(j>=w[i]) dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            else dp[i][j]=dp[i-1][j];
        }
    for(ll i=0;i<=W;i++)
        ans=max(dp[n][i], ans);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 81664
#include <iostream>

using namespace std;

int X, Y;
int field[17][17];
int dp[18][17];

void solve() {
	fill(dp[0], dp[17], 0);
	for (int x = 1; x <= X; x++)
		if (field[1][x] == 0) dp[1][x] = 1;
	for(int y = 1; y < Y; y++)
		for (int x = 1; x <= X; x++) {
			switch (field[y][x]) {
			case 0:
				if(field[y+1][x-1] == 0) dp[y + 1][x - 1] += dp[y][x];
				dp[y + 1][x] += dp[y][x];
				if(field[y+1][x+1] == 0) dp[y + 1][x + 1] += dp[y][x];
				break;
			case 2:
				dp[y + 2][x] += dp[y][x];
			default:
				break;
			}
		}
	int sum = 0;
	for(int y = Y; y <= Y+1; y++)
		for (int x = 1; x <= X; x++) 
			if (field[y][x] != 1) sum += dp[y][x];
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> X >> Y, X, Y) {
		fill(field[0], field[17], 0);
		for (int y = 1; y <= Y; y++)
			for (int x = 1; x <= X; x++)
				cin >> field[y][x];
		solve();
	}
}

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

using namespace std;

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

    vector<int> a(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }

    vector<int> ans;
    vector<int> b(N + 1, 0);
    for(int i = N; i >= 1; i--){
        int sum = 0;
        for(int j = i; j <= N; j += i){
            sum += b[j];
        }
        if(sum % 2 != a[i]){
            b[i]++;
            ans.push_back(i);
        }
    }

    if(!ans.empty()){
        cout << ans.size() << endl;
        reverse(ans.begin(), ans.end());
        for(int i = 0; i < ans.size()-1; i++){
            cout << ans[i] << " ";
        }
        cout << ans[ans.size()-1] << endl;
    }else{
        cout << ans.size() << endl;
    }


    return 0;
 }

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>

int main()
{
	int n;
	while( std::cin >> n, n != -1 )
	{
		double x = 1.0, y = 0.0;
		
		for( int i = 0; i != n - 1; ++i )
		{
			double t = sqrt( x * x + y * y );
			double vx = -y / t, vy = x / t;
			x += vx;
			y += vy;
		}

		std::cout << std::fixed << std::setprecision( 2 );
		std::cout << x << std::endl;
		std::cout << y << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include<cstdio>
using namespace std;
int d2b(int n,int b,char c[])
{
    int i=0,k;                                                                                                                                                   
    while(n!=0)
    {
        k=n%b;
        n/=b;
        if(k<0){k-=b;n+=1;}//这里是负进制的重点
        if(k>9)c[i]=char(k-10+'A');
        else c[i]=char(k+'0');
        i++;
    }
    return i-1;
}
char b[int(1e7)];
int main()
{
    int a,n,i;
    scanf("%d",&a);
    n = -2;
//    printf("%d=",a);
    if(a==0)printf("0");
    for(i=d2b(a,n,b);i>=0;i--)printf("%c",b[i]);
//    printf("(base%d)",n);
}

Measured memory_bytes: 128