akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a<10)b+=100*(10-a);
	printf("%d\n",b);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;

int n;
int a[200002];
int b[200002];
vector<int> v;

int main () {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i ++) cin >> a[i];
	
	for (int i = n; i >= 1; i --) {
		if (b[i] != a[i]) {
			b[i] ++;
			b[i] %= 2;
			
			v.push_back(i);
			for (int j = 1; j <= sqrt(i); j ++) {
				if (i % j == 0) {
					b[j] ++;
					b[j] %= 2;
					if (i/j != j) {
						b[i/j] ++;
						b[i/j] %= 2;
					}
				}
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 3192
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int N = in.nextInt();
        List<Task> taskList = new ArrayList<>(N);
        for (int i = 0; i < N; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            taskList.add(new Task(a, b));
        }
        taskList.sort((x, y) -> Integer.compare(x.B, y.B));

        long currentTime = 0;
        for (Task task : taskList) {
            currentTime += task.A;

            if (currentTime > task.B) {
                out.println("No");
                return;
            }
        }

        out.println("Yes");
    }
}

class Task {
    int A;
    int B;

    Task(int a, int b) {
        A = a;
        B = b;
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 71176
s=input()
al="abcdefghijklmnopqrstuvwxyz"
ans=""
d={}
for i in range(int(len(s))):
    if s[i] not in d:
        d[s[i]]=1
for i in range(26):
    if al[i] not in d:
        ans+=al[i]
        print(ans)
        exit()
print("None")

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

using namespace std;

int main(){
  int n,k;
  
  cin >> n >> k;
  
  vector<int> h;
  int wk;
  int ans =0 ;
  for(int i = 0; i < n; i++){
    cin >> wk;
	if(wk >= k)ans++;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int n;
  cin>>n;
  vector<int>dp(n,INT_MAX), arr(n,0);
  
  for(int i = 0;i<n;i++){
    cin>>arr[i];
  }
  dp[0] = 0;
  dp[1] = abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1]<<endl;
  
  return 0;  
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes";
    else cout<<"No";

    return 0;
}


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

using namespace std;
using ll=long long;

ll dp(ll i,ll k);

int n,k;
vector<ll> ans(100010,0);
vector<ll> field(100010,0);



int main()
{

    cin >> n >> k;

    for(int i=0;i<n;i++)
    {
        cin >> field.at(i);
    }
    ans.at(0)=0;
    ans.at(1)=abs(field.at(1)-field.at(0));
    for(int i=2;i<n+1;i++)
    {
        ans.at(i)=ans.at(i-1)+abs(field.at(i-1)-field.at(i));
        for(int o=2;o<k+1;o++)
        {
            if(i-o>=0)
            {
                ans.at(i)=min(ans.at(i),ans.at(i-o)+abs(field.at(i-o)-field.at(i)));
            }
        }
        
    }

    cout << ans.at(n-1) <<endl;
    return(0); 
}



Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



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

int N,L;cin>>N>>L;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  vsort(vec);
  for(int i=0;i<N;i++){
    cout<<vec[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int binary(int a[], int n, int key) {
    int left = 0;
    int right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (a[mid] == key) return 1;
        if (a[mid] < key) left = mid + 1;
        else if (a[mid] > key) right = mid;
    }
    return 0;
}
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    int q;
    cin >> q;
    int cnt = 0;
    for (int i = 0; i < q; ++i) {
        int tmp;
        cin >> tmp;
        cnt += binary(a, n, tmp);
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 3448
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    macro_rules! get { () => (stdin.next().unwrap().parse().unwrap()) }
    
    let n = get!();
    let mut f = vec![vec![vec![0; 2]; 5]; n];
    for i in 0..n {
        for j in 0..5 {
            for k in 0..2 {
                f[i][j][k] = get!();
            }
        }
    }
    let mut p = vec![vec![0_i64; 11]; n];
    for i in 0..n {
        for j in 0..11 {
            p[i][j] = get!();
        }
    }
    
    let mut ans = -100_000_000_000;
    for x in 1..1<<10 {
        let mut bene = 0;
        for i in 0..n {
            let mut c = 0;
            for j in 0..5 {
                for k in 0..2 {
                    if f[i][j][k] == 0 { continue; }
                    let e = (x >> (k*5+j)) & 1;
                    if e != 0 { c += 1; }
                }
            }
            bene += p[i][c];
        }
        ans = std::cmp::max(ans, bene);
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

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

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

int main() {
  int n;
  cin >> n;
  vector<ll> t(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  sort(t.rbegin(), t.rend());
  ll ans = t[0];
  for (int i = 0; i < n; i++) {
    ans = lcm(ans, t[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int M, N;
    cin >> M >> N;
    vector<int> coin(N);
    for (auto &x : coin) {
        cin >> x;
    }
    vector<int> dp(M + 1, INT_MAX);
    dp[0] = 0;
    for (auto &x : coin) {
        FOR(j, x, M + 1) { dp[j] = min(dp[j], dp[j - x] + 1); }
    }
    cout << dp[M] << endl;
    return 0;
}



Measured memory_bytes: 3352
import heapq

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

job = [[] for i in range(M)]

for i in range(N):
    A, B = list(map(int, input().split()))
    if A <= M:
        job[A-1].append(-B)

heap = []
ans = 0
for i in range(M):
    [heapq.heappush(heap, r) for r in job[i]]
    
    if len(heap) > 0:
        ans -= heapq.heappop(heap) 
        

print(ans)


Measured memory_bytes: 23752
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void) {
    int n, m;
    while(~scanf("%d%d", &n, &m)) {
        int t = 1 << m;
        printf("%d\n", 1900 * m * t + (n - m) * 100 * t);
    }
}

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

int main(int argc, char* argv[]) {
  int a, b, c, cnt;
  cin >> a >> b >> c;

  for(int i = a ; i < b+1 ; i++){
    if(c % i == 0){
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] num_list = new int[n];
    for (int i = 0; i < n; i++){
      num_list[i] = sc.nextInt();
    }
    sc.close();
    
    bubble_sort(num_list, n);
  }

  public static void output(int[] lst, int n){
    for (int i = 0; i < n; i++){
      if (i == n - 1){
        System.out.println(lst[i]);
      }else{
        System.out.print(lst[i] + " ");
      }
    }
  }

  public static void bubble_sort(int[] lst, int n){
    int count = 0;
    for (int i = lst.length - 1; i > 0; i--){
      for (int j = 0; j < i; j++){
        if (lst[j] > lst[j + 1]){
          int tmp = lst[j];
          lst[j] = lst[j + 1];
          lst[j + 1] = tmp;
          count ++;
        }
      } 
    }
    output(lst, n);
    System.out.println(count);
  }
}



Measured memory_bytes: 26308
#include <iostream>
using namespace std;
 
int main()
{
  long long x, a, b;
  cin >> x >> a >> b;
  if(b <= a){
    cout << "delicious" << endl;
  }
  else if(b <= a + x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
//
//  main.cpp
//  Competitive
//
//  Created by Ashutosh Tiwari on 16/05/20.
//  Copyright © 2020 Ashutosh Tiwari. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <climits>
#include <functional>
#include <unordered_map>
#include <tuple>
#include <iterator>
#include <unordered_set>
#include <chrono>
#include <zconf.h>

using namespace std;

int solve(vector<int>& frog) {
    vector<int> dp(frog.size(), INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < frog.size(); i ++) {
        for (int j: {i + 1, i + 2}) {
            if (j < frog.size())
                dp[j] = min(dp[j], dp[i] + abs(frog[i] - frog[j]));
        }
    }
//    for (int i = 0; i < frog.size(); i ++) {
//        cout << i << " << " << dp[i]  << " << " << frog[i] << endl;
//    }
    return dp[frog.size() - 1];
}
int main()
{
    ios_base::sync_with_stdio(false);
//    cout << get_current_dir() << endl;
//     freopen("../in.txt", "r", stdin);

//    vector<int> v = {10, 15, 20};

    int T;
    cin >> T;
    vector<int> frog(T);
    for (int i = 0; i < T; i ++) cin >> frog[i];
    cout << solve(frog) << endl;

    return 0;
}

Measured memory_bytes: 1024
import queue

N = int(input())

q = queue.Queue()
for i in [3,5,7]:
    q.put(i)
#print(q)

cnt = 0
while True:
    n = q.get()
    if n > N:
        break
    elif '3' in str(n) and '5' in str(n) and '7' in str(n):
        cnt += 1
        #print(n)
    q.put(n * 10 + 3)
    q.put(n * 10 + 5)
    q.put(n * 10 + 7)
print(cnt)

Measured memory_bytes: 59604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int n;
  cin>>n;
  vector<tuple<string,int,int>> t;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    t.push_back(tie(s,p,i));
  }
  sort(all(t));
    rep(i,n){
      cout<<get<2>(t[i])<<endl;
    }
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC152A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var N = NN;
            var M = NN;
            if( N == M) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


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

int N;
int A[100001];
int Q;
long long B[100001];
long long C[100001];

long long acc[100001] = {0};

long long S = 0;

int main(){
	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d",&A[i]);
		acc[A[i]]++;
		S += A[i];
	}
	scanf("%d",&Q);
	for(int i = 0; i < Q; i++){
		scanf("%lld%lld",&B[i],&C[i]);
		int t = acc[B[i]];
		acc[B[i]] = 0;
		acc[C[i]] += t;
		
		S += t * (C[i] - B[i]);

		printf("%lld\n",S);
	}

	return 0;
}


Measured memory_bytes: 6452
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int n;

void bfs(vector<vector<int>> &da, vector<int> &st){
	queue<int> q;
	q.push(0);
	st[0] = 1;
	while(!q.empty()){
		int now = q.front();
		q.pop();
		rip(i,da[now].size(),0){
			if(st[da[now][i]]){
				continue;
			}
			else{
				st[da[now][i]] = 3-st[now];
				q.push(da[now][i]);
			}
		}
	}
	return;
}

void xx(vector<int> &st, int x){
	int a = 1, b = 2, c = 3;
	rip(i,n,0){
		if(st[i] == x){
			if(a <= n){
				st[i] = a;
				a+=3;
			}
			else if(b <= n){
				st[i] = b;
				b += 3;
			}
			else{
				st[i] = c;
				c += 3;
			}
		}
		else{
			st[i]  =c;
			c += 3;
		}
	}
	vdeb(st);
	return;
}

void yy(vector<int> &st){
	int a = 1, b = 2, c = 3;
	rip(i,n,0){
		if(st[i] == 1 && a <= n){
			st[i] = a;
			a += 3;
		}
		else if(st[i] == 2 && b <= n){
			st[i] = b;
			b += 3;
		}
		else{
			st[i] = c;
			c += 3;
		}
	}
	vdeb(st);
	return;
}

int main(){
	cin >> n;
	vector<vector<int>> da(n, vector<int>(0));
	rip(i,n-1,0){
		int x,y;
		cin >> x >> y;
		da[x-1].push_back(y-1);
		da[y-1].push_back(x-1);
	}
	vector<int> st(n);
	bfs(da, st);
	vector<int> co(2);
	rip(i,n,0){
		co[st[i]-1]++;
	}
	if(n/3 >= min(co[0], co[1])){
		if(co[1] > co[0]) xx(st, 2);
		else xx(st, 1);
	}
	else{
		yy(st);
	}
}

Measured memory_bytes: 14452
import math

n, d=map(int, input().split())
x=[]
for i in range(n):
    x.append([int(i) for i in input().split()])

ans=0
for i in range(n-1): #0-n
  for j in range(i+1,n):
    s = 0
    for k in range(d):
      s += (x[i][k]-x[j][k])**2
    a = math.sqrt(s)
    if a.is_integer():
      ans += 1
print(ans)

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

template<typename T>
class BIT {
private:
  vector<T> bit;
public:
  BIT(const int n) : bit(n + 10) {}
  void add(int idx, T val) {
    ++idx;
    while (idx <= bit.size()) {
      bit[idx] += val;
      idx += idx & -idx;
    }
  }
  T get(int l, int r) {
    return this->get(r) - this->get(l - 1);
  }
  T get(int r) {
    ++r;
    T res = 0;
    while (r > 0) {
      res += bit[r];
      r -= r & -r;
    }
    return res;
  }
};

const int MAX = 2 * 1e5 + 10;
int N;
long long K, a[MAX], asum[MAX], asum2[MAX];
BIT<long long> bit(MAX);

int main() {
  scanf("%d%lld", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%lld", a + i);
    a[i] -= K;
    asum[i + 1] = asum[i] + a[i];
  }
  
  memcpy(asum2, asum, sizeof(asum));
  sort(asum2, asum2 + N + 1);
  map<long long, int> mp;
  for (int i = 0; i <= N; i++) {
    mp[asum2[i]] = i;
  }
  long long ans = 0;
  for (int i = 0; i <= N; i++) {
    ans += bit.get(mp[asum[i]]);
    bit.add(mp[asum[i]], 1);
  }
  
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 18944
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N, -1));
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N - 1; ++j){
            cin >> A[i][j];
            --A[i][j];
        }
    }
    
    vector<int> nxt_idx(N, 0);
    queue<P> play_game;
    set<P> nxt_game;
    for(int i = 0; i < N; ++i){
        P game(i, A[i][nxt_idx[i]]);
        P rev_game(A[i][nxt_idx[i]], i);
        if(nxt_game.find(rev_game) != nxt_game.end()){
            play_game.emplace(game);
            nxt_game.erase(rev_game);
        }
        else{
            nxt_game.emplace(game);
        }
        ++nxt_idx[i];
    }

    int ans = 0;
    while(!play_game.empty()){
        ++ans;
        queue<P> que;
        while(!play_game.empty()){
            int p1 = play_game.front().first;
            int p2 = play_game.front().second;
            play_game.pop();

            P game(p1, A[p1][nxt_idx[p1]]);
            P rev_game(A[p1][nxt_idx[p1]], p1);
            ++nxt_idx[p1];
            if(nxt_game.find(rev_game) != nxt_game.end()){
                que.emplace(game);
                nxt_game.erase(rev_game);
            }
            else{
                nxt_game.emplace(game);
            }

            game = P(p2, A[p2][nxt_idx[p2]]);
            rev_game = P(A[p2][nxt_idx[p2]], p2);
            ++nxt_idx[p2];
            if(nxt_game.find(rev_game) != nxt_game.end()){
                que.emplace(game);
                nxt_game.erase(rev_game);
            }
            else{
                nxt_game.emplace(game);
            }
        }
        play_game = move(que);
    }

    for(int i = 0; i < N; ++i){
        if(nxt_idx[i] != N){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7620
import math


a, b, h, m = map(int, input().split())
m_dig = 6*m
h_dig = 30*h + m*0.5
angle = abs(m_dig-h_dig)
cosa = math.cos(math.radians(angle))
ans_2 = a**2 + b**2 - 2*a*b*cosa
print(math.sqrt(ans_2))


Measured memory_bytes: 9496
#include<stdio.h>
int main(void)
{
int a,b,k,swap;
scanf("%d %d",&a,&b);
if (a > b)
{
  swap = a;
  a = b;
  b = swap;
}
if (a > 0)
{
    a = -a;
}
if (b < 0)
{
    b = -b;
}
for (k = 0;k < b;k++)
{
    if (a+k == b-k)
    {
        break;
    }
}
if (a+k == b-k)
{
    printf ("%d",k);
}else{
    printf("IMPOSSIBLE");
}
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 1e9+7
#define ll long long
#define F first
#define S second
#define N 100005
#define M 1000000009
#define mp make_pair
#define ull unsigned long long
#define sc(n) scanf("%d",&n)
#define gcd __gcd
#define pb push_back
using namespace std;

std::vector<int> v[N],jh;
stack<pair<int,pair<int,int> > > qu;
pair<int,pair<int,int> > pa;

int dis[N],col[N];
void line(int s,int d,int c){
	if(!col[s])
		col[s]=c;
	if(dis[s]>=d || d<1)
		return;
	if(d>dis[s])
		dis[s]=d;
	for(int i: v[s]){
		line(i,d-1,c);
	}
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int u,d,c,q;
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>u>>d>>c;
		qu.push(mp(u,mp(d,c)));
	}
	while(!qu.empty()){
		pa = qu.top();
		qu.pop();
		line(pa.F,pa.S.F,pa.S.S);
	}
	for(int i=1;i<=n;i++)
		cout<<col[i]<<endl;
	return 0;
}

Measured memory_bytes: 8568
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  const K = Number.parseInt(inputStr[1]);
  const Q = Number.parseInt(inputStr[2]);
  //正答者情報を配列Aに溜め込む
  var A = [];
  for(var i=1 ; i<=Q ; i++){
    inputStr = input[i];
    A.push(Number.parseInt(inputStr));
  }
  //回答者N人分の持ち点配列を作る
  var ans = Array(N).fill(0);
  //問題数分ループ
  //console.log(ans);
　for(var i=0 ; i<A.length ; i++){
    ans[A[i]-1] += 1;
  }
  //console.log(ans);
  //出力処理
　for(var i=0 ; i<N ; i++){
    if(ans[i]+K-Q>0){
      console.log("Yes");
    }else{
      console.log("No");
    }
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 31660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N;
   cin >> N;
   long long s[N];
   for(int i=0; i<N; i++){
      cin >> s[i];
   }
   long long ans = 0;
   for(int i=1;i<N; i++){
      long long tmp = 0;
      for(int k=1; k*i < N && i < N-1-k*i; k++){
         if((N-1-k*i)%i ==0 && (N-1-k*i)/i <=k) break;
         tmp += s[k*i];
         tmp += s[N-1-k*i];
         ans = max(ans,tmp);
      }
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 1152
from collections import defaultdict

h, w, n = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    a, b = map(int, input().split())
    for k in range(3):
        if 1 <= a - k <= h - 2:
            for l in range(3):
                if 1 <= b - l <= w - 2:
                    x = (a - k, b - l)
                    d[x] += 1
ans = [0] * 10
for v in d.values():
    ans[v] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans[1:])
for i in range(10):
    print(ans[i])


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int INF = 1e9 + 7;

int main() {
  double a, b;
  cin >> a >> b;
  printf("%f\n", (a * b) / (a + b));
  return 0;
}


Measured memory_bytes: 256
H,N=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]

inf=float("inf")
dp=[inf]*(H+1)
dp[0]=0
ans=inf
for i in range(N):
    A,B=AB[i]
    for j in range(max(0,H-A+1)):
        dp[j+A]=min(dp[j+A],dp[j]+B)
    for j in range(max(0,H-A+1),H):
        ans=min(ans,dp[j]+B)
ans=min(ans,dp[H])

print(ans)



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

int N;
vector<string> S;
int cur;

int dfs(int depth){
    char c = S[cur][depth];
    if(isdigit(c)){
        cur++;
        return c - '0';
    }
    if(c == '+'){
        int s = 0;
        cur++;
        while(cur < N && depth < S[cur].size() && S[cur][depth] == '.'){
            s += dfs(depth+1);
        }
        return s;
    }
    if(c == '*'){
        int p = 1;
        cur++;
        while(cur < N && depth < S[cur].size() && S[cur][depth] == '.'){
            p *= dfs(depth+1);
        }
        return p;
    }
    
    return -1;
}

int main(){
    while(cin >> N, N){
        S.resize(N);
        for(auto &s: S){
            cin >> s;
        }
        
        cur = 0;
        cout << dfs(0) << endl;
    }
}

Measured memory_bytes: 3228
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

fn main() {
    let mut sc = Scanner::new();
    let t: usize = sc.cin();
    for _ in 0..t {
        let n: i32 = sc.cin();
        let mut d: u32 = sc.cin();
        let mut a = 0;
        for __ in 0..(n-1) {
            d = d ^ 127;
            a += 127;
        }
        a += d;
        println!("{}", a);
    }
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


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

#define db double
#define ll long long
#define RG register

inline int gi()
{
	RG int ret; RG bool flag; RG char ch;
	ret=0, flag=true, ch=getchar();
	while (ch < '0' || ch > '9')
		ch == '-' ? flag=false : 0, ch=getchar();
	while (ch >= '0' && ch <= '9')
		ret=(ret<<3)+(ret<<1)+ch-'0', ch=getchar();
	return flag ? ret : -ret;
}

const db pi = acos(-1.0);
const int N = 142857, inf = 1<<30;

struct poi
{
	int x,y;
}p[N];
struct edge
{
	int fr,to;
	db dis;
	inline bool operator <(const edge &E) const { return dis > E.dis; }
}e[N*10];
int fa[N];

inline db Dis(int a,int b)
{
	return sqrt((p[a].x-p[b].x)*(p[a].x-p[b].x)+(p[a].y-p[b].y)*(p[a].y-p[b].y));
}

inline int find(int o)
{
	return fa[o] == o ? o : fa[o]=find(fa[o]);
}

int main()
{
	int n,m,i,x,y;
	db ans,len;
	n=gi(), m=gi();
	for (i=1; i<=n; ++i)
		p[i].x=gi(), p[i].y=gi();
	ans=0;
	for (i=1; i<=m; ++i)
		e[i].fr=x=gi(), e[i].to=y=gi(), e[i].dis=len=Dis(x,y), ans+=len;
	sort(e+1,e+m+1);
	for (i=1; i<=n; ++i)
		fa[i]=i;
	for (i=1; n>1 && i<=m; ++i)
		{
			x=e[i].fr, y=e[i].to;
			x=find(x), y=find(y);
			if (x != y)
				ans-=e[i].dis, fa[x]=y, n--;
		}
	printf("%.3f\n",ans);
	return 0;
}

Measured memory_bytes: 3748
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	string r;


	for (int i = s.length() - 1; i >= 0; i--)
	{
		r += s.substr(i, 1);
	}

	int res = 0;
	for (int i = 0; i < s.length() / 2; i++)
	{
		if (s.substr(i, 1) != r.substr(i, 1))
		{
			res++;
		}
	}
	println(res);
}

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

int main(){
  char s[1001];
  int sum;
  while(1){
    sum = 0;
    scanf("%s", s);
    if (s[0] == '0') break;
    for(int i = 0; i < strlen(s); i++){
      sum += (s[i] - '0');
    }
    printf("%d\n", sum);
  }

  return 0;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code
bool graph[50][50];
bool visited[50];

int dfs(int n,int v) {
    int ret = 1;
    bool all_visited = true;
    visited[v] = true;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            all_visited = false;
        }
    }
    if (all_visited) {
        return 0;
    }
    
    for (int i = 0; i < 50; i++) {
        if (graph[v][i] && !visited[i]) {
            ret = dfs(n,i);
        }
    }
    return ret;
}
int main(int argc, char const* argv[])
{
    int n,m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        graph[a-1][b-1] = true;
        graph[b-1][a-1] = true;
    }
    
    int ans = 0;
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            if (graph[i][j]) {
                graph[i][j] = false;
                graph[j][i] = false;
                ans += dfs(n,0);
                graph[i][j] = true;
                graph[j][i] = true;
                for (int i = 0; i < n; i++) {
                    visited[i] = false;
                }
            }
        }
    }
    cout << ans/2 << endl;  
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios::sync_with_stdio(0);
bool check(string s)
{
	for(int i=0;i<s.length()/2;i++)
	{
		if(s[i]!=s[s.length()-i-1]) return 0;
	}
	return 1;
}
signed main()
{
	//IOS
	string s;
	while(cin>>s)
	{
		if(!check(s))
		{
			cout<<"No\n";
		} 
		else
		{
			int n=s.length();
			string a=string(s.begin(),s.begin()+(n-1)/2);
			string b=string(s.begin()+(n+3)/2-1,s.begin()+n);
			
		//	cout<<a<<" "<<b<<"\n";
			if(check(a)&&check(b) )cout<<"Yes\n";
			else cout<<"No\n";
		}
	}
 } 

Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	ll n;cin>>n;
	ll a[n+1],b[n+1];
	b[0]=0;
	for(ll i=0;i<n+1;i++)cin>>a[i];
	for(ll i=1;i<=n;i++)cin>>b[i];
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ll x=min(a[i-1],b[i]);
		b[i]-=x;
		a[i-1]-=x;
		ans+=x;
		ll y=min(a[i],b[i]);
		b[i]-=y;
		a[i]-=y;
		ans+=y;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
n = int(input())
a = list(input().split())
half = int(n / 2)
for i in range(0, half):
    t = a[i]
    a[i] = a[n - i - 1]
    a[n - i - 1] = t

for i in range(n):
    if i == n - 1:
        print(a[i])
    else:
        print(a[i], end = " ")
        

Measured memory_bytes: 7664
import numpy as np

def acinput():
    return list(map(int, input().split(" ")))


def chk(x,d):
    for l,xx in enumerate(x):
        if xx==1:
            for dd in d[l]:
                #print(dd)
                #print(x)
                if dd[1]==1 and x[dd[0]-1]==0:
                    return False
                if dd[1]==0 and x[dd[0]-1]==1:
                    return False
    return True


N=int(input())

d=[]
for k in range(N):
    aa=int(input())
    #print(aa)
    d.append([])
    for j in range(aa):
        d[-1].append(acinput())


#print(d)
res=0

for x in range(2**N):
    x=list(map(int,list(bin(x)[2:].zfill(N))))
    #print(x)
    if chk(x,d):
        res=sum(x)
    
print(res)


Measured memory_bytes: 12500
H, W = map(int, input().split())
S = H*W
ans = 10**19
for w in range(1, W//2+1):
    s = w*H
    w2s = ((W-w)//2)*H
    h2s = (H//2)*(W-w)

    ws = [s, w2s, S-w2s-s]
    hs = [s, h2s, S-h2s-s]
    wm = max(ws)-min(ws)
    hm = max(hs)-min(hs)
    m = min(wm, hm)
    if m < ans:
        ans = m

H, W = W, H
for w in range(1, W//2+1):
    s = w*H
    w2s = ((W-w)//2)*H
    h2s = (H//2)*(W-w)

    ws = [s, w2s, S-w2s-s]
    hs = [s, h2s, S-h2s-s]
    wm = max(ws)-min(ws)
    hm = max(hs)-min(hs)
    m = min(wm, hm)
    if m < ans:
        ans = m
print(ans)


Measured memory_bytes: 42844
use std::io;

fn main() {
    let mut ln = String::new();
    if let Ok(_) = io::stdin().read_line(&mut ln) {
        let v: Vec<i32> = ln
            .split_whitespace()
            .map(|s| s.trim().parse().unwrap())
            .collect();
        let x = v[0] * v[1];
        if x < v[2] {
            println!("{}", x);
        } else {
            println!("{}", v[2]);
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N;
	int count = 0;
	cin >> N;
	vector<int> A(N - 1);
	vector<int> B(N,0);
	for (int i = 0; i < N - 1; i++) {
		cin >> A.at(i);
	}
	for (int i = 0; i < N - 1; i++) {
		B.at(A.at(i) - 1)++;
	}
	for (int i = 0; i < N; i++) {
		cout << B.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define REP(i, t) for(int i = 0; i < t; i++)
 
int main()
{
    bool db[200010] = {0};
    int W, a, b;
    cin >> W >> a >> b;
    fill(&db[a], &db[a + W], 1);
    fill(&db[b], &db[b + W], 1);
 
    int find_mode = 0, start_index = 0, end_index = 0;
    REP(i, 200009)
    {
        switch(find_mode)
        {
            case 0:
                if(db[i] == true && db[i + 1] == false) start_index = i, find_mode++;
                break;
            case 1:
                if(db[i] == false && db[i + 1] == true) end_index = i, i = (1 << 30);
                break;
        }
    }
 
    cout << (end_index - start_index) * (start_index < end_index) << endl;
 
    return 0;
}


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

int main(){
  int h,w,i,j;
  cin>>h>>w;
  string a[h];
  for(i=0;i<h;i++){
    cin>>a[i];
  }
  int cnt=0;
  string p[h];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a[i][j]=='#'){
        p[cnt]=a[i];
        cnt++;
		break;
      }
    }
  }
  int flg;
  for(i=0;i<w;i++){
	flg=0;
    for(j=0;j<cnt;j++){
      if(p[j][i]=='#'){
		  flg++;
		  break;
      }
    }
	if(!flg){
		for(j=0;j<cnt;j++){
			p[j]==p[j].erase(i,1);
		}
	w--;
	i--;
	}
  }
  for(i=0;i<cnt;i++){
    cout<<p[i]<<endl;
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.math;

void main(){
  auto nums = readln().chomp.split.map!(to!int);
  int[] result;
  result.length = nums[1];
  for(int i; i < nums[0]; i++){
    auto input = readln().chomp.split.map!(to!int);
    foreach(a; input[1..$]){
      result[a-1]++;
    }
  }

  result.count!("a==b")(nums[0]).writeln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

void solve()
{
	int n,q;
	cin>>n>>q;
	vi edges[n+1];
	int a,b;
	rep(i,0,n-1)
	{
		cin>>a>>b;
		edges[a].pb(b);
		edges[b].pb(a);
	}
	int arr[n+1]={0};
	while(q--)
	{
		cin>>a>>b;
		arr[a]+=b;
	}
	
	stack<int> ss;
	ss.push(1);
	vi::iterator itr;
	int visited[n+1]={0};
	visited[1]=1;
	while(!ss.empty())
	{
		int x=ss.top();
		ss.pop();
		
		for(itr=edges[x].begin();itr!=edges[x].end();itr++)
		{
			if(!visited[*itr])
			{
				arr[*itr]+=arr[x];
				ss.push(*itr);
				visited[*itr]=1;
			}
		}
	}
	
	rep(i,1,n+1)
	{
		cout<<arr[i]<<" ";
	}
	
}

signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t=1;
		while(t--)
		{
			solve();
		}
}

Measured memory_bytes: 16372
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int H = 202 << 1;
int fa[H] , out[H] , in[H] , n , h;
vi g[H];
int F(int x){return fa[x]==x?x:fa[x]=F(fa[x]);}
int id(int x){
    return x>0?x-1:h+(-x-1);
}

int main(){
    scanf("%d%d",&n,&h);
    rep(i,0,h+h) fa[i]=i;
    rep(i,0,n) {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        int l=c?-c:a,r=d?d:-b;
        l=id(l),r=id(r);
        fa[F(r)]=F(l);
        out[l]++;
        in[r]++;
    }
    rep(i,0,h+h) g[F(i)].pb(i);
    rep(i,0,h) if(out[i]<in[i]) return puts("NO") , 0;
    rep(i,h,h+h) if(out[i]>in[i]) return puts("NO") , 0;
    rep(i,0,h+h) if(sz(g[i])) {
        bool end = false , has = false;
        for(auto e : g[i]) {
            has |= in[e] | out[e];
            if(e < h && out[e] > in[e]) end = true;
            if(e >= h && out[e] < in[e]) end = true;
        }
        if(has && !end) return puts("NO") , 0;
    }
    puts("YES");
    return 0;
}


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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line
ll dp[52][52][2510]; // おそらく初期値は全部0
int main()
{
	int n, a;
	cin >> n >> a; // average を a 円にする！
	vector<int> x(n);
	rep(i,n) cin >> x[i]; 
	// dp[i][j][k] := i 枚目までで j 枚選択して和を k にするときの組み合わせが何通りあるか。 

	rep(i,52){
		rep(j,52){
			rep(k,2510){
				// 任意の i に対して j == 0 , k == 0 は1
				if(j == 0 && k == 0) dp[i][j][k] = 1;
				else dp[i][j][k] = 0;
			}
		}
	}

	/* 遷移は、今見ているカードの数字が X のとき,Xを使うなら X が j 枚目になるから
	   dp[i][j][k] = dp[i-1][j-1][k-X] + dp[i-1][j][k];
	 */

	ll ans = 0;
	for(int i = 1; i <= n; i++){
		int X = x[i-1]; 
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= 2500; k++){
				if(k <= X - 1){
					// (X - 1　までは、そいつを使うことはできない)
					dp[i][j][k] = dp[i-1][j][k];
					continue;
				}
				dp[i][j][k] = dp[i-1][j-1][k-X] + dp[i-1][j][k];
			}
		}
	}

	// n 枚目までで j 枚選んだとき j * a になるやつをansに足す
	rep(j,n+1){
		ans += dp[n][j][j*a] ;
	}
	// なぜか1大きい値が出力されるので-1する
	cout << ans - 1<< endl;
	// 原因わかった。j = 0 のときに、和が0となるやつが1通りあって、それが ans にたされているからだ。
}


Measured memory_bytes: 53248