akhauriyash/Code-Regression huggingface dataset:
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var x = nextInt();
  myout(1 ^ x);
}


Measured memory_bytes: 30144
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    int l; cin >> l;
    
    double d = l;
    
    double dd = d/3.0;
    dd = dd*dd*dd;
    
    cout<<fixed<<setprecision(7)<<dd<<endl;
    
	return 0;
}






Measured memory_bytes: 256
n, m, q = gets.strip.split.map(&:to_i)
lr = m.times.map { gets.strip.split.map(&:to_i)}
pq = q.times.map { gets.strip.split.map(&:to_i)}

cum_time_table = Array.new(n+1) { [0]*(n+1) }

lr.each do |l, r|
  cum_time_table[l][r] += 1
end

(1..n).each do |i|
  (2..n).each do |j|
    cum_time_table[i][j] = cum_time_table[i][j] + cum_time_table[i][j-1]
  end
end

(1..n).each do |j|
  (2..n).each do |i|
    cum_time_table[i][j] = cum_time_table[i][j] + cum_time_table[i-1][j]
  end
end

#cum_time_table.each do|ll|
#  p ll
#end

pq.each do |p, q|
  p cum_time_table[q][q] - cum_time_table[q][p-1] - cum_time_table[p-1][q] + cum_time_table[p-1][p-1]
end


Measured memory_bytes: 47992
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

s = input()
print(s.count("1"))

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

using namespace std;

using ll = long long;
using ld = long double;

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

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, x, y;
  cin >> n >> x >> y;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  reverse(all(a));
  vll mn(n), mx(n);
  mn[0] = a[0];
  mx[0] = a[0];
  REP(i, n) {
    mn[i] = min(mn[i - 1], a[i]);
    mx[i] = max(mx[i - 1], a[i]);
  }

  ll ans = ans = abs(a[0] - y);

  if (n > 1) {
    chmax(ans, abs(a[0] - a[1]));
  }

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


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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

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

}
/*
think fast
think simple
*/
void mysol()
{
	int n, k;
	cin >> n;
	int arr[n];
	map<int, int>m;
	for (int &a : arr)
		cin >> a, m[a]++;
	int sum = accumulate(arr, arr + n, 0ll);
	w(Q)
	{
		int a, b; cin >> a >> b;
		int ma = m[a];
		sum -= ma * a;
		sum += ma * b;
		m[b] += m[a];
		m.erase(a);
		cout << sum << endl;
	}
	// sort(arr, arr + n);
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 8340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int count = 1;

		for(int i = 0;i < 10000;i++) {
			if(n < k) {
				break;
			}
			n /= k;
			count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
N = int(input())

f = [0] * (N + 1)
for x in range(1, int(N ** 0.5) + 1):
    for y in range(1, int(N ** 0.5) + 1):
        for z in range(1, int(N ** 0.5) + 1):
            s = x * x + y * y + z * z + x * y + y * z + z * x
            if s <= N:
                f[s] += 1

for i in range(1, N + 1):
    print(f[i])

Measured memory_bytes: 9620
<?php 
$arr = [];
$ans = 0;
fscanf(STDIN, "%d %d", $N, $M);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    $arr[$A][] = $B;
}

$objPQ = new SplPriorityQueue;
//$objPQ->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
$objPQ->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
for ($i = 1; $i <= $M; $i++) {
    if (!isset($arr[$i])) {
        
    } else {
        foreach ($arr[$i] as $key => $val) {
            // echo "{$key} {$val}\n";
            $objPQ->insert("{$i}-{$key}", $val); 
        }
    }
    // echo "COUNT->".$objPQ->count()."<BR>"; 
    if ($objPQ->count() === 0) {
        
    } else {
        $objPQ->top();
        $ans += $objPQ->current();
        $objPQ->next();
    }
}
echo $ans;


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

struct Node
{
	int data;
	Node* next;
	Node* prev;
};

class List
{
private:
	Node* mother;
public:
    List()
    {
    	mother = new Node;
    	mother->data = -1;
    	mother->next = this->mother;
    	mother->prev = this->mother;
    }

    ~List()
    {
    	Node *tmp;
    	tmp = mother->next;
    	while (1)
    	{
	    	tmp = tmp->next;
    		delete tmp->prev;
	    	if (tmp == mother)
	    		break;
	    }
	    delete mother;
    }

    void Ins(int x)
    {
	    Node *tmp;
    	tmp = this->mother->next;
    	this->mother->next = new Node;
	    this->mother->next->data = x;
    	this->mother->next->next = tmp;
	    this->mother->next->prev = mother;
    	tmp->prev = mother->next;
	
	    return;
    }

    void Del(int x)
    {
    	Node *tmp;
    	tmp = this->mother->next;
    	while (tmp != this->mother)
    	{
    		if (tmp->data == x)
    		{
    			tmp->prev->next = tmp->next;
    			tmp->next->prev = tmp->prev;
    			delete tmp;
    			break;
    		}
    		tmp = tmp->next;
    	}
    	return;
    }
    
    void DelFirst()
    {
    	Node *tmp;
    	tmp = this->mother->next;
    	tmp->next->prev = mother;
    	this->mother->next = tmp->next;
    	delete tmp;
    }

    void DelLast()
    {
    	Node *tmp;
    	tmp = this->mother->prev;
    	this->mother->prev = tmp->prev;
    	tmp->prev->next = mother;
    	delete tmp;
    }

    void Show()
    {
    	Node *tmp;
    	tmp = mother->next;
    	cout << tmp->data;
    	tmp = tmp->next;
    	while (tmp != mother)
    	{
    		cout << " " << tmp->data;
    		tmp = tmp->next;
    	}
    	cout << endl;
    	return;
    }
};


int main()
{
	int n, x;
	char command[20];
	List list;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> command;
		if (command[0] == 'i')
		{
			cin >> x;
			list.Ins(x);
		}
		else if (command[6] == '\0')
		{
			cin >> x;
			list.Del(x);
		}
		else if (command[6] == 'F')
			list.DelFirst();
		else
			list.DelLast();
	}
	list.Show();

	return 0;
}


Measured memory_bytes: 34304
#include <vector>
#include <algorithm>
#include<iostream>
#include<climits>

using namespace std;

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<long long> a, b, c, comb;
    for(int i=0;i<x;i++){
        long long tmp; cin >> tmp;
        a.push_back(tmp);
    }
    for(int i=0;i<y;i++){
        long long tmp; cin >> tmp;
        b.push_back(tmp);
    }
    for(int i=0;i<z;i++){
        long long tmp; cin >> tmp;
        c.push_back(tmp);
    }
    sort(a.begin(),a.end(),greater<long long>());
    sort(b.begin(),b.end(),greater<long long>());
    sort(c.begin(),c.end(),greater<long long>());
    for(int i=0;i<x;i++)for(int j=0;j<y;j++)for(int l=0;l<z;l++){
        if((i+1)*(j+1)*(l+1)>k) break;
        comb.push_back(a[i]+b[j]+c[l]);
    }
    sort(comb.begin(),comb.end(),greater<long long>());
    for(int i=0;i<k;i++)
        cout << comb[i] << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main() {
  int n, c;
  cin >> n >> c;
  vector<vector<int>> d(c, vector<int>(c));
  rep(i,c) rep(j,c) cin >> d[i][j];
  vector<int> a(n * n);
  rep(i,n) rep(j,n) cin >> a[i * n + j], a[i * n + j]--;
  vector<vector<int>> dp(3, vector<int>(c, 0));
  
  for (int i = 0; i < n * n; i++) {
    for (int j = 0; j < c; j++) {
      int x = i / n, y = i % n;
      dp[(x + y) % 3][j] += d[a[i]][j];
    }
  }
  int res = INF;
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < c; j++) {
      if (i == j) continue;
      for (int k = 0; k < c; k++) {
        if (j == k) continue;
        if (i == k) continue;
        res = min(dp[0][i] + dp[1][j] + dp[2][k], res);
      }
    }
  }
  cout << res << endl;
  return 0;
} 

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int D, N; cin >> D >> N;
    int ans = pow(100, D);
    if(N == 100) cout << ans * 101 << endl;
    else cout << ans * N << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

void solve(int H) {
        int i, j;
        vector<vector<int> > block(H, vector<int> (5));
        for (i = H - 1; i >= 0; i --) {
                for (j = 0; j < 5; j ++) {
                        cin >> block[i][j];
                }
        }
        int ans = 0;
        for (int l = 0; l < 100; l ++) {
                for (i = 0; i < H; i ++) {
                        int p = block[i][2];
                        int l = 1, r = 3;
                        while (block[i][l] == p) l --;
                        while (block[i][r] == p) r ++;
                        l ++, r --;
                        if (r - l + 1 >= 3) { 
                                for (j = l; j < r + 1; j ++) block[i][j] = 0;
                                ans += p * (r - l + 1);
                        }
                }
                for (i = 0; i < 5; i ++) {
                        for (int k = 0; k < 10; k ++) {
                                for (j = 0; j < H; j ++) {
                                        if (block[j][i] == 0 && j != H - 1) {
                                                swap(block[j][i], block[j + 1][i]);
                                        }
                                }
                        }
                }
        }
        cout << ans << endl;
}

int main() {
        int H;
        while (cin >> H) {
                if (H == 0) break;
                solve(H);
        }
        return 0;
}

Measured memory_bytes: 3024
fun main(){
    readLine()!!.toInt()
    var A = readLine()!!.split(" ").map{it.toLong()}

    var mul: Long = 1L

    if(A.contains(0L)){ mul = 0L ;println(mul); return}
    for(a in A) {
        try {
            mul = Math.multiplyExact(mul, a)
            if (mul > Math.pow(10.0, 18.0).toLong()) {
                println(-1)
                return
            }
        } catch(e: Exception) {
            println(-1)
            return
        }
    }
    println(mul)
}

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

int main(){
    int n; cin >> n;
    vector <int> a(n + 1);
    //vector <int> xor_sum(n + 1);

    rep(i, n + 1){
        if (i == 0) continue;
        cin >> a.at(i);
        //xor_sum.at(i) = a.at(i);

        //if (i == 1) continue;
        //xor_sum.at(i) ^= xor_sum.at(i - 1);
    }

    vector <int> ball_cnt(n + 1);
    int M = 0;
    for (int i = n; i >= 1; i --){
        int sum_ball = 0;
        for (int j = i; j < n + 1; j += i){
            sum_ball += ball_cnt.at(j);
        }

        if (sum_ball % 2 == a.at(i)) continue;
        else {
            ball_cnt.at(i) = 1;
            M += 1;
        }
        
    }

    cout << M << endl;
    for (int i = 1; i < n + 1; i ++){
        if (ball_cnt.at(i) == 0) continue;
        cout << i << " ";
    }
    if (M != 0) cout << endl;
    

//     bool ok = true;
//     for (int i = 2; i < n + 1; i ++){
//         for (int j = i; j + i < n + 1; j += i){
//             int xor_range = xor_sum.at(j + i) ^ xor_sum.at(j);
            
//             if (a.at(j) ^ a.at(j + i) != xor_range) ok = false;
//         }
//     }
    
//     if (!ok){
//         cout << -1 << endl;
//     }
//     else{
//         long long ball_cnt = 0;
//         deque <long long> ans;
//         reverse(a.begin(), a.end());

//         //for (auto _a :a) cout << _a << " " << endl;
//         if (a.at(0) == 1){
//             ball_cnt += 1;
//             ans.push_front(1);
//         }
//         for (int i = 1; i < n; i ++){
//             if (a.at(i) ^ a.at(i - 1) == 0) ball_cnt += 0;
//             else ball_cnt += 1;
//             if (ball_cnt == 0) continue;

//             ans.push_front(ball_cnt);
//         }

//         cout << ans.size() << endl;
//         int s = ans.size();
//         rep(i, s){
//             cout << ans.front() << " ";
//             ans.pop_front();
//         }
//         cout << endl;
//     }

}

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

#define H 500001

int n;

void maxHeapify(int A[], int target) {
    int l = 2*target;
    int r = 2*target + 1;

    int largest;
    if (l <= n && A[l] > A[target]) {
        largest = l;
    } else {
        largest = target;
    }

    if (r <= n && A[r] > A[largest]) {
        largest = r;
    }

    if (largest != target) {
        swap(A[largest], A[target]);
        maxHeapify(A, largest);
    }
}

int main() {
    cin >> n;
    int A[H];

    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }

    for (int i = (n / 2); i >= 1; i--) {
        maxHeapify(A, i);
    }

    for (int i = 1; i <= n; i++) {
        cout << " " << A[i];
    }
    cout << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N; cin >> N;
    deque<char> que;
    
    for (int i = 0;i < N;i++){
        char c; cin >> c;
        que.push_back(c);
    }

    int cnt = 0;
    int idx= 0;
    for (int i = 0;i < N;i++){
        if(que[idx] == '('){
            cnt++;
        }else{
            if(cnt > 0){
                cnt--;
            }else{
                que.push_front('(');
                idx++;
            }
        }
        idx++;
    }

    for (int i = 0;i < cnt;i++){
        que.push_back(')');
    }

    for (int i = 0;i < que.size();i++){
        cout << que[i];
    }

    cout << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s,ss;
  while(cin >>s){
    ss = s;
    bool f = true;
    for(int i=0; i<10; i++){
      for(int j=0; j<s.size(); j++){
	if(s[j] == 'X'){ss[j] = i+'0';}
	else{ss[j] = s[j];}
      }
      string a,b,c,d;
      int pos_add = ss.find('+');
      int pos_equ = ss.find('=');
      a = ss.substr(0,pos_add);
      b = ss.substr(pos_add+1,pos_equ-pos_add-1);
      c = ss.substr(pos_equ+1,ss.size());
      int as = a.size(), bs = b.size();
      int alls = max(as,bs);
      int x = 0;
      for(int j=0; j<alls; j++){
	if(j<as && j<bs){x+=a[as-j-1]+b[bs-j-1]-'0'*2;}
	else if(j<as){x+=a[as-j-1]-'0';}
	else if(j<bs){x+=b[bs-j-1]-'0';}
	d = (char)(x%10+'0')+d;
	x/=10;
      }
      if(x){d = (char)(x%10+'0')+d;}
      if(d == c){cout <<i<<endl;f = false;break;}
    }
    if(f){cout <<"NA"<<endl;}
  }
  return 0;
}

Measured memory_bytes: 1196
import java.util.*;
import java.io.*;

class Main {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
   while(sc.hasNext()){
	   int a=sc.nextInt();
	   int b=sc.nextInt();
	   int keta=1;
	   if((a+b)/10>0)keta++;
	   if((a+b)/100>0)keta++;
	   if((a+b)/1000>0)keta++;
	   if((a+b)/10000>0)keta++;
	   if((a+b)/100000>0)keta++;
	   if((a+b)/1000000>0)keta++;
	   System.out.println(keta);
	  }
   
      }
}

Measured memory_bytes: 20412
N = int(input())
S = list(input() for i in range(N))

import collections

c = collections.Counter(S)
max = max(c.values())
 
max_k_list = [kv[0] for kv in c.items() if kv[1] == max]
max_k_list.sort()
for l in max_k_list:
    print(l)

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

int main(){
	/*input*/
	int n;	cin >> n;
	int* l = new int[n];  
	for(int i = 0; i < n; i++){
		cin >> l[i];
	}
	/*calculation*/
	int sum = 0;
	int max = 0;
	for(int i = 0; i < n; i++){
		sum += l[i];
		if(max < l[i])	max = l[i];
	}
	/*output*/
	if((sum - max) > max){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	delete[] l;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i, min = 10, time = 0, a[5];
    for (i = 0; i < 5; i++)
        scanf("%d", &a[i]);

    for (i = 0; i < 5; i++)
        time += (a[i] + 9) / 10 * 10;

    for (i = 0; i < 5; i++){
        if(min > (a[i] % 10) && 0 < (a[i] % 10)){
            min = a[i] % 10;
        }
    }

    printf("%d\n", time + (min - 10));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
const int INF = 1 << 30;
typedef pair < int , int > Pi;
int n, m, mas[101][101], hoge[4][51][51];

bool isfind( const int& k, const int& y, const int& x, Pi& exitp)
{
  for(int i = 0 ; i < m ; i++ ){
    for(int j = 0 ; j < m ; j++ ){
      if( hoge[k][i][j] == -1) continue;
      if( mas[i + y][j + x] != hoge[k][i][j]) return false;
      if(exitp == Pi(-1,-1)) exitp = Pi(i + y + 1,j + x + 1);
    }
  }
  return true;
}

Pi solve()
{

  for(int i = 0 ; i <= n - m ; i++ ){

    Pi ret = Pi( INF, INF);

    for(int j = 0 ; j <= n - m ; j++ ){
      for(int k = 0 ; k < 4 ; k++ ){
        Pi p = Pi( -1, -1);
        if(isfind( k, i, j, p)){
          ret = min( ret, p);
        }
      }
    }
    if(ret.first != INF) return ret;
  }
  return Pi( INF, -1);
}
int main()
{
  while(cin >> n >> m, n){
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < n ; j++ ){
        cin >> mas[i][j];
      }
    }
    for(int i = 0 ; i < m ; i++ ){
      for(int j = 0 ; j < m ; j++ ){
        cin >> hoge[0][i][j];
      }
    }

    for(int k = 1 ; k < 4 ; k++ ){
      for(int i = 0 ; i < m ; i++ ){
        for(int j = 0 ; j < m ; j++ ){
          hoge[k][j][m - i - 1] = hoge[k - 1][i][j];
        }
      }
    }

    Pi pos = solve();
    if(pos.first == INF) cout << "NA" << endl;
    else cout << pos.second << " " << pos.first << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
#define MAX 100005
#define NIL -1
using namespace std;
typedef long long ll;

vector<int> T[200005];
vector<int> ans;

void dfs(int a, int p){
	for(int x : T[a]) {
		if(x != p){
			ans[x] += ans[a];
			dfs(x, a);
		}
	}
}

int main(void){
	int n, q;
	cin >> n >> q;
	rep(i, n - 1){
		int a, b;
		cin >> a >> b;
		T[a].push_back(b);
		T[b].push_back(a);
	}
	ans.resize(n + 1);
	rep(i, q){
		int p, x;
		cin >> p >> x;
		ans[p] += x;
	}
	dfs(1, 0);
	for(int i = 1; i <= n; i++) cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const int MAX = 1e5;

int main(){
    int n,k; cin >> n >> k;
    int t;
    map<int,int> m;
    REP(i,n){
        cin >> t;
        ++m[t];
    }
    vector<int> v;
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        v.push_back(itr->second);
    }
    sort(v.begin(),v.end());
    int ans = 0;
    if(k < v.size()){
        for(int i = 0; i < v.size() - k; ++i){
            ans += v[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10748
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import floor

x = int(read())
v = 100
for i in range(x):
    v = floor(v * 1.01)
    if v >= x:
        print(i + 1)
        exit()


Measured memory_bytes: 9112
#include<stdio.h>
int main(void)
{
	int t,a,b,x;
	scanf("%d %d %d",&t,&a,&b);
	x=t*a;
	if(x<=b){
		printf("%d\n",x);
	}
	else if(b<=x){
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	string s;
	cin >> s;
	int a = 10*(s[0]-'0') + s[1]-'0';
	int b = 10*(s[2]-'0') + s[3]-'0';
	bool a1,b1;
	if(a>=1 && a<= 12) a1 =true;
	else a1 = false;
	if(b>=1 && b<= 12) b1 =true;
	else b1 = false;

	if(a1&&b1){
		cout << "AMBIGUOUS" << endl;
	}else if(a1&&!b1){
		cout << "MMYY" << endl;
	}else if(!a1 && b1){
		cout << "YYMM" << endl;
	}else{
		cout << "NA" << endl;
	}

	

		return 0;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const [string, stringK] = input.split('\n').map(v => v.trim())
  const k = Number(stringK)
  const s = string.split('')
  // 1pattern
  if (s.length === 1) {
    console.log(Math.floor(k / 2))
    return
  }
  let allSameFlg = true
  let count = 0
  let changeFlg = false
  let combo = 1
  let initialCombo = 1
  let initialComboFlg = true
  const s2 = s.reduce((a, b)=> {
    if (a === b){
      combo++
      if (changeFlg === false) {
        count++
        changeFlg = true
      } else {
        changeFlg = false
      }
    } else {
      if (initialComboFlg) {
        initialCombo = combo
        initialComboFlg = false
      }
      combo = 1
      changeFlg = false
      allSameFlg = false
    }
    return b
  })
  if (allSameFlg) {
    initialCombo = combo
  }
  const lastCombo = combo
  // そのほかのパターン
  count *= k
  if (s.length !== 2 && s[0] === s[s.length - 1]) {
    if (initialCombo % 2 !== 0 && combo % 2 !== 0) {
      count += (k - 1)
    }
  }

  // 奇数で全部同じパターン
  if (allSameFlg && s.length % 2 !== 0) {
    console.log(Math.floor((s.length * k) / 2))
  } else {
    console.log(count)
  }
}
main()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << 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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
const int INF = 1001001001;
signed main(){
    int n;cin >> n;
    int a[n+1];

    rep(i,n)cin >> a[i];
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    a[n] = 0;
    //if(a[n-1] <= a[n])a[n] = INF;
    //else if(a[n-1] >= a[n])a[n] = -INF;
    
    int ret = 0;
    for(int i = 0,j;i < n;i = j+1){
        for(j = i;j < n && a[j]>= a[j+1];j++);
        int res1 = j;
        for(j = i;j< n & a[j] <= a[j+1];j++);
        int res2 = j;
        ret++;
        j = max(res1,res2);
        //trace(i,j,res1,res2,ret);
        //if(j == n-1)break;


    }
    cout << ret << endl;

    return 0;
}

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

int main(int argc, char const *argv[]) {

    while(1) {
        string cards;
        int m;
        cin >> cards >> m;
        int len = cards.size();

        if (cards == "-") {
            break;
        }

        while(m--) {
            int h;
            cin >> h;
            cards = cards.substr(h, len - h) + cards.substr(0, h);
        }

        cout << cards << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
  #endif

  int R;
  cin >> R;
  cout << setprecision(10)<<  2*3.14159265358979323*R << endl;
  return 0;
}

Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int main(){
	int N, Q; cin >> N >> Q;
	char S[N]; cin >> S;
	int l[Q], r[Q];
	for(int i = 0; i < Q; i++) cin >> l[i] >> r[i];
	int acl[N-1];
	if(S[0] == 'A' && S[1] == 'C') acl[0] = 1;
	else acl[0] = 0;
	for(int i = 1; i < N - 1; i++){
		if(S[i] == 'A' && S[i+1] == 'C') acl[i] = acl[i-1] + 1;
		else acl[i] = acl[i-1];
	}
	for(int i = 0; i < Q; i++){
		if(l[i]-2 < 0) cout << acl[r[i]-2] << endl;
		else cout << acl[r[i]-2] - acl[l[i]-2] << endl;
	}
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, A;
    cin >> N >> A;

    cout << (N * N - A) << endl;
    
    return 0;
}

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

int N,M;
char temp[100][100] = {0},temp2[100][100] = {0};

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            scanf(" %c",&temp[i][j]);
        }
    }
    for(int i = 0; i < M; i++)
    {
        for(int j = 0; j < M; j++)
        {
            scanf(" %c",&temp2[i][j]);
        }
    }
    for(int i = 0; i <= N - M; i++)
    {
        for(int j = 0; j <= N - M; j++)
        {
            bool flag = true;
            for(int k = 0; k < M; k++)
            {
                for(int l = 0; l < M; l++)
                {
                    if(temp[i + k][j + l] != temp2[k][l])flag = false;
                }
            }
            if(flag)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
typedef complex<double> cd;
static const double pi = 3.141592653589793;

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

  int n; cin >> n;
  unordered_map<int,int> cnt;
  rep(i, n) {
    int a; cin >> a;
    ++cnt[a];
  }

  bool ok = 1;
  int m; cin >> m;
  rep(i, m) {
    int t; cin >> t;
    if(!ok) continue;

    if(cnt[t] == 0) {
      ok = 0;
    } else {
      --cnt[t];
    }
  }

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


Measured memory_bytes: 8520
#include<stdio.h>
int main(void){
    int r, D;
    int x[11];
    scanf("%d %d %d", &r, &D, &x[0]);
    for(int i = 1; i < 11; i++){
        x[i] = r*x[i-1] - D;
        printf("%d\n", x[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解説を思い出しながら自分で書く
const int INF =1001001001;
vector<int>to[100005];
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    --a;--b;//ここを忘れない！
    to[b].push_back(a);
    to[a].push_back(b);
  }
  queue<int>q;
  vector<int> dist(n,INF);
  vector<int> pre(n,-1);
  q.push(0);
  dist[0]=0;

  while(!q.empty()){
    int v=q.front();q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF)continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++){
    if(i==0)continue;
    int kotae=pre[i];
    kotae++;
    cout<<kotae<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 10696
n, k = map(int, input().split())
As = list(map(int, input().split()))

from itertools import accumulate
acc = [0]+list(accumulate(As))
dp = [0] * 50
mx = 0
sums = []
for i in range(n+1):
    for j in range(i+1,n+1):
        s = acc[j]-acc[i]
        sums.append(s)

# 最大の桁数
for d in range(50):
    if max(sums) & (1<<d):
        mx = max(mx, d)
        dp[d] += 1
mx = 0
for i in range(50):
    if dp[i] >= k:
        mx = max(mx,i)

# 計算
ans = 0
now = 0
for d in range(50,-1,-1):
    cnt = 0
    for s in sums:
        if s & (now+(1<<d)) == now+(1<<d):
            cnt += 1
    # print(d,cnt)
    if cnt >= k:
        now += 1<<d
print(now)

Measured memory_bytes: 109908
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll H, W, K;
  cin >> H >> W >> K;

  vector<string> field(H);
  for (int h = 0; h < H; h++) {
    cin >> field[h];
  }

  vector<string> field_copy = field;

  ll ans = 0;
  for (ll h = 0; h < 1 << 7; h++) {
    if (h >= (1 << H)) break;
    for (ll w = 0; w < 1 << 7; w++) {
      if (w >= (1 << W)) break;
      // 初期化
      field_copy = field;

      // 行の変更
      ll h_copy = h;
      ll change_h = 0;
      while (h_copy) {
        if (h_copy & 1) {
          for (auto& x : field_copy[change_h]) {
            if (x == '#') {
              x = '.';
            } else {
              x = '.';
            }
          }
        }
        h_copy >>= 1;
        change_h++;
      }
      // 列の変更
      ll w_copy = w;
      ll change_w = 0;
      while (w_copy) {
        if (w_copy & 1) {
          for (ll i = 0; i < H; i++) {
            auto& x = field_copy[i][change_w];
            if (x == '#') {
              x = '.';
            } else {
              x = '.';
            }
          }
        }
        w_copy >>= 1;
        change_w++;
      }
      // カウント
      ll count = 0;
      for (const auto& x : field_copy) {
        for (const auto& y : x) {
          if (y == '#') {
            count++;
          }
        }
      }

      // 判定
      if (count == K) {
        ans++;
      }
    }
  }

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


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(){
  int k;
  int a,b;
  cin >> k;
  cin >> a >> b;
  int s = 0;
  while(s<=b){
    if(a <= s && s <= b) {
      cout << "OK" << endl;
      return 0;
    }
    s+=k;
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3636
#include<cstring>
#include<cstdio>
using namespace std;

char s1[100],s2[100];
int main()
{
	scanf("%s%s",s1,s2);
	if (s1[0]=='D' && s2[0]=='D') printf("H\n");
	if (s1[0]=='H' && s2[0]=='D') printf("D\n");
	if (s1[0]=='D' && s2[0]=='H') printf("D\n");
	if (s1[0]=='H' && s2[0]=='H') printf("H\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
#include<cctype>
#include<algorithm>
const int INF=1e9;
using namespace std;

int main(){
    int n, a;
    cin>>n>>a;
    cout<<n*n-a<<endl;
    
}


Measured memory_bytes: 256
require 'set'

n = gets.to_i
as = []
n.times do
  as << gets.split.map(&:to_i)
end

dp = {}

(0...n).each do |i|
  dp[i] ||= []
  (0..2).each do |j|
    if i == 0
      dp[i][j] = as[i][j]
    else
      case j
      when 0
        tmp = [1,2]
      when 1
        tmp = [0,2]
      when 2
        tmp = [0,1]
      end
      # tmp = (Set.new([0,1,2]) ^ [j]).to_a
      dp[i][j] = [dp[i-1][tmp[0]], dp[i-1][tmp[1]]].max + as[i][j]
    end
  end
end

puts dp[n-1].max


Measured memory_bytes: 21884
def compute_depth(node: int, depth: int) -> None:
    global trees
    trees[node]["depth"] = depth
    for child in trees[node]["children"]:
        compute_depth(child, depth + 1)


def compute_height(node: int, height: int) -> None:
    global trees
    trees[node]["height"] = height
    parent = trees[node]["parent"]
    if -1 != parent:
        compute_height(parent, height + 1)


if __name__ == "__main__":
    node_num = int(input())
    trees = {idx:
             {"parent": -1, "sibling": -1, "children": [], "depth": 0, "height": 0,
              "node_type": ""} for idx in range(node_num)}

    for _ in range(0, node_num):
        node, *children = map(lambda x: int(x), input().split())
        if (-1 != children[0]) and (-1 != children[1]):
            trees[node]["children"] = children
            trees[children[0]]["sibling"], trees[children[1]]["sibling"] = children[1], children[0]
            trees[children[0]]["parent"] = trees[children[1]]["parent"] = node
        elif [-1, -1] != children:
            child = children[0] * children[1] * (-1)
            trees[node]["children"] = [child]
            trees[child]["parent"] = node

    for node, values in sorted(trees.items(), key=lambda x: x[1]["parent"]):
        if -1 == values["parent"]:
            trees[node]["node_type"] = "root"
            compute_depth(node, 0)
        else:
            if [] == values["children"]:
                trees[node]["node_type"] = "leaf"
            else:
                trees[node]["node_type"] = "internal node"

    for node, values in sorted(filter(lambda x: x[1]["node_type"] == "leaf", trees.items()), key=lambda x: x[1]["depth"]):
        compute_height(node, 0)

    for node, values in trees.items():
        print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(
            node, values["parent"], values["sibling"], len(values["children"]), values["depth"], values["height"], values["node_type"]
        ))



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

int main() {
  long long x, y = 100, n = 1;
  cin >> x;

  while (1) {
    y = floor(y * 1.01);
    if (y >= x) {
      cout << n << endl;
      return 0;
    } else {
      n++;
    }
  }
}

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

using namespace std;

int main()
{
    int A;
    int B;
    int C;
    int D;
    int L;
    int R;

    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;

    L = A + B;
    R = C + D;

    if(L > R)
    {
        cout << "Left" << endl;
    }

    else if(L == R)
    {
        cout << "Balanced" << endl;
    }

    else if(L < R)
    {
        cout << "Right" << endl;
    }

return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int dp[22][2020];

int main(){
  int D,G; cin>>D>>G;
  int P[D],C[D];
  int cnt=0;
  rep(i,D){
    cin>>P[i]>>C[i];
    cnt+=P[i];
  }
  rep(i,22) rep(j,2020) dp[i][j]=-1;
  dp[0][0]=0;
  int ans=1e9;
  rep(i,D) rep(j,cnt+1) if(dp[i][j]!=-1){
    for(int k=0;k<=P[i];k++){
      int tmp=0;
      if(k==P[i]) tmp=C[i];
      dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+(100*(i+1)*k)+tmp);
      if(dp[i+1][j+k]>=G) ans=min(ans,j+k);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

class BFS
{
    vector<int> tree, state;
    vector<vector<int>> edges;
    int N, Q;

public:
    BFS(int n = 0, int q = 0) : N(n), Q(q)
    {
        tree.resize(N);
        state.resize(N);
        edges.resize(N);
        load_edge();
    }

    void load_edge()
    {
        int u, v;
        for (int i = 0; i < N - 1; i++)
        {
            cin >> u >> v;
            edges.at(--u).push_back(--v);
            edges.at(v).push_back(u);
        }

        int p, x;
        for (int i = 0; i < Q; i++)
        {
            cin >> p >> x;
            tree.at(--p) += x;
        }
    }

    void bfs(int node)
    {
        queue<int> qu;
        qu.push(node);
        while (!qu.empty())
        {
            node = qu.front();
            qu.pop();
            for (int v : edges.at(node))
            {
                if (state.at(v) != 1)
                {
                    qu.push(v);
                    tree.at(v) += tree.at(node);
                }
            }
            state.at(node) = 1;
        }
    }

    void print()
    {
        for (int i = 0; i < N; i++)
        {
            if (i)
                cout << " ";
            cout << tree.at(i);
        }
        cout << endl;
    }
};

int main()
{
    int N, Q;
    cin >> N >> Q;
    BFS bfs(N, Q);
    bfs.bfs(0);
    bfs.print();
}

Measured memory_bytes: 16372
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

#60 90 120
#80 150 80 150

for i in range(N):
    a.append(a[i] + A[i])

for j in range(M):
    b.append(b[j] + B[j])
#print(a,b)
ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
        
    ans = max(i + j, ans)
    
print(ans)


Measured memory_bytes: 47544
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t,i,j,a,b;
     
        scanf("%d%d",&a,&b);
     
        if( b>=2*a && b<=4*a && b%2==0)
        printf("Yes\n");
        else
        printf("No\n");
    }   

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void max_self(ll& a, ll b) {
    a = max(a, b);
}

// O(n * W)

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value of items with total weight exactly i
    for(int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        // dp[0] -> dp[3] -> dp[6]
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) {
            //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            max_self(dp[weight_already+weight], dp[weight_already] + value);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= W; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 4044
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N, A, g = 0;
    cin >> N;
    REP(i, 5) {
        cin >> A;
        g = max(g, (N + A - 1) / A);
    }
    cout << 4 + g << endl;
    return 0;
}

Measured memory_bytes: 384
l = int(input())
num_lis = list(input().split())

for i in range(l):
    num_lis[i] = int(num_lis[i])

ans = 'APPROVED'
for i in range(l):
    if num_lis[i]%2 == 0:
        if num_lis[i]%3 != 0:
            if num_lis[i]%5 !=0:
                ans ='DENIED'
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void)
{
    int K, X, min, max, i;

    cin >> K >> X;

    min = X - K + 1;

    max = X + K - 1;

    for(i=min; i<=max; i++){
	cout << i << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	string s; cin >> s;
	LL letter_count[26], ans = 1;
	memset(letter_count, 0, sizeof letter_count);
	rep(i, 0, s.length())	letter_count[s[i]-'a']++;
	rep(i, 0, 26)	ans = (ans * (letter_count[i] + 1)) % MOD;
	ans--; // remove empty string
	pll(ans); nl;
}


Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	long long bb=0;
	map<long long,long long> mp;
	for(int i = 0;i<n;i++)
	{
		long long a;
		cin >> a;
		bb += a;
		mp[bb]++;
	}
	long long k=0;
	for(auto itr=mp.begin();itr!=mp.end();itr++)
	{
		long long d;
		d = itr->second;
		if(itr->first == 0)
		{
			k += d * (d + 1) / 2;
		}
		else
		{
			k += (d - 1) * d / 2;
		}
	}
    cout << k << endl;
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
//Coding Is Shit
#define  ll long long int
const int MAXN = (int)2e5+100;

bool cool[MAXN];


vector< int >v1;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i = 0 ;i<m;i+=1)
    {
        int x,y;
        cin>>x>>y;
        
        if(x==1)
        {
           v1.push_back(y);
        }
        else if (y==1)
        {
            v1.push_back(x);
        }
        if(x==n)
        {
            cool[y] = true;
        }
        if(y==n)
        {
            cool[x] =true;
        }
    }
    bool ans = false;
    for(int i = 0;i<v1.size();i+=1)
    {
        if(cool[v1[i]])
        {
            ans =true;
        }
    }
    if(ans)
    {
        cout<<"POSSIBLE"<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    
    
    
    return 0;
    
}


Measured memory_bytes: 1148