akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll = long long int;
using llu = unsigned long long int;
using ld = long double;
const long long int NUM = 1000000;
const long double PI = 2*acos(0.0);
const int INF = 1e9 + 10 ;
const long long int maximum = (-1*INF);
#define LCM(a,b)            (a / __gcd(a,b)) * b
#define GCD(a,b)            __gcd(a,b)
#define dist(x1,y1,x2,y2)   sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define sqr(a)              ((a)*(a))
#define fast                ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define precision(a)        fixed<<setprecision(a)
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define REP(i,b)            for(long long int i = 0; i < b; i++)
#define READ(f)             freopen("f", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)

/*void sieve(ll n) {
    bool status[(n>>1)+1] = {false};
    ll inc, i;
    for(i = 3; i*i <= n; i += 2)
    {
        if(!status[i>>1])
        {
            inc = i<<1;
            for(ll j = i*i; j <= n; j += inc)
                status[j>>1] = true;
        }
    }
}*/

/*struct A {
    ll a;
    ll low;
    ll high;
};*/

/*bool compare(A x, A y)
{
    if(x.high == y.high) {
        if (x.low == y.low)
            return x.a <= y.a;
        return x.low > y.low;
    }
    return x.high > y.high;
}*/

/*ll logs(ll x)
{
    return 64 - __builtin_clzll(x) - 1;
}*/

//map<char, ll> m = { {'q', 9}, {'r', 5}, {'b', 3}, {'n', 3}, {'p', 1}, {'k', 0}, {'.', 0} };

//||

int main() {
    fast;
    string s;
    cin >> s;
    ll cntA, cnt, sum = 0;
    ll prev = 0;
    ll n = s.size();
    for (ll i = 0; i < n-2; i++) {
        cnt = 0; cntA = 0;
        if (s[i] != 'A') prev = 0;
        else if (s[i] == 'A') {
            cntA = prev;
            for (; i < n-2; i++) {
                if (s[i] != 'A')
                    break;
                cntA++;
            }
            if (s[i] == 'B' && s[i+1] == 'C') {
                for (; i < n-1; i += 2) {
                    if (s[i] == 'B' && s[i+1] == 'C')
                        cnt++;
                    else break;
                }
                sum += cnt * cntA;
                //debug(sum);
                prev = cntA;
            }
            i--;
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 720
#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);

	
	int N;
	cin >> N;
	pair<int, int> P[200000];
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		P[i] = mp(b, a);
	}
	sort(P, P + N);

	ll time = 0;
	bool OK = true;
	rep(i, N) {
		time += P[i].second;
		if (time > P[i].first) OK = false;
	}

	if (OK) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,n;
	cin>>h>>n;
	vector<ll> a(n),b(n);
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	vector<vector<ll>> dp(n+1,vector<ll>(h+1,inf));
	dp[0][h]=0;
	rep(i,n)for(ll j=h;j>=0;j--){
		chmin(dp[i+1][j],dp[i][j]);
		if(j+a[i]<=h) chmin(dp[i+1][j],dp[i+1][j+a[i]]+b[i]);
		if(j+a[i]>h) chmin(dp[i+1][j],dp[i+1][h]+b[i]);
	}
	//cout<<dp<<endl;
	cout<<dp[n][0]<<endl;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long int ll;
int x;
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>x;
    cout<< (x/500)*1000 + ( (x%500) - ((x%500)%5) ) <<'\n';

    return 0;
}


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

int n,m,x[200000],li[200000],ans;

int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x[i];
    }
    sort(x,x+m);
    for(int i=1;i<m;i++){
        li[i]=x[i]-x[i-1];
    }
    sort(li,li+m);
    reverse(li,li+m);
    for(int i=n-1;i<m;i++){
        ans+=li[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {

		int n = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}

		long ba = 0;
		long ab = 0;
		
		for (int i = 0; i < n; i++) {
			if (b[i] > a[i]) {
				ba += (b[i] - a[i]) / 2;
			} else {
				ab += (a[i] - b[i]);
			}
		}

		
		System.out.println(ab <= ba ? "Yes" : "No");
	}
}


Measured memory_bytes: 42064
#include <iostream>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

using ll = long long;

#define say(s) cout << s << endl
#define rep(i, n) for(int i=0; i<(int)(n); i++)

#define vec vector

const ll INF = ll(1e18)+1;

int main() {
  int n, r;
  cin >> n >> r;

  if (n >= 10) {
    say(r);
  } else {
    say(r + (100 * (10 - n)));
  }
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
    int key;
    struct Node *next;
    struct Node *prev;
};

typedef struct Node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
    NodePointer cur = nil->next; // 番兵の次の要素から辿る
    while(cur->key != key && cur != nil){
        cur = cur->next;
        
    }
    return cur;
}

void init(){
    nil = malloc(sizeof(struct Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    NodePointer cur = nil->next;
    int isf = 0;
    while(1){
        if (cur == nil) break;
        if (isf ++ > 0)printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
       
    }
    printf("\n");
}
void deleteNode(NodePointer t){
    if(t==nil) return; // t が番兵の場合は処理しない
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
void deleteFirst(){
    deleteNode(nil->next);
}
void deleteLast(){
    deleteNode(nil->prev);
}
void deleteKey(int key){
    // 検索したノードを削除
    deleteNode(listSearch(key));
}
void insert(int key){
   NodePointer x = malloc(sizeof(struct Node));
    x->key = key;
    // 番兵の直後に要素を追加
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}
int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d", com, &key);
        if (com[0] == 'i') {
            insert(key);
            np++;
            size++;
            
        }
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
    
}


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


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

    int c = 0;

    for(int i=0;i<S.size();i++){
        if(S[i] != S[(S.size()-1)-i]) c++;
    }

    cout << c/2 << endl;

    return 0;
}

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

int field[10][10] = {0};

void small(int x,int y){
	int vx[4] = {-1,0,1,0};
	int vy[4] = {0,-1,0,1};
	if(x>=0 && x<10 && y>=0 && y<10)
		field[x][y]++;
	for(int i=0;i<4;i++){
		if(x+vx[i]>=0 && x+vx[i] <10 && y+vy[i]>=0 && y+vy[i]<10)
			field[x+vx[i]][y+vy[i]]++;
	}	
}
void mid(int x,int y){
	int vx[3] = {-1,0,1};
	int vy[3] = {-1,0,1};
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
		if(x+vx[i]>=0 && x+vx[i] <10 && y+vy[j]>=0 && y+vy[j]<10)
			field[x+vx[i]][y+vy[j]]++;
		}
	}
}
void large(int x,int y){
	int vx[4] = {-2,0,2,0};
	int vy[4] = {0,-2,0,2};
	mid(x,y);
	for(int i=0;i<4;i++){
		if(x+vx[i]>=0 && x+vx[i] <10 && y+vy[i]>=0 && y+vy[i]<10)
			field[x+vx[i]][y+vy[i]]++;
	}
}

void search()
{
	int m = 0;
	int zerocount = 0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(field[i][j]==0)
				zerocount++;
			m = max(m,field[i][j]);
		}
	}
	cout << zerocount << endl;
	cout << m << endl;
}
int main()
{
	int x,y,size;
	char dot;
	while(cin >> x >> dot >> y >> dot >> size){
		if(size == 1)
			small(x,y);
		else if(size == 2)
			mid(x,y);
		else if(size == 3)
			large(x,y);
	}
	search();
	return 0;
}

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

int main(){
int r;
  cin>>r;
  if(r<1200)
    cout<<"ABC"<<endl;
  else if(1200 <= r && r < 2800){
  cout<<"ARC"<<endl;
  }
else{
cout<<"AGC"<<endl;
}
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll INF=1e15;


int main(){
    ll n;
    cin >> n;
    vector<ll> p(n),pos(n);
    set<ll> s;
    rep(i,n){
        cin >> p[i];
        p[i]--;
        pos[p[i]]=i;
    }
    ll ans=0;
    rep(i,n){
        ll now=pos[n-1-i];
        s.insert(now);
        //左に最大値を含む場合
        if(*s.begin()<now){
            ll le=0,ri=n-1;
            auto it=s.lower_bound(now);
            it--;
            ll mx=*it;
            if(*s.begin()<mx){
                it--;
                le=*it;
                le++;
            }
            if(*s.rbegin()>now){
                it=s.lower_bound(now);
                it++;
                ri=*it;
                ri--;
            }
            ans+=(ri-now+1)*(mx-le+1)*(n-i);
        }
        //右に最大値を含む場合
        if(*s.rbegin()>now){
            ll le=0,ri=n-1;
            auto it=s.lower_bound(now);
            it++;
            ll mx=*it;
            if(*s.rbegin()>mx){
                it++;
                ri=*it;
                ri--;
            }
            if(*s.begin()<now){
                it=s.lower_bound(now);
                it--;
                le=*it;
                le++;
            }
            ans+=(ri-mx+1)*(now-le+1)*(n-i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

using namespace std;

int main(){
	int n;
	string s; cin>>n>>s;

	vector<int> cum1(n+1),cum2(n+1);
	rep(i,n){
		cum1[i+1]=cum1[i]+(s[i]=='R'?1:0);
		cum2[i+1]=cum2[i]+(s[i]=='W'?1:0);
	}

	int ans=n;
	rep(i,n+1){
		ans=min(ans,max(cum2[i],cum1[n]-cum1[i]));
	}
	printf("%d\n",ans);

	return 0;
}


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

int main()
{
	int n;
	cin>>n;
	
	for(int i=1; i<=10; i++)
		if(1000*i>=n)
		{
			cout<<i*1000-n;
			break;
		}
	
	return 0;
}

Measured memory_bytes: 3632
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N-1)]

child = [[] for _ in range(N+1)]
par = [0]*(N+1)

for ab in AB:
    a,b = ab[0], ab[1]
    child[a].append(b)
    par[b] = a

k = 0
for i in range(1,N+1):
    l = len(child[i])
    if par[i] > 0:
        l += 1
    k = max(k, l)

print(k)#Maxの数

col = [0] * (N+1)
col[1] = 1
for i in range(1, N):
    cnt = 0
    for c in child[i]:
        cnt += 1
        col[c] = (col[i] + cnt) % k #k以下のものを順番に割り当てていく

for ab in AB:
    b = ab[1]
    print(col[b] + 1)

Measured memory_bytes: 77016
#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 j = -1;
    rep(i, 5) {
        int n;
        cin >> n;
        if(n == 0) j = i;
    }
    cout << j+1 << endl;
    return 0;
}

Measured memory_bytes: 3596
# coding : utf-8

import numpy as np

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

Xed = sorted(X)

t1 = Xed[int(N/2)-1]
t2 = Xed[int(N/2)]

for i in range(N):
	if X[i] <= t1:
		print(t2)
	else:
		print(t1)


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

int n,t,a[100010],mx1,mx2,ans;

int main()
{
	cin>>n>>t;
	for(int i=0;i<n;i++) cin>>a[i];
	
	for(int i=n-1;i>=0;i--)
	{
		mx1=max(mx1,a[i]);
		a[i]=mx1-a[i];
		mx2=max(mx2,a[i]);
	}
	for(int i=0;i<n;i++) ans+=(a[i]==mx2);
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 640
fun main(args:Array<String>){
    val (a, b) = readLine()!!.split(" ").map{it.toLong()}
    println(lcm(a, b))
}

fun gcd(a : Long, b : Long) : Long{
    if(a % b == 0L) return b
    return gcd(b, a % b)
}

fun lcm(a : Long, b : Long) : Long{
    return a / gcd(a, b) * b
}


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

int main() {
  int A,B,X;
  cin >> A >> B;
  for (int i = 1; i < 1011; i++){
    int At,Bt;
    At=floor(i*0.08);
    Bt=floor(i*0.1);
    if(At==A&&Bt==B){X=i;break;}
    if(i==1010){X=-1;break;}
  }
  cout << X << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,p,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
double a,b,d;
queue<int> que;
signed main(){
    cin>>n>>m>>o>>p;
    a=p*6*1.0;
    b=o*30+p*0.5;
    d=min(abs(b-a),abs(b-a-360))*1.0;
    printf("%.11f",sqrt(n*n+m*m-2*n*m*cos(3.141592653589793*d/180)*1.0));
}

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

int main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> p(N);
    rep(i, N) cin >> p[i];

    vector<long long> q(N, 0); // q(a)はp(a)からp(a + K - 1)の総和

    for(int i = 0; i < K; i++){
        q[0] += p[i];
    }
    long long sol = q[0];

    for(int i = 1; i < N-K+1; i++){
        q[i] = q[i-1] + p[i+K-1] - p[i-1];
        if (sol < q[i]) sol = q[i];
        // cout << sol << ",";
    }

    // cout << endl;

    // rep(i, N) cout << q[i] << ",";

    // cout << 0.5 * (K + sol) << endl;
    printf("%.10f\n", 0.5 * (K + sol));

    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, L;
string S[110];

signed main() {
    cin >> N >> L;
    for (int i = 0; i < N; i++)cin >> S[i];
    sort(S, S + N);
    for (int i = 0; i < N; i++)cout << S[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main()
{
	string command;
	int operand;
	priority_queue<int> q;
	while (cin >> command)
	{

		if (command == "insert")
		{
			cin >> operand;
			q.push(operand);
			continue;
		}

		if (command == "extract")
		{
			cout << q.top() << endl;
			q.pop();
			continue;
		}
		break;
	}
	return 0;
}


Measured memory_bytes: 7028
#include <stdio.h>
 
int main (void) {
    int a, b, c;
 
    scanf("%d %d %d", &a, &b, &c);
 
    if ((a == b && b != c) || (b == c && c != a) || (c == a && a != b)) {
        puts("Yes");
    } else {
        puts("No");
    }
 
    return 0;
}

Measured memory_bytes: 1636
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int n,x;
	vector<int> v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	cout << v[n-1] - v[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt(),c=nxt(),d=nxt();
    if(c>b||a>d)
        cout<<"0\n";
    else if(c>=a&&d>=b)
        cout<<b-c<<endl;
    else if(a>=c&&b>=d)
        cout<<d-a<<endl;
    else if(c>=a&&d<=b)
        cout<<d-c<<endl;
    else
        cout<<b-a<<endl;

    
    
    
    return 0;   
}




 
 


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vl x(n),y(n),h(n);
	map<ll,ll>d;
	rep(i,n){
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]==0)d[h[i]]++;
	}
	if(n==1){
		cout<<x[0]<<" "<<y[0]<<" "<<h[0]<<endl;
		return 0;
	}
	if(d[0]==n-1){
		rep(i,n){
			if(h[i]==0)continue;
			else{
				cout<<x[i]<<" "<<y[i]<<" "<<h[i]<<endl;
				return 0;
			}
		}
	}
	ll cx=0,cy=0,ans=0;
	for(int k=0;k<=100;++k){
		for(int j=0;j<=100;++j){
			bool a=true;
			for(int i=0;i<n-1;++i){
				for(int l=i+1;l<n;++l){
				if((h[l]-h[i])!=abs(x[i]-k)-abs(x[l]-k)+abs(y[i]-j)-abs(y[l]-j)){
					if(h[i]==0||h[l]==0){
						continue;
					}
					else{
						a=false;
						break;
					}
				}
				}
			}
			if(a){
				cx=k;
				cy=j;
				rep(i,n){
					if(h[i]==0)continue;
		            else{
			            ans=abs(x[i]-cx)+abs(y[i]-cy)+h[i];
						cout<<cx<<" "<<cy<<" "<<ans<<endl;
                        return 0;
		            }
            	}
			}
			if(!a)continue;
		}
	}
	
}


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def solve():
  h,w,d  = (int(i) for i in input().split())
  a = deque([])
  for i in range(h):
    tmp = list(int(i) for i in input().split())
    a.append(tmp)

  query = [False]*(h*w)
  distance = [0]*(h*w+1)
  for i in range(h):
    for j in range(w):
      query[a[i][j] - 1] = (i,j)
  q = int(input())
  
  for i in range(d,h*w):
    leftx,lefty = query[i-d]
    rightx,righty = query[i]
    distance[i] = distance[i-d]+abs(rightx-leftx)+abs(righty-lefty)
  #print(distance)

  for i in range(q):
    l,r = (int(m) for m in input().split())
    print(distance[r-1]-distance[l-1])
    
solve()

Measured memory_bytes: 18524
import Data.Char

main = interact $ solve
  where
    solve [] = []
    solve (x:xs) = (f x):solve xs
    f x | isLower x = toUpper x
        | isUpper x = toLower x
        | otherwise = x
      where
        isLower x = x `elem` ['a'..'z']
        isUpper x = x `elem` ['A'..'Z']



Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a, b, c, cost[10][10];
int32_t main(){_

   cin>>a>>b>>c;

   cost[0][1] = a;
   cost[1][0] = a;

   cost[1][2] = b;
   cost[2][1] = b;

   cost[2][0] = c;
   cost[0][2] = c;
   

   vector<int> v = {0,1,2};

   int cost0 = inf;

   do{

      vector<int> p = v;
      int ans = 0;
      for (int i = 0; i+1 < sz(p); ++i)
      {
         int curr = p[i];
         int nxt = p[i+1];
         ans += cost[curr][nxt];
      }

      smin(cost0, ans);

   }while(next_permutation(v.begin(), v.end()));

   cout<<cost0;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

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

using namespace std;

int main(){
    std::vector<char> S(4, 0);

    for(int i =  0; i < S.size(); i++) cin >> S[i];
    for(int i =  1; i < S.size(); i++){
        if(S[i - 1] == S[i]){
            cout << "Bad\n" << endl;
            return 0;
        }
    }
    cout << "Good\n" << endl;
    return 0; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
template < int xn, int xe > struct flow
{
	int head[xn], next[xe], to[xe], fl[xe], N, E, q[xn], dep[xn + 1], cur[xn];
	inline void add(int u, int v, int f)
	{
		next[E] = head[u], to[E] = v, fl[E] = f, head[u] = E++;
		next[E] = head[v], to[E] = u, fl[E] = 0, head[v] = E++;
	}
	void clear(int n)
	{
		N = n, E = 0;
		for (int i = 0; i < N; i++)
			head[i] = -1;
	}
	bool BFS()
	{
		for (int i = 0; i < N; i++)
		{
			dep[i] = 0;
			cur[i] = head[i];
		}
		int H = 0, T = 1, u;
		q[1] = 0;
		dep[0] = 1;
		while (H < T)
			for (int e = head[u = q[++H]]; ~e; e = next[e])
				if (fl[e] && !dep[to[e]])
				{
					dep[q[++T] = to[e]] = dep[u] + 1;
					if (to[e] == N - 1)
						return true;
				}
		return false;
	}
	int DFS(int p, int f)
	{
		if (p == N - 1)
			return f;
		int u = 0, y;
		for (int &e = cur[p]; ~e; e = next[e])
			if (fl[e] && dep[to[e]] == dep[p] + 1 && (y = DFS(to[e], std::min(f, fl[e]))))
			{
				u += y;
				f -= y;
				fl[e] -= y;
				fl[e ^ 1] += y;
				if (!f)
					return u;
			}
		if (!u)
			dep[p] = 0;
		return u;
	}
	int operator () ()
	{
		int r = 0;
		while (BFS())
			r += DFS(0, 1000000000);
		return r;
	}
};
flow < 66666, 666666 > G;
int N, M, in[101][101], out[101][101], o;
char a[101][102];
int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; i++)
		scanf("%s", a[i] + 1);
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++)
			if (a[i][j] == 'o')
			{
				in[i][j] = ++o;
				out[i][j] = ++o;
			}
	G.clear(1 + o + N + M + 1);
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++)
			if (a[i][j] == 'o')
				G.add(in[i][j], out[i][j], 1);
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= M; j++)
			if (a[i][j] == 'o')
			{
				G.add(out[i][j], o + i, 1000000000);
				G.add(o + i, in[i][j], 1000000000);
			}
			else if (a[i][j] == 'S')
				G.add(0, o + i, 1000000000);
			else if (a[i][j] == 'T')
				G.add(o + i, G.N - 1, 1000000000);
	for (int i = 1; i <= M; i++)
		for (int j = 1; j <= N; j++)
			if (a[j][i] == 'o')
			{
				G.add(out[j][i], o + N + i, 1000000000);
				G.add(o + N + i, in[j][i], 1000000000);
			}
			else if (a[j][i] == 'S')
				G.add(0, o + N + i, 1000000000);
			else if (a[j][i] == 'T')
				G.add(o + N + i, G.N - 1, 1000000000);
	int ans = G();
	printf("%d\n", ans > N * M ? -1 : ans);
	return 0;
}


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
long long a[100050];
int main()
{
	int m,n;
	while(~scanf("%d%d",&m,&n))
	{
		long long ans=922337203685477586;
		for(int i=0;i<m;i++)
		scanf("%lld",&a[i]);
		for(int i=0;i<=m-n;i++)
		{
			long long l=a[i];
			long long r=a[i+n-1];
			if(l<0&&r<0)	
			ans=min(ans,-l);
			else if(l>0&&r>0)	
			ans=min(ans,r);
			else	
			ans=min(ans,r-l+min(abs(r),abs(l)));
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main{
 public static void main(String[] a){
     Scanner s = new Scanner(System.in);
     int i,x,now;
     boolean ch=false;
     x = s.nextInt();
     for(i=1;i<=x;i++){
         now=i;
         if(i%3==0)ch=true;
         while(now>0&&ch==false){
            if(now%10==3)ch=true;
            now/=10;
         }
         if(ch==true){
             ch=false;
             System.out.print(" "+i);
         }
     }
    System.out.println();
 }   
}


Measured memory_bytes: 28892
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <iomanip>
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
//#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;


void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M,long long MOD) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2,MOD);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<pair<long long,long long>> dish(N);
    long long aoki = 0;
    for(int i = 0;i<N;i++) {
        cin >> dish.at(i).first >> dish.at(i).second;
        aoki -= dish.at(i).second;
    }
    vector<long long> takahashi_chase(N);
    for(int i = 0;i<N;i++){
        takahashi_chase.at(i) = dish.at(i).first + dish.at(i).second;
    }
    sort(takahashi_chase.begin(),takahashi_chase.end(),greater<long long>());
    for(int i = 0;i<N;i+=2){
        aoki += takahashi_chase.at(i);
    }
    cout << aoki << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for(ll i=0; i<N; ++i)

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

int main() {
  //ポイントとしては幅優先探索を二回やるということ
  int N;
  cin >> N;
  //隣接行列 => グラフが密な場合に有利
  //頂点配列 => 木などグラフが疎な場合に有利
  vector<vector<int>> edges(N+1);
  for(int i=0; i<N-1; ++i) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  
  vector<int> gcolf(N+1, -1);
  vector<int> gcols(N+1, -1);
  
  {
    queue<int> q;
    q.push(1);
    gcolf[1] = 0;
    while(!q.empty()) {
      int n = q.front(); q.pop();
      for(int e : edges[n]) {
        if(gcolf[e] != -1) continue;
        //次を見る時にもう経路の長さを数える
        gcolf[e] = gcolf[n] + 1;
        q.push(e);
      }
    }
  }
  
  {
    queue<int> q;
    q.push(N);
    gcols[N] = 0;
    while(!q.empty()) {
      int n = q.front(); q.pop();
      for(int e : edges[n]) {
        if(gcols[e] != -1) continue;
        //次を見る時にもう経路の長さを数える
        gcols[e] = gcols[n] + 1;
        q.push(e);
      }
    }
  }
  
  //数える
  int fcount = 0;
  for(int i=1; i<=N; ++i) {
    if(gcolf[i] <= gcols[i]) {
      ++fcount;
    }
  }
  
  if(fcount > N - fcount) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b;
  cin >>a>>b;
  if (a%3==0 || b%3==0 || (a+b)%3==0) {
    cout<<"Possible"<<endl;
  }
  else{
    cout<<"Impossible"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main(){
    ll n,k;cin >>n>>k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    map<ll,int>memo;//memo[x]=xの初出位置
    ll x=1;
    for (ll i = 0; i <k; ++i) {
        if(memo[x]){
            auto t=i-memo[x],c=(k-1-i)/t;//t=周期　c=どれくらい周期を回せるか
            i+=c*t;
        }
        else {
            memo[x]=i;
        }
        x=a[x-1];
    }
    cout <<x<<endl;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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; }

vector<int> z_algo(string s) {
    int l = s.size(), k;
    vector<int> z(l);
    z[0] = l;
    for (int i = 1, j = 0; i < l;) {
        while (i + j < l && s[j] == s[i + j]) j++;
        z[i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        for (k = 1; k < j && k + z[k] < j; ++k) {
            z[i + k] = z[k];
        }
        i += k;
        j -= k;
    }
    return z;
}

int main() {
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        auto z = z_algo(s);
        int l = s.size();
        for (int j = 0; j < l; ++j) {
            if (j >= z[j])
                chmax(ans, z[j]);
        }
        s = s.substr(1, l);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int n,m,ans;
int a[200005];
int main()
{
	int i;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		cin>>a[i];

	ans=500000000;
	for(i=m;i<=n;i++)
			ans=min(ans,a[i]-a[i-m+1]+min(abs(a[i]),abs(a[i-m+1])));	
	cout<<ans;
	return 0;	
} 



Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CMaximalValue {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] dif = new int[n - 1];
            int[] ar = new int[n];
            long sum = 0;
            for (int i = 0; i < n - 1; i++) {
                dif[i] = in.nextInt();
            }
            ar[0] = dif[0];
            ar[n - 1] = dif[n - 2];
            for (int i = 1; i < n - 1; i++) {
                ar[i] = Math.min(dif[i], dif[i - 1]);
            }

            for (int i = 0; i < n; i++) {
                sum += (long) ar[i];
            }

            out.println(sum);

        }

    }
}



Measured memory_bytes: 21716
#include <iostream>
#define N 8
#define NOT_FREE 1
#define FREE -1
using namespace std;
int col[N],row[N],dpos[2*N-1],dneg[2*N-1];
bool P[N][N];

void initialize(){
    for(int i = 0; i < N; i++)
       for(int j = 0; j < N; j++) P[i][j] = false;
    for(int i = 0; i < N; i++) col[i] = row[i] = FREE;
    for(int i = 0; i < 2*N-1; i++) dpos[i] = dneg[i] = FREE;
}

void printBoard(){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(P[i][j]){
                if(row[i] != j) return;
            }
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(row[i] == j) cout << 'Q';
            else cout << '.';
        }
        cout << endl;
    }
}

void putQueen(int i){
    if(i == N){
        printBoard();
        return;
    }

    for(int j = 0; j < N; j++){
        if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;
        row[i] = j;
        col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
        
        putQueen(i+1);

        col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
    }
}

int main(){
    initialize();

    int k, r, c;
    cin >> k;
    for(int i = 0; i < k; i++){ 
        cin >> r >> c;
        P[r][c] = true;
    }

    putQueen(0);

    return 0;
}


Measured memory_bytes: 3104
n, m = map(int, input().split())
data = []   #値段、個数
for i in range(n):
    a, b = map(int, input().split())
    data.append([a, b])
data.sort(key=lambda x: x[0])   #値段でソート
ans = 0
for p in data:
    ans += p[0] * min(m, p[1])
    m -= p[1]
    if m <= 0:
        break

print(ans)


Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int main() {
    int n, m,q; cin >> n >> m>> q;
    int dp[n+1][n+1] = {};
    int r[n+1][n+1] = {};
    for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; r[x][y]++; }

    for (int i = 0; i <= n; i++) {
        for (int j = 1; i + j <= n; j++)
            if (i == 0) dp[j][j] = r[j][j];
            else dp[j][i+j] = dp[j][i+j-1] + dp[j+1][j+i] - dp[j+1][i+j-1] + r[j][i+j];
    }

    while (q--) {
        int x,y; cin >> x >> y;
        cout << dp[x][y] << endl;
    }
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int choco =0;
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc. nextInt();
		for(int i = 0;i<N;i++){
			int A = sc.nextInt();
			for(int j =0;j<200;j++){
				if(1+A*j<=D){
					choco++;
				}else{
					break;
				}
			}
		}
		System.out.println(choco+X);
 		sc.close();
	}
}


Measured memory_bytes: 21972
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            while (true) {
                String str=Console.ReadLine();
                if (str == null) {
                    break;
                }
                String[] strArray = str.Split();
                double[] a = new double[6];
                for (int i = 0; i < 6; i++) {
                    a[i] = double.Parse(strArray[i]);
                }
                double y = (a[2] * a[3] - a[0] * a[5]) / (a[1] * a[3] - a[0] * a[4]);
                double x = (a[2] - a[1] * y) /a[0];
                System.Console.WriteLine("{0:f3} {1:f3}", x, y);
            }
        }
    }
}

Measured memory_bytes: 5784
#include <iostream>

typedef long long ll;

using namespace std;

int main() {
	int n;
	int x;
	cin >> n >> x;
	ll arr[200001]{};
	for(int i = 0; i < n; i++) {
		cin >> arr[n-i];
	}
	for(int i = 1; i <= n; i++) {
		arr[i] += arr[i-1];
	}

	ll ans = 1LL<<60;
	for(int i = 1; i <= n; i++) {
		ll sum = 0;
		ll gcount = 1;
		for(int j = 0; j < n; j+=i) {
			ll l = arr[min(j+i,n)]-arr[j];
			if(gcount==1) {
				sum += l*5LL;
			}else {
				sum += (2LL*gcount+1LL)*l;
			}
			gcount++;
		}
		sum += ((ll)i)*x;
		if(sum>=0LL) ans = min(ans,sum);
	}

	ans += ((ll)n)*x;

	cout << ans << endl;
}


Measured memory_bytes: 1792
import sys

while True:
	m, f, r = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if -1 == m and -1 == f and -1 == r:
		break
	
	mf = ( m + f )
	if -1 == m or -1 == f:
		print( "F" )
	elif 80 <= mf:
		print( "A" )
	elif 65 <= mf and mf < 80:
		print( "B" )
	elif 50 <= mf and mf < 65:
		print( "C" )
	elif 30 <= mf and mf < 50:
		if 50 <= r:
			print( "C" )
		else:
			print( "D" )
	else:
		print( "F" )	

Measured memory_bytes: 6724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	ll n,m;
	ll ans=0;
	
	cin>>n>>m;
	if(m==1)
	{
		m=n;
		n=1;
	}
	if(n==1&&m==1)
	{
		ans=1;
	}else if(n==1){
		ans=m-2;
	}else{
		ans=(n-2)*(m-2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int i=1; i<10001; i++) {
            int aa = (int) (i * 0.08);
            int bb = (int) (i * 0.1);
            if(a == aa && b == bb) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}

Measured memory_bytes: 23764
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int h, w, k;
vector<vector<char>> s;

void solve() {
	cin >> h >> w >> k;
    s.assign(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }
    int ans = h - 1 + w - 1;
    for(int bit = 0; bit < (1<<(h - 1)); ++ bit) {
        int co = __builtin_popcount(bit) + 1;
        vector<int> cnt(co, 0);
        bool ok = 1;
        int res = co - 1;
        rep(i, w) {
            int now = 0;
            rep(j, h) {
                if(bit & (1<<j)) {
                    if(s[j][i] == '1') ++cnt[now];
                    ++ now;
                } else {
                    if(s[j][i] == '1') ++cnt[now];
                }
            }
            bool flag = 1;
            rep(j, co) {
                if(cnt[j] > k) {
                    flag = 0;
                }
            }
            if(flag) continue;
            else {
                ++ res;
                rep(j, co) {
                    cnt[j] = 0;
                }

                now = 0;
                rep(j, h) {
                    if(bit & (1<<j)) {
                        if(s[j][i] == '1') ++cnt[now];
                        ++ now;
                    } else {
                        if(s[j][i] == '1') ++cnt[now];
                    }
                }
                bool flag1 = 1;
                rep(j, co) {
                    if(cnt[j] > k) {
                        flag1 = 0;
                    }
                }
                if(!flag1) {
                    ok = 0;
                    break;
                }
            }
        }

        if(ok) chmin(ans, res);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int solve(int n, int s, int p){

  if(!n && !s) return 1;
  if(!n || s < 0) return 0;

  int ans = 0;
  for(int i=p;i<10;i++) ans += solve(n-1,s-i,i+1);

  return ans;
}

int main(){

  int n, s;
  while(true){
    cin >> n >> s;
    if(!n && !s) break;

    cout << solve(n, s, 0) << endl;
  }

}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int p = 0;
    string s;
    cin >> s;
    for(int j = 97; j < 123; j++)
    {
        int k = 0;
        for(int i = 0; i < s.size(); i++)
        {
            if((int)s[i] == j)
                k++;
        }
        if(k == 0)
            {
            cout << (char)j;
            return 0;
            }
            else
                p++;
    }
    if(p != 0)
        cout << "None";
    return 0;
}

Measured memory_bytes: 512
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
//
ll sum(ll n) { return n * (n + 1) / 2; }
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    rep(i, N / 2)
    {
        bool b0 = (S[i] == S[(N - 1) / 2 - 1 - i]);
        bool b1 = S[i] == S[((N + 3) / 2 - 1 + i)];
        bool b2 = S[i] == S[(N - 1 - i)];
        if (!b0 || !b1 || !b2)
        {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int h = Integer.parseInt(strArr[0]);
            int w = Integer.parseInt(strArr[1]);
            String ans[] = new String[h];
            for (int i = 0; i < h; i++) {
                ans[i] = br.readLine();
            }
            StringBuffer strBuf = new StringBuffer();
            for (int i = 0; i < w + 2; i++) {
                strBuf.append("#");
            }
            System.out.println(strBuf.toString());
            for (int i = 0; i < h; i++) {
                System.out.print("#");
                System.out.print(ans[i]);
                System.out.println("#");
            }
            System.out.println(strBuf.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 23124