akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

using ll = long long;

inline ll min(ll a, ll b) {
	return a < b ? a : b;
}

const int Max = 1e4;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long A, B;
	cin >> A >> B;
	if ((A - B) % 2 == 0)
		cout << B + (A - B) / 2;
	else
		cout << "IMPOSSIBLE";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    if (a + w < b) {
        std::cout << b - (a + w) << std::endl;
        return 0;
    }

    if (b + w < a) {
        std::cout << a - (b + w) << std::endl;
        return 0;
    }

    std::cout << 0 << std::endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        ArrayList<String> Sa = new ArrayList<String>();

        int prev = 0;
        for(int i=0;i<S.length()-1;i++){
            if(S.charAt(i) == 'R' && S.charAt(i+1) == 'L'){
                for(int j=i+1;j<S.length();j++){
                    if(S.charAt(j) == 'R'){
                        String str = S.substring(prev,j);
                        Sa.add(str);
                        prev = j;
                        break;
                    }else if(j == S.length()-1){
                        String str = S.substring(prev,S.length());
                        Sa.add(str);
                        prev = i+j;                        
                        break;
                    }
                }
            }
        }

        for(int i=0;i<Sa.size();i++){
            String str = Sa.get(i);
            int len = str.length();
            int index = str.indexOf("RL");

            boolean flag = false;
            if((str.substring(0,index).length())%2==1 && (str.substring(index+1,str.length()-1).length())%2==0)
                flag = true;
            else
                flag = false;

            if((len % 2) == 0){
                for(int j=0;j<len;j++){
                    if(j == index || (j == index+1)){
                        System.out.print((len/2) + " ");
                    }else{
                        System.out.print(0 + " ");                        
                    }
                }
            }else{
                for(int j=0;j<len;j++){
                    if(j == index){
                        if(flag)
                            System.out.print((len/2) + " ");
                        else
                            System.out.print((len/2)+1 + " ");
                    }else if(j == index + 1){
                        if(flag)
                            System.out.print((len/2)+1 + " ");
                        else
                            System.out.print((len/2) + " ");
 
                    }else{
                        System.out.print(0 + " ");                        
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 53348
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int k = vs[1];
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

			int ans = 1;
			n -= k;
			if (n > 0) {
				int t = n / (k - 1);
				ans += t;
				n -= (k - 1) * t;
				if (n > 0) {
					ans++;
				}
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 35576
#include <stdio.h>

int main(void) {
    int n, c, f, p;
    char buf[3];
    while(scanf("%d", &n), n) {
        p = 3;
        c = f = 0;
        while(n--) {
            scanf("%s", buf);
            f ^= buf[0] == 'l' ? 2 : 1;
            f ^ p || (p ^= 3, c++);
        }
        printf("%d\n", c);
    }
    return 0;
}

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

using namespace std;

#define int long long
#define uint unsigned int
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(x, f, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() { int x; scanf("%lld", &x); return x; }
void wint(int x) { printf("%lld\n", x); }

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template<typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template<typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }
inline int lg(int x) { return 63 - __builtin_clzll(static_cast<unsigned int>(x)); }

#ifdef EBUG
#define INT_WIDTH ""
#include "debug.h"
#else
#define inspect(...) do {} while (0)
#define debugf(...) do {} while (0)
#define debugv(...) do {} while (0)
#endif

template<typename RandomAccessIterator>
vector<int> z_algorithm(const RandomAccessIterator first, const RandomAccessIterator last) {
  const int n = last - first;
  vector<int> Z(n);
  for (int l = 0, r = 0, k = 1; k < n; k++) {
    if (k >= r) {
      int j = 0;
      while (j < n - k && *(first + j) == *(first + k + j))
        j++;
      Z[k] = j;
      if (j) {
        l = k;
        r = k + j;
      }
    } else {
      int i = k - l, j = r - k;
      if (Z[i] < j)
        Z[k] = Z[i];
      else {
        while (j < n - k && *(first + j) == *(first + k + j))
          j++;
        Z[k] = j;
        l = k;
        r = k + j;
      }
    }
  }
  return Z;
}

template<typename RandomAccessIterator>
class KMP {
  RandomAccessIterator p;
  vector<int> A;
public:
  KMP(const RandomAccessIterator p_first, const RandomAccessIterator p_last) : p(p_first) {
    vector<int> Z = z_algorithm(p_first, p_last);
    A.resize(Z.size()+1);
    dotimes(i, Z.size())
      if (Z[i] && !A[i+Z[i]])
        A[i+Z[i]] = Z[i];
  }
  template<typename ForwardIterator, typename F>
  void search(const ForwardIterator s_first, const ForwardIterator s_last, F f) {
    int i = 0, j = 0, m = ::size(A) - 1;
    for (ForwardIterator s = s_first; s != s_last;)
      if (*s == *(p + j)) {
        ++s;
        i++;
        j++;
        if (j == m) {
          f(i - j);
          j = A[j];
        }
      } else if (j)
        j = A[j];
      else {
        ++s;
        i++;
      }
  }
};

signed main() {
  char T[1'000'001], P[10'001];
  scanf("%s\n%s\n", T, P);
  int n = strlen(T), m = strlen(P);
  if (n < m)
    return 0;
  KMP<char*> kmp(P, P + m);
  kmp.search(T, T + n, wint);
  return 0;
}



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

using namespace std;

int main(){
	
	int N;
	while(scanf("%d",&N) == 1){
		int sum = 0;
		for(int i=1 ; i<=N ; ++i){
			int t;
			scanf("%d",&t);
			sum += t - 1;
		}
		printf("%d\n",sum);
	}
	
	return 0;
}

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

using namespace std;
const int N = 600000;

long long dp[101][101 * 101];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, a;
    cin >> n >> a;
    dp[0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        for (int s = 50; s >= 0; s--)
        {
            for (int si = 50 * 50; si >= 0; si--)
            {
                dp[s + 1][si + x] += dp[s][si];
            }
        }
    }
    long long ans = 0;
    for (int cnt = 1; cnt <= n; cnt++)
    {
        ans += dp[cnt][cnt * a];
    }
    cout << ans;
}


Measured memory_bytes: 3072
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
s = ["".join(sorted(input())) for _ in range(N)]
dic = defaultdict(int)
for x in s:
	dic[x] += 1
ans = 0
for n in dic.values():
	ans += n*(n-1)//2
print(ans)


Measured memory_bytes: 21508
#include <iostream>
using namespace std;
int main() {
  int a;
  cin >> a;
  int count = 1;
  int num = 1;
  for(int i = 1; i < a; i++) {
    if(count * 2 > a) break;
    count *= 2;
  }
  cout <<  count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    ll n;
    ll ans = 1;
    cin >> n;
    for(int i=1; i<=n; i++){
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {

    char c1[4];
    char c2[4];
    char c3[4];

    scanf("%s %s %s", c1, c2, c3);

    printf("%c", c1[0]);
    printf("%c", c2[1]);
    printf("%c", c3[2]);


    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

int main(){
  int n;
  cin>>n;
  int c[n];
  int cnt[13]={};
  for(int i=0;i<n;i++){
    cin>>c[i];
    cnt[c[i]/400]++;
  }
  int ans=0,aans=0;
  for(int i=0;i<=12;i++){
    if(i<=7){
      if(cnt[i]>0){
        ans++;aans++;
      }
    }
    else{
      aans+=cnt[i];
    }
  }
  if(ans==0){
    ans=1;
  }
  cout<<ans<<" "<<aans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int calc(int a, int b, int n) {
	int tmp = n-a-b;
	int count = 0;
	for (int c=0; c<10; c++) {
		for (int d=0; d<10; d++) {
			if (tmp == c+d)
				count++;
		}
	}
	return count;
}

void solve(int n) {
	int count = 0;
	for (int a=0; a<10; a++) {
		for (int b=0; b<10; b++) {
			count += calc(a,b,n);
		}
	}
	cout << count << endl;
}

int main() {
	int n;
	while (cin >> n) {
		solve(n);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
int main(void){
    while(1){
    int H,W;
    scanf("%d %d", &H, &W);
        if(H == 0 && W == 0)break;
        else{
            for(int j=0; j<H; j++){
                for(int i=0; i<W; i++){
                    printf("#");
                }
                printf("\n");
            }
        }
    printf("\n");
    }
}

Measured memory_bytes: 2564
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#define ll long long
#include<math.h>
using namespace std;
int a[105];
int main()
{
    ll n;
    scanf("%lld",&n);
    memset(a,0,sizeof(a));
    if(n==0)
        puts("0");
    else
    {
        int t=0;
        while(n)
        {
            int yu=n%(-2);
            if(yu==-1)
            {
                yu=1;
                a[t++]=yu;
                n=n/(-2)+1;
            }
            else
            {
                a[t++]=yu;
                n=n/(-2);
            }
        }
        for(int i=t-1;i>=0;i--)
        {
            printf("%d",a[i]);
        }
        printf("\n");
    }
    return 0;
}

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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> pre(n + 1, 0);
    for(int i = 1; i < n; i++){
        if(s.substr(i - 1, 2) == "AC"){
            pre[i + 1] += 1;
        }
        pre[i + 1] += pre[i];
    }
    debug(pre);
    while(q--){
        int l, r;
        cin >> l >> r;
        cout << pre[r] - pre[l] << nl;
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 1480
from collections import Counter

n = int(input())
S = [input() for _ in range(n)]
C = Counter(S[0])
for i in range(1, n):
    c = Counter(S[i])
    for k, v in C.items():
        if C[k] > c[k]:
            C[k] = c[k]
C = sorted(C.most_common())
ans = ''
for c in C:
    ans += c[0]*c[1]
print(ans)


Measured memory_bytes: 9300
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  vector<ll> a(n);
  ll t = 1;
  REP(i, n) {
    cin >> a[i];
    if(a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  REP(i, n) {
    if(LLINF / a[i] < t) {
      cout << -1 << endl;
      return 0;
    } else {
      t *= a[i];
    }
  }
  cout << t << endl;
}


Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include<iomanip>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

vector<bool> passed(100010, false);
vector<int> res(100010);
vector<vector<pair<int, int>>> edge(100010);

void dfs(int now, int v, int dist)
{
	if (passed[v]) return;

	passed[v] = true;
	
	if (dist & 1)now = 1 - now;
	res[v] = now;
	int e = edge[v].size();
	for (int i = 0; i < e; ++i)
	{
		dfs(now, edge[v][i].first, edge[v][i].second);
	}
	return;
}

int main()
{
	int n; cin >> n;
	for (int i = 1; i < n ; ++i)
	{
		int u, v, w; cin >> u >> v >> w;
		--u;
		--v;
		edge[u].push_back({ v,w });

		edge[v].push_back({ u,w });
	}
	int now = 1;
	res[0] = now;
	dfs(now, edge[0][0].first, edge[0][0].second);
	rep(i, 0, n - 1)
	{
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 8448
#include<iostream>
#include<stdio.h>
using namespace std;
main(){
	int w,n;
	cin>>w>>n;
	int a,b,ans[w+1];
	for(int i=0;i<=w;++i)ans[i]=i;
	for(int i=1;i<=n;++i){
		scanf("%d,%d",&a,&b);
		int tmp;
		tmp=ans[a];
		ans[a]=ans[b];
		ans[b]=tmp;
	}
	for(int i=1;i<=w;++i)cout<<ans[i]<<endl;
}

Measured memory_bytes: 1240
def pow(x, n, mod)
  ans = 1
  while n > 0
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  ans
end

N = gets.to_i
MOD = 10 ** 9 + 7

ans = pow(10, N, MOD) - 2 * pow(9, N, MOD) + pow(8, N, MOD)
ans += MOD if ans < 0
ans += MOD if ans < 0

puts ans


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

string youbi[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    REP(i,7){
        if(s == youbi[i]){
            ANS(7 - i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		int d = (int) (a/b);
		int r = (int) (a%b);
		double f = a/b;

		String str = String.format("%.7f", f);
		//BigDecimal bi = new BigDecimal(String.valueOf(f));
		//double k= bi.setScale(9, BigDecimal.ROUND_DOWN).doubleValue();
		sc.close();

		System.out.println(d + " " + r +" " + str);
	}

}

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

int main(){
  int n;
  cin >> n;
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  if(n < 4){
    cout << 2 << endl;
    return 0;
  }
  if(n < 8){
    cout << 4 << endl;
    return 0;
  }
  if(n < 16){
    cout << 8 << endl;
    return 0; 
  }
  if(n < 32){
    cout << 16 << endl;
    return 0;
  }
  if(n < 64){
    cout << 32 << endl;
    return 0;
  }
  else{
    cout << 64 << endl;
    return 0;
  }
}

Measured memory_bytes: 3564
#include <stdio.h>

int main()
{
	int n;
	char str[99];
	int use[256];
	int use2[256];
	int i, j;
	scanf("%d", &n);
	for (j = 0; j < 256; j++)
	{
		use[j] = 9999;
	}
	for (i = 0; i < n; i++)
	{
		scanf("%s", str);
		for (j = 0; j < 256; j++)
		{
			use2[j] = 0;
		}
		for (j = 0; str[j]; j++)
		{
			use2[str[j]]++;
		}
		for (j = 0; j < 256; j++)
		{
			if (use[j] > use2[j])
			{
				use[j] = use2[j];
			}
		}

	}
	for (i = 'a'; i <= 'z'; i++)
	{
		for (j = 0; j < use[i]; j++)
		{
			putchar(i);
		}
	}
	puts("");
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
ll get_digent(ll);


int main(){
  often();
  int n,ans=0;
  cin >> n;
  vi p(n);
  rep(i,n) cin >> p[i];
  rep(i,n-2){
    int minimum = min(p[i],p[i+1]);
    minimum = min(minimum,p[i+2]);
    int maximum = max(p[i],p[i+1]);
    maximum  = max(maximum,p[i+2]);
    if(minimum != p[i+1] && maximum != p[i+1]) ans++;
  }
  cout << ans << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll get_digent(ll x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    ans = 0
    for p in range(1000):
        pattern = str(p).zfill(3)
        cnt = 0
        T = S
        for n in pattern:
            i = T.find(n)
            if i != -1:
                T = T[i+1:]
                cnt += 1
        if cnt == 3:
            ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) - (C + D) == 0){
    cout << "Balanced" << endl;
  }else if (A + B > C + D){
    cout << "Left" << endl;
  }else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/05/25
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int A = 0, B = 0, ans = 0;
	scanf("%d %d", &A, &B);
	if(A >= 13) {
		ans = B;
	} else if(A <= 5) {
		ans = 0;
	} else {
		ans = B/2;
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pdi = pair<double, int>;

int N;
ll X;
ll nlayer[51];
ll nP[51];

ll npatty(int n, ll x) {
	if (n >= 1)
		if (x == 1) {
			return 0;
		}
		else if (x <= 1 + nlayer[n - 1]) {
			return npatty(n - 1, x - 1);
		}
		else if (x == 1 + nlayer[n - 1] + 1) {
			return npatty(n - 1, x - 1) + 1;
		}
		else if (x <= 1 + nlayer[n - 1] + 1 + nlayer[n - 1]) {
			return nP[n - 1] + 1 + npatty(n - 1, x - (1 + nlayer[n - 1] + 1));
		}
		else {
			return nP[n - 1] * 2 + 1;
		}
	else
		return 1;
}

int main() {
	cin >> N >> X;
	for (int i = 0; i <= N; i++)
	{
		nlayer[i] = pow(2, i + 2) - 3;
		nP[i] = pow(2, i + 1) - 1;
	}
	cout << npatty(N, X) << endl;
	return 0;
}



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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int N;
  cin >> N;
	cout << N + N* N + N*N*N << endl;
return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  ll cnt = 0;
  ll k = N / 2 + N % 2;
  string ans = "YES";
  if (k < K) ans = "NO";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int N,M,i,sum=0;
    cin>>N>>M;
    int A[M];
    for(i=1;i<=M;i++){
            cin>>A[i];
        sum=sum+A[i];
    }
    sum=N-sum;
    if(sum>=0){
        cout<<sum<<endl;
    }
    else{
        cout<<"-1"<<endl;
    }
}

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

int calc(int x) {
	int ret = 0;
	while(x % 100 == 0) {
		x /= 100;
		++ret;
	}
	return ret;
}
int main() {
  int d, n;
  cin >> d >> n;
  int val = 0, cnt = 0;
  while (cnt < n){
    val++;
    if (calc(val) == d) cnt++;
  }
  cout << val << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 3010, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);

int a[N], dp[N][N], vis[N][N];

void rec(int l, int r, int who = 0) {
	if(l > r) {
		return;
	}
	if(vis[l][r]) return;
	vis[l][r] = 1;

	rec(l + 1, r, 1 - who);
	rec(l, r - 1, 1 - who);

	if(l == r) {
		dp[l][r] = pow(-1, who) * a[l];
		return;
	}

	if(who) {
		dp[l][r] = inf;
		dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r]);
	} else {
		dp[l][r] = 0;
		dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r]);
	}
}
// 0 -first   1 - second
void solve() {
	//soln
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	rec(1, n);

	cout << dp[1][n];
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}


Measured memory_bytes: 96380
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String NM = scanner.nextLine();
		int N = Integer.parseInt(NM.split(" ")[0]);
		int sumA = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).sum();
		System.out.println(sumA > N ? -1 : N - sumA);
	}
}


Measured memory_bytes: 34404
import java.util.*;
class Main {
  public static void main(String[] args) {
    
    Scanner sc=new Scanner(System.in);
    int D=sc.nextInt();
    double T=sc.nextInt();
    int S=sc.nextInt();
    double g=(double)(D/(S*1.0));
    if(g <= T){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35760
def bubble_sort(a):
    res = 0
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j-1] > a[j]:
                a[j], a[j-1] = a[j-1], a[j]
                res += 1
    return res

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = bubble_sort(a)
    print(' '.join(map(str, a)))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define test int t;cin>>t;while(t--)
#define INF 10000000
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back
//#include "debug.cpp"
//__builtin_popcount

int32_t main()
{
    fast
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        /* code */
    }

    int sum[n]={0};
    sum[0]=a[0]%mod;
    for(int i=1;i<n;i++)
    {
        sum[i]=(sum[i-1]+a[i])%mod;
    }

    int ans=0;
    int val=sum[n-1];
    //watch(val);
    for (int i = 0; i <n-1; ++i)
    {
        ans=(ans+((val-sum[i])*a[i])%mod)%mod;
        //ans=(ans+(ans*a[i])%mod)%mod;
        // watch(sum[i]);
        // watch(ans);
    }
    if(ans<0)
        ans+=mod;
    cout<<ans<<endl;

}


Measured memory_bytes: 6740
#include <iostream>

using namespace std;
bool is = false;

int main() {
  int a, b, c;

  cin >> a >> b >> c;

  int tmp = b + c;

  int t = 100;

  while (t > 0) {
    if(tmp % a == 0){ is = true; break;}
    t--;
    tmp += b;
  }

  if(is)cout <<"YES"<<endl;
  else cout << "NO" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 15;

int MOD = 1000000007;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    std::ios_base::sync_with_stdio(false);

    int n,m; cin >> n >> m;

    ll cnt = ((1LL+(n-1LL))*(n-1LL))/2LL;
    std::vector<ll> ans;
    ans.push_back(cnt);

    std::vector<pair<int, int>> bridges;
    REP(i,m){
        int a,b; cin >> a >> b;
        bridges.push_back(make_pair(a-1,b-1));
    }

    reverse(bridges.begin(), bridges.end());

    UnionFind uft(n);



    REP(i, m){
        int s = bridges[i].first;
        int t = bridges[i].second;

        //cout << uft.root(s) << " " << uft.root(t) << endl;

        int before_size_s = uft.size(s);
        int before_size_t = uft.size(t);

        if(uft.findSet(s,t)){
            //cout << cnt << endl;
            ans.push_back(cnt);
            continue;
        } else {
            uft.unionSet(s,t);
            cnt -= before_size_s*before_size_t+0LL;
            ans.push_back(cnt);
        }
    }

    reverse(ans.begin(), ans.end());

    REP(i, m){
        cout << ans[i+1] << endl;
    }



    return 0;
}


Measured memory_bytes: 3444
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100010]={0};
int main(){
	int i,j,k,m,n;
	scanf("%d",&n);
	int max=0,min=1e9;
	for (i=1;i<=n;i++){
		scanf("%d",&m);
		a[m]++;a[m+1]++;a[m+2]++;
		min=min<m?min:m;
		max=max>m?max:m;
	}
	int ans=0;
	for (i=min;i<=max;i++)
		ans=ans>a[i]?ans:a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
L1 = [int(x) for x in input().split()]
L2 = [int(x) for x in input().split()]
L3 = [int(x) for x in input().split()] 
AL = L1 + L2 + L3
N = int(input())
for x in range(N):
    IN = int(input())
    if IN in AL:
        AL[AL.index(IN)] = 0
for x in range(3):
    if AL[0+x] == AL[3+x] == AL[6+x] == 0:
        print("Yes")
        exit()
if AL[0] == AL[4] == AL[8] == 0:
    print("Yes")
    exit()
elif AL[2] == AL[4] == AL[6] == 0:
    print("Yes")
    exit()
elif AL[0] == AL[1] == AL[2] == 0:
    print("Yes")
    exit()
elif AL[3] == AL[4] == AL[5] == 0:
    print("Yes")
    exit()
elif AL[6] == AL[7] == AL[8] == 0:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
int main()
{
  ll n, A[200100], tmp = 0, ans = 0;
  cin >> n;
  for(int i=0; i<n; ++i) cin >> A[i];
  for(int i=n-2; i>=0; --i){
      tmp += A[i+1];
      tmp = tmp%MOD;
      ans += A[i]*tmp%MOD;
      ans = ans%MOD;
  } 
  cout << ans << endl;
}


Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=1e9;cin>>n;
  lvector X(n,0);rep(i,n) cin>>X[i];
  for(ll pos=1;pos<=100;++pos) {
    ll ans_=0;
    rep(i,n) ans_+=abs(X[i]-pos)*abs(X[i]-pos);
    ans=min(ans,ans_);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n,q,*data1,*data2,i,j,count=0,c=0;

  scanf("%d",&n);

  data1=(int *)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&data1[i]);
  }

  scanf("%d",&q);

  data2=(int *)malloc(sizeof(int)*q);
  for(i=0;i<q;i++){
    scanf("%d",&data2[i]);
  }
 
  for(i=0;i<q;i++){
    count=0;
    for(j=0;j<n;j++){
      if(data1[j]==data2[i]) count++;

    }
    if(count>0) c++;

  }
  printf("%d\n",c);
  free(data1);
  free(data2);
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
int a[100005];

long long ans = 0;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    int no_neg = 0;
    int nin = 1000000000;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        no_neg += (a[i] < 0);
        ans += abs(a[i]);
        nin = min(nin, abs(a[i]));
    }

    if(no_neg % 2) ans -= nin * 2LL;
    cout << ans;
}

Measured memory_bytes: 640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto keys = new ulong[](M);
    auto value = new long[](M);
    ulong sum;
    foreach (i; 0 .. M)
    {
        long a, b;
        scan(a, b);
        value[i] = a;
        auto C = aryread();
        foreach (c; C)
            keys[i] |= (1 << (c - 1));
        sum |= keys[i];
    }
    if (sum != (1 << N) - 1)
    {
        writeln(-1);
        return;
    }
    auto dp = new long[][](M + 1, 2 ^^ N);
    // dp[i][j] == i番目まで鍵を選んで状態jに到達する最小コスト
    foreach (i; 0 .. M + 1)
        dp[i][] = long.max;
    dp[0][0] = 0;
    foreach (i; 0 .. M)
        foreach (j; 0 .. (1 << N))
            if (dp[i][j] != long.max)
            {
                // writefln("%d %010b %d", i, j, dp[i][j]);
                dp[i + 1][j] = dp[i + 1][j].min(dp[i][j]);
                dp[i + 1][j | keys[i]] = dp[i + 1][j | keys[i]].min(dp[i][j] + value[i]);
            }
    writeln(dp[M][(1 << N) - 1]);
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  
  for(int i=0;i<n;i++) cin>>a[i];
  
  vector<int> rev(n);
  for(int i=0;i<n;i++) rev[a[i]-1]=i+1;
  for(int i=0;i<n;i++) cout << rev[i]<<endl;
  return 0;
} 

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

struct Edge {
	ll to;
    ll cost;
};

struct edge {
    ll from;
    ll to;
    ll cost;
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define mp make_pair
#define pb push_back
/***** define constant start *******/
const int MAX = 10000000;
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1LL << 60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/****** define constant end ********/

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

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

void debug_out() { std::cout << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0)
        res += m;
    return res;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1)
        res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
	    a -= t * b;
        swap(a, b);
	    u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
/****** define variable start ******/
long double n;
/******* define variable end *******/
int solve() {
	cin >> n;
	ll st = ceil(sqrt(n));
	ll ans = 0;
	FOR(i, 1, st){
		ans += (((ll)n-1) / i - i + 1) * 2 - 1;
	}
	cout << ans << endl;
    return 0;
}

int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3816
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	i64 a,b,c,k;
	cin>>a>>b>>c>>k;
	i64 ans;
	if(k==0){
		ans=a-b;
	}else{
		i64 aa=b+c;
		i64 bb=a+c;
		ans=(aa-bb)*((k%2==0)? -1:1);
	}
	if(abs(ans)>pow(10,18)){
		cout<<"Unfair"<<endl;
	}else{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	string S;
	cin >> S;
	int Q;
	cin >> Q;
	vector<int> K(Q);
	for(int i=0; i<Q; i++) cin >> K[i];

	for(int k: K){
		ll ans = 0;
		ll n_d=0, n_m=0, n_dm=0;
		for(int i=0; i<k; i++){
			if(S[i]=='D') n_d++;
			if(S[i]=='M'){
				n_dm += n_d;
				n_m++;
			}
			if(S[i]=='C') ans += n_dm;
		}
		for(int i=k; i<N; i++){
			if(S[i-k]=='D'){
				n_d--;
				n_dm -= n_m;
			}
			if(S[i-k]=='M') n_m--;
			if(S[i]=='D') n_d++;
			if(S[i]=='M'){
				n_dm += n_d;
				n_m++;
			}
			if(S[i]=='C') ans += n_dm;
		}
		cout << ans << endl;
	}

	return 0;
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll d[100010] = { };

int main(){
	int n, W;
	cin >> n >> W;
	ll w[n], v[n];
	REP(i, n) cin >> w[i] >> v[i];
	FOR(i, 1, W+1) d[i] = -1;
	REP(i, n){
		for(int j = W; j >= w[i]; j--){
			if(d[j-w[i]] >= 0) d[j] = max(d[j], d[j-w[i]]+v[i]);
		}
	}
	FOR(i, 1, W+1) d[i] = max(d[i], d[i-1]);
	cout << d[W] << endl;
} 

Measured memory_bytes: 1024
package main

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

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)

	/* 単語ごとに入力するならこれ */
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
  digit := len(sc.Text())
  div := 1

  ret := 0
  for i := 0; i < digit; i++ {
    if i % 2 == 0 {
      if i == digit - 1 {
        ret += n - div + 1
      } else {
        ret += div * 9
      }
    }
    div *= 10
  }
  fmt.Println(ret)

}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int A[100],i,n,flag,count,key;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);

  flag = 1;
  count = 0;

  while(flag){
    flag = 0;

    for(i = n-1; i > 0; i--){
      if(A[i] < A[i-1]){
	key = A[i-1];
	A[i-1] = A[i];
	A[i] = key;
	count++;
	flag = 1;
      }
    }

  }
	
  for(i = 0; i < n-1; i++)
    printf("%d ",A[i]);

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

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 600
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    writeln(N * (N - 1) / 2);
    // iota(N - 1).map!"a+1"().sum().writeln();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string a,b; cin >> a >> b;

    int s = stoi(a+b);

    bool flg = false;
    for(int i=1; i<1000; i++) if(i*i == s) flg = true;

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long K, A, B;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> K >> A >> B;
  long long n = min(K, A-1);
  long long ret = 1;
  ret += n;
  K -= n;
  ret += 1LL*max(2LL, B-A)*(K/2);
  K%=2;
  if (K) ret++;
  cout << ret << "\n";
  return 0;
}


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

int main (){
	
	int n, m, sum, x, a;
	sum =0;

	cin>>n>>m;
	 for (int i=0; i<m; i++){
	 	cin>> a;
	 	sum = sum +a;
	 	
	 }
	 
	 x= n- sum;
	 
	 if (x>= 0){
      cout << x;	 	
	 }
	 else 
	 cout << -1;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  if (n>=30){
	  cout<<"Yes"<<endl;
	  return 0;
  }else{
	  cout<<"No"<<endl;
	  return 0;
  }

  return 0;
}

Measured memory_bytes: 3632
///BISMILLAH'IR  RO'HMANIR  ROH'IM
///RIFAT SHARIAR SAKIL
///SOFTWARE ENGINEERING(SUST)

#include<stdio.h>
int main()
{
    int N,i,j,k,s=0,p,m,a[100],b[100],c[100];
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<N;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<N-1;i++)
    {
        scanf("%d",&c[i]);
    }
    for(k=0;k<N;k++)
    {
        p=a[k];
        s=s+b[p-1];
        if(a[k]-a[k-1]==1)
        {
            m=a[k-1];
            s=s+c[m-1];
        }
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
ans = 0
tmp = 0
for i in range(1, n + 1):
    cnt = 0
    x = i
    while x % 2 == 0:
        x //= 2
        cnt += 1
    if cnt > tmp:
        tmp = cnt
        ans = i
print(ans if n != 1 else 1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n>0){
        n/=k;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

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

const int N = 1010, W = 10010;
ll pd[N][W];
int val[N];
int w[N], s[N];
int v[N];

bool cmp(int a, int b)
{
	return s[a] + w[a] > s[b] + w[b];
}

int main()
{
	int n;
	scanf("%d", &n);
	iota(v, v+n, 0);
	for (int i = 0; i < n; i++)
		scanf("%d %d %d", w+i, s+i, val+i);
	sort(v, v+n, cmp);
	for (int i = n-1; i >= 0; i--)
	{
		int a = v[i];
		for (int j = 0; j < w[a]; j++)
			pd[i][j] = pd[i+1][j];
		for (int j = w[a]; j < W; j++)
			pd[i][j] = max(pd[i+1][j], val[a] + pd[i+1][min(j - w[a], s[a])]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++)
		ans = max(ans, val[v[i]] + pd[i+1][s[v[i]]]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if((a[1]==a[2]&&a[2]!=a[3])||(a[1]!=a[2]&&a[2]==a[3]))
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int A, P;
    cin >> A >> P;

    P += 3 * A;
    cout << P / 2 << endl;

    return 0;
}



Measured memory_bytes: 256