akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< LL > Div( LL n ) {
    vector< LL > ret;
    for( LL i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL n;
    cin >> n;
    vector< LL > div = Div( n );

    LL mn = LINF;
    int r = div.size() - 1;
    int l = 0;
    while( l <= r ) {
        mn = min( mn, div[l] - 1 + div[r] - 1 );
        ++l; --r;

    }
    cout << mn << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        cin>>a[i];
        c=max(c,a[i]);
    }
    rrrep(i,c,0){
        rep(j,n)b[j]=a[j];
        fl=true;
        rep(j,n){
            if(b[j]<i){
                fl=false;
                continue;
            }
            b[j]-=i;
            b[j+1]+=b[j];
        }
        if(!fl)continue;
        Cout(i);
        return 0;
    }
    return 0;
}



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


int main() {
	ll A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	ll M = max(X,Y);
	ll ans = min(A * X + B * Y, 2 * M * C);
	rep(z,2*M+1) {
		ll x = max(0LL, X - z/2LL);
		ll y = max(0LL, Y - z/2LL);
		ans = min(ans, A*x+B*y+C*z);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
let cnt = ref 0

let print_array a =
  Array.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) a;
  print_newline ()

let bubble_sort a n =
  let swap i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
  let rec bubble j flag =
    if j <= 0 then doit flag
    else if a.(j - 1) <= a.(j) then bubble (j - 1) flag
    else (swap j (j - 1); incr cnt; bubble (j - 1) true)
  and doit flag =
    if not flag then ()
    else bubble (n - 1) false
  in
  doit true

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (read_line ()))) in
  bubble_sort a n;
  print_array a;
  Printf.printf "%d\n" !cnt

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

using namespace std;
typedef long long ll;
ll t , k,n,x , y , a, b,c , d ,sum;
string s;
char ch;
int main()
{
    cin >> n;
    a=26;
    s="";
    while(n>0)
    {
        //n--;
        x=(n-1)%26;
        s+=(x+'a');
        n=(n-1)/26;
    }
    reverse(s.begin(),s.end());
    cout << s;
    return 0;
}


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

int main(){
    int k, rel;
  	ll n;
   	rel = 1;
    cin >> n >> k;
    while(k<=n){
        ll s,r;
        s = n / k;
        r = n - s*k;
        n = s;
        ++rel;
    }
    cout << rel << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>

using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(a - x) < abs(b - x)){
        cout << "A" << endl;
    }
    else{
        cout << "B" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
    n, *a = map(int, read().split())
    coma = combinations(a, 3)
    r = 0
    for c in coma:
        if sum(c) > max(c)*2:
            if len(set(c)) > 2:
                r += 1
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 73880
#include<stdio.h>

int main(void){
    int n;
    register int i,j;
    scanf("%d",&n);
    int a[n];
    for(i = 0;i < n;i++)scanf("%d",&a[i]);
    short b[n];
    int al = n/2;
    int tmp = 0;
    for(i = al;i < n;i++)b[i] = a[i];
    for(i = al - 1;i >= 0;i--){
        tmp = 0;
        for(j = 2;(i+1) * j <= n;j++)tmp += b[(i+1)*j-1];
        tmp %= 2;
        b[i] = (tmp == a[i] ? 0:1);
    }
    int ans = 0;
    for(i = 0;i < n;i++)ans += b[i];
    printf("%d\n",ans);
    if(!ans)return 0;
    for(i = 0;i < n;i++)if(b[i])printf("%d ",i+1);
    return 0;
}

Measured memory_bytes: 2048
#include<cstdio>

long long int d[200000];
int main(void) {
    long long int n,k;
    scanf("%lld%lld",&n,&k);
    for(long long int i=0;i<n; i++) {
        long long int a,b;
        scanf("%lld%lld",&a,&b);
        d[a] += b;
    }
    long long int s = 0;
    long long int i=0;
    for(;; i++) {
        s += d[i];
        if(s >= k)
            break;
    }
    printf("%lld\n", i);
}

Measured memory_bytes: 896
def SumDegit(N):
    s = str(N)
    Sum = 0
    for i in range(len(s)):
        Sum = Sum + int(s[i])
    return Sum

N = input().split()
N = [int(n) for n in N]

count = 0
for i in range(N[0]):
    if((SumDegit(i+1)>=N[1])and(SumDegit(i+1)<=N[2])):
        count = count + (i+1)
print(count)


Measured memory_bytes: 3060
using System;
class P
{
  static void Main()
  {
    int D = int.Parse(Console.ReadLine());
    switch (D){
      case 22:
        Console.WriteLine("Christmas Eve Eve Eve");
        return;
      case 23:
        Console.WriteLine("Christmas Eve Eve");
        return;
      case 24:
        Console.WriteLine("Christmas Eve");
        return;
      case 25:
        Console.WriteLine("Christmas");
        return;
    }
  }
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 4e2 + 5;
int n , a[21][21];
int dp[22][1 << 21];
vector<int> bit[22];
const int mod = 1e9 + 7;
void add(int & x , int y)
{
    x += y;
    if(x >= mod)x -= mod;
    if(x < 0)x += mod;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 0 ; i < n ; ++i)
        for(int j = 0 ; j < n ; ++j)
            cin >> a[i][j];
    dp[0][0] = 1;
    for(int i = 0 ; i < (1 << n) ; ++i)
        bit[__builtin_popcount(i)].pb(i);
    for(int i = 0 ; i < n ; ++i)
    {
        for(int c : bit[i])
        {
            for(int j = 0 ; j < n ; ++j)
            {
                if(((c >> j) & 1) || a[i][j] == 0)continue;
                add(dp[i + 1][c | (1 << j)],dp[i][c]);
            }
        }
    }
    cout << dp[n][(1 << n) - 1];
}


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

int main() {
        int n, m, l;
        cin >> n >> m >> l;

        int a[n][m], b[m][l];
        long c[n][l];

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

        for(i = 0; i < n; i++) {
                for(j = 0; j < m; j++) {
                        cin >> a[i][j];
                }
        }

        for(i = 0; i < m; i++) {
                for(j = 0; j < l; j++) {
                        cin >> b[i][j];
                }
        }

        int k;
        for(i = 0; i < n; i++) {
                for(j = 0; j < l; j++) {
                        for(k = 0; k < m; k++) {
                                c[i][j] += a[i][k] * b[k][j];
                        }
                }
        }

        for(i = 0; i < n; i++) {
                for(j = 0; j < l; j++) {
                        if(j != l - 1) {
                                cout << c[i][j] << " ";
                        }
                        else {
                                cout << c[i][j];
                        }
                }
                cout << endl;
        }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e16;

signed main(){
  int N, M; cin >> N >> M;
  vector<int> a(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i]; sum += a[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(sum <= 4 * a[i] * M) ans++;
  }
  if(ans >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
arr = []
arr.push(gets.chomp.split(" ").map(&:to_i))
arr.push(gets.chomp.split(" ").map(&:to_i))

ue = 0
sita = arr[1].inject(&:+)
max = sita
#puts "ue:#{ue} sita:#{sita}"
n.times do |i|
	ue += arr[0][i]
	sita -= arr[1][i]
	sum = ue + sita + arr[1][i]
	max = sum if max < sum
	
#puts "ue:#{ue} sita:#{sita}"
end
puts max


Measured memory_bytes: 1788
#include<stdio.h>

void swap(int *a,int *b){
	int temp=*a;
	*a=*b;
	*b=temp;
}

int bubbleSort(int A[],int N){
	int i,j;
	int sw = 0;
	unsigned short flag = 1;
	for(i=0;flag;i++){
		flag=0;
		for(j=N-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(&A[j],&A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void){
	int i,A[100],N,sw;
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	sw = bubbleSort(A,N);
	
	for(i=0;i<N;i++){
		if(i)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n%d\n",sw);
	
	return 0;
}


Measured memory_bytes: 1996
n,k = map(int, input().split())
a = []
for i in range(1,n+1):
  j = i
  b =0
  while j<k:
    j*=2
    b+=1
  a.append(b)
ans = 0
for i in range(n):
  ans+=0.5**a[i]
print(ans/n)

Measured memory_bytes: 9936
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 200100
vector<int> g[N], g2[N];
int n, x, y, a[N], b[N], c[N], d[N];
int d2[N], w[N], used[N], p[N];

int dfs2(int u){
	for(auto v: g2[u]){
		if(d2[v]<0){
			d2[v] = d2[u]+1;
			dfs2(v);
			p[v] = u;
		}
	}
}

int main(){
	cin>>n>>x>>y; x--; y--;
	rep(i, n-1) cin>>a[i]>>b[i];
	rep(i, n-1) cin>>c[i]>>d[i];
	rep(i, n-1){
		a[i]--; b[i]--;
		g[a[i]].pb(b[i]);
		g[b[i]].pb(a[i]);
	}
	rep(i, n-1){
		c[i]--; d[i]--;
		g2[c[i]].pb(d[i]);
		g2[d[i]].pb(c[i]);
	}
	mset(d2, -1);
	d2[y] = 0;
	dfs2(y);
	p[y] = -1;
	rep(i, n-1){
		int t = d2[a[i]]-d2[b[i]];
		if(abs(t)>2){
			w[a[i]] = 1;
			w[b[i]] = 1;
			continue;
		}
		int a2 = a[i], b2 = b[i];
		if(t==0){
			a2 = p[a2];
			b2 = p[b2];
		}
		while(t>0){
			a2 = p[a2];
			t--;
		}
		while(t<0){
			b2 = p[b2];
			t++;
		}
		if(a2!=b2){
			w[a[i]] = 1;
			w[b[i]] = 1;
		}
	}
	queue<int> q, q2;
	q.push(x); q2.push(y);
	w[y] = -1;
	if(w[x]==1){
		cout<<-1<<endl;
		return 0;
	}
	w[x] = 2;
	int cnt = 1;
	for(int i = 2; ; i+=2){
		queue<int> q3, q4;
		while(!q2.empty()){
			int u = q2.front(); q2.pop();
			for(auto v: g2[u]){
				if(w[v]<0) continue;
				if(w[v]==2) cnt--;
				w[v] = -1;
				q4.push(v);
			}
		}
		while(!q.empty()){
			int u = q.front(); q.pop();
			for(auto v: g[u]){
				if(w[v]<0||w[v]==2) continue;
				if(w[v]==1){
					cout<<-1<<endl;
					return 0;
				}
				w[v] = 2;
				cnt++;
				q3.push(v);
			}
		}
		if(cnt==0){
			cout<<i<<endl;
			break;
		}
		q.swap(q3);
		q2.swap(q4);
	}
	return 0;
}


Measured memory_bytes: 36220
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int sita = 1;
		int ue = n;
		for(int i = 0; i < m; i++){
			int l = sc.nextInt();
			int r = sc.nextInt();
			sita = Math.max(sita,l);
			ue = Math.min(ue,r);
		}
		System.out.print(Math.max(ue-sita+1,0));
	}
}


Measured memory_bytes: 65612
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ATenki {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        string s, t;
        cin >> s >> t;
        int res = 0;
        REP(i, s.size()) {
            if (s[i] == t[i]) res++;
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ATenki solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)


int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    cout << min(min(min(x, y) * 2 * c + (max(x, y) - min(x, y)) * (x >= y ? a : b), max(x, y) * 2 * c), a * x + b * y) << endl;

    return 0;
}

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

ans = 0
d = dict()
for _ in range(n):
    s = input()
    t = sorted(list(s))
    t = ''.join(t)
    if t not in d: d[t] = 1
    else: 
        ans += d[t]
        d[t] += 1

print(ans)        

Measured memory_bytes: 65880
#include <iostream>
#include <vector>
#include <sstream>
#include <cmath>
using namespace std;

int main(){
	double dp[12][1<<12] = {};
	string ln;
	while( getline(cin,ln) ){
		for(int i = 0 ; i < 12 ; i++)
			for(int j = 0 ; j < 1<<12 ; j++)
				dp[i][j] = 1e9;
		stringstream ss(ln);
		vector<int> item;
		
		int w,t;
		ss >> w;
		while(ss >> t)item.push_back(t);
		for(int i = 0 ; i < item.size() ; i++){
			dp[i][1<<i] = item[i];
		}
		for(int i = 0 ; i < (1<<item.size()) ; i++){
			for(int j = 0 ; j < item.size() ; j++){
				for(int k = 0 ; k < item.size() ; k++){
					dp[k][i|(1<<k)] = min( dp[k][i|(1<<k)] , dp[j][i] + sqrt( (item[j]+item[k])*(item[j]+item[k])-(item[j]-item[k])*(item[j]-item[k]) ) );
				}
			}
		}
		
		double ans = 1e9;
		for(int i = 0 ; i < item.size() ; i++){
			ans = min( ans , dp[i][(1<<item.size())-1] + item[i]);
		}
		if( ans <= w + 1e-9 ){
			cout << "OK" << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1304
#import math
N, K = list(map(int, input().strip().split()))

def gcd2(a, b):
  while True:
    if a > b:
      if a % b == 0:
        return 0
      else:
        #a = a-b
        a = a % b
    elif a == b:
      return 0
    else:
      return min(a, abs(a-b))

ans = gcd2(N, K)
if ans == K:
  print(0)
else:
  print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<stack>
#include<algorithm>
#include<map>
using namespace std;

int h,w;
char m[512][512];

int AboveHeight(int x,int y)
{
	int res=0;
	while(m[y][x]=='.')
	{
		++res;
		--y;
	}
	return res;
}

int Solve(int y)
{
	typedef pair<int,int>P;
	int res=0, x;
	stack<P> s;
	for(x=1; x<=w+1; ++x)
	{
		int a=AboveHeight(x,y);
		if(s.empty() || s.top().first <= a)
			s.push(P(a,x));
		else
		{
			int lastX = -1;
			while(!s.empty() && s.top().first > a)
			{
				P p=s.top();
				s.pop();
				res = max(res, p.first * (x-p.second));
				lastX = p.second;
			}
			s.push(P(a,lastX));
		}
	}
	return res;
}

int main()
{
	while(scanf("%d%d",&h,&w),h)
	{
		memset(m,'*',sizeof(m));
		int x,y;
		int res=0;
		for(y=1; y<=h; ++y)
			scanf("%s",&m[y][1]);
		for(y=1; y<=h; ++y)
			res=max(res,Solve(y));
		printf("%d\n",res);
	}
	return 0;
}

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

int main() {
    long long int n, b, i;
    cin >> n >> b;
    long long int arr[n];

    long long int c = 0;
    long long int sum = 0;

    for(i=0; i<n, sum<=b; i++) {
        cin >> arr[i];

        sum = sum + arr[i];
        c++;
    }

    cout << c << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back()
#define MP(x,y) make_pair(x,y)
#define F first
#define S second
using namespace std;

typedef double DB;
typedef long double LDB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<int,DB> pid;
typedef pair<DB,int> pdi;
typedef pair<DB,DB> pdd;

template<typename T>
inline bool getmin(T& a,const T& b) {return b < a? (a=b,true):false;}
template<typename T>
inline bool getmax(T& a,const T& b) {return b > a? (a=b,true):false;}
template<typename T>
inline bool inrange(const T& x,const T& L,const T& R) {return L<=x && x<=R;}

const int maxn=100000+5;
int pairs[maxn],num[maxn];
int main()
{
    int N;
    LL ans=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%d",num+i);
        pairs[i]=num[i]/2;
        ans+=pairs[i];
        num[i]%=2;
    }
    for(int i=0;i<N-1;i++)
    {
        if(num[i]==1 && num[i+1]==1) ans++,num[i]=0,num[i+1]=0;
        else if(num[i]==1 && num[i+1]==0)
        {
            if(pairs[i+1]) pairs[i+1]--,num[i]=0,num[i+1]=1;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    vi v(5, 0);
    REP(i,n) {
        cin >> s;
        if(s[0]=='M'){
            v[0]++;
        }else if(s[0]=='A'){
            v[1]++;
        }else if(s[0]=='R'){
            v[2]++;
        }else if(s[0]=='C'){
            v[3]++;
        }else if(s[0]=='H'){
            v[4]++;
        }
    }
    REP(i,3) {
        FOR(j,i+1,4) {
            FOR(k,j+1,5) {
                ans += v[i] * v[j] * v[k];
            }
        }
    }
    cout << ans << endl;
    
}

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

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  std::string S;
  std::cin >> S;

  int res = 0;
  for (int i = 0; i < S.length(); ++i)
    if (S[i] == 'o')
      res += 1;
  res += 15 - S.length();

  // Main
  if (res >= 8)
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;

  // Output

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010


int main(){
	IOS;
	tihs;
	ll n;cin>>n;
	map<string,ll>mp;
	string s[n];
	vector<string>ans;
	ll mx=-1;
	rep(i,0,n){
		cin>>s[i];
		mp[s[i]]++;
		mx=max(mx,mp[s[i]]);
	}
	for(auto p:mp){
		if(p.se==mx)ans.pb(p.fi);
	}
	sort(all(ans));
	for(auto s:ans)cout<<s<<"\n";




	return 0;
}

Measured memory_bytes: 27120
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
#define pi acos(-1.00)
int main() {
    IO;
    cout << setprecision(15);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle_h = 2 * pi * (h + m / 60.0) / 12;
//    cout << angle_h << '\n';
    double angle_m = m * 2 * pi / 60;
//    cout << angle_m << '\n';
    double diff = abs(angle_h - angle_m);
    if(diff > pi) diff = 2 * pi - diff;
//    cout << diff << '\n';
    double ans = a * a + b * b - 2.0 * a * b * cos(diff);
    ans = sqrt(ans);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4300
#include <iostream>
using namespace std;
int n,i,a,m[1000000];
int main ()
{
	cin >> n;
	for (i=2; i<=n; i++)
	{
		cin >> a;
		m[a]++;
	}
	for (i=1; i<=n; i++)
	cout << m[i] << endl;

}



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

double ex(ll p){
  double dest=0.0;
  rep(i, p){
    dest+=i;
  }
  dest/=p;
  return dest;
}

int main(){
  ll n,k; cin >> n >>k;
  double ans=0;
  double temp=0;
  vector<double> v;v.push_back(0.0);
  
  rep(i,n){
    ll p; cin >> p;
    double e = ex(p);
    v.push_back(e);
    temp+=e;
    if(i>=k){
      temp-=v[i-k];
      ans = max(ans, temp);
    }
  }
  printf("%10.12f" , ans);

}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N, M;
	cin >> N >> M;
	vpii Islands(M, pair<int, int>());
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		Islands[i].first = b;
		Islands[i].second = a;
	}
	sort(all(Islands));
	int ans = 0, broke = -1;
	for (int i = 0; i < M; i++)
	{
		int W = Islands[i].second;
		int E = Islands[i].first;
		if (broke < W)
		{
			broke = E-1;
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
// Problem : D - Gathering Children
// Contest : AtCoder - AtCoder Beginner Contest 136
// URL : https://atcoder.jp/contests/abc136/tasks/abc136_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	string s;
	cin>>s;
	vi left,right,a(sz(s),0);
	loop(i,sz(s)-1)
	{
		if(s[i]=='R'&&s[i+1]=='L')
		left.pb(i+1); 
	}
	loop(i,sz(s))
	{
		if(s[i]=='L')
		{
			int pos=left[ub(all(left),i)-1-left.begin()];
			int to=pos-1;
			if((i-pos+1)%2==1)
			to=pos;
			a[to]++;
		}
		else
		{
			int pos=left[lb(all(left),i)-left.begin()];
			int to=pos;
			if((pos-i)%2==1)to=pos-1;
			a[to]++;
		}
	}
	trav(i,a)
	cout<<i<<" ";
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b){return (b==0?a:gcd(b,a%b));}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


ll calc(ll x, ll C, ll D){
  ll a = x / C;
  ll b = x / D;
  ll y = x / lcm(C, D);

  return x - (a + b - y);
}

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  cout << calc(B,C,D) - calc(A-1,C,D) << endl;
  
  return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int N, M;
int K[12] = {0};
int SW[12][12] = {0};
int P[12] = {0};

int lighting(int l, int b){
	int ret = 0;
	for(int i=0; i<N; i++){
		int s = SW[l][i];
		if(b & (1<<(s-1)) ){
			ret++;
		}
	}
	if( (ret % 2) == P[l] )
		return 1;
	else
		return 0;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i=0; i<M; i++){
		cin >> K[i];
		for(int j=0; j<K[i]; j++){
			cin >> SW[i][j];
		}
	}
	for(int i=0; i<M; i++){
		cin >> P[i];
	}

	int ans = 0;
	for(int b = 0; b < (1<<N); b++){
		int c = 0;
		for(int l = 0; l < M; l++){
			c += lighting(l, b);
		}
		if(c == M) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())

res = [0 for i in range(N)]

for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        d = min(abs(j - i), abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X))
        res[d] += 1

for k in range(1, N):
    print(res[k])


Measured memory_bytes: 3444
n=int(input())
L=[]
if n==0:
    print('0')
else:    
    while n!=0:
        if n>0 and n%2==0:
            n=-n//2
            L.append('0')
        elif n>0 and n%2==1:
            n=(-n+1)//2
            L.append('1')
        elif n<0 and -n%2==0:
            n=-n//2
            L.append('0')
        elif n<0 and -n%2==1:
            n=(-n+1)//2
            L.append('1')
    print(int(''.join(L[::-1])))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	
	rep(i,s.size()){
	    if(i%2==0 and s[i]=='L'){
	        puta("No");
	        return 0;
	    }
	    if(i%2==1 and s[i]=='R'){
	        puta("No");
	        return 0;
	    }
	}
	puta("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int r;
  cin>>r;

  string ans;
  if(r<1200) ans="ABC";
  else if(r<2800) ans="ARC";
  else ans="AGC";

  cout<<ans<<endl;
}

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


using namespace std;

int main()
{long long int N;
cin>>N;
long long int A;
long long int S = 0;
for(int x = 0;x<N;x++){
    cin>>A;
    if(A%2!=0){
        S++;
    }
}
if(S%2==0){
    cout<<"YES"<<"\n";
}if(S%2!=0){
    cout<<"NO"<<"\n";
}
}




Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll l, r;
    cin >> l >> r;
    if (r - l >= 2018)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        ll minv = 2020;
        for (ll i = l; i < r + 1; i++)
        {
            for (ll j = i + 1; j < r + 1; j++)
            {
                ll x = i * j % 2019;
                minv = min(minv, x);
            }
        }
        cout << minv << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const long long INF = 1LL << 60;

int main(){
  int N, W; cin >> N >> W;
  long long weight[110], value[110];
  long long dp[110][100100] = {0};
  for(int i = 1; i <= N; i++){
    cin >> weight[i] >> value[i];
  }
  
  for(int i = 1; i <= N; i++){
    for(int sum_w = 0; sum_w <= W; sum_w++){
      if(sum_w - weight[i] >= 0){
        chmax(dp[i][sum_w], dp[i - 1][sum_w - weight[i]] + value[i]);
      }
      chmax(dp[i][sum_w], dp[i - 1][sum_w]);
    }
  }
  cout << dp[N][W] << endl;
}

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

int main(void){
  char txt[3];

  scanf("%s",txt);
  if(0==strcmp(txt,"ABC"))
    printf("ARC\n");
  else if(0==strcmp(txt,"ARC"))
    printf("ABC\n");
  else
    printf("error\n");
  return 0;
}
  

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

#define N_MAX 1111
int field[N_MAX][N_MAX];
pair<int,int> dp[N_MAX][N_MAX];

pair<int,int> pos[1000010];

int isp[1000010];

int f(){
	for(int i = 0 ; i < 1000010 ; i++)
		isp[i] = 1;
	isp[0] = isp[1] = 0;
	for(int i = 0 ; i * i < 1000010 ; i++){
		if( isp[i] ){
			for(int j = i * i ; j < 1000010 ; j += i)
				isp[j] = 0;
		}
	}
}

pair<int,int> dfs(int x,int y){
	if( x < 0 || x >= N_MAX || y >= N_MAX ) return {0,0};
	if( dp[x][y].first != -1 ) return dp[x][y];
	pair<int,int> ans = {isp[field[y][x]],field[y][x]};
	if( !isp[field[y][x]] ) ans.second = 0;
	for(int i = -1 ; i <= 1 ; i++){
		ans = max(make_pair(dfs(x+i,y+1).first+isp[field[y][x]],dfs(x+i,y+1).second),ans);
	}
	return dp[x][y] = ans;
}
int main(){
	f();
	int n,m;
	while(cin >> m >> n && n){
		for(int i = 0 ; i < N_MAX ; i++)
			for(int j = 0 ; j < N_MAX ; j++)
				dp[i][j] = {-1,-1};
		memset(field,0,sizeof(field));
		int x = 550, y = 550;
		int d = 0;
		int len = 1;
		int now = 1;
		pos[now++] = {x,y};
		int dx[] = {1,0,-1,0};
		int dy[] = {0,-1,0,1};
		while( now <= m ){
			for(int k = 0 ; k < 2 ; k++){
				for(int i = 0 ; i < len ; i++){
					x += dx[d+k];
					y += dy[d+k];
					if( now <= m ){
						field[y][x] = now;
						pos[now++] = {x,y};
					}
				}
			}
			d ^= 2;
			len++;
		}
		cout << dfs(pos[n].first,pos[n].second).first << " " << dfs(pos[n].first,pos[n].second).second << endl;
	}
	
}

Measured memory_bytes: 27480
import java.util.*;

class Main
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(),
			m = sc.nextInt(),
			colors = sc.nextInt();
		int color_num[] = new int[colors];
		
		int arr[][] = new int[n][m];

		for(int i = 0; i < colors; i++)
			color_num[i] = sc.nextInt();

		int i = 0, j = 0, addY = 1; 
		
		for(int now_color = 0; now_color < colors; now_color++)
		{
			for(int color_cnt = 0; color_cnt < color_num[now_color]; j += addY, color_cnt++)
			{
				if(j < 0)
				{
					addY = 1;
					j = 0;
					i++;
				}
				else if(j >= m)
				{
					addY = -1;
					j = m - 1;
					i++;
				}
				arr[i][j] = (now_color + 1);
			}
		}

		for(i = 0; i < n; i++)
		{
			for(j = 0; j < m; j++)
				System.out.print(arr[i][j] + " ");
			System.out.println();
		}
		
	}
}

Measured memory_bytes: 32712
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string s; cin >> s;
    int ans = 0;
    for (char c : s) {
        if (c == '1') ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> T(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		sum += T[i];
	}
	int M;
	cin >> M;
	vector<int> P(M);
	vector<int> X(M);
	for (int i = 0; i < M; i++) {
		cin >> P[i] >> X[i];
		cout << sum - T[P[i] - 1] + X[i] << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>
#define PI  2*acos(0.0)
#define pb push_back

       
using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;



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

int n;
cin>>n;
if(n>=30) cout<<"Yes"<<"\n";
else cout<<"No"<<"\n";















	
	
	return 0;
	
	
	       /***Israil Hosen
	            Computer Science & Engineering
	         University Of Rajshahi.
	         ***/
	
	
	
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){

    int X;
    cin >> X;
    if(X==3 || X==5 || X==7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    k, x = map(int, input().split())
    print('Yes' if k * 500 >= x else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
    return 0;
  }
  if (n - b > a - 1)
    cout << a + (b - a) / 2 << endl;
  else
    cout << n - b + 1 + (b - a) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,x;
vi a;

int main(){
	cin>>n>>x;
	int t=0,res=1;
	for(int i=0;i<n;i++){
		int X;
		cin>>X;
		t+=X;
		if(t<=x) res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

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

    ll k = 0;  // 木の直径
    vl v(n);  // v[i] : iの個数
    rep(i, n) {
        ll a;
        cin >> a;
        v[a]++;
        chmax(k, a);
    }

    bool ok = true;
    if(k%2 == 0) {
        v[k/2]--;
        exrep(i, k/2 + 1, k) {
            v[i] -= 2;
        }
        for(ll i = k/2; i >= 1; i--) {
            if(v[i] > 0) {
                ok = false;
            }
        }
    }
    else {
        exrep(i, k/2 + 1, k) {
            v[i] -= 2;
        }
        for(ll i = k/2 + 1; i >= 1; i--) {
            if(v[i] > 0) {
                ok = false;
            }
        }
    }
    
    rep(i, n) {
        if(v[i] < 0) {
            ok = false;
        }
    }

    if(ok) {
        out("Possible");
    }
    else {
        out("Impossible");
    }
    
    re0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )

using namespace std;

const int N = 305, mod = 1e9 + 7;

int n, m;
long long dp[N][N][N];

main ()
{
    cin >> n >> m;
    dp[0][1][1] = 1;
    for (int i = 0; i <= m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int k = 0; k <= j; k++)
            {
                dp[i + 1][j + 1][k] += dp[i][j][k] * (n - j);
                dp[i + 1][j + 1][k] %= mod;

                dp[i + 1][j][k] += dp[i][j][k] * (j - k);
                dp[i + 1][j][k] %= mod;

                dp[i + 1][j][j] += dp[i][j][k] * k;
                dp[i + 1][j][j] %= mod;
            }
        }
    }
    cout << dp[m][n][n] << endl;
}


Measured memory_bytes: 220672
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n, g;
    cin >> n >> g;
    vector<pair<int, int>> v;
    for(int i = 0; i < n; i++){
        pair<int, int> x;
        cin >> x.first >> x.second;
        v.push_back(x);
    }
    
    int ans = 1002;
    
    
    for(int i = 0; i < (1 << n); i++){
        int sum = 0;
        int cnt = 0;
        for(int j = 0; j < n; j++){
            if(i & (1 << j)){
                cnt += v[j].first;
                sum += v[j].first * ((j + 1) * 100) + v[j].second;
            }
        }
        if(sum >= g){
            ans = min(ans, cnt);
            continue;
        }
        for(int j = n - 1; j >= 0; j--){
            if(!(i & (1 << j))){
                for(int k = 0; k < v[j].first - 1; k++){
                    sum += (j + 1) * 100;
                    cnt++;
                    if(sum >= g){
                        break;
                    }
                }
            }
            if(sum >= g){
                ans = min(ans, cnt);
                break;
            }
        }
    }
    
    cout << ans;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int x = Integer.parseInt(br.readLine());

		System.out.println(x*x*x);


	}

}



Measured memory_bytes: 24428