akhauriyash/Code-Regression huggingface dataset:
/* ***********************************************
Author        :pkwv
Created Time  :2017年10月22日 星期日 21时32分24秒
File Name     :D.cc
************************************************ */

#include <algorithm>
#include <bitset>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
  std::string s;
	while (std::cin >> s) {
		std::vector<int> state(s.size() + 1);
		for (int i = s.size() - 1; i >= 0; -- i) {
			state[i] = state[i + 1] ^ (1 << (s[i] - 'a'));
		}
		std::unordered_map<int, int> dp;
		dp[0] = 0;
		for (int i = s.size() - 1; i >= 0; -- i) {
			int min_p(s.size());
			for (int j = 0; j < 26; ++ j) {
				int from_state(state[i] ^ (1 << j));
				auto iter = dp.find(from_state);
				if (iter != dp.end()) {
					min_p = std::min(min_p, iter->second + 1);
				}
			}
			if (dp.count(state[i])) {
				dp[state[i]] = std::min(dp[state[i]], min_p);
			} else {
				dp[state[i]] = min_p;
			}
		}
		std::cout << (dp[state[0]] ? dp[state[0]] : 1) << std::endl;
	}
  return 0;
}


Measured memory_bytes: 9420
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		System.out.println(a / b);
		System.out.println(a % b);
		System.out.printf("%.5f\n", (double) a / b);
	}
}

Measured memory_bytes: 26484
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.algorithm;
import std.range;

void main(){
  auto A=readln.split.to!(int[]),a=A[0],b=A[1];
  if(a+b<10)writeln(a+b);
  else writeln("error");
}  

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

vector<int64_t> puni(int64_t lim) {
	set<int64_t> s;
	s.insert(2);
	for (int64_t i = 3; i <= lim; i += 2) {
		for (int64_t j = 2; j * j <= i; j++) {
			if (i % j == 0) {
				goto next;
			}
		}
		s.insert(i);
		next:;
	}
	vector<int64_t> ps;
	for (auto &p : s) {
		if (s.find((p + 1) / 2) == s.end()) {
			continue;
		}
		ps.emplace_back(p);
	}
	return ps;
}

int main() {
	auto ps = puni(100000);
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int64_t l, r;
		cin >> l >> r;
		int64_t ans = 0;
		for (auto &p : ps) {
			if (l <= p && p <= r) {
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int S, W;
	cin >> S >> W;

	if (W >= S) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}

	
}


Measured memory_bytes: 3520
s=input()
n=len(s)
t=[0]*2019
t[0]=1
d=1
tkk=0
for k in reversed(range(n)):
  tk=tkk+int(s[k])*d
  tk=tk%2019
  t[tk]=t[tk]+1
  tkk=tk
  d=d*10
  d=d%2019
ans=0
for i in t:
  ans=ans+i*(i-1)//2
print(ans)

Measured memory_bytes: 9320
#include<stdio.h>
   int main(void)
   {
      int A,B,C,D;
    scanf("%d %d %d",&A,&B,&C);
     D=B/A;
    if(D<C){
              printf("%d\n",D);                                    
     }
    else{
              printf("%d\n",C);
     }
     return 0;
  }


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using static System.Console;

class Program {
    static void Main() {
        var n = NextInt();
        var c = NextInt();
        var k = NextInt();
        var t = new int[n];
        var ans = 0;
        var waitStart = 0;
        var waitPeople = 0;

        for (var i = 0; i < n; i++) {
            t[i] = NextInt();
        }
        Array.Sort(t);

        for (var i = 0; i < n; i++) {
            if (t[i] - waitStart > k || waitPeople == c) {
                waitPeople = 0;
            }
            waitPeople++;

            if (waitPeople == 1) {
                waitStart = t[i];
                ans++;
            }
        }
        WriteLine(ans);
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

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


int main()
{
    int a,b,c,A,B;

    cin>>a>>b>>c;
     A=b-a;
     B=c-b;
    if(A==B)printf("YES\n");
    else cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rgi register int
using namespace std;
string s;
bool flag;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    for(rgi i=0;i<s.size();++i)
    {
        if(s[i]=='C')
            flag=1;
        if(flag&&s[i]=='F')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  char S[2];
  scanf("%s",S);
  if (S[0] == 'A') printf("T\n");
  if (S[0] == 'T') printf("A\n");
  if (S[0] == 'C') printf("G\n");
  if (S[0] == 'G') printf("C\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>

using namespace std;


int main() {

	//input
	int n;
	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b = 0;
		cin >> a >> b;
		cout << a + b << endl;
	}


	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    vector<vector<ll>> table(3, vector<ll>(3,0));
    REP(i, 3){
        REP(j,3){
            cin >> table[i][j];
        }
    }

    ll N;
    cin >> N;
    REP(k,N){
        ll num;
        cin >> num;
        REP(i, 3){
            REP(j,3){
                if( table[i][j] == num){
                    table[i][j] = 0;
                }
            }
        }
    }

    REP(i, 3){
        if( table[i][0] == 0 && table[i][1] == 0 && table[i][2] == 0 ){
            cout << "Yes" << endl;
            return 0;
        }
        if( table[0][i] == 0 && table[1][i] == 0 && table[2][i] == 0 ){
            cout << "Yes" << endl;
            return 0;
        }
    }

    if( table[0][0] == 0 && table[1][1] == 0 && table[2][2] == 0 ){
        cout << "Yes" << endl;
        return 0;
    }
    if( table[0][2] == 0 && table[1][1] == 0 && table[2][0] == 0 ){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


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

#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  int r;
  cin >> r;
  cout << r*r << endl;
  
  return 0;
  
}


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

#define BUFSIZE         (1024)

char buf[BUFSIZE];

long
readnum()
{
    long        ret;
    char        *bp;

    bp = fgets(buf, BUFSIZE, stdin);
    if (bp == NULL) goto err;
    ret = atol(buf);
    return ret;

  err:
    perror("error fgets");
    exit(EXIT_FAILURE);
}

int
readnar(char *buf, long *nar, int sz)
{
    int         idx;
    char        *rp;
    char        *nrp;
    long        num;

    rp = buf;
    for (idx = 0; idx < sz; ++idx) {
        num = strtol(rp, &nrp, 10);
        *nar = num;
        ++nar;
        if (rp == nrp) break;
        rp = nrp;
    }
    return idx;
}

void
print_arr(int *arr, int sz)
{
    int idx;

    printf("%d", arr[0]);    
    for (idx = 1; idx < sz; ++idx) {
        printf(" %d", arr[idx]);
    }
    puts("");
}


#define MAX(a, b)       ((a) < (b) ? (b) : (a))
#define MIN(a, b)       ((a) > (b) ? (b) : (a))

bool
binsearch(long key, long *nar, int nsz)
{
    bool        ret;
    int         aa = 0;
    int         bb = nsz - 1;
    int         mm;

    ret = false;
    while (aa <= bb) {
        mm = (aa + bb) / 2;
        if (nar[mm] == key) return true;
        if (nar[mm] < key) {
            aa = mm + 1;
        } else {
            bb = mm - 1;
        }
    }
    return ret;
}

#define SAMAX    (10 * 10000)

int
main()
{
    long        num;
    long        snar[SAMAX];
    long        sn;
    long        tn;
    int         nr;
    int         idx;
    int         cnt;
    
    sn = readnum();
    for (idx = 0; idx < sn; idx++) {
        nr = scanf(" %ld", &num);
        if (nr <= 0) goto err;
        //printf("[%d] = %ld ", idx, num);
        snar[idx] = num;
    }
    fgets(buf, BUFSIZE, stdin); // flush
        
    tn = readnum();
    //printf("tn = %ld\n", tn);
    cnt = 0;
    for (idx = 0; idx < tn; idx++) {
        nr = scanf(" %ld", &num);
        if (nr <= 0) goto err;
        //printf("[%d] = %ld ", idx, num);
        if (binsearch(num, snar, sn)) {
            ++cnt;
        }
    }
    printf("%d\n", cnt);

    exit(EXIT_SUCCESS);

  err:
    exit(EXIT_FAILURE);
}



Measured memory_bytes: 2480
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans;
    char a,b,c;
    cin>>c>>b>>a;
    if (!(c==a&&a==b))cout <<"Yes"<<endl;
        else cout <<"No"<<endl;

    return 0;

}

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

using namespace std;

int main()
{
	ll n;
	ll keta;
	ll temp;
	ll ans=0;
	
	cin>>n;
	keta = pow(10,(int)log10(n));
	temp = (n/keta)*keta; //nと最上位の数字が同じかつnを超えない最小の整数を求める
	temp--;
	if(temp+keta==n)
	{
		temp+=keta;
	}
	while(temp!=0)
	{
		ans += temp%10;
		temp/=10;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String x = sc.nextLine();
			if(x.equals("0")) {
				break;
			}
			int sum = 0;
			String xary[] = x.split("");
			for (int i = 0; i < x.length(); i++) {
				sum += Integer.parseInt(xary[i]);
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 27440
n = int(input())
H = list(map(int, input().split()))
cou = 0
now_h = 0

for i in range(n):
    h = H[i]
    if h > now_h:
        cou += (h - now_h)
        now_h = h
    elif now_h > h:
        now_h = h

print(cou)

Measured memory_bytes: 3064
local mod = 1000000007
local mfl = math.floor

local s = io.read()
local n = #s
local t = {}
for i = 1, n do
  t[i] = {}
  for j = 0, 12 do
    t[i][j] = 0
  end
end
local sstr = s:sub(1, 1)
if sstr == "?" then
  for i = 0, 9 do
    t[1][i] = 1
  end
else
  t[1][tonumber(sstr)] = 1
end

local jumptbl = {0, 10, 7, 4, 1, 11, 8, 5, 2, 12, 9, 6, 3}

for i = 2, n do
  -- times 10
  local tmp = {}
  for j = 0, 12 do
    tmp[jumptbl[j + 1]] = t[i - 1][j]
  end
  for j = 0, 12 do
    t[i - 1][j] = tmp[j]
  end
  -- add
  sstr = s:sub(i, i)
  if sstr == "?" then
    for num = 0, 9 do
      for j = 0, 12 do
        t[i][(j + num) % 13] = (t[i][(j + num) % 13] + t[i - 1][j]) % 1000000007
      end
    end
  else
    local num = tonumber(sstr)
    for j = 0, 12 do
      t[i][(j + num) % 13] = t[i - 1][j]
    end
  end
end
print(t[n][5])


Measured memory_bytes: 37976
#include <stdio.h>
#include <math.h>
int main(void)
{
	int a,b,c,x;
	int z;
	int i,j,p;
	int temp=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&x);
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(p=0;p<=c;p++){
				z=500*i+j*100+p*50;
				if(x==z){
					temp++;
					
					
				}
				
				
				
			}
			
			
			
			
		}
		
		
		
		
		
		
	}
	printf("%d\n",temp);
	return 0;
}

Measured memory_bytes: 128
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    n, p = [next_int() for _ in range(2)]
    odd = even = 0

    for i in range(n):
        a = next_int()
        odd += a % 2
        even += (a % 2) ^ 1

    if odd == 0:
        print(2 ** even * int(p == 0))
    else:
        print((2 ** (odd - 1)) * (2 ** even))


if __name__ == '__main__':
    main()

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

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

	if(3200 <= a) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N;
bool flag=0;
int main(){
    cin>>N;
    char S[N];
    rep(i,N){
        cin>>S[i];
        if(S[i]=='Y')flag=1;
    }
    if(flag)out("Four");
    else out("Three");
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int compress(vector<long long> &v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v.size();
}

int main(){
  int n,K;
  long long x1[50],y1[50],z1[50],x2[50],y2[50],z2[50];
  vector<long long> vx,vy,vz;
  scanf("%d %d",&n,&K);
  for(int i=0;i<n;i++){
    scanf("%lld %lld %lld %lld %lld %lld",x1+i,y1+i,z1+i,x2+i,y2+i,z2+i);
    vx.push_back(x1[i]);
    vy.push_back(y1[i]);
    vz.push_back(z1[i]);
    vx.push_back(x2[i]);
    vy.push_back(y2[i]);
    vz.push_back(z2[i]);
  }
  int size_x = compress(vx);
  int size_y = compress(vy);
  int size_z = compress(vz);
  int area[99][99][99];
  fill(area[0][0],area[0][0]+99*99*99,0);
  for(int i=0;i<n;i++){
    for(int j=0;j<size_x-1;j++){
      for(int k=0;k<size_y-1;k++){
        for(int l=0;l<size_z-1;l++){
          if(x1[i]<=vx[j]&&vx[j+1]<=x2[i]&&y1[i]<=vy[k]&&vy[k+1]<=y2[i]&&z1[i]<=vz[l]&&vz[l+1]<=z2[i]) area[j][k][l]++;
        }
      }
    }
  }
  long long ans = 0;
  for(int i=0;i<size_x-1;i++){
    for(int j=0;j<size_y-1;j++){
      for(int k=0;k<size_z-1;k++){
        if(area[i][j][k]>=K) ans+=(vx[i+1]-vx[i])*(vy[j+1]-vy[j])*(vz[k+1]-vz[k]);
      }
    }
  }
  printf("%lld\n",ans);
  return 0;
}

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

using int64 = long long;

int main() {
  static int64 dp[30][20][200];
  dp[0][0][0] = 1;

  for (int i = 1; i <= 20; i++) {
    for (int j = 0; j <= 10; j++) {
      for (int sum = 0; sum <= 155; sum++) {
        dp[i][j][sum] += dp[i - 1][j][sum];
        if (j > 0 and sum - i >= 0) {
          dp[i][j][sum] += dp[i - 1][j - 1][sum - i];
        }
      }
    }
  }
  int n, k, s;
  while (cin >> n >> k >> s, n | k | s) {
    cout << dp[n][k][s] << endl;
  }
  return 0;
}

Measured memory_bytes: 3496
#include <iostream>
#include <algorithm>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int mxsz = 1e5 + 4;
int n;
pair<LL,LL> x[mxsz];

bool cmp(pii a, pii b){
	return a.fi + a.se > b.fi + b.se;
}
int main(){
	LL tot = 0LL;
	cin >> n;
	for (int i = 1; i<= n; i++){
		cin >> x[i].fi >> x[i].se;
		tot -= x[i].se;
	}
	sort(x+1, x+n+1, cmp);
	int a = 1, b;
	for (int i = 1; i <= n; i++){
		if (i & 1){tot += x[i].fi + x[i].se;}
	}
	cout << tot << '\n';
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string.h>
#include<cmath>
using namespace std;
int main()
{
	char strings[5];
	long long int t=1,i,l,n;
	while(t--)
	{
	scanf("%s",strings);
	l=strlen(strings);
	if(l==2)
	{
		printf("%s",strings);
	}
	if(l==3)
	{
		for(i=2;i>=0;i--)
		printf("%c",strings[i]);
		}	
		return 0;
		
		
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
import math

# nまでの和
def n_sum(n):
    return n * (n - 1) // 2

def main():
    N, D = list(map(int, input().split()))
    point = []
    for _ in range(N):
        point.append(list(map(int, input().split())))

    ite_num = n_sum(N)
    ans = 0
    for i in range(N-1):
        for j in range(i+1, N):
            tmp_sum = 0
            for k in range(D):
                tmp_sum += abs(point[i][k] - point[j][k])**2
            if math.sqrt(tmp_sum).is_integer():
                ans += 1
    return ans

if __name__ == '__main__':
    print(main())

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

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

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

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

int main() {
  double a;
  while(cin >> a && a >= 0) {
    double b = a - (int)a;
    string ans = "";
    rep(i, 0, 2) rep(j, 0, 2) rep(k, 0, 2) rep(l, 0, 2) {
      double c = i * 0.5 + j * 0.25 + k * 0.125 + l * 0.0625;
      if(c == b) {
        ans += (char)(i + 48);
        ans += (char)(j + 48);
        ans += (char)(k + 48);
        ans += (char)(l + 48);
      }
    }
    double d = a - b;

    if(ans == "" || (int)d > 255) {
      cout << "NA" << endl;
      continue;
    }
    string ni = "0";
    rep(i, 0, (int)d) {
      dep(j, ni.length(), 0) {
        if(ni[j] == '0') {
          ni[j] = '1';
          rep(k, j + 1, ni.length()) {
            ni[k] = '0';
          }
          break;
        }
        if(j == 0) {
          int nii = ni.length();
          ni = "1";
          rep(i, 0, nii) ni += "0";
        }
      }
    }
    int kk = ni.length();
    rep(i, 0, 8 - kk) {
      ni = '0' + ni;
    }

    cout << ni + '.' + ans << endl;
  }
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int n, k;
cin >> n >> k;
vl x(n);
rep(i,n) {
    cin >> x[i];
    if(x[i] == 0) --k;
}

if(k == 0) {
    cout << 0 << endl;
    return 0;
}

ll ans = 1001001001001001001;
for(int i = 0; i <= n-k; ++i) {
    if(x[i] * x[i+k-1] < 0) {
        chmin(ans, x[i+k-1] - x[i] + min(abs(x[i+k-1]), abs(x[i])));
        continue;
    }
    if(x[i] + x[i+k-1] > 0) {
        chmin(ans, x[i+k-1]);
    }
    if(x[i] + x[i+k-1] < 0) {
        chmin(ans, abs(x[i]));
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i;
    cin>>n;
    int v[n],c[n],sum=0;
    for(i=0;i<n;i++)
    cin>>v[i];
    for(i=0;i<n;i++)
    cin>>c[i];
    for(i=0;i<n;i++){
        if(v[i]-c[i]>0)
        sum+=v[i]-c[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    String s=sc.nextLine();
    String t=sc.nextLine();
    int n=s.length();
    int m=t.length();
    int min=Integer.MAX_VALUE;
    for(int i=0;i<n-m+1;i++)
    {
      int cnt=0;
      for(int j=0;j<m;j++)
      {
        if(s.charAt(i+j)!=t.charAt(j))
        cnt++;
      }
      min=Math.min(min,cnt);
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 35632
#include <cstdio>
#include <utility>
#include <algorithm>
#include<cmath>

using namespace std;

long mylog(int x, int b){
  long p = 1;
  long res = 0;
  while(1){
    if(x <= p){
      return res;
    }
    res++;
    p *= b;
  }
}

long mypow(long x, long b){
  long res = 1;
  for(long i=0; i < x; i++){
    res *= b;
  }
  return res;
}

long get_min_times(long val, long base){
  long div = mypow(mylog(val, base), base);
  long res = 0;
  // prlongf("debug %d, %d %d\n", val, div, val/div);
  while(val > 0){
    long temp = val/div;
    res += temp;
    val = val % div;
    div /= base;
  }

  return res;

}


  


int main(){
  long N;

  scanf("%ld\n", &N);

  if(N == 0){
    printf("0\n");
    return 0;
  }

  int times = mylog(abs(N), 2) + 2 ;
  
  int res[100] = {};

  for(int i=0; i < times; i++){
    if(abs(N) % (mypow(i+1, 2)) == 0){
      res[i] = 0;
    }else{
      res[i] = 1;
      N = N - mypow(i, -2);
    }
  }    

  bool startprint = false;
  for(int i=times-1; i >=0; i--){
    if(res[i] == 1){
      startprint = true;
    }
    if(startprint){
      printf("%d", res[i]);
    }
  }
  
  printf("\n");
  
  return 0;
}
  


Measured memory_bytes: 128
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main(){
    
    om_shree_ganeshaya_namah();

    in(n); in(w);
    vector<vector<int>> dp(n, vector<int>(w+1));
    vector<pair<int, int>> arr;
    f(n){
    	in(weight); in(value);
    	pair<int, int> p = make_pair(weight, value);
    	arr.push_back(p);
    }
    sort(arr.begin(), arr.end());

    for(int j=arr[0].first; j<=w; j++)
    	dp[0][j] = arr[0].second;

    for(int i=1; i<n; i++){
    	for(int j=1; j<=w; j++){
    		if(j<arr[i].first)
    			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    		else{
    			int a = arr[i].second+dp[i-1][j-arr[i].first];
    			dp[i][j] = max(a, max(dp[i-1][j], dp[i][j-1]));
    		}
    	}
    }
    cout<<dp[n-1][w];
}

Measured memory_bytes: 82268
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    int ans = 29;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int test = 0;
        while (a % 2 == 0) {
            a = a / 2;
            test++;
        }
        ans = min(ans, test);
    }
    cout << ans << endl;
}


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

int main(){
  string s; cin >>s;
  int n = s.size()+1;
  vector<int> a(n);
  rep(i,n){
    if(s[i]=='<'){
      a[i+1] = max(a[i+1], a[i]+1);
    }
  }
  for(int i = n-1; 0<=i; i--){
    if(s[i]=='>'){
      a[i] = max(a[i], a[i+1]+1);
    }
  }
  ll ans = 0;
  for(auto x : a){
    ans += x;
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 5752
int main(int argc, const char * argv[]) {
    // insert code here...
    int x,y,syuu,menseki;
    scanf("%d %d",&x,&y);
    syuu=x+x+y+y;
    menseki=x*y;
    printf("%d %d\n",menseki,syuu);
    return 0;
}

Measured memory_bytes: 596
def geta(n=0)
  return $stdin.gets.to_i if n==0
  ar = []
  n.times do 
    ar << $stdin.gets.chomp.split
  end
  return ar.flatten(1) if n<=1
  return ar
end

def jadge(n)
  sqrt = Math.sqrt(n).ceil
  2.step(sqrt) do |i|
    return 0 if n%i == 0
  end
  return 1
end

n = geta(0)
ar = geta(n)

result = []
buyv,celv = 0,0
ar.flatten.map(&:to_i).each_with_index do |n,i|
  if i==0
    buyv = n
    next
  end
  result << n - buyv
  buyv = n if n < buyv
end
p result.max


Measured memory_bytes: 33216
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    vector<int> v(3);
    REP(i, 3) cin >> v[i];
    ASC(v);
    cout << v[0] + v[1] << endl;
}


Measured memory_bytes: 888
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    //ll N = 0, L =0;
    //cin >> N >> L;
    string s;
    string t; 
    cin >> s >> t;

    //vll X(N);
    //REP(i,N) cin >> X[i];

    //本文
    ll ls = s.size();
    ll lt = t.size();
    ll c = 0;
    vector<vector<char>> S(ls-lt+1,vector<char>(ls));
    REP(i,ls-lt+1){
        REP(j,ls){
        S[i][j]=s[j];
        }
    }
    REP(i,ls-lt+1){
        REP(j,lt){
        S[i][i+j]=t[j];
        }
    }
    REP(i,ls-lt+1){
        ll count = 0;
        REP(j,ls){
            if(S[i][j]==s[j]||s[j]=='?'){
                count++;
            }
        }
        if(count!= ls){
            REP(j,ls){
                S[i][j]='z';
            }
        }
        else{
            REP(j,ls){
                if(S[i][j]=='?') S[i][j]='a';
            }
            c++;
        }
    }
    //出力
    if(c==0){cout << "UNRESTORABLE" << endl;return 0;}
    vector<string> ans(ls-lt+1);
    REP(i,ls-lt+1){
        REP(j,ls){
            ans[i]+=S[i][j];
        }
    }
    sort(ALL(ans));
    cout << ans[0];

    
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

const ll MOD = 1000000007;
vector<vector<int>> G;
ll K;

ll dfs(int n, int p) {
    ll k;
    if(p==-1) k=K-1;
    else k=K-2;

    ll ans = 1;
    for (auto e : G[n]) {
        if (e == p) continue;
        ans *= k;
        ans %= MOD;
        ans *= dfs(e, n);
        ans %= MOD;
        k = k -1;
    }
    return ans%MOD;
}

int main() {
    int N;
    cin >> N >> K;
    G.resize(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << K*dfs(0, -1)%MOD << endl;
}

Measured memory_bytes: 11520
local sx, sy, tx, ty = io.read("n","n","n","n")
local t = {}
local function _p(a) table.insert(t, a) end
local function pp(a,c) for i=1,c do _p(a) end end
tx = tx - sx
ty = ty - sy

local h_to = tx > 0 and "R" or "L"
local h_bk = tx > 0 and "L" or "R"
local v_to = ty > 0 and "U" or "D"
local v_bk = ty > 0 and "D" or "U"

pp(h_to, math.abs(tx))
pp(v_to, math.abs(ty))
pp(h_bk, math.abs(tx))
pp(v_bk, math.abs(ty))
pp(v_bk, 1)
pp(h_to, math.abs(tx))
pp(h_to, 1)
pp(v_to, 1)
pp(v_to, math.abs(ty))
pp(h_bk, 1)
pp(v_to, 1)
pp(h_bk, math.abs(tx))
pp(h_bk, 1)
pp(v_bk, math.abs(ty))
pp(v_bk, 1)
pp(h_to, 1)

print(table.concat(t,""))

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
pair<int,int> P;
priority_queue<int,vector<int>,less<int>> pq;
int n,ans;
bool cmp(int p,int q)
{
    return p>q?1:0;
}
main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) if(i<10||(i>=100&&i<1000)||(i>=10000&&i<100000))
    ans++;
    printf("%d",ans);
}

Measured memory_bytes: 256
#! /usr/bin/env python3

n = int(input())

res = 0

for i in range(n):
    if (i + 1) % 2 == 0:
        continue
    cnt = 0
    for j in range(n):
        if (i + 1) % (j + 1) == 0:
            cnt += 1
    if cnt == 8:
        res += 1

print(res)


Measured memory_bytes: 2940
#include <iostream> 
#include <numeric> 
#include <cstdlib> 
#include <climits> 
#include <cmath> 
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <memory> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <string> 
#include <vector> 
using namespace std; 

#define rep(i, n) for(int i = 0; i < n; i++) 
#define rep2(i, m, n) for(int i = m; i < n; i++) 
const double EPS = 1E-9; 
typedef long long ll; 
typedef pair<int, int> P; 
typedef pair<int, P> PP; 
typedef complex<double> xy_t; 
const int INF = 1 << 30; 

int w, d;
int side[20];
int front[20];

int calc(){
  int res = 0;
  int a = w - 1;
  int b = d - 1;
  while(a >= 0 && b >= 0){
    if(front[a] == side[b]){
      res += side[b];
      a--;
      b--;
    }else if(front[a] > side[b]){
      res += front[a];
      a--;
    }else{
      res += side[b];
      b--;
    }
  }
  while(a >= 0) res += front[a--];
  while(b >= 0) res += side[b--];
  return res;
}

int main(){
  while(cin >> w >> d && (w || d)){
    rep(i, w) cin >> front[i];
    rep(i, d) cin >> side[i];
    sort(front, front + w);
    sort(side, side + d);
    cout << calc() << endl;
  }
      
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long x,y;
	cin>>x>>y;
	if(x%y==0){
		cout<<"-1"<<endl;
		return 0;
	}
	if(x>y){
		cout<<x<<endl;
		return 0;
	} 
	else if(2*x!=y){
		cout<<2*x<<endl;
		}
	else if(3*x!=y){
		cout<<3*x<<endl; 
	}

	return 0;
}

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

using namespace std;

int main(){
  int n; cin >> n;
  
  vector<pair<string, int> > v(n);
  for(auto &it : v) cin >> it.first >> it.second;
  
  string x; cin >> x;
  bool ok = false;
  int sum = 0;
  
  for(auto it : v){
     if(ok){
       sum += it.second;
     }
     if(it.first == x) ok = true;
  }
  
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	unsigned long long n, temp;
	cin >> n;
	string ans;

	while (n > 26)
	{
		n -= 1;
		ans = static_cast<char>('a' + (n % 26)) + ans;
		n /= 26;
	}
	if (n <= 26)
		ans = static_cast<char>('a' + (n - 1)) + ans;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3632
import sys
def hantei(N,M,X,A,l):
  skill = [0] * M
  money = 0
  for i in range(N):
    if l[i] == '1':
      money += A[i][0]
      for j in range(M):
        skill[j] += A[i][j+1]
  for k in skill:
    if k < X:
      return -1
      sys.exit()
  return money
      
N,M,X = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
mny = 12 * (10 ** 5) + 1
for i in range(1,2**N):
  l = bin(i)[2:].zfill(N)
  if hantei(N,M,X,A,l) != -1 and hantei(N,M,X,A,l) < mny:
    mny = hantei(N,M,X,A,l)
    a = l
if mny == 12 * (10 ** 5) + 1:
  print(-1)
else:
  print(mny)

Measured memory_bytes: 9260
// abc128_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> S(N);
    REP(i, N) cin >> S[i];

    ll ans = 0;
    REPN(C, 1, N) {
        ll dp = 0;
        vector<bool> used(N, false);

        for (int k=1; N - 1 - (k+1) * C > 0; k++) {
            if (used[k * C]) break;
            dp += S[k * C];
            used[k * C] = true;

            if (used[N - 1 - k * C]) break;
            dp += S[N - 1 - k * C];
            used[N - 1 - k * C] = true;

            ans = max(dp, ans);
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
void chmin(int &a, int b) {
	if (a > b) a = b;
}

int N, A, B, C;
vector<int> L;

// 再帰
int rec(int i, int a, int b, int c) {
	if (i == N) {
		if (!a || !b || !c)
			return 100000; // A, B, C いずれも竹は 1 本は必ず使ってないとダメ
		return abs(a - A) + abs(b - B) +
		       abs(c - C); // 合体してできた a, b, c を A, B, C にするコスト
	}

	// 今ある竹を採用しない場合
	int res = rec(i + 1, a, b, c);

	// A, B, C を使う場合。
	// (a ? 10 : 0) とかは、最初の 1 本目は合体コストなし、2 本目からはコスト 10
	// かかることを意味する
	chmin(res, rec(i + 1, a + L[i], b, c) + (a ? 10 : 0));
	chmin(res, rec(i + 1, a, b + L[i], c) + (b ? 10 : 0));
	chmin(res, rec(i + 1, a, b, c + L[i]) + (c ? 10 : 0));

	return res;
}

int main() {
	// 入力
	cin >> N >> A >> B >> C;
	L.resize(N);
	for (int i = 0; i < N; ++i) cin >> L[i];

	// 再帰する
	cout << rec(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long int kaizyou3(int n){
  if(n==0){
    return 1;
  }else{
    return kaizyou3(n-1)*3;
  }
}

main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long int ans;
  ans=kaizyou3(n);
  long long int flag=1;
  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      flag*=2;
    }
  }
  ans-=flag;
  cout << ans << endl;
}


Measured memory_bytes: 256
# coding: utf-8

import fractions

a, b, c, d = map(int, input().split())

def lcm(x, y):
    return x * y // fractions.gcd(x, y)

a_c = (a-1) // c
a_d = (a-1) // d
a_cd = (a-1) // lcm(c, d)

b_c = b // c
b_d = b // d
b_cd = b // lcm(c, d)


print((b-a+1) - ((b_c + b_d - b_cd) - (a_c + a_d - a_cd)))


Measured memory_bytes: 5076
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;



ll ans,mx,mn=1e8,sum;
int main(){
	int a,b;
	cin>>a>>b;
	for(int i=1; i<=10000; i++){
		double flag=i;
		flag = flag*.1;
		double ok=i;
		ok = ok*.08;
		if(floor(flag)==b&&floor(ok)==a){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	
}


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

using namespace std;

#define FOR(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define lli long long int
#define INF 100000001
#define all(c) (c.begin(),c.end())
#define sz(c) c.size()
const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;


void solve() {
	lli n, d;
	cin >> n >> d;
	lli x, y, cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		if ((x * x) + (y * y) <= d * d)cnt++;

	}
	cout << cnt << endl;
}

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

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--) {
	solve();

	// }




	return 0;

}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline

#+++++
		
def main():
	n, a, b = map(int, input().split())
	print(min(n*a,b))
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
p=[0]*6**6
for w,s,v in sorted([list(map(int,input().split()))for _ in[0]*int(input())],key=lambda a:a[0]+a[1]):
 for j in range(s,-1,-1):p[j+w]=max(p[j+w],p[j]+v)
print(max(p))

Measured memory_bytes: 42604
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  ll N;
  cin >> N;
  vector<ll> P(N);
  vector<ll> ind(N);
  rep(i, N) {
    cin >> P[i];
    P[i]--;
    ind[P[i]] = i;
  }

  multiset<ll> s;
  s.insert(-1);
  s.insert(-1);
  s.insert(N);
  s.insert(N);

  ll ans = 0;
  repr(i, N - 1, 0) {
    s.insert(ind[i]);
    auto it = s.lower_bound(ind[i]);
    it--;
    it--;
    ll l2, l1, c, r1, r2;
    l2 = *it;
    it++;
    l1 = *it;
    it++;
    c = *it;
    it++;
    r1 = *it;
    it++;
    r2 = *it;

    ll temp = (c - l1) * (r2 - r1) + (r1 - c) * (l1 - l2);
    ans += (ll)(i + 1) * temp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  i32 N;
  cin >> N;
  
  vector<i32> P(N);
  vector<i32> Q(N);
  vector<i32> list(N);
  for(i32 i = 0; i < N; ++i) {
    i32 p;
    cin >> p;
    P[i] = p;
    list[i] = i+1;
  }
  for(auto& q : Q) cin >> q;
  
  i32 i = 1, ip=0, iq=0;
  do {
    if(list == P) ip = i;
    if (list == Q) iq = i;
    ++i;
  } while(next_permutation(list.begin(), list.end()));
  cout << abs(ip-iq) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<algorithm>
#include<stack>
#include<unordered_map>
#include<cstdlib>
#include<unordered_map>
#include<algorithm>
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
		
#define ii pair	<long long ,long long >
#define i64ii pair< long long, pair<int,int> >
#define i64i pair<long long , int >
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >	
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
 
typedef long long ll;	
typedef vector< int> vi;
typedef long double ld;
 
const int MAX = 800;
const int maxn = 2e5+100;

 
int main (){
	//~ in
	
	ll a, b, k;
	cin >> a >> b >> k;
	
	a-=k;
	if ( a < 0)
		b-=abs(a);
 	cout << max ( 1LL *0 ,a) << ' '<< max (  1LL *0 , b) << '\n';
	return 0;
}




Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    a,b = IS().split()
    if a == 'H':
        print(b)
    elif a == 'D':
        if b == 'H':
            print('D')
        elif b == 'D':
            print('H')



if __name__ == '__main__':
    main()

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

int main() {
    int n ,x;
    std::cin>>n>>x;
    std::vector <int> l(n+1);
    l[0]=0;
    for(int i=0; i<n;i++){
        int t;
        std::cin>>t;
        l[i+1]=(t+l[i]);
    }
    int s=0;
    int i;
    for(i=0;i<=n;i++){
        if(l[i]<=x){
            s++;
        }
    }
    std::cout<<s<<std::endl;
    return 0;
}

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

using namespace std;
string str;

int main()
{
	cin >> str;
	if (str.length() <= 2)
	{
		cout << str << endl;
	}
	else{
			for(int i = 2;i >= 0;i--){
			  cout << str[i];
				}
	}
			
	
	}

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

using namespace std;
int main()
{
	int n;
	
	cin >> n;
	
	vector<int> tmp(n);
	for (int i = 0; i < n; i++) {
		cin >> tmp.at(i);
	}
	
	set<int> a;	
	for (int i = 0; i < n; i++) {
		a.insert(tmp.at(i));
	}

	cout << a.size() << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/agc032/tasks/agc032_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  VL bs(N);
  rep(i, N) cin >> bs[i];

  auto remove = [](VL& arr, ll index) {
    VL res(0);

    rep(i, arr.size()) {
      if (i == index) continue;
      res.push_back(arr[i]);
    }

    arr = res;
  };

  VL res(0);

  rep(i, N) {
    bool deleted = false;

    repr(j, bs.size()) {
      if (bs[j] == j + 1) {
        remove(bs, j);
        deleted = true;
        res.push_back(j);
        break;
      }
    }

    if (!deleted) drop(-1);
  }

  repr(i, N) { cout << res[i] + 1 << "\n"; }
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

typedef complex<double> P;

double dp[41][41][41][41];
double getA[41][41][41];
int nx[41];
const double INF = 1e100;

double cross( P a, P b ){ return a.real() * b.imag() - a.imag() * b.real(); }

int N,M;

P getpos(double p){
  double a = 2*M_PI*p;
  return P( cos(a), sin(a) );
}

void init(const vector<P> pos){
  for(int i=0;i<N;i++) nx[i] = (i+1)%N;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)
        for(int l=0;l<=M;l++)
          dp[i][j][k][l] = -1.0;

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<N;k++)
        getA[i][j][k] = cross( pos[j]-pos[i], pos[k]-pos[i] )/2.0;
      
}


double solve(int a,int b,int c,int m){
  if( abs(dp[a][b][c][m]+1.0) > 0.5 ) return dp[a][b][c][m];
  if( m == M ) return dp[a][b][c][m] = 0.0;
  if( c == a ) return dp[a][b][c][m] = -INF;
  int nc = nx[c];
  return dp[a][b][c][m] = max(  solve( a, c, nc, m+1 ) + getA[a][b][c],
                                 solve( a, b, nc, m ) );    
}

int main(){
  while( cin >> N >> M && (N||M) ){
    vector<P> pos;
    for(int i=0;i<N;i++){
      double p; cin >> p;
      pos.push_back( getpos(p) );
    }
    init(pos);
    double res = 0.0;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if( i == j ) continue;
        res = max( res, solve( i, j, nx[j], 2 ) );
      }
    }
    printf("%.6lf\n",res);
  }
}

Measured memory_bytes: 23748