akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    if(a<10&&b<10){
        cout << a * b << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		run();
	}
	static void run(){
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		if(a.equals("a") || a.equals("i") || a.equals("u") || a.equals("e") || a.equals("o")){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 10064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,a;
    cin >> n >> a;
    cout << n*n - a << endl;
    return 0;
}

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

int main(void)
{
    long long N,M,K,X,count=0;
    vector<long long> A,B,c;

    cin >> N >> M >> K;
    
    A.push_back(0);
    for(int i=1;i<=N;i++)
    {
        cin >> X;
        A.push_back(X+A[i-1]);
    }
    B.push_back(0);
    for(int i=1;i<=M;i++)
    {
        cin >> X;
        B.push_back(X+B[i-1]);
    }
    int ans=0;
    for(int i=0,j=0;i<=N;i++)
    {
        if(K<A[i])
        {
            break;
        }
        int left=0,right=M,mid;
        while(left<=right)
        {
            mid=(left+right)/2;
            if(A[i]+B[mid]<=K)
            {
                ans=max(i+mid,ans);
                left=mid+1;
            }
            else
            {
                right=mid-1;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7992
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int fibo[44], n, i;
    
    cin >> n;
    
    fibo[0] = 1;
    fibo[1] = 1;
    
    i = 0;
    while (i <= n) {
        if (i > 1) fibo[i] = fibo[i-2] + fibo[i-1];
        i++;
    }
    
    cout << fibo[n] << endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define fcout cout << fixed << setprecision(10)
ll digsum(ll n){
    ll a=0;
    while (n) {
        a+=n%10;
        n/=10;
    }
    return a;
}
int main(){
    ll n;
    cin>>n;
    ll wave=1;
    ll cnt=1;
    while (n) {
        if((double)cnt/digsum(cnt)<=(double)(cnt+wave)/digsum(cnt+wave)){
            cout<<cnt<<endl;
            n--;
            cnt+=wave;
        }
        else{
            wave*=10;
            cnt=(cnt/wave+1)*wave-1;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int N,X;
   cin >> N >>X;
   vector<int>m(N);
   FOR(i,N)cin >> m[i];
   sort(m.begin(),m.end());
   ll ans = 0;
   FOR(i,N){
      X-=m[i];
      ans++;
   }
   while(X >= m[0]){
      X -= m[0];
      ans++;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var S = Console.ReadLine();
            var ans = 0;
            foreach (var c in S)
            {
                ans = c == '+' ? ans + 1 : ans - 1;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main() {
    ll S;  cin >> S;
    
    ll x2, y2, x3, y3;
    ll v = 1000000000;
    x2 = v;
    y2 = 1;
    x3 = (v - S % v) % v;
    y3 = (S + x3) / v;

    cout << 0 << ' ' << 0 << ' ';
    cout << x2 << ' ' << y2 << ' ';
    cout << x3 << ' ' << y3 << endl;

    return 0;
}



Measured memory_bytes: 256
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
	var N = one[0];
	var A = one[1];
	var B = one[2];
	var output = 0;
	for(var i = 0; i < N; i++){
		var tmp = nextInt();
		if(tmp < A || B <= tmp){
			output++;
		}
	}
	myout(output);
}

Measured memory_bytes: 7372
from sys import stdin

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

s = S()

ans = ''
for i in range(len(s)):
    if s[i] == '0' or s[i] == '1':
        ans += s[i]
    else:
        ans = ans[0:len(ans)-1]

print(ans)

Measured memory_bytes: 9140
# Edit: 2014/09/09
# Lang: Python3
# Time: .00s

from math import factorial

if __name__ == "__main__":
    r, c, ar, ac, br, bc = map(int, input().strip("\n").split(" "))
    maxans = 100000007  # 100,000,007

    # tate Row
    dr = min(abs(br - ar), r - abs(br - ar))
    if 2 * dr == r:
        gainr = 2
    else:
        gainr = 1

    # yoko Column
    dc = min(abs(bc - ac), c - abs(bc - ac))
    if 2 * dc == c:
        gainc = 2
    else:
        gainc = 1

    #dr = int(dr)
    #dc = int(dc)
    #gainr = int(gainr)
    #gainc = int(gainc)

    # print(dr, dc)
    # print(gainr, gainc)

    #ans1 = factorial(dr+dc)
    #print("ans1",ans1)
    #print("type",type(ans1))

    #ans2 = factorial(dr)
    #print("ans2",ans2)
    #print("type",type(ans2))

    #ans3 = factorial(dc)
    #print("ans3",ans3)
    #print("type",type(ans3))

    #ans4 = ans1//ans2//ans3*gainr*gainc
    #print("ans4",ans4)
    #print("type",type(ans4))

    #ans = ans4
    ## ans = factorial(dr + dc) / factorial(dr) / factorial(dc) # * gainr * gainc
    # python overflow error integer division result too large for a float

    ans = factorial(dr + dc) // factorial(dr) // factorial(dc) * gainr * gainc


    # t = 1
    #for i in range(dr, dr + dc):
    #print(t)
    #    t *= i
    #ans = t / factorial(dc) * gainr * gainc

    #print(ans)
    #print(ans, type(ans))
    print(ans % maxans)

    # print("34807775")
    #67,352,549

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

int cnt, n, s;
bool used[10];

void rec(int pos, int t, int sum ){
    if ( t == n ){
	if ( sum == s ) cnt++;
	return;
    }
    if ( pos > 9 ) return;

    rec(pos+1, t, sum);
    rec(pos+1, t+1, sum + pos);
}   
 
main(){
    while( cin >> n >> s ){
	if ( n == 0 && s == 0 ) break;
	cnt = 0;
	rec(0,  0, 0);
	cout << cnt << endl;
    }
}

Measured memory_bytes: 0
import itertools
N,X,Y = map(int,input().split())
C = list(itertools.combinations(range(1,N+1),2))
ansdic = {i:0 for i in range(1,N)}
#print(C)
for i in C:
    a = i[0]
    b = i[1]
    tmpxy = abs(X - a) + 1 + abs(Y - b)
    tmp = b - a
    #print(a,b,min(tmpxy,tmp))
    ansdic[min(tmpxy,tmp)] += 1
    #print(ansdic)
for i in ansdic.keys():
    print(ansdic[i])

Measured memory_bytes: 148452
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly int INFTY = int.MaxValue / 2;
        static int n, all;
        static int[,] map, dp;
        static int[] bitIdx;

        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int V = input[0];
            int E = input[1];

            n = V;
            map = new int[n, n];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    map[i, j] = INFTY;
                }
            }

            for (int i = 0; i < E; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                map[input[0], input[1]] = input[2];
            }

            bitIdx = new int[n];
            bitIdx[1] = 1;
            for (int i = 2; i < n; i++) bitIdx[i] = bitIdx[i - 1] << 1;

            all = (bitIdx[n - 1] << 1) - 1;

            dp = new int[n, all + 1];

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j <= all; j++)
                {
                    dp[i, j] = INFTY;
                }
            }

            int res = TSP(0, 0);
            Console.WriteLine(res != INFTY ? res : -1);
        }

        static int TSP(int s, int mask)
        {
            if (mask == all) return map[s, 0];
            if (dp[s, mask] < INFTY) return dp[s, mask];

            int min = INFTY;
            for (int i = 1; i < n; i++)
            {
                if ((mask & bitIdx[i]) != 0 || map[s, i] == INFTY) continue;

                int d = TSP(i, (mask | bitIdx[i]));

                if (d == INFTY) continue;

                min = Math.Min(min, d + map[s, i]);
            }
            dp[s, mask] = min;
            return min;
        }
    }
}

Measured memory_bytes: 10196
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>

using namespace std;

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    ll ans = K;
    rep(i, N-1) ans *= (K-1);
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
n=int(input())
h=[int(i) for i in input().split()]
inf=10**10
dp=[inf]*n
def rec(i):
  if dp[i]<inf:
    return dp[i]
  elif i==0:
    return 0
  res=inf
  res=min(inf,rec(i-1)+abs(h[i]-h[i-1]))
  if i>1:
    res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
  dp[i]=res
  return res
print(rec(n-1))


Measured memory_bytes: 94208
a=int(input())
b=int(input())
c=int(input())
x=int(input())

#3重ループする
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k==x:
                ans+=1

print(ans)
       
       

Measured memory_bytes: 3060
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int digitSum(int n,int digit=8) {
	// digit > 2
	int x = 1;
	FOR(i,0,digit){
		x *= 10;
	}
	int sum = 0;
	FOR(i, 0, digit) {
		sum += n / x;
		n %= x;
		x /= 10;
	}
	sum += n;
	return sum;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
map<int,int> mp;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll ans = 0,n;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        ll a;
        cin >> a;
        ans += mp[a-i];
        mp[-1*a-i]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20728
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

lin x, y;

int main(void)
{
    cin >> x >> y;

    if (x % y == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    lin ed = 1;
    rep(i, 18)
    {
        ed *= 10;
    }

    lin ans = x * 2;
    while (ans <= ed)
    {
        if (ans % y != 0)
        {
            cout << ans << endl;
            return 0;
        }

        ans += x;
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect
A,B,Q=map(int, input().split())
s=[int(input()) for _ in range(A)] + [10**11]
t=[int(input()) for _ in range(B)] + [10**11]
for _ in range(Q):
	x = int(input())
	ans = []
	ps = bisect(s, x)
	pt = bisect(t, x)
	for vs in (s[ps], s[ps-1]):
		for vt in (t[pt], t[pt-1]):
			ans.append(abs(x - vs) + abs(vs - vt))
			ans.append(abs(x - vt) + abs(vt - vs))
	print(min(ans))


Measured memory_bytes: 12820
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int a, v, n;
	int max_v = -1;
	int max_a = -1;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> a >> v;
#else
		std::cin >> a >> v;
#endif
		if(max_v < v){
			max_v = v;
			max_a = a;
		}
		else if(max_v == v && max_a > a){
			max_a = a;
		}
	}
 
	std::cout << max_a << " " << max_v << std::endl;

#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	
	int n,a,b,i,j,mn=-1;
	cin>>n;
	vector<int> ar[n+1];
	vector<pair<int,int>> v;
	
	for(i=0;i<n-1;i++)
		cin>>a>>b , ar[a].pb(b) , ar[b].pb(a) , v.pb({a,b});
	
	for(i=1;i<=n;i++)
	{
		int tmp=ar[i].size();
		mn=max(mn,tmp);
	}
	
	int vis[mn];
	map<pair<int,int>,int> mp,ans;
	
	for(i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		
		for(auto el : ar[i])
		{
			if(ans.find({i,el})!=ans.end())
				vis[ans[{i,el}]-1]=1;
			else if(ans.find({el,i})!=ans.end())
				vis[ans[{el,i}]-1]=1;
		}
		
		for(auto el : ar[i])
		{
			if(mp.find({i,el})==mp.end() && mp.find({el,i})==mp.end())
			{
				int start = lower_bound(vis,vis+mn,0)-vis;
				for(j=start;j<ar[i].size();j++)
				{
					if(vis[j]==0)
					{
						ans[{i,el}]=ans[{el,i}]=j+1;
						vis[j]=1;
						mp[{el,i}]=mp[{i,el}]=1;
						break;
					}
				}
			}
		}
	}
	
	cout<<mn<<"\n";
	for(auto pair : v)
		cout<<ans[pair]<<"\n";
	return 0;
}


Measured memory_bytes: 34480
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}// 改行付き出力


constexpr long double pi = 3.1415926535897932384626433832795028841;
#define double long double
double f(double a,double b,double t){
  if(t > pi / 2 - 0.0000000001)return 0;
  if(a*tan(t)<=b){
    return a*a*b - a*a*a*tan(t)/2;
  }else{
    return b*b / tan(t)*a / 2;
  }
}


// TODO: write
int main() {
  int a,b,x;cin>>a>>b>>x;
  double ok = pi/2;
  double ng = 0;
  rep(i,1000000){
    double mid = (ok+ng)/2.0;
    if(f(a,b,mid)<x) ok = mid;
    else ng = mid;
  }
  print(ok / pi*180);
  return 0;
}

Measured memory_bytes: 4160
N = int(input())
A = [int(x) for x in input().split()]

for i in range(N) :
    A[i] -= i

A.sort()
if N%2 == 1 :
    med = A[N//2]
else :
    med = (A[N//2 - 1] + A[N//2]) // 2

ans = 0
for i in range(N) :
    ans += abs(A[i] - med)

print(int(ans))


Measured memory_bytes: 25196
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");

	// 変数宣言
	var H = parseInt(input[0].split(" ")[0], 10);
	var W = parseInt(input[0].split(" ")[1], 10);
	var h = parseInt(input[1].split(" ")[0], 10);
	var w = parseInt(input[1].split(" ")[1], 10);

	// 計算
	var sum = (H - h) * (W - w);

	//出力
	console.log('%d',sum);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

    int N;
    cin >> N;
    int V[N], C[N];
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }
    int max_val = 0;
    for (int i = 0; i < 1 << N; ++i) {
        int num = i;
        int val = 0;
        for (int j = 0; j < N; ++j) {
            if (num & 1 == 1) {
                val += V[j] - C[j];
            }
            num /= 2;
        }
        max_val = max(max_val, val);
    }

    cout << max_val << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#define M 1000000
using namespace std;
int a[M]={0};
int main()
{
    int n,i,j,k=0,l;

    a[0]=1;
    a[1]=1;
    for(i=2;i<=M;i++){
        for(j=2;i*j<M && a[i]!=1;j++){
            a[i*j]=1;
        }
    }
    while(cin>>n)
    {
        k=0;


    for(i=1;i<=n;i++){
        if(a[i]==0)k++;
    }
    cout<<k<<endl;
    //k=0;
    }



    return 0;
}

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

using namespace std;
using ll =long long;

//Write From this Line

int main()
{
	//sをk回出力する
	//それ以降はsより大きい数を出力すれば良い
	int n, k , s ;
	cin >> n >> k >>  s;
	int yes = s ;
	int no = s+1 ;
	if (s== 1e9) no = 7 ;
	for(int i = 0 ; i < n ; i++){
		if(i < k){
			cout << yes ;
		}
		else{
			cout << no ;
		}
		if( i < n -1 ) {
			cout <<" ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 1280
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll A;
ll B;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> A;
    cin >> B;
    solve();
}

// 1 <= A <= 100
// 1 <= B <= 100
// 入力は全て整数である。

// ll A, ll B
// 値 A × B を整数として出力せよ。
void solve(){
    cout<<A*B<<endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll INF = 1e15;


int main() {
	ll n, k;
	cin >> n >> k;
	vector<bool> has(n, false);
	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int a;
			cin >> a;
			a--;
			has[a] = true;
		}
	}
	ll sum = 0;
	rep(i, n) {
		if (!has[i]) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main()
{
    int n;

    // data (from stdin)
    long a,b,ans;
        ans=0;
    std::cin >> n;
    vector<long> v,u,x;
    for (int i=0; i<n; ++i){
        std::cin >> a;
        v.push_back(a);
        u.push_back(a-(i+1));
    }
    std::sort(u.begin(), u.end());
    if(n%2==0){b=u[n/2];}
    else {b=u[(n-1)/2];}
    for (int j=1;j<=n; j++){
        ans += abs(v[j-1]-(j+b));
    }
    std::cout << ans << endl;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
using ll = long long;
typedef pair<ll, ll> P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*def*/
ll dpa[100100];
ll dpb[100100];
ll dpc[100100];
ll n;
ll a, b, c;

int main() {
/*input*/
    cin >> n;

    rep(i, 100100){
        dpa[i] = LLONG_MIN;
        dpb[i] = LLONG_MIN;
        dpc[i] = LLONG_MIN;
        }
    dpa[0] = 0;
    dpb[0] = 0;
    dpc[0] = 0;

/*main貰うdp*/
    for(int i = 1; i <= n; i++){
        cin >> a >> b >> c;
        dpa[i] = max({dpa[i], dpb[i-1] + a, dpc[i-1] + a});
        dpb[i] = max({dpb[i], dpc[i-1] + b, dpa[i-1] + b});
        dpc[i] = max({dpc[i], dpa[i-1] + c, dpb[i-1] + c});
    }

/*output*/
/* for debug
    for(int i = 1; i<=n;i++){
        cout << dpa[i]<< " " << dpb[i]<< " " << dpc[i] << endl;
    }
*/
    cout << max({dpa[n], dpb[n], dpc[n]}) << endl;
    return 0;
}


Measured memory_bytes: 5900
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int a, b, c;
		int temp;
		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();

		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		if(b > c){
			temp = b;
			b = c;
			c = temp;
		}
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}

		System.out.println(a + " " + b + " " + c);
	}
}


Measured memory_bytes: 26416
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef float f;
using namespace std;

void solve()
{   ull ans,a,c;f b;
    cin >> a >> b;
    c=b*100+0.5;
    ans=(a*c)/100;
    cout << ans;
}

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


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

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	String[] ary = new String[n];
    	List<String> ans = new ArrayList<String>();
    	for(int i = 0; i < n; i++){
    		String s = sc.next();
    		ary[i] = s;
    	}
    	sc.close();
    	Arrays.sort(ary);
    	Set<String> set = new HashSet<String>(Arrays.asList(ary));
    	if(ary.length == set.size()){
    		for(int i = 0; i < ary.length; i++){
        		System.out.println(ary[i]);
        	}
    		return;
    	}
    	int maxcnt = 0;
    	int cnt = 0;
    	ans.add(ary[0]);
    	for(int i = 0; i < n-1; i++){
    		if(ary[i].equals(ary[i+1])){
    			cnt++;
    		}else{
    			cnt = 0;
    		}
    		if(maxcnt == cnt){
    			ans.add(ary[i]);
    		}else if(maxcnt < cnt){
    			maxcnt = cnt;
    			ans.clear();
    			ans.add(ary[i]);
    		}
    	}
    	for(int i = 0; i < ans.size(); i++){
    		System.out.println(ans.get(i));
    	}
    }
}

Measured memory_bytes: 82728
#include<bits/stdc++.h>
using namespace std;
#define ff(i,n) for(i=0;i<n;i++)
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg=998244353;
ll power(ll x,ll y)
{
	ll ss=1;
	if(y==0)
	return ss;
	ll h=(power(x,y/2))%bg;
	h=(h*h)%bg;
	ll gg=(x*h)%bg;
	if(y%2==1)
	 return gg;
	else
	 return h;
}
ll modinv(ll k)
{
	return (power(k,bg-2))%bg;
}
ll dp[500001];
int main()
{
    ll n;
	cin>>n;
	ll h=(n+1)/2;
	cout<<h;  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n;
	cin>>n;
	cout<<n+n*n+n*n*n;
}	
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

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

using namespace std;

int main(void) {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        sort(a.begin(), a.end());

        int ans = 1e9;
        for (int i = 1; i < n; i++)
            ans = min(ans, a[i] - a[i - 1]);
        
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            Yes;
            return 0;
        }
        a-=d;
        if(a<=0){
            No;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, M);
  print(48 - M);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	string S;
	cin >> S;

	ll kotae = 0;
	int a = 0;
	char mae = 'A';
	rep(i, S.size()) {
		if (S[i] == 'A') {
			if (mae == 'B') {
				a = 0;
				a++;
			}
			else {
				a++;
			}
		}
		else if (S[i] == 'B') {
			if (mae == 'B') {
				a = 0;
			}
		}
		else {
			if (mae == 'B') {
				kotae += a;
			}
			else {
				a = 0;
			}
		}
		ce(a);
		mae = S[i];
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 720
public class Hello
{
    public static void Main()
    {

        int s = int.Parse(System.Console.ReadLine());
        string k = System.Console.ReadLine();
        if (k.Length > s)
        {
            k = k.Substring(0, s) +  "...";
        }
 
        System.Console.WriteLine(k);


    }
}

Measured memory_bytes: 27472
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  map<ll, ll, greater<ll>> mp;
  rep(i, n) {
    ll a;
    cin >> a;
    mp[a]++;
  }
  rep(i, m) {
    ll b, c;
    cin >> b >> c;
    mp[c] += b;
  }
  ll cnt = 0;
  ll ans = 0;
  for(auto v : mp) {
    ll i = v.first;
    ll j = min(n - cnt, v.second);
    ans += i * j;
    cnt += j;
    if(cnt == n) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
   
public class Main {
     
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
     
    public void exec() throws IOException {
        SimpleInputUtil in = new SimpleInputUtil();
        PrintWriter out = new PrintWriter(System.out);
        out.print(new SectionDiagram().analyze(in.br.readLine()));
        out.flush();
    }
}

class SectionDiagram {
	public static final String EOF = System.lineSeparator();

	Deque<Integer> downhillDeque = new ArrayDeque<>();
	Deque<WaterHazardElement> waterHazardDeque = new ArrayDeque<>();
	int A = 0;
	int k = 0;
	String L = "";
	
	public SectionDiagram analyze(String s) {
		int len = s.length();
		for(int i=0; i<len; i++) {
			switch(s.charAt(i)) {
			case '\\':
				downhillDeque.push(i);
				break;
			case '/':
				if(!downhillDeque.isEmpty()) {
					int start = downhillDeque.pop();
					WaterHazardElement wh = new WaterHazardElement(start,i);
					while(true) {
						if(!waterHazardDeque.isEmpty()){
							WaterHazardElement whPre = waterHazardDeque.getFirst();
							if(wh.include(whPre)) {
								wh.merge(whPre);
								waterHazardDeque.removeFirst();
							} else {
								waterHazardDeque.addFirst(wh);
								break;
							}
						}else{
							waterHazardDeque.addFirst(wh);
							break;
						}
					}
				}
				break;
			}
		}
		
		StringBuilder sbL = new StringBuilder();
		for(int i=0; !waterHazardDeque.isEmpty(); i++){
			int c = waterHazardDeque.removeLast().getCapacity();
			A += c;
			k++;
			sbL.append(" ").append(c);
		}
		L = sbL.toString();
		return this;
	}
	
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(A).append(EOF);
		sb.append(k).append(L).append(EOF);
		return sb.toString();
	}
	
}

class WaterHazardElement {
	int st = -1;
	int ed = -1;
	int childCapacity = 0;
	
	public WaterHazardElement(int st, int ed) {
		this.st = st;
		this.ed = ed;
	}
	
	public void merge(WaterHazardElement s) {
		childCapacity += s.getCapacity();
	}
	
	public int getCapacity() {
		return childCapacity + ed - st;
	}
	
	public boolean include(WaterHazardElement s) {
		return this.st < s.st && s.ed < this.ed;
	}
	
}
 
class SimpleInputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
        return br.readLine().split(delim);
    }
     
    public int readInt() throws NumberFormatException, IOException{
        return Integer.parseInt(br.readLine());
    }
     
    public int[] readIntArray(int[] a) throws NumberFormatException, IOException{
        int i=0;
        while(i<a.length) {
            for(String s: br.readLine().split(" ")){
                if(i<a.length) {
                    a[i++] = Integer.parseInt(s);
                }
            }
        }
        return a;
    }
 
     
}

Measured memory_bytes: 25812
K=int(input())
num=7
count = 0
checkK = [0 for j in range(K)]
result = ""

flag = True
while(flag):
    count += 1
    if num%K==0:
        flag = False
        result = str(count)
    num = (num*10+7)%K
    checkK[num] += 1
    if checkK[num] == 2:
        flag = False
        result = "-1"
print(result)

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

b = list(map(int, input().split()))
b.insert(0, 9999999)

ans = 0
for i in range(1, len(b)):
    if b[i] < b[i-1]:
        ans += b[i]
    else:
        ans += b[i-1]
ans += b[-1]
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define met(a,x) memset(a,x,sizeof(a))
#define inf 0x3f3f3f3f
//met(dp,0x7F);
using namespace std;
const int mod=1e9+7;
const int N=1e6+10;
int a[300010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int i,j,k,m,n;
    cin>>k>>n;
    int cnt=n,ans;
    if(k%2)
    {
        for(int i=1; i<=n; i++)
            a[i]=(k+1)/2;
        for(int i=1; i<=n/2; i++)
        {
            if(a[cnt]==1)
                cnt--;
            else
            {
                a[cnt]--;
                for(int j=cnt+1; j<=n; j++)
                    a[j]=k;
                cnt=n;
            }
        }
        for(int i=1; i<=cnt; i++)
            printf("%d ",a[i]);
    }
    else
    {
        printf("%d ",k/2);
        for(int i=2; i<=n; i++)
            printf("%d ",k);
    }
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
long long dp[104][100005];
long long n,w;
vector<long long>peso,val;
long long rec(int el, int valor_actual){
    if(dp[el][valor_actual]!=-1)return dp[el][valor_actual];
    if(valor_actual<0)return INT_MAX/2;
    if(el==n){
        if(valor_actual==0)return 0;
        else return INT_MAX/2;
    }
    dp[el][valor_actual]=INT_MAX/2;
    dp[el][valor_actual]=min(dp[el][valor_actual],rec(el+1,valor_actual-val[el])+peso[el]);
    dp[el][valor_actual]=min(dp[el][valor_actual],rec(el+1,valor_actual));
    return  dp[el][valor_actual];
}
int main(){
    cin>>n>>w;
    memset(dp,-1,sizeof dp);
    peso.resize(n);
    val.resize(n);
    for(int i=0;i<n;i++){
        cin>>peso[i]>>val[i];
    }
    int ans = 0;
    for(int i = 0; i<=1e5; i++) {
        if(rec(0, i) <= w) {
            ans = i;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 81536
///                                                     ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define vec  vector
#define gcd  __gcd
#define pi   acos( -1 )
#define ll   long long
#define ld   long double
#define N    300256
#define M    1000000007
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define rep( a, b, c, d )  for( int a = b; a <= c; a += d )
#define rvv( a, b, c, d )  for( int a = b; a >= c; a -= d )
#define en                 printf( "\n" )
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() )
#define numcounts          __builtin_popcount
#define mxn( x, y, z )     max( x, min( y, z ) )
#define mnx( x, y, z )     min( x, max( y, z ) )
const int dx[ ] = { 1, -1, 0, 0 };
const int dy[ ] = { 0, 0, -1, 1 };
using namespace std;
ll ttt = 1;
int n, m, a[85][85], b;
bitset <25600> dp[85][85];
void solve()
{
    sc( "%d%d", &n, &m );
    for( int i = 0; i < n; i ++ )
        for( int j = 0; j < m; j ++ )
            sc( "%d", &a[i][j] );
    for( int i = 0; i < n; i ++ )
        for( int j = 0; j < m; j ++ )
        {
            sc( "%d", &b );
            a[i][j] = abs( b - a[i][j] );
        }
    dp[0][0][12800+a[0][0]] = 1;
    for( int i = 0; i < n; i ++ )
        for( int j = 0; j < m; j ++ )
        {
            if( i + 1 < n )
                dp[i + 1][j] |= dp[i][j] << a[i + 1][j] | dp[i][j] >> a[i + 1][j];
            if( j + 1 < m )
                dp[i][j + 1] |= dp[i][j] << a[i][j + 1] | dp[i][j] >> a[i][j + 1];
        }
    b = 0;
    while( !dp[n - 1][m - 1][12800 + b] && !dp[n - 1][m - 1][12800 - b] )b ++;
    pr( "%d", b );
}
int main()
{
    //sc( "%I64d", &ttt );
    for( int i = 0; i < ttt; i ++ )
        solve();
}


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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int c[10][10], s[10][10];
int q[201][201];
int a, b;


int solve(int cost, int p, int f) {
  rep(i, 0, 10) {
    if(cost + c[p][i] < c[f][i]) {
      c[f][i] = cost + c[p][i];
      solve(cost + c[p][i], i, f);
    }
  }
}

signed main() {
  cin >> a >> b;
  rep(i, 0, 10) rep(j, 0, 10) cin >> c[i][j];
  rep(i, 0, a) rep(j, 0, b) cin >> q[i][j];
  rep(i, 0, 10) {
    rep(j, 0, 10) {
      solve(c[i][j], j, i);
    }
  }
  ll ans = 0;
  rep(i, 0, a) {
    rep(j, 0, b) {
      if(q[i][j] == -1) continue;
      ans += c[q[i][j]][1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	string str;
	cin>>str;
	long long sum=0,flag=0;	
	int len=str.length();
	for(int i=0;i<len;){
		if(str[i]=='<'){
			long long t=1;
			while(str[++i]=='<')t++;
			flag=t;
			sum+=(t+1)*t/2;
		}
		if(str[i]=='>'){
			long long t=1;
			while(str[++i]=='>')t++;
			sum+=(t+1)*t/2;
			if(flag<t)sum-=flag;
			else sum-=t;
			flag=0;
		}		
	}
	printf("%lld\n",sum);
	return 0;
} 

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

#define MAX_V 105
#define INF 1e9

// ????????¨????§??????? (?????????, ??????, ??????)
struct edge {
    int to, cap, rev;
};

vector<edge> G[MAX_V]; // ??°???????????£??\???????????¨???
int level[MAX_V];           // s??????????????¢
int iter[MAX_V];            // ???????????§??????????????£??????

// from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

// s????????????????????¢???BFS??§?¨??????????
void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int i = 0; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

// ?¢?????????????DFS??§??¢???
int dfs(int v, int t, int f) {
    if (v == t)
        return f;
    for (int &i = iter[v]; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// s??????t???????????§???????±???????
int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        bfs(s);
        if (level[t] < 0)
            return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, INF)) > 0) {
            flow += f;
        }
    }
}


int main(){
    int V, E;
    cin >> V >> E;
    for(int i=0;i<E;++i){
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }

    cout << max_flow(0, V-1) << endl;

    return 0;
}


Measured memory_bytes: 3192
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
h = na()

ys = h[:] + [0]
ys.sort()

ys2 = []
for v in ys:
    if len(ys2) > 0 and ys2[-1] == v:
        continue
    ys2.append(v)
ys = ys2
m = len(ys)

dp = [[999999999999999999] * m for _ in range(k+1)]
dp[0][0] = 0

for v in h:
    ndp = [[999999999999999999] * m for _ in range(k + 1)]
    for i in range(k+1):
        plus = 99999999999999999
        for j in range(m):
            plus = min(plus + (ys[j] - ys[j-1] if j > 0 else 0), dp[i][j])
            if ys[j] == v:
                ndp[i][j] = min(ndp[i][j], plus)
            elif i+1 <= k:
                ndp[i+1][j] = min(ndp[i+1][j], plus)
        plus = 99999999999999999
        for j in range(m-1, -1, -1):
            plus = min(plus, dp[i][j])
            if ys[j] == v:
                ndp[i][j] = min(ndp[i][j], plus)
            elif i+1 <= k:
                ndp[i+1][j] = min(ndp[i+1][j], plus)
    dp = ndp

ans = min(min(row) for row in dp)
print(ans)


Measured memory_bytes: 139528