akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define f(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define vl vector<ll>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";
#define printv(v) for(auto it : v) cout<<it<<" ";


//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;
const long long int MOD = 1e9+7;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{ll sum = 0 ; 
string s;
cin>>s;
ll n;
int i = 0 ; 
n = s.length();
    while(i<n){
    sum+=(s[i]-'0');
    sum=sum%9;
    i++;
}
if(sum%9)
cout<<"No\n";
else
cout<<"Yes\n";

    
}
}


Measured memory_bytes: 3752
#include <stdio.h>
#define N 300
void gyouretsu(int,int);
int main()
{
  int i,count;
  int ROW,COLUMN;
  int mat1[N],mat2[N];

  count=0;

  while(1)
  {
    scanf("%d %d",&ROW,&COLUMN);

    if(ROW==0 && COLUMN==0) break;

    mat1[count]=ROW;
    mat2[count]=COLUMN;
    count++;
  }

  for(i=0;i<count;i++)
  {
    gyouretsu(mat1[i],mat2[i]);
  }

  return 0;
}

void gyouretsu(int x,int y)
{
  int i,j;
  for(i=0;i<x;i++)
  {
    for(j=0;j<y;j++)
    {
      if(i!=0 && i!=x-1 && j!=0 && j!=y-1) printf(".");
      else printf("#");
    }
    printf("\n");
  }
  printf("\n");
}

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

int used[12];
int a[12];
int buf[12];
int c=0;
void check(){
	if(a[0]+a[1]*10+a[2]+a[3]*100+a[4]*10+a[5]==a[6]*100+a[7]*10+a[8])c++;
}

void solve(int k){
	// cout<<"call:"<<k<<endl;
	if(buf[k]==-1){check();return;}
	for(int i=1;i<10;i++){
		if(used[i])continue;
		used[i]=true;
		a[buf[k]]=i;
		solve(k+1);
		a[buf[k]]=-1;
		used[i]=false;
	}
}

int main(void){
	int k=0;
	for(int i=1;i<10;i++)used[i]=false;
	for(int i=0;i<9;i++){
		cin>>a[i];
		used[a[i]]=true;
		if(a[i]==-1)buf[k++]=i;
	}
	buf[k]=-1;
	solve(0);
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3096
using System;
namespace ConsoleApplication1
{
    class Program
    {
        //1 ≤ N ≤ 10^4
        //1 ≤ A ≤ B ≤ 36
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var n = int.Parse(inputs[0]);
            var a = int.Parse(inputs[1]);
            var b = int.Parse(inputs[2]);

            var count = 0;

            for (int i = 1; i <= n; i++)
            {
                var sum = 0;
                var iMozi = i.ToString();
                foreach (var c in iMozi)
                {
                    sum += int.Parse(c.ToString());
                    
                }

                if (a <= sum && sum <= b)
                {
                    count += i;
                }
            }

            //出力
            Console.WriteLine(count.ToString());

            Console.ReadLine();
        }
    }
}

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

int main() {
    string S;
    cin >> S;
    int price = 700;
    if (S.at(0) == 'o') price += 100;
    if (S.at(1) == 'o') price += 100;
    if (S.at(2) == 'o') price += 100;
    printf("%d", price);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <map>

using namespace std;
map<string, int> mp;
string name;
int s[110];
int main()
{
	int n; cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> name >> s[i];
		mp[name] = i;
	}
	cin >> name;
	int sum = 0;
	for (int i = mp[name] + 1; i <= n; ++i) sum += s[i];
	printf("%d\n", sum);
	return 0;
}

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

using namespace std;

int n;
int dp[2001][2];
int a[2001];

int f(int k, int t) {
  if (dp[k][t] != -1) return dp[k][t];
  if (t == 0) {
    int ans = abs(a[k] - a[n]);
    for (int i = k + 1; i < n; i++) {
      ans = max(ans, f(i, t ^ 1));
    }
    return dp[k][t] = ans;
  } else {
    int ans = abs(a[k] - a[n]);
    for (int i = k + 1; i < n; i++) {
      ans = min(ans, f(i, t ^ 1));
    }
    return dp[k][t] = ans;
  }
}

int main() {
  cin >> n;
  cin >> a[0] >> a[0];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  fill_n(*dp, 2001 * 2, -1);

  cout << f(0, 0) << endl;
}


Measured memory_bytes: 384
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun main() {
	abc000X()
}

fun abc000X() {
	val (x,k,d) = list {toLong()}
	val t = abs(x)/d
	System.err.println(t)
	if(t<=k) {
		System.err.println("a")
		abs(abs(x)-d*(t+(k-t)%2))
	} else {
		System.err.println("b")
		abs(x)-d*k
	}.let {println(it)}
}


Measured memory_bytes: 36460
#include <bits/stdc++.h>
using namespace std;
static long long int dp[100000001]={0};
void getDiviser(long long int n){
  int steps = 0;
   //103668 steps
   for(int i=1;i<=n;i++){
     for(int j=0;j<=n;j+=i){
            dp[j]++;
     }
   }
}
int main() {
  std::ios_base::sync_with_stdio(false);
      std::cin.tie(NULL);
      long long int n;
      std::cin >>n;
      getDiviser(n);
      long long int ans = 0;
      for(int i=1;i<=n;i++){
         ans += i*dp[i];
      }
      std::cout << ans << '\n';
return 0;
}


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

int main(){
  ll H, W;
  cin >> H >> W;
  if(H == 1 || W == 1) cout << 1 << endl;
  else{
    if(H%2!=0 && W%2!=0){
    cout << H*W/2 + 1 << endl;
    }
    else cout << H*W/2 << endl;
  }
}

Measured memory_bytes: 256
l = []
for i in range(int(input())):
   l.append(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in l:
    if i == "AC":
        ac+=1
    if i == "TLE":
        tle+=1
    if i == "WA":
        wa+=1
    if i == "RE":
        re+=1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 16208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    int x, y;
    cin >> x >> y;
    
    int a[4];
    for (auto& ai : a) ai = x;
    int b[4];
    for (auto& bi : b) bi = y;
    
    int ans = inf;
    rep(i, 4) {
        int ret = 0;
        if (i == 1 || i == 2) { a[i] = -a[i]; ret++; }
        if (i == 2 || i == 3) { b[i] = -b[i]; ret++; }
        if (b[i] < a[i]) ret = inf;
        else {
            ret += b[i] - a[i];
        }
        chmin(ans, ret);
    }
    out(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 30000;

int n, uni[N];
char s[N];

ll ans;
set<char> seen;
bool done[10][10];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = n - 1; i >= 0; --i) {
		seen.insert(s[i]);
		uni[i] = seen.size();
	}
	
	
    for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			if (!done[s[i] - '0'][s[j] - '0']) {
				done[s[i] - '0'][s[j] - '0'] = true;
				ans += uni[j + 1];
			}
		}
	}
    
    cout << ans;
    return 0;
}


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

int main(void){
	int N;
	cin>>N;
	vector<int> a(N);
	rep(i,N)cin>>a[i];
	sort(a.begin(),a.end());
	cout<<a[N-1]-a[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,k; cin >> n >> k;
    string s; cin >> s;

    int h = 0;
    for(int i = 0;i < n-1;i ++){
        if(s.at(i) == s.at(i+1)) h ++;
    }

    for(int i = 0;i < k;i ++){
        if(h < n-2) h += 2;
        else if(h == n-2) h ++;
    }

    cout << h << endl;


}

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

int main() {
    ll x;
    cin >> x;
    for(int i = -1000; i <= 1000; ++i){
        for(int j = -1000; j <= 1000; ++j) {
            if(pow(i, 5)-pow(j, 5)==x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4100
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

S = input()
N = len(S)

ans = mod
for i in range(N - 2):
    opt = abs(int(S[i:i + 3]) - 753)
    ans = min(ans, opt)
print(ans)

Measured memory_bytes: 39732
#include <stdio.h>
#include<limits.h>
 
int main(void) {
 
        int N;
      scanf("%d",&N);
    
  
      long long int G = 1;
      
        for(int i=1;i<=N;i++){
        G *=10;
          if(G>1000000007){
            G %=1000000007;
          }
      }
        
     long  long int P = 1;
      for (int j=1;j<=N;j++){
        P *=8;
          if(P>1000000007){
            P %=1000000007;
              
        }
          
      }
      
     
    
    long long int D =1;
    for (int l=1;l<=N;l++){
        D *=9;
         if (D>1000000007){
            D %=1000000007;
        }
    
    }
    
    
    
    
      
    long long int answer;
    answer = G-2*D+P;
    if(answer<0){
        answer +=1000000007;
    }
    if(answer<0){
        answer +=1000000007;
    }
      printf("%lld",answer);
    
  
 
    
 
    return 0;
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum;
ll x,y;
ll n;
ll a[200005];
int main()
{
    scanf("%lld",&n);
    for(ll i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    ll x1,x2,y1,y2;
    int flag=0;
    ll xiao=INT_MAX;
    ll h=sum/2;
    for(int i=0;i<n-1;i++)
    {
        x+=a[i];
        y=sum-x;
        xiao=min(abs(x-y),xiao);
    }
    printf("%lld\n",xiao);
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define INF 1145141919810364364

int N, M;
static vector<pair<int, long long> > V[100000];
static long long Num[100000];
bool check = true;

void DFS(int p) {
	for (pair<int, long long> x : V[p]) {
		if (Num[x.first] == INF) {
			Num[x.first] = Num[p] + x.second;
			DFS(x.first);
		}
		else {
			if (Num[x.first] != Num[p] + x.second) check = false;
		}
	}
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int L, R, D;
		cin >> L >> R >> D;
		L--, R--;
		V[L].push_back({ R, D });
		V[R].push_back({ L, -D });
	}
	for (int i = 0; i < N; i++) {
		Num[i] = INF;
	}
	for (int i = 0; i < N; i++) {
		if (Num[i] == INF) {
			Num[i] = 0;
			DFS(i);
		}
	}
	if (check) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 16512
n = gets.chomp.to_i

list = [1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
ans = [0]*(n+1)
(1..n).each do |i|
  min = 100000
  list.each do |j|
    min = ans[i-j] if i-j>=0 && min > ans[i-j]
  end
  ans[i] = min + 1
end
printf("%d\n",ans[n])

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<'\n'
#define int long long
using namespace std;

const int MAX=305;

int n,k,a[MAX],P[MAX],f[MAX][MAX][MAX];
bool mark[MAX][MAX][MAX];

int dp(int i,int k,int cur) {
	if(i==n+1)
		return 0;
	if(mark[i][k][cur])
		return f[i][k][cur];
	mark[i][k][cur]=true;
	// not change
	int rs=dp(i+1,k,a[i])+max(P[a[i]]-P[cur],0LL);
	// change
	if(k>0)
		rs=min(rs,dp(i+1,k-1,cur));
	return f[i][k][cur]=rs;
}

int32_t main() {
	//freopen("input","r",stdin);
	cin>>n>>k;
	vector<int> V;
	map<int,int> M;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		V.push_back(a[i]);
	}
	V.push_back(0);
	sort(V.begin(),V.end());
	V.resize(unique(V.begin(),V.end())-V.begin());
	for(int i=0;i<V.size();i++) {
		M[V[i]]=i;
		P[i]=V[i];
	}
	for(int i=1;i<=n;i++)
		a[i]=M[a[i]];
	cout<<dp(1,k,0);
}


Measured memory_bytes: 126508
unittest
{
	assert( [ "4", "1 2 2 1" ].parse.expand.solve == 2 );
	assert( [ "5", "3 1 2 3 1" ].parse.expand.solve == 5 );
	assert( [ "8", "4 23 75 0 23 96 50 100" ].parse.expand.solve == 221 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto hs = input.front.split.to!( long[] );
	return tuple( hs );
}

auto solve( long[] hs )
{
	auto ans = 0L;
	
	for( auto k = 0; k < hs.length; k++ )
	{
		while( 0 < hs[ k ] )
		{
			for( auto i = k; i < hs.length; i++ )
			{
				if( hs[ i ] <= 0 ) break;
				hs[ i ]--;
			}
			ans++;
		}
	}
	
	return ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int num;
    int t, a;
    scanf("%d", &num);
    scanf("%d %d", &t, &a);

    int list[num];
    double list_t[num];
    double likeNum[2];
    for (int i = 0; i < num; i++)
    {
        scanf("%d", &list[i]);
        list_t[i] = t - list[i] * 0.006;
    }
    likeNum[0] = 1;
    likeNum[1] = list_t[0];
    for (int i = 1; i < num; i++)
    {
        if ((a - likeNum[1]) * (a - likeNum[1]) > (a - list_t[i]) * (a - list_t[i]))
        {
            likeNum[0] = i + 1;
            likeNum[1] = list_t[i];
        }
    }
    printf("%.0f\n", likeNum[0]);

    return 0;
}

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

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> dp(n);
	dp[n - 1] = 0;
	dp[n - 2] = abs(a[n - 1] - a[n - 2]);
	for(int i = n - 3; i >= 0; i--){
		dp[i] = min(abs(a[i] - a[i + 1]) + dp[i + 1], abs(a[i] - a[i + 2]) + dp[i + 2]);
	}
	cout<<dp[0]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    reverse(t.begin(), t.end());
    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;} 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}
signed main(){
  fio;
    string s;
    cin>>s;
    const int n = s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
  rr;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string.h>
using namespace std;
main()
{
    long long i, j, k, m, n, ans, cnt = 0, x;
    vector<long long> l(110), d(110);
    cin >> n >> x;
    d[1] = 0;
    if( x < 0 ) {puts("0");return 0;};
    if (n == 0 || x == 0)
    {
        puts("1");
        return 0;
    }
    for (int i = 0; i < n; i++)
        cin >> l[i];
    if(n == 1 )
    {
        if( l[0] <= x ) {puts("2");return 0;}
        else {puts("1");return 0;}
    }
    for (int i = 1; i <= n; i++)
    {
        d[i] = d[i - 1] + l[i - 1];
    }
    for (int i = 1; i <= n; i++)
    {
        if (d[i] > x)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << n + 1 << endl;
    return 0;
}


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

const double PI = acos(-1);

int main(void){
    int a,b,H,M;
    cin >> a >> b >> H >> M;
    
    double th = double (H*60+M)/720 * 2*PI;
    double tm = double (M)/60 * 2*PI;
    
    double xh = a*cos(th), yh = a*sin(th);
    double xm = b*cos(tm), ym = b*sin(tm);
    
    double dx = xh - xm, dy = yh - ym;
    double ans = sqrt(dx*dx + dy*dy);
    printf("%.12f",ans);
    return 0;
}

Measured memory_bytes: 4076
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    string S, T;
    cin >> S >> T;

    if (S == T) {
        cout << "Yes" << endl;
        return 0;
    }

    vector<int> ab(26, 0);
    vector<int> ab_T(26, 0);
    for (int i = 0; i < S.size(); i++) {
        int t1 = S[i] - 'a';
        int t2 = T[i] - 'a';
        ab[t1]++;
        ab_T[t2]++;
    }

    sort(ab.begin(), ab.end());
    sort(ab_T.begin(), ab_T.end());

    bool flag = true;

    for (int i = 0; i < 26; i++) {
        if (ab[i] != ab_T[i]) flag = false;
    }

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

    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

int H = 0, W = 0;
void dfs(int i, int j, vector<string> &mp, vector<vector<int>> &ok) {
  auto cont = false;
  ok[i][j] += (i+1 <  H && mp[i+1][j] == '#' ||
    i-1 >= 0 && mp[i-1][j] == '#' ||
    j+1 <  W && mp[i][j+1] == '#' ||
    j-1 >= 0 && mp[i][j-1] == '#');
}

int main(int argc, char const *argv[])
{
  cin >> H >> W;
  vector<string> mp(H);
  vector<vector<int>> ok;
  ok.assign(H, vector<int>(W));
  REP(i, H) cin >> mp[i];
  REP(i, H) REP(j, W) ok[0][0] = 0;
  REP(i, H) REP(j, W) {
    if (!ok[i][j] && mp[i][j] == '#') {
      dfs(i, j, mp, ok);
    }
  }
  REP(i, H) REP(j, W) {
    if (!ok[i][j] && mp[i][j] == '#') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <assert.h>
#include <unordered_map>

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

    int64_t N, M;
    std::cin >> N >> M;
    std::unordered_map<int64_t, int64_t> modM_map;
    int64_t cnt = 0;
    int64_t sum = 0;
    for(int32_t i = 0; i < N; i++){
        int64_t ai = 0;
        std::cin >> ai;
        sum += ai;
        if(sum % M == 0) cnt++;
        cnt += modM_map[sum % M];
        modM_map[sum % M]++;
    }
    std::cout << cnt << std::endl;

    return 0;

}


Measured memory_bytes: 3724
def judge(N,str):
    a = list(str)
    b = []
    c = []
    if N%2 == 0:
        for k in range(int(N/2)):
            b.append(a[k])
            c.append(a[k+int(N/2)])
        if b == c:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
N = int(input())
S = input()
judge(N,S)


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	long long a, b; cin >> a >> b;
	if (a < b) swap(a, b);
	if (a-b <= 1) cout << "Brown";
	else cout << "Alice";
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define Fr(i,a,b) for(int i=a;i<=b;i++)
#define RF(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair< int, int>
#define vpii vector<pii>
using namespace std;
vvi a;
vi b;
int dfs(int x){
	if(b[x]!=-1){
		return b[x];
	}
	int v=0;
	for(int i=0;i<a[x].size();i++){
		v=max(v,dfs(a[x][i])+1);
	}
	return b[x]=v;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
    int t=1;
    //cin>>t;
    while(t--){
    	int n,m;
    	cin>>n>>m;
    	a.clear();
    	b.clear();
    	a.resize(n);
    	int x,y;
    	Fr(i,0,m-1){
    		cin>>x>>y;
    		x--;y--;
    		a[x].pb(y);
    	}
    	b.resize(n,-1);
    	int ans=0;
    	Fr(i,0,n-1){
    		if(b[i]==-1){
    			dfs(i);
    		}
    		ans=max(ans,b[i]);
    	}
    	cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    long long int a[n],x,sum=0;
    cin>>x;
    cin>>a[0];
    for(int i=1; i<n; i++){
        cin>>a[i];
        int wa=a[i]+a[i-1];
        if(wa>x){
            if(a[i]<wa-x){
                int rest=wa-x-a[i];
                a[i]=0;
                a[i-1]-=rest;
                sum+=wa-x;
                //cout<<'a'<<endl;
            }
            else{
                a[i]-=wa-x;
                sum+=wa-x;
                //cout<<'b'<<endl;
            }
        }
    }
    /*for(int i=0; i<n; i++){
        cout<<a[i]<<endl;
    }
    cout<<endl;*/
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

type Edge struct {
    to, c, rev int
}

const INF int = 1000000007

var adj [][]Edge
var used []bool

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

func add_edge(from, to, c int) {
    adj[from] = append(adj[from], Edge {to, c, len(adj[to])})
    adj[to] = append(adj[to], Edge {from, 0, len(adj[from]) - 1})
}

func dfs(v, t, f int) int {
    if v == t {
        return f
    }
    used[v] = true
    for i, e := range adj[v] {
        if used[e.to] == false && e.c > 0 {
            d := dfs(e.to, t, min(f, e.c))
            if d > 0 {
                adj[v][i].c -= d
                adj[e.to][e.rev].c += d
                return d
            }
        }
    }
    return 0
}

func max_flow(s, t int) int {
    flow := 0
    for {
        for i := 0; i < len(used); i++ {
            used[i] = false
        }
        f := dfs(s, t, INF)
        if f == 0 {
            return flow
        }
        flow += f
    }
}

func main() {
    var n int
    fmt.Scan(&n)
    a := make([]int, n)
    b := make([]int, n)
    c := make([]int, n)
    d := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i], &b[i])
    }
    for i := 0; i < n; i++ {
        fmt.Scan(&c[i], &d[i])
    }
    adj = make([][]Edge, 2 * n + 2)
    used = make([]bool, 2 * n + 2)

    for i := 0; i < n; i++ {
        add_edge(2 * n, i, 1)
    }
    for i := n; i < 2 * n; i++ {
        add_edge(i, 2 * n + 1, 1)
    }
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            if a[i] < c[j] && b[i] < d[j] {
                add_edge(i, n + j, 1)
            }
        }
    }
    fmt.Println(max_flow(2 * n, 2 * n + 1))
}


Measured memory_bytes: 1024
N = int(input())
As = list(map(int, input().split()))

dpP = [0] * N
dpN = [0] * N
dpP[0] = As[0]
dpN[0] = -As[0]

for i, A in enumerate(As[1:-1], 1):
    dpP[i] = max(dpP[i-1]+A, dpN[i-1]-A)
    dpN[i] = max(dpP[i-1]-A, dpN[i-1]+A)

dpP[N-1] = dpP[N-2]+As[N-1]
dpN[N-1] = dpN[N-2]-As[N-1]

print(max(dpP[N-1], dpN[N-1]))


Measured memory_bytes: 17628
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<H(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define pll				pair <ll,ll>
#define vii				vector <pll>
#define PI				double PPPPPP = 3.14159265358979323846;
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
void solve(){
	ll n;
	cin>>n;
	ll ans=pow(n,3);
	cout<<ans;
}
int main() {
	run();
	int t=1;
	///cin>>t;
	while(t--)solve();

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long int a[200000];
int main() {
	//B
	int n;
	cin >> n;

	long long int bou = 0, habou = 0;
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		bou = bou + a[i];
	}
	for (i = 0; i < n; i++) {
		habou = habou + a[i];
		if (habou * 2 >= bou)break;
	}
	if (bou - (habou - a[i]) * 2 < habou * 2 - bou) {
		cout << bou - (habou - a[i]) * 2;
	}
	else {
		cout << habou * 2 - bou;
	}

	return 0;


	//A
	/*int money = 0;
	int x, y;
	cin >> x >> y;
	if (x == 1 && y == 1)
		money = 1000000;
	else 
	{
		if (x <= 3) {
			money = (4 - x) * 100000;
		}
		if (y <= 3) {
			money = money + (4 - y) * 100000;
		}
	
	}
	cout << money << endl;
	return 0;
	*/
}

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

map<long, int> pf(long n) {
  map<long, int> ma;
  for (long i = 2; i * i <= n; i++) {
    while (n % i == 0) ma[i]++, n /= i;
  }
  if (n != 1) ma[n]++;
  return ma;
}

int main() {
  long N;
  cin >> N;
  auto MA = pf(N);
  long ans = 0;
  for (auto[a, b] : MA) {
    int i = 1, cnt = 0;
    while (b >= i) b -= i++, cnt++;
    ans += cnt;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
#define INF 1000000
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<int, int> P;

struct edge{ int u, v; lli cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
	vector< vector<lli> > distance_matrix;
};


template <typename T>
vector<int> argsort(const vector<T> &v) {

  // initialize original index locations
  vector<int> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](int i1, int i2) {return v[i1] < v[i2];});

  return idx;
}

template<typename T>
void displayVector(vector<T> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}

int count_comb(int a, int b, int c){
  if(a!=b && b!=c){ return 6; }
  else if( a==b && b==c){ return 1; }
  else{ return 3; }
}

string sub(string str, int start, int end){
  // require : start < end
  return str.substr(start, end-start+1);
}

struct C{ int a; int b; };

int main(){
  int a,b,c; cin >> a >> b >> c;
  int k; cin >> k;
  int jud = 0;

  REP(i, k){
    if(a < b){
      if(b < c){ jud=0; break; 
      } else{
        c *= 2;
      }
    } else{
      b *= 2;
    }
  }
  if( a<b && b<c ){ jud=1; }

  if(jud){ cout << "Yes" << endl; 
  } else{ cout << "No" << endl; }
  return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    if (n >= m) {
        cout << 0 << endl;
        exit(0);
    }

    vector<int> x(m), b(m - 1);
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());

    for (int i = 0; i < m - 1; i++) {
        b[i] = x[i + 1] - x[i];
    }
    sort(b.begin(), b.end());

    int s = 0;
    for (int i = 0; i < m - n; i++) {
        s += b[i];
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<double> x(n);
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        x[i]=tmp;
    }
    sort(x.begin(), x.end());

    for(i=1; i<n; i++) {
        x[i]=(x[i-1]+x[i])/2.0;
    }
    printf("%.10lf\n", x[n-1]);


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define mod 998244353
using namespace std;
int n, i;
char s[105];
int d[105], a[105][105];
int modul(int x){
    if(x >= mod){
        return x - mod;
    }
    return x;
}
int solve(char s[], int n){
    int i, j, ii, jj;
    int a[105][105];
    for(i = 1; i <= n; i++){
        for(j = i + 1; j <= n; j++){
            a[i][j] = 0;
        }
    }
    char v[105];
    for(ii = 1; ii <= n / 2; ii++){
        for(i = 1; i <= n - 2 * ii + 1; i++){
            for(j = i; j < i + ii; j++){
                v[j - i + 1] = s[j];
            }
            jj = 1;
            for(j = i + ii; j <= n; j++){
                v[jj] &= s[j];
                if(jj == ii){
                    jj = 0;
                    a[i][j] = modul(a[i][j] + solve(v, ii) );
                }
                jj++;
            }
        }
    }
    d[0] = 1;
    for(i = 1; i <= n; i++){
        d[i] = modul(d[i - 1] * (s[i] + 1) );
        for(j = i - 1; j > 0; j--){
            d[i] = (d[i] + d[j - 1] * 1LL * a[j][i]) % mod;
        }
    }
    return d[n];
}
int main(){
    cin>> s + 1;
    n = strlen(s + 1);
    for(i = 1; i <= n; i++){
        s[i] -= '0';
    }
    cout<< solve(s, n);
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
   int N, Ncopy, SN, Div;

   scanf("%d", &N);

   Ncopy = N;
   SN = 0;
   Div = 10;
   while(Ncopy != 0 ){   
       SN += Ncopy % Div;
       Ncopy /= Div;
   }
   
   if( N % SN == 0 ){
      printf("Yes\n");
   }
   else{
      printf("No\n");
   }
}

Measured memory_bytes: 128
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;

void main() {
    size_t n;
    string s1, s2;
    readf("%d\n%s\n%s\n", &n, &s1, &s2);
    auto a1 = s1.split.map!(to!int).array;
    auto a2 = s2.split.map!(to!int).array;
    foreach (i; 1..n) {
        a1[i] += a1[i-1];
        a2[n-i-1] += a2[n-i];
    }
    a1[] += a2[];
    sort(a1);
    writeln(a1[n-1]);
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author SimplyDivine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < m; i++) {
                int e1 = in.nextInt() - 1;
                int e2 = in.nextInt() - 1;
                a[e1]++;
                a[e2]++;
            }

            for (int num : a) {
                out.println(num);
            }
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21204
#include<iostream>

using namespace std;

int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  
  int total = 0;
  for(int i = 0;i<=n;i++){
    int number = i;
    int keta_total = 0;
    while(number != 0){
      keta_total += number%10;
      number = number/10;
    }
    if(a <= keta_total && keta_total <= b)total += i;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    char c;
    cin>>c;
    cout<<(c - 'a' >= 0 ? 'a' : 'A')<<endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

bool primes[(int)1e6];

int
main()
{
  long int n;
  cin >> n;
  
  if ( n == 1 ) { cout << 0 << endl; return 0; }
  int max_v;
  for ( max_v = 1 ; (long int)max_v * (long int)max_v <= n ; ++max_v );
  {
    for ( int i = 2 ; i <= max_v ; ++i ) primes[i] = true;
    primes[0] = primes[1] = false;
    for ( int i = 2 ; i <= max_v ; ++i ) {
      if ( primes[i] ) {
        for ( int j = i + i ; j <= max_v ; j += i ) primes[j] = false;
      }
    }
  }
  
  int ans = 0;
  for ( int p = 2 ; p <= max_v ; ++p ) {
    if ( primes[p] == false ) continue;
    int div_num = 0;
    while( n % p == 0 ) {
      n /= p;
      div_num++;
    }
    int p_ans;
    for ( p_ans = 1 ; p_ans * ( p_ans + 1 ) <= div_num * 2 ; ++p_ans );
    ans += p_ans - 1;
  }
  if ( 1 < n ) ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 4620
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>

using namespace std;

long long value[100016] = {0};

int main() {
	int N, W;
	scanf("%d%d", &N, &W);
	for(int i=0; i<N; ++i) {
		int w, v;
		scanf("%d%d", &w, &v);
		for(int j=W-w; 0<=j; --j) {
			value[j+w] = max(value[j+w], value[j]+v);
		}
	}
	long long ret = 0;
	for(int i=0; i<=W; ++i) {
		ret = max(ret, value[i]);
	}
	printf("%lld\n", ret);
	return 0;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	queue<int> q;
	q.push(0);
	const int inf = 1e9;
	vector<int> d(n, inf);
	d[0] = 0;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (auto nv : g[v]) {
			if (d[nv] != inf) continue;
			d[nv] = d[v] + 1;
			q.push(nv);
		}
	}

	// priority_queue<pii, vector<pii>> q;
	// q.push(make_pair(0, 0));
	// vector<int> d(n, 1e9);
	// d[0] = 0;
	// while (!q.empty()) {
	// 	pii p = q.top();
	// 	q.pop();
	// 	if (d[p.second] < p.first) continue;
	// 	for (auto a : g[p.second]) {
	// 		if (d[a] > p.first + 1) {
	// 			d[a] = p.first + 1;
	// 			q.push(make_pair(d[a], a));
	// 		}
	// 	}
	// }

	if (d[n - 1] <= 2) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE " << endl;
	return 0;
}

Measured memory_bytes: 16064
N = int(raw_input())
nums = map(int, raw_input().split(" "))

count = 0
for i in range(0, len(nums)):
    for j in range(len(nums)-1, i, -1):
        if nums[j-1] > nums[j]:
            temp = nums[j-1]
            nums[j-1] = nums[j]
            nums[j] = temp
            count += 1

nums = map(str, nums)
print(" ".join(nums))
print(count)

Measured memory_bytes: 6456
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <random>
#include <stack>
#include <ctime>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

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

    if (b >= a) cout << a << endl;
    else cout << a - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio : writeln, write, stdin;
import std.array;
import std.range;
import std.algorithm : filter, min;

int INF = 1<<28;

int solve(int[][] map, int n){
	int ptr = 0;
	bool[] done = new bool[n];
	int[] last = new int[n];
	int[] list = repeat(INF).take(n).array;
	list[ptr] = 0;
	while(true){
		int min_ = INF;
		for(int i=0; i<n; ++i){
			if(!done[i]){
				if(list[i] < min_){
					min_ = list[i];
					ptr = i;
				}
			}
		}
		if(min_==INF){ break; }
		
		done[ptr] = true;
		for(int i=0; i<n; ++i){
			if(!done[i]){
				if(map[ptr][i] < INF){
					if(map[ptr][i] < list[i]){
						list[i] = map[ptr][i];
					}
				}
			}
		}
	}
	assert(filter!(a => a==INF)(list).array.length==0);
	
	int count = 0;
	foreach(ite; filter!(a => a!=0)(list).array){
		count += ite -1;
	}
	
	return count;
}

void main(){
	while(true){
		delim = "\n";
		int n = next!int();
		
		if(n==0){ break; }
		
		int m = next!int();

		int[][] map;
		foreach(i; n.iota){
			map ~= repeat(INF).take(n).array;
		}
		delim = ",";
		for(int i=0; i<m; ++i){
			int a = next!int();
			int b = next!int();
			int d = next!int()/100;
			
			map[a][b] = d;
			map[b][a] = d;
		}
		
		solve(map, n).writeln;
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

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


dp = [0] * (N + 1)
dp[0] = 1

# 行けない段
for ai in a:
    dp[ai] = -1

for i in range(1, N + 1):
    # 1段目だけ例外処理
    if i == 1:
        dp[1] += dp[0]

    elif i > 1 and dp[i] != -1:
        if dp[i - 2] != -1:
            dp[i] += dp[i - 2]
        if dp[i - 1] != -1:
            dp[i] += dp[i - 1]

print(dp[N] % (10**9 + 7))


Measured memory_bytes: 468328
#include<iostream>
#include<string>
   
using namespace std;
   
int main(){
    int n;
    int a[100],b[100];
    int x,y,v;
    while(true){
    cin>>n;
    if(n==0)
        break;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int tmp;
  for (int i=0;i<n;i++) { 
    for (int j=i+1;j<n;j++) { 
      if (a[i]>a[j]) { 
        tmp=a[i]; 
        a[i] =a[j]; 
        a[j] = tmp; 
      } 
    } 
  }
  int s=1;
  for(int i=0;i<n;i++){
      while(true){
          int d=0;
      for(int j=0;j<n;j++){
          if(a[j]!=s)
              d++;
      }
      if(d==n){
          b[i]=s;
          s++;
          break;
      }
      s++;
      }
  }
  x=n-1;
  y=n;
  v=a[0];
  a[0]=0;
  while(true){
      int i=0;
      while(true){
          if(i==n){
              v=0;
              break;
          }
          if(b[i]>v){
              v=b[i];
              b[i]=0;
              y--;
              break;
          }
          i++;
      }
      if(y==0)
          break;
      int j=0;
      while(true){
          if(j==n){
              v=0;
              break;
          }
          if(a[j]>v){
              v=a[j];
              a[j]=0;
              x--;
              break;
          }
          j++;
      }
      if(x==0)
          break;
    }
      cout<<y<<endl;
      cout<<x<<endl;
    }
    return 0;
} 

Measured memory_bytes: 1160
import java.util.Scanner;
import java.util.HashMap;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	String sentence = scan.nextLine();
	String[] words = sentence.split(" ");
	HashMap<String, Integer> map = new HashMap<String, Integer>();
	String word;
	int maxLen = 0, mostFrequently = 0;
	Integer cnt;
	String mostFrequentlyWord = "", maxLenWord = "";
	for (int i = 0; i < words.length; i++) {
	    word = words[i];
	    cnt = map.get(word);
	    if (cnt == null) {
		map.put(word, 1);
		if (maxLen < word.length()) {
		    maxLen = word.length();
		    maxLenWord = word;
		}
	    } else {
		int num = map.put(word, cnt+1) + 1;
		if (mostFrequently < num) {
		    mostFrequently = num;
		    mostFrequentlyWord = word;
		}
	    }
	}
	System.out.println(mostFrequentlyWord + " " + maxLenWord);
    }
}

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

int main() {
	int n;
	while (cin >> n) {
		int c = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					for (int l = 0; l < 10; l++) {
						int m = i + j + k + l;
						if (m == n) c++;
					}
				}
			}
		}

		cout << c << endl;
	}
}


Measured memory_bytes: 3088