akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        x: usize,
    }
    println!("{}", if x == 7 || x==5 || x ==3{"YES"}else {"NO"})
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;

signed main(){
	cin>>S;
	if(S[0]=='7'||S[1]=='7'||S[2]=='7'){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

int main()
{
	int a, b, c, m;
	cin >> a >> b >> c;
	if (a > b)
	{
		if (a > c)
		{
			cout << a * 10 + b + c;
		}
		else
		{
			cout << c * 10 + b + a;
		}
	}
	else
	{
		if (b > c)
		{
			cout << b * 10 + a + c;
		}
		else
		{
			cout << c * 10 + a + b;
		}
	}

	return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 097C.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S          PIC X(5000).
01 K          PIC 9(1) COMP.
01 I          PIC 9(4) COMP.
01 J          PIC 9(4) COMP.
01 JW         PIC 9(4) COMP.
01 TBL.
   03 DIC     PIC X(5) OCCURS 25000 DEPENDING ON S-N.
01 S-N        PIC 9(5) COMP.
01 IX         PIC 9(5) COMP.
01 LEN        PIC 9(4) COMP. 
01 OUT        PIC X(5).
*>
PROCEDURE DIVISION.
  ACCEPT S.
  ACCEPT K.
  UNSTRING S DELIMITED BY ' '
      INTO S COUNT LEN.
*>
  if (LEN < 5)
    COMPUTE S-N = LEN * (LEN + 1) / 2
  ELSE
    COMPUTE S-N = (LEN - 4) * 5 + 10
  END-IF.
*>
  MOVE 0 TO IX.  
  MOVE SPACE TO TBL.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > LEN
    PERFORM VARYING J FROM 1 BY 1 UNTIL J > 5 OR I + J - 1 > LEN
      ADD 1 TO IX
      MOVE S(I:J) TO DIC(IX)
    END-PERFORM  
  END-PERFORM.
*>
  SORT DIC ASCENDING KEY DIC.
*>
  MOVE 1 TO I J.
  PERFORM UNTIL I >= K
    MOVE J TO JW
    PERFORM VARYING J FROM JW BY 1 UNTIL DIC(J) NOT = DIC(JW)
    END-PERFORM
    ADD 1 TO I
  END-PERFORM.
  MOVE DIC(J) TO OUT.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 636
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.IO;

public class Playground
{
    private static int[] item1;
    private static int[] item2;

    public static void Main(string[] args)
    {
        Input();
        Method();
        System.Console.ReadLine();
    }

    private static void Input()
    {
        Console.ReadLine();
        item1 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        Console.ReadLine();
        item2 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    private static void Method()
    {
        int sum = 0;
        foreach (var t in item2)
        {
            int lo = 0;
            int hi = item1.Length;
            while (lo <= hi && lo < item1.Length)
            {
                int medium = lo + (hi - lo) / 2;
                if (t == item1[medium])
                {
                    sum++;
                    break;
                }
                else if (t > item1[medium])
                {
                    lo = medium + 1;
                }
                else
                {
                    hi = medium - 1;
                }
            }
        }

        System.Console.WriteLine(sum);
    }
}

Measured memory_bytes: 19688
#coding:utf-8


N, M = list(map(int, input().split()))

A = []
B = []
for i in range(N):
    info = list(map(int, input().split()))
    A.append(info[0])
    B.append(info[1])

AB = [[A[i], B[i]] for i in range(N)]

AB = sorted(AB, key = lambda x: x[0])

yen = 0
head = 0
temp_M = M
while(True):
    nokori = AB[head][1]
    for i in range(temp_M):
        yen += AB[head][0]
        temp_M -= 1
        nokori -= 1
        if nokori == 0:
            break
    head += 1
    if temp_M ==0:
        break
print(yen)

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 1 << 18;

vi mx[MN];

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

	rep(i, 1 << N) {
		int x; cin >> x;
		mx[i].pb(x);
	}

	rep(i, N) {
		rep(j, 1 << N) {
			if (!((j >> i) & 1)) {
				int b = j | (1 << i);
				for (int x : mx[j]) {
					mx[b].pb(x);
				}
				sort(ALL(mx[b]));
				reverse(ALL(mx[b]));
				while (mx[b].size() > 2) {
					mx[b].pop_back();
				}
			}
		}
	}

	vi ans(1 << N);
	rep(i, 1 << N) {
		if (mx[i].size() >= 2) {
			ans[i] = mx[i][0] + mx[i][1];
		}
		if (i) {
			ans[i] = max(ans[i], ans[i-1]);
			cout << ans[i] << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   long int ans = 0;
   cin>>n;

   for(long int a = 1; a < n; a++){
   		long int bMax = (n + a - 1) / a;
   		ans += bMax - 1;
   }

   cout<<ans;
   return 0;
}

Measured memory_bytes: 3648
### classes

class Node
  attr_accessor :nv, :nbrs, :prv

  def initialize(nv)
    @nv = nv
    @nbrs = []
    @prv = nil
  end

  def next_nv
    @nv = 3 * @nv + 1
    while (@nv & 1) == 0
      @nv >>= 1
    end
    @nv -= 12345678 if @nv > 12345678
    @nv
  end

  def leaf_bonus
    lb = (@nv + 1) / 2
    (lb & 1) == 1 ? lb : lb + 1
  end

  def root_bonus
    rb = (@nv + 1) / 2
    (rb & 1) == 1 ? rb : rb - 1
  end

  def root?
    @prv.nil?
  end
  
  def leaf?
    @nbrs.empty?
  end

  def add(nd)
    nd.prv = self
    @nbrs << nd
    nd
  end

  def to_s
    self.leaf? ?
      @nv.to_s :
      @nv.to_s + "(" + @nbrs.map{|nd| nd.to_s}.join(',') + ")"
  end
end

### global variables

### subroutines

### main

loop do
  ki = gets.to_i
  break if ki == 0

  root = Node.new(ki)
  max_n = 1
  t = 0
  #p root.to_s
  #p "t=#{t}, max_n=#{max_n}"

  loop do
    t += 1

    # 1.
    q = [root]
    n = 0
    cds = []
    max_nv = 0
    uniq_cd = nil
    
    while ! q.empty?
      u = q.shift
      unv0 = u.nv
      unbrs = u.nbrs
      uprv = u.prv

      unv = u.next_nv
      if unv == 1
        break if u.root?
        uprv.nbrs.delete(u)

        if unbrs.length == 1
          uprv.add(unbrs.first)
          q << unbrs.first
        end
        next
      end

      n += 1

      if max_nv < unv
        max_nv = unv
        uniq_cd = u
      elsif max_nv == unv
        uniq_cd = nil
      end

      if u.leaf? && unv > unv0
        cds << u
      end

      for v in unbrs
        q << v
      end
    end

    break if root.nv == 1
    
    # 2.
    for cd in cds
      lbnv = cd.leaf_bonus
      lb = Node.new(lbnv)
      cd.add(lb)
      n += 1
      
      if max_nv < lbnv
        max_nv = lbnv
        uniq_cd = lb
      elsif max_nv == lbnv
        uniq_cd = nil
      end
    end
    #p (uniq_cd ? uniq_cd.nv : nil)
    
    # 3.
    if ! uniq_cd.nil? && uniq_cd != root
      prnt = nil
      nd = uniq_cd

      while nd != root
        nd0 = nd.prv
        nd.nbrs << nd0
        nd.nbrs.delete(prnt)
        nd.prv = prnt
        prnt = nd
        nd = nd0
      end

      root.nbrs.delete(prnt)
      root.prv = prnt

      root = uniq_cd
    end

    if ! uniq_cd.nil?
      rbnv = root.root_bonus
      rb = Node.new(rbnv)
      root.add(rb)
      n += 1
    end

    max_n = n if max_n < n

    #p root.to_s
    #p "t=#{t}, max_n=#{max_n}"
  end
  #p root.to_s
  #p "finished: t=#{t}, max_n=#{max_n}"

  puts [t, max_n].join(' ')
end

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

int main() {
  #define int long long
  int n, a, b;
  cin >> n >> a >> b;
  int q = n / (a + b);
  int r = n % (a + b);
  if (r < a) {
    cout << a * q + r << endl;
  }
  else {
    cout << a * q + a << endl;
  }
}


Measured memory_bytes: 256
from itertools import accumulate
def myAnswer(N:int,A:list) -> int:
   accum = list(accumulate(A))
   ans = 10**10
   now = accum.pop()
   for a in accum:
      if(abs(now - a - a) < ans):
         ans = abs(now - 2*a)
   return ans

   

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()


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





int main(){
    int K;
    int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> K;
    cout << A[K-1] << endl;
} 

Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int[][] card = new int[4][13];

        int sheets = Integer.parseInt(br.readLine());
        for(int i=0; i<sheets; i++){
            String[] str = br.readLine().split(" ");
            int num = Integer.parseInt(str[1]);
            if(str[0].equals("S")){
                card[0][num-1] = 1;
            }else if(str[0].equals("H")){
                card[1][num-1] = 1;
            }else if(str[0].equals("C")){
                card[2][num-1] = 1;
            }else if(str[0].equals("D")){
                card[3][num-1] = 1;
            }else break;
        }

        for(int i=0; i<4; i++){
            for(int j=0; j<13; j++){
                if( card[i][j] == 0){
                    if(i == 0){
                        sb.append("S");
                    }else if(i == 1){
                        sb.append("H");
                    }else if(i == 2){
                        sb.append("C");
                    }else if(i == 3){
                        sb.append("D");
                    }
                    sb.append(" ").append(j+1).append("\n");
                }
            }
        }
        System.out.print(sb);

    }
}

Measured memory_bytes: 24288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n;
    string s;
    cin >> n >> s;
    cout << (n < 3200 ? "red" : s);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		if (b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}

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

int main()
{
	ll a,b,m;
	cin>>a>>b>>m;
	ll ar[a],br[b];
	for(ll i=0;i<a;i++)
	{
		cin>>ar[i];
	}
	ll ma=*min_element(ar,ar+a);
	for(ll j=0;j<b;j++)
	{
		cin>>br[j];
	}
		ll mb=*min_element(br,br+b),o=ma+mb;
	for(ll i=0;i<m;i++)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		o=min(o,ar[x-1]+br[y-1]-z);
	}
	cout<<o<<endl;
}

Measured memory_bytes: 1792
S=input()
B0=int(S[-1])
B1=10-int(S[-1])
for s in S[::-1][1:]:
    x=int(s)
    B0,B1=min(B0+x,B1+x+1),min(B0+(10-x),B1+(10-x-1))
print(min(B0,B1+1))

Measured memory_bytes: 7992
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    string s,t,u;
    ll a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u)cout << max(a - 1,0ll) << " " << b;
    else cout << a << " " << max(b - 1,0ll);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
as_ = map(int, input().strip().split())

d = defaultdict(int)

for a in as_:
    d[a] += 1

counts = 0
for k, v in d.items():
    if k < v:
        counts += v - k
    elif k > v:
        counts += v

print(counts)


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

int main(){
	int m;
	int c,a,n;
	cin>>m;
	for(int j=0;j<m;j++){
		int i=0;
		cin>>c>>a>>n;
		//cout<<c<<a<<n<<endl;
		while(a>=1&&n>=1&&c>=1){a--;n--;c--;i++;}
		while(a>=1&&c>=2){a--;c-=2;i++;}
		while(c>=3){c-=3;i++;}
		cout<<i<<endl;
		
		//cout<<c<<a<<n<<endl;
	}

}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll count = 0; 
	for (ll i = 1; i < n-1; i++) {
		if (a[i] != max({ a[i - 1],a[i],a[i + 1] }) && a[i] != min({ a[i - 1],a[i],a[i + 1] })) {
			count++;
		}
	}
	cout << count << endl;

}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += min(B[i], A[i]+A[i+1])
    A[i+1] = max(0, A[i+1] - max(0, (B[i]-A[i])))
print(ans)


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

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define fill(a,v)  memset(a, v, sizeof (a))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N=501000;
const int MOD = 1e9 + 7 ;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
	faster;

    int n;

    cin >> n;
    vi stick(n);
    for(int i = 0; i < n; ++i){
    	cin >> stick[i];
    }

    sort(stick.begin(), stick.end());

    int res = 0;
    for(int i = 0; i < n; ++i){
    	for(int j = i+1; j < n; ++j){
    		int be = j+1, en = n-1, pos = -1, mid;

    		while(be <= en){
    			mid = (be+en)/2;

    			if(stick[mid] < stick[i]+stick[j]){
    				pos = mid;
    				be = mid+1;
    			}
    			else{
    				en = mid-1;
    			}
    		}

    		if(pos != -1)	res += pos-j;
    	}
    }
    cout << res;

	return 0;
}

// READ
// THINK
// CODE 
// DEBUG 
// AC	

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli pop=0;
lli modpow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return modpow(n,k-1,m)*n%m;
  else{
    lli temp=modpow(n,k/2,m);
    return temp*temp%m;
  }
}
lli solve(string S){
  lli N=S.size();
  lli num=0;
  rrep(i,N,0)num+=(S[i]-'0')*modpow(2,N-i-1,pop);
  return num%pop;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,X,Y,N,num=0,sum=0,flag=0;string S,T;
  cin >> N >> S;
  rep(i,0,N)if(S[i]=='1')pop++;
  Vec(dp,lli,200001,INF);
  dp[0]=0;
  rep(i,1,200001)dp[i]=dp[i%(__builtin_popcount(i))]+1;
  A=INF;
  B=INF;
  rep(i,0,N){
    if(S[i]=='1'){
      A=i;
      break;
    }
  }
  rep(i,0,N){
    if(S[i]=='0'){
      B=i;
      break;
    }
  }
  T=S;
  if(A!=INF){
    T[A]='0';
    pop--;
    if(pop)X=solve(T);
    else X=0;
    if(pop)X+=modpow(2,N-A-1,pop);
    T[A]='1';
    pop++;
  }
  if(B!=INF){
    T[B]='1';
    pop++;
    Y=solve(T);
    T[B]='0';
    Y-=modpow(2,N-B-1,pop);
    Y=(Y+1000*pop)%pop;
    pop--;
  }
  rep(i,0,N){
    if(S[i]=='1'&&pop!=1)Out(dp[(X+1000*(pop-1)-modpow(2,N-i-1,(pop-1)))%(pop-1)]+1);
    else if(S[i]=='1')Out(0);
    else Out(dp[(Y+modpow(2,N-i-1,pop+1))%(pop+1)]+1);
  }
}

Measured memory_bytes: 5444
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		if("+".equals(op)){
			System.out.println(a+b);
		}else if("-".equals(op)){
			System.out.println(a-b);
		}
	}
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll rans = 0, lans = 0;
  ll sum = 0;
  rep(i, n) {
    sum += a[i];
    if(i%2 == 0 && sum <= 0) {
      rans += 1-sum;
      sum = 1;
    }
    else if(i%2==1 && sum >= 0) {
      rans += sum+1;
      sum = -1;
    }
  }
  sum = 0;
  rep(i, n) {
    sum += a[i];
    if(i%2==0 && sum >= 0) {
      lans += sum+1;
      sum = -1;
    }
    else if(i%2==1 && sum <= 0) {
      lans += 1-sum;
      sum = 1;
    }
  }
  cout << min(rans, lans) << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

int N;
string S;
void input() {
  cin>>N;
  cin>>S;
}
int cnt[26]={};
void solve() {
  for(auto x : S){
    cnt[x-'a']++;
  }

  int ans = 1;
  rep(i,0,25){
    ans *= cnt[i]+1;
    ans %= MOD;
  }
  cout<<(ans+MOD-1)%MOD<<endl;


  
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, K) = read_tuple::<f64>();
    println!("{}", ((N-1.0) / (K-1.0)).ceil());
}


Measured memory_bytes: 4352
def main():
    K, N = map(int, input().split())
    A = [int(a) for a in input().split()]
    dlist = list()

    for i in range(N):
        if i == N - 1:
            d = A[0] + K - A[-1]
            dlist.append(d)
        else:
            d = abs(A[i] - A[i+1])
            dlist.append(d)
    dlist.sort()
    print(sum(dlist[:N-1]))

if __name__ == "__main__":
    main()

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

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = 9000000000000000000;
  vector<ll> vx;
  vector<ll> vy;
  vector<pair<ll, ll>> vxy;
  rep(i,n){
    ll x,  y;
    cin >> x >> y;
    vx.push_back(x);
    vy.push_back(y);
    vxy.push_back(make_pair(x, y));
  }
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  for (int xi = 0; xi < n; xi++){
    for (int xj = xi + 1; xj < n; xj++){
      for (int yi = 0; yi < n; yi++){
        for (int yj = yi + 1; yj < n; yj++){
          int cn = 0;
          ll tmp = (ll)(vx[xj] - vx[xi]) * (vy[yj] - vy[yi]);
          for (int i = 0; i < n; i++){
            pair<ll, ll> p = vxy[i];
            if(vx[xi] <= p.first && p.first <= vx[xj] && vy[yi] <= p.second && p.second <= vy[yj]){
              cn++;
            }
            if(cn >= k && ans > tmp){
              ans = tmp;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import itertools
n = int(input())
sl = []
for _ in range(n):
    sl.append(int(input()))

if sum(sl) % 10 != 0:
    print(sum(sl))
    exit()

ans = 0
for v in itertools.combinations(sl,n-1):
   if sum(v) % 10 != 0:
    ans = max(ans, sum(v))
print(ans)

Measured memory_bytes: 9192
n, m = map(int, input().split())
a = [int(i) for i in input().split()]

import heapq
class MaxHeap(object):
    def __init__(self, x):
        self.heap = [-e for e in x]
        heapq.heapify(self.heap)
    def push(self, value):
        heapq.heappush(self.heap, -value)
    def pop(self):
        return -heapq.heappop(self.heap)
    def sum(self):
        return -sum(self.heap)

a = MaxHeap(a)

for i in range(m):
    largest = a.pop()
    a.push(largest//2)
print(a.sum())

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int X,Y,Z; cin >> X >> Y >> Z;
    int i = 0;
    while(i * Y + (i + 1) * Z <= X) i++;
    cout << i - 1 << endl;
}

Measured memory_bytes: 256
def main():
  N = int(input())
  A = [int(_) for _ in input().split()]
  k = f = 0
  can = False
  for a in A:
    if a%2 == 1:
      k += 1
    if a%4 == 0:
      f += 1
  if k == 0: #すべて偶数の場合
    can = True
  else:
    if N - k - f == 0:
      if f+1 >= k:
        can = True
    else:
      if f >= k:
        can = True
  print('Yes' if can else 'No')
  return

if __name__ == '__main__':
  main()

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

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

	if (a < b && b < c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}




	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (auto& c : s) {
        if (c == '7') {
            Yes();
            return 0;
        }
    }
    No();


    solve();
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main() {
    char s[4];
    scanf("%s", &s);
    int i, a, b, c;
    a = b = c = 0;
    for (i = 0; i < 3; i++) {
        if (s[i] == 'a')
            a = 3;
        if (s[i] == 'b')
            b = 3;
        if (s[i] == 'c')
            c = 3;
    }
    if (a == 3 && b == 3 && c == 3)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int a, b;
    //string s;
    cin >> a >> b;
    /*
    int x[100];
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    */
    int ans = 0;
    
    if(a==1 && b==2){
        cout << 3 << endl;
    }else if(a==1 && b==3){
        cout << 2 << endl;
    }else if(a==2 && b==1){
        cout << 3 << endl;
    }else if(a==2 && b==3){
        cout << 1 << endl;
    }else if(a==3 && b==1){
        cout << 2 << endl;
    }else if(a==3 && b==2){
        cout << 1 << endl;
    }
 
 
 


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=20+5;
int n,arr[maxn],q,vis[400010];
void dfs(int cur,int sum){
    if(cur==n) return ;
    vis[sum]=1;
    dfs(cur+1,sum+arr[cur+1]);
    dfs(cur+1,sum);
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    cin>>q;
    int num;
    dfs(0,0);
    dfs(0,arr[0]);
    while(q--){
        cin>>num;
        if(vis[num]) cout<<"yes\n";
        else cout<<"no\n";
    }
}



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()
#define alln(a, n) a, a+n 

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

const vi a = {2, 4, 14, 24, 74}, p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

int c[109], ret;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ini(n);
	forn(i, 1, n+1) {
		int t = i;
		while (t != 1) {
			for(auto d : p) {
				if (t % d == 0) {
					c[d]++;
					t /= d;
				}
			}
		}
	}
	for(auto i : p) if (c[i] >= 74) ret++;
	for(auto i : p) for(auto j : p) {
		if (i == j) continue;
		if (c[i] >= 2 && c[j] >= 24) ret++;
		if (c[i] >= 4 && c[j] >= 14) ret++;
	}
	for(auto i : p) forn(j, 0, p.size()) forn(k, j+1, p.size()) {
		if (i == p[j] || i == p[k] || k == j) continue;
		if (c[i] >= 2 && c[p[j]] >= 4 && c[p[k]] >= 4) ret++;
	}
	outn(ret);
	
	return 0;
}


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

int arr[46];

int fib(int n)
{
    if(n==1 || n==0)
    {
        return arr[n];
    }
    if(arr[n]!=-1)
        return arr[n];

    else
        arr[n]=fib(n-1)+fib(n-2);
    return arr[n];

}


int main()
{
    arr[0]=1;
    arr[1]=1;

    for(int i=2;i<=44;i++)
    {
        arr[i]=-1;
    }


    int n;
    cin>>n;
    cout<<fib(n)<<endl;




    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  int count = 0;
  for(int i=0;i<N;i++){
    if(p.at(i)!=i+1){
      count++;
    }
  }
  if(count<=2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
    return 0;
  }
}



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

using namespace std;

int main(void) {

	//long long a, b;
	string a, b;

	cin >> a >> b;

	if (a.size() > b.size()) {
		cout << "GREATER\n";
	}
	else if (a.size() < b.size()) {
		cout << "LESS\n";
	}
	else {
		for (long long i = 0; i < a.size(); i++)
		{

			if (a[i] > b[i]) {
				cout << "GREATER\n";
				break;
			}
			else if (a[i] < b[i]) {
				cout << "LESS\n";
				break;
			}
			else if (i == a.size() - 1) {
				cout << "EQUAL\n";
			}
		}
	}


	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))

dp = [(a, 0) for a in A]
for i in range(N):
    for j in range(1<<N):
        if not j & (1<<i):
            k = j|(1<<i)
            a, b = dp[k]
            c, d = dp[j]
            res = None
            if a > c:
                if b > c:
                    res = (a, b)
                else:
                    res = (a, c)
            else:
                if a > d:
                    res = (c, a)
                else:
                    res = (c, d)
            assert res == tuple(sorted([a, b, c, d], reverse = True)[:2]), ''
            dp[k] = res
dp[0] = sum(dp[0])
for i in range(1, 1<<N):
    dp[i] = max(dp[i-1], sum(dp[i]))
print('\n'.join(map(str, dp[1:])))

Measured memory_bytes: 153608
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

class Solution {
 public:
  void solve() {
    int h, w, n;
    cin >> h >> w >> n;
    cout << (n - 1) / max(h, w) + 1;
  }
};

int main() {
  Solution solution = Solution();
  solution.solve();
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int q;
string x, y;
int dp[1111][1111];

void solve() {
   for (int i = 0; i < x.size(); i++) {
      for (int j = 0; j < y.size(); j++) {
         if (x[i] == y[j]) {
            dp[i+1][j+1] = dp[i][j] + 1;
         } else {
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
         }
      }
   }
   cout << dp[x.size()][y.size()] << endl;
}

int main() {
   cin >> q;
   while (q--) {
      cin >> x >> y;
      solve();
   }

   return 0;
}


Measured memory_bytes: 7492
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include<queue>
#include<list>
#include<algorithm>
#include <utility>

int main()
{
    int n;
    std::cin>>n;
    std::pair<int,int> a[n];
    for(int i = 0; i < n; i++)
    {
        std::cin>>a[i].first>>a[i].second;
    }
    sort(a, a+n);
    for(int i = 0; i < n; i++)
    {
        std::cout<<a[i].first<<" "<<a[i].second<<std::endl;
    }
    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    int counter = 0;
    for (size_t i = 0; i < s.length(); ++i){
        if (s[i] == '1') counter += 1;
    }
    cout << counter << endl;
    return 0;
}

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

const int INF = 1e9;
int main(){
  int w;
  scanf("%d",&w);
  vector<int> a(w),pop(w,0);
  for(int i=0;i<w;i++)scanf("%d",&a[i]);

  int t = 0;
  for(int i=0;i<w;i++){
    if(a[i]==0)t = INF;
    else if(a[i]<0)t = min(t,-a[i]);
    else pop[i] = max(pop[i], t);
    t--;
  }

  t = 0;
  for(int i=w-1;i>=0;i--){
    if(a[i]==0)t = INF;
    else if(a[i]<0)t = min(t,-a[i]);
    else pop[i] = max(pop[i], t);
    t--;
  }

  int ans = 0;
  for(int i=0;i<w;i++)ans += min(pop[i], abs(a[i]));
  cout << ans << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll x;
  cin >> x;
  ll y;
  cin >> y;
  rep(i, 100) rep(j, 100) {
    if (i*2+j*4 == y && i+j == x) {
      cout << yes << endl;
      return 0;
    }
  }
  cout << no << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;
typedef long long ll;
constexpr ll mod = 998244353;
ll dp[3010][3010] = {},dp2[3010] = {},beki[3010][3010] = {},invbeki[3010][3010];
ll pw(ll a,ll x){
    ll ret = 1;
    while(x){
        if(x&1) (ret *= a) %= mod;
        (a *= a) %= mod; x /= 2;
    }
    return ret;
}

int main(){
    ll i,j,a,b,c,d;
    cin >> a >> b >> c >> d;
    for(i=0;i<=3000;i++){
        beki[i][0] = 1; invbeki[i][0] = 1;
        ll inv = pw(i,mod - 2);
        for(j=1;j<=3000;j++){
            beki[i][j] = beki[i][j - 1]*i%mod;
            invbeki[i][j] = invbeki[i][j - 1]*inv%mod;
        }
    }
    dp[b][a] = 1;
    for(i=b + 1;i<=d;i++){
        dp2[0] = dp[i - 1][0];
        for(j=1;j<=c;j++){
            dp2[j] = dp2[j - 1];
            (dp2[j] += invbeki[i - 1][j]*dp[i - 1][j]%mod) %= mod;
        }
        for(j=a;j<=c;j++){
            dp[i][j] = (j*dp[i - 1][j] + beki[i - 1][j]*dp2[j - 1]%mod)%mod;
        }
    }
    ll ans = 0;
    for(i=1;i<=c;i++){
        (ans += (dp[d][i]*beki[d][c - i]%mod)) %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 215148
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    int n,k;
//    while(cin >> n >> k){
//            if(n % k) cout << 1 << endl;
//    else cout << 0 << endl;
////        cout << n / k - n % k << endl;
//    }
//    return 0;
//}


#include <bits/stdc++.h>

using namespace std;

const int maxn = 200000;
bool vis[maxn];
int main() {
    int n;
    while(cin >> n) {
        memset(vis,0,sizeof(vis));
        for(int i = 0; i < 100; i++) {
            int sum = i * 4;
            for(int j = 0; j < 100; j++) {
                sum += j * 7;
                vis[sum] = 1;
            }
        }
    if(vis[n]) printf("Yes\n");
    else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int a = nextInt();
			int d = nextInt();
			int n = nextInt();
			if (a == 0) {
				break;
			}

			ArrayList<Integer> list = new ArrayList<Integer>();
			if (a == 1) {
				a += d;
			}
			if (a == 2) {
				list.add(a);
				a += d;
			}
			while (list.size() < n) {
				boolean is_prime = true;
				if (a % 2 == 0) {
					is_prime = false;
				} else {
					for (int i = 1; 2 * i + 1 <= Math.sqrt(a); i++) {
						if (a % (2 * i + 1) == 0) {
							is_prime = false;
							break;
						}
					}
				}
				if (is_prime) {
					list.add(a);
				}
				a += d;
			}

			System.out.println(list.get(n - 1));
		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

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


void solve(long long K, long long A, long long B){
    if(B <= A + 2 || K <= A - 1){
        cout << K + 1 << endl;
    }else{
        cout << A + (B - A) * ((K - A + 1) / 2) + ((K - A + 1) % 2) << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    cin >> n;
    int out;
    out = n*800 - 200*(n/15);
    std::cout << out << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include <string>
#include<stdio.h>
#include<cmath>

using namespace std;

int main(){
    int A,l;

    while (1) {
        cin>>A>>l;
        if(A==0 && l==0){
            return 0;
        }

        int max,min,dif,com;
        bool f = true;
        int* a=new int[22];
        int* num= new int[l];

        a[0]=A;

        for(int i=1; i<22; i++){
            a[i]=-1;
        }
        for(int i=0; i<21; i++){
            max=0;
            min=0;
            dif=0;

            com = a[i];
            for(int j=0; j<l; j++){
                num[j] = com%10;        //各桁ごとに配列に記憶
                com = com/10;
            }

            sort(num, num+l);   //並び替え

            for(int j=0; j<l; j++){
                max+=num[j]*pow(10,j);
                min+=num[j]*pow(10,l-1-j);
            }
            dif = max-min;
            a[i+1]=dif;

            for(int j=0; j<i+1; j++){
                if(dif==a[j]){
                    printf("%d %d %d\n", j, dif, i-j+1);
                    f=false;
                    break;
                }
            }
            if(!f){
                break;
            }
        }
    }
}



Measured memory_bytes: 3412
#include <bits/stdc++.h>
#define int long long
#define S second
#define F first
#define pb push_back
#define sz size()
using namespace std;
const int N=1e6+7;
int b[N],c[N],dp[150][N] ;
int n,x=1,ans,k,w ;
pair < int, int > a[N] ;
vector < int > vec ;
vector < int > pos ;
multiset < int > st ;
main()
{
    cin >> n >> w ;
    for (int i=1; i<=n; i++)
    {
        cin >> a[i].F >> a[i].S ;
        x+=a[i].S  ;
    }
    for (int i=0; i<=n+19; i++)
        for (int j=0; j<=x+19; j++)
            dp[i][j]=1e10 ;
    sort(a+1,a+n+1) ;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=x; j++)
            if (a[i].S>=j)
                dp[i][j]=min(dp[i-1][j],a[i].F) ;
            else
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-a[i].S]+a[i].F) ;
    for (int i=1; i<=x; i++)
        if (dp[n][i]<=w)
            ans=i ;
    cout << ans << endl ;
}


Measured memory_bytes: 97656