akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long double,int> P;
long double a,b;
int n;
long double x[1005],y[1005],r[1005];
struct edge{
    int to;
    long double cost;
};
vector<edge> G[1005];
long double d[1005];
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+(n+2),10000000000);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
int main(void){
    cin>>x[0]>>y[0]>>a>>b;
    cin>>n;
    x[n+1]=a; y[n+1]=b;
    r[0]=0; r[n+1]=0;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i]>>r[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=i+1;j<=n+1;j++){
            long double t;
            if(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))<(r[i]+r[j])){
                t=0;
            }else{
                t=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-(r[i]+r[j]);
            }
            G[i].push_back(edge{j,t});
            G[j].push_back(edge{i,t});
        }
    }
    dijkstra(0);
    cout<<setprecision(22)<<d[n+1]<<endl;

}



Measured memory_bytes: 44212
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
const int N=2005;
int n,m,cnt,head[N],d[N],tot,x,y,ans;
struct edge{int to,nxt;}e[N<<1];
void adde(int x,int y){e[++cnt].to=y; e[cnt].nxt=head[x]; head[x]=cnt;}
void dfs(int u,int par){
	for (int i=head[u],v;i;i=e[i].nxt)
		if (v=e[i].to,v!=par) d[v]=d[u]+1,dfs(v,u);
}
int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,n-1) scanf("%d%d",&x,&y),adde(x,y),adde(y,x);
	ans=n;
	if (m&1){
		rep (i,1,n-1){
			int x=e[2*i].to,y=e[2*i-1].to;
			d[x]=d[y]=0; dfs(x,y); dfs(y,x); tot=0;
			rep (j,1,n) if (d[j]>m/2) tot++;
			ans=min(ans,tot);
		}
	} else{
		rep (x,1,n){
			d[x]=0; dfs(x,0); tot=0;
			rep (j,1,n) if (d[j]>m/2) tot++;
			ans=min(ans,tot);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
typedef  long long ll;

int main(void)
{
  int a[5];
  for(int i=1;i<=5;i++){
    scanf("%d",&a[i]);
    if(i!=a[i]){
      printf("%d\n",i);return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 1680
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var H = input[0];
            var A = input[1];

            Console.WriteLine(H % A == 0 ? H / A : H / A + 1);
        }
    }
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int calc(int n){
    //1,3,6,10,...
    int start = 1;
    int inc = 1;
    for(int i = 0;; i++, start += inc){
        inc++;
        if(n < start) return i;
    }
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    map<ll, int> yakusuu;
    ll ulim = sqrt(N)+1;
    for(ll i = 2; i <= ulim; i++){
        if(N % i == 0){
            N /= i;
            yakusuu[i]++;
            i--;
        }
    }
    if(N > 1) yakusuu[N]++;
    if(yakusuu.empty()) cout << 0 << endl;
    else{
        int ans = 0;
        for(auto op: yakusuu){
            ll p = op.first;
            int cnt = op.second;
            ans += calc(cnt);
        }
        cout << ans << endl;
    }
    return 0;
}

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



int main(){
  int N;
  cin>>N;
  
  int A=0;
  int B=0;
  int C=0;
  int D=0;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="AC") A++;
    if(S=="WA") B++;
    if(S=="TLE") C++;
    if(S=="RE") D++;
  }
  cout<<"AC"<<" "<<"x"<<" "<<A<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<B<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<C<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<D<<endl;    
    
}

Measured memory_bytes: 3628
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(string s) {
    long ans = 0; // int だと overflow
    int a = 0; // a の個数
    int p = 0;
    while (p < s.length) {
        if (s[p] == 'A') {
            a++;
            p++;
        }
        else if (s[p] == 'B') {
            if (p + 1 < s.length && s[p + 1] == 'C') {
                ans += a;
                p += 2;
            }
            else {
                a = 0;
                p++;
            }
        }
        else {
            a = 0;
            p++;
        }
    }
    return ans;
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 2684
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    long double a, b, c;
    cin >> a >> b >> c;
    long double res = 2 * sqrt(a) * sqrt(b);
    if(a+b+res < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 764
<?php
  
  $str = trim(fgets(STDIN));

  $len = strlen($str);
  $flag = true;
  for($i=0; $i<$len; $i++){
    if($i%2==0){
      //奇数
      if($str[$i]=="L"){
        $flag = false;
        break;
      }
    }else{
      //偶数
      if($str[$i]=="R"){
        $flag = false;
        break;
      }
    }
  }
  
  if($flag){
    echo "Yes\n";
  }else{
    echo "No\n";
  }
  
  ?>

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define in insert
#define se second
#define fr(i,n) for(i = 0 ; i < n ; i++)
ll dp[100000];
 map<int,vi> mp;
ll max_len(int x)
{
    if(mp[x].size()==0)
        return 0;
    if(dp[x-1]!=-1)
        return dp[x-1];
ll mx = -1;
     for(int j = 0 ; j < mp[x].size() ;j++)
        {
             mx= max(mx,1+max_len(mp[x][j]));
        }
        dp[x-1] = mx;
    return mx;

}
int main()
{
    fio
    int e,i,n,j,k,x,y;
    cin>>n>>e;
ll mx;
    fr(i,e)
    {
        cin>>x>>y;
        mp[x].pb(y);
    }
    //vector<ll> dp(n);
    fr(i,n+1)
    dp[i] =-1 ;

    for(auto it = mp.begin();it!=mp.end();it++)
    {
        mx = -1;
        for(j = 0 ; j < (it->se).size() ;j++)
        {
             mx= max(mx,1+max_len((it->se)[j]));
        }
        dp[it->fi - 1] = mx;
    }

    cout<<*max_element(dp,dp+n);


}


Measured memory_bytes: 15360
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2590

 ???ICPC(International Company of Plugs & Connectors)?????¬?????????????????????
  N??????????????????????????£???????????????????????§??????M?????????????????????????????????????????¨???
  ???????????????????????£?????£?¢???????????????????????????????????????§????????????????????????????????°???
  ?????????????????????????????§???????????????????????????????????????????????????????????????????????????
  ????????????????????¨??£??????????????????????????????????????¶?????????????????????
  ??????????????????????????¨?????????????????????????¨????????????¨???????????????????????????????????¨???
  ??????????????????

  ??????????????\???????????????????????????????????????????¢???????????????¨????±??????????

  ???????????????????????????????????????????????????????????????????????????????????????????????????
  ???????????????S1??????????????????????????????????????????????????????
  ???????????????B1????????????????????¶???????¢??????????
  ???????????????S2?????????????????????????????????????????????????????????
  ???????????????B2???????????????????????¶???????¢??????????
  ??????
  ???SQ???BQ?????§??°?????????

  ???????????????????????????????????????????????¶???????¢???????????????????????????????????????????????????????
  ?????????????????????????????¶???????????????????????±????????¨????????????????????????????????¨????????????
  ??????????????¨?????§????????????


*/

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, M, Q;
	while (cin >> N >> M >> Q) {
		if (N == 0 && M == 0 && Q == 0) break;
		string S, B;
		vector<int> light(N, 0); // on or off
		vector<vector<int>> Switch(M, vector<int>(N, 0)); // switch j := may connect light i
		for (int q = 0; q < Q;q++) {
			cin >> S >> B;
			for (int i = 0; i < N;i++) {
				if (S[i] == '1') {
					light[i] = (light[i] == 0) ? 1 : 0;
				}
				for (int j = 0; j < M;j++) {
					if (light[i] == (B[j] - '0')) {
						Switch[j][i]++;
					}
				}
			}
		}

		for (int j = 0; j < M;j++) {
			int Max = -1;
			for (int i = 0; i < N;i++) {
				Max = max(Switch[j][i], Max);
			}
			bool f = false;
			int ans = -1;
			for (int i = 0; i < N;i++) {
				if (Switch[j][i] == Max) {
					if (ans == -1) {
						ans = i;
					}
					else {
						f = true;
						break;
					}
				}
			}
			if (f) { cout << '?'; continue; }
			if (ans < 10) {
				cout << ans;
			}
			else {
				cout << (char)('A' + (ans - 10));
			}
		}
		cout << endl;
	}

}

Measured memory_bytes: 3268
# -*- coding: utf-8 -*-

while True:
    try:
        list = [float(x) for x in raw_input().split() ]
        x = (list[2]*list[4]-list[1]*list[5])/(list[0]*list[4]-list[1]*list[3])+0
        y = (list[0]*list[5]-list[2]*list[3])/(list[0]*list[4]-list[1]*list[3])+0

        print("%.3f %.3f" %(x, y))

    except EOFError:
        break

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

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

Measured memory_bytes: 1024
//Volume5-0510
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int ret=0;
		int S = sc.nextInt()+sc.nextInt()+sc.nextInt()+sc.nextInt();
		int T = sc.nextInt()+sc.nextInt()+sc.nextInt()+sc.nextInt();
		if   (S<T){ret = T;}
		else      {ret = S;}
		System.out.println(ret);
	}
}

Measured memory_bytes: 17164
def mainFunc():
    N = int(input())
    arr = list(map(int, input().split(" ")))
    minN = arr[0]
    ans = 0

    for i in range(N):
        if minN >= arr[i]:
            minN = arr[i]
        if minN >= arr[i]:
            ans += 1
    
    print(str(ans))

mainFunc()

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

int main(){
  int H,W;
  cin >> H >> W;
  for(int i=0;i<W+2;i++) cout << '#';
  cout << endl;
  for(int i=0;i<H;i++){
    cout << '#';
    for(int j=0;j<W;j++){
      char c;
      cin >> c;
      cout << c;
    }
    cout << '#' << endl;
  }
  for(int i=0;i<W+2;i++) cout << '#';
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  char maze[3][3];
  while(cin>>maze[0][0]){
    if(maze[0][0] == '0')break;
    rep(i,3)rep(j,3){
      if(i==0&&j==0)continue;
      cin>>maze[i][j];
    }
    bool find = false;
    rep(i,3)if(maze[0][i] == maze[1][i] && 
	       maze[1][i] == maze[2][i] && 
	       maze[0][i] != '+'){
      cout<<maze[0][i]<<endl;
      find = true;
    }
    if(find)continue;
    rep(i,3)if(maze[i][0] == maze[i][1] && 
	       maze[i][1] == maze[i][2] && 
	       maze[i][2] != '+'){
      cout<<maze[i][1]<<endl;
      find = true;
    }
    if(find)continue;
    if(maze[0][0] == maze[1][1] && 
       maze[1][1] == maze[2][2] &&
       maze[1][1] != '+'){
      cout<<maze[0][0]<<endl;
      continue;
    }else if(maze[2][0] == maze[1][1] && 
	     maze[1][1] == maze[0][2] &&
	     maze[2][0] != '+'){
      cout<<maze[1][1]<<endl;
      continue;
    }else{
      cout<<"NA"<<endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 1132
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);




int main()
{
    int q=1;

    while(q--)
    {
       ll n;  cin>>n;
      map<string,int>m;
      string s;
      int z;
      for(int i=0;i<n;i++){
        cin>>s;
        m[s]++;
      }
      cout<<"AC x "<<m["AC"]<<endl;
      cout<<"WA x "<<m["WA"]<<endl;
      cout<<"TLE x "<<m["TLE"]<<endl;
      cout<<"RE x "<<m["RE"]<<endl;
    }


    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
string s;
inline bool check(int l,int r) {
    for (int i=0;i<r-l;++i)
        if (s[i+l]!=s[r-i-1])
            return false;
    return true;
}
int main()
{
    cin>>s;
    int n=s.length();
    if (check(0,n)&&check(0,(n-1)/2)&&check((n+1)/2,n)) puts("Yes");
    else puts("No");
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool answer = true;
    rep(i,n) {
        if(i%2==0 && s.at(i)=='L') answer=false;
        if(i%2==1 && s.at(i)=='R') answer=false;
    }
    if(answer) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a%2==0||b%2==0){
    cout <<"Even"<<endl;
  }else{
    cout<<"Odd"<<endl;
  }
  return 0;
  
}

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

using namespace std;

main()
{
	double ans = 0;
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		
		ans += 1.0 / x;
	}
	
	ans = 1.0 / ans;
	
	cout << fixed << setprecision(7) << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long gcd(long long a, long long b){
  while(a > 0 && b > 0){
    if(a > b){
      a %= b;
    } else {
      b %= a;
    }
  }
  return a + b;
}
int main(){
    long long n, m;
    cin >> n >> m;
    long long g = n * m / gcd(n, m);
    map<long long, char> fu;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < n; i++){
      fu[i * g / n] = s[i];
    }
    for(int i = 0; i < m; i++){
      if(fu.find(i * (g / m)) != fu.end()){
        if(fu[i * (g / m)] != t[i]) return !printf("-1\n");
      } else {
        fu[i * (g / m)] = t[i];
      }
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 10880
#include<iostream>
#include<string>
using namespace std;
int main(){
    string w,t;
    int al=0;
    cin>>w;
    while(cin>>t){
        for(int i=0;t[i];i++)
            if(isupper(t[i])) t[i]=tolower(t[i]);
        if(t==w) al++;
    }
    cout<<al<<endl;
    return 0;
}


Measured memory_bytes: 3180
import itertools
a1, a2, a3 = map(int, input().split())
ans = 10 ** 9
for v in itertools.permutations([a1, a2, a3]):
    d = 0
    for i in range(1, 3):
        d += abs(v[i]-v[i-1])
    ans = min(ans, d)

print(ans)


Measured memory_bytes: 9092
import math
A,B = map(int,input().split())
Anum=[]
Bnum=[]

for i in range(2,int(math.sqrt(A)+1)):
    while A % i ==0:
        A //= i
        if i not in Anum:
            Anum.append(i)
if A!=1:
    Anum.append(A)


for i in range(2,int(math.sqrt(B)+1)):
    while B % i ==0:
        B //= i
        if i not in Bnum:
            Bnum.append(i)
if B!=1:
    Bnum.append(B)

ABnum=set(Anum) & set(Bnum)
print(len(ABnum)+1)




Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
W_list = _li()

cum_W = np.cumsum(W_list)
ans = float('inf')
for i in range(N-1):
    ans = min(ans, abs(cum_W[i]*2 - cum_W[-1]))
print(ans)


Measured memory_bytes: 21640
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int max = 0;
        int sub = 0;
        int c = 0;

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

        for(int i = 0; i < N; i++){
            if(max <= A[i]){
                max = A[i];
                c = i;
            }
        }

        for(int i = 0; i < N; i++){
            if(i == c){
                continue;
            }
            if(sub <= A[i]){
                sub = A[i];
            }
        }

        for(int i = 0; i < N; i++){
            if(i == c){
                System.out.println(sub);
            }else{
                System.out.println(max);
            }
        }
        
    }

}

Measured memory_bytes: 86300
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    int a, b;
    cin >> a >> b;
    int x = b * 10;
    int y = (b + 1) * 10 - 1;
    // cout << x << " " << y << endl;
    repd(i, x, y)
    {
        if (i * 8 / 100 == a)
        {
            printf("%d\n", i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}




Measured memory_bytes: 256
#include <string>
#include <iostream>
int main()
{
    std::string input;
    std::cin >> input;
    bool found[26]{};
    // 入力がASCII互換であると決め打ちする
    for(auto c : input) {
        if (found[c - 'a']){
            std::cout << "no" << std::endl;
            return 0;
        }
        found[c - 'a'] = true;
    }
    std::cout << "yes" << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int answer[100100];
bool visited[100100];

/*struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};*/
using Graph = vector<vector< pair<int,int> > >;

void dfs(Graph &G,int v){
    visited[v] = true;
    for(auto it :G[v]){
        if(visited[it.first])continue;
        answer[it.first]=(answer[v]+it.second)%2;
        dfs(G,it.first);
    }
}

int main(){
    int n;
    cin >> n;
    Graph G(n);
    REP(i,n)answer[i]=0;
    REP(i,n)visited[i]=false;
    REP(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        G[a-1].push_back(make_pair(b-1,c));
        G[b-1].push_back(make_pair(a-1,c));
    }

    dfs(G,0);
    REP(i,n)cout << answer[i] << endl;
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    long long n,a[10],s,k,i,m;
    cin>>n;
    for(i=0;i<5;i++)
        cin>>a[i];
    sort(a,a+5);
    if(n%a[0]!=0)
    s=n/a[0]+5;
    else
        s=n/a[0]+4;
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
/*
 
dunjen_master
 
*/
 
 

 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

inline ll mul(ll a,ll b){

    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}

  

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

/* ordered_set A;
   A.insert(x);
   A.erase(x);
   A.order_of_key(x) // no of elements less than (<) x
   *A.find_by_order(k-1) // kth smallest element
*/






int main(){
 

  
  
  int n;
  cin>>n;
  int deg[n+1];
  memset(deg,0,sizeof(deg));

  for(int i=2;i<=n;i++){
     int x;
     cin>>x;
     deg[x]++;
  }

  for(int i=1;i<=n;i++){
    cout<<deg[i]<<"\n";
  }
  
  
  
  return 0;
  }
  


   

    


    


    
    
    
    
 
    


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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 998244353;
const double pi = 3.14159265358979;



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

    ll n;
    cin >> n;
    vector<ll> d(n);
    for (ll i = 0;i < n;i++){
        cin >> d[i];
    }

    if (d[0] != 0){
        cout << 0 << endl;
        return 0;
    }

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

    vector<ll> num(d[n-1] +1);

    for (ll i = 0; i < n; i++){
        num[d[i]]++;
    }

    if (num[0] > 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;

    /*for (auto p : num){
        cout << p << endl;
    }*/

    for (ll i = 1; i < (d[n-1]+1); i++){
        if (num[i] == 0){
            cout << 0 << endl;
            return 0;
        }

        rep(j,num[i]){
            ans *= num[i-1];
            ans %= MOD;
        }
    }

    cout << ans << endl;

}

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

#define lol long long
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol abs(lol x){return(x<0?-x:x);}
lol n,m,k,r;
int x[500010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  set<string> g;
  cin >>n;
  int ans=0;
  for(int i=0;i<n;i++){
    cin >>s;
    if(g.find(s)==g.end()){
      ans++;
      g.insert(s);
    }
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 19216
n, m = map(int, input().split())
list_pS = []
for _ in range(m):
  list_pS.append(input().split())

flag_correct = [False]*(n+1)
count_correct = 0
list_count_pena = [0]*(n+1)
count_pena = 0
for i,ans in enumerate(list_pS):
  if ans[1] == 'AC':
    if not(flag_correct[int(ans[0])]):
      count_correct +=1 
      flag_correct[int(ans[0])] = True
  if ans[1] == 'WA':
    if not(flag_correct[int(ans[0])]):
      list_count_pena[int(ans[0])] +=1

for i,pena in enumerate(flag_correct):
  if flag_correct[i]:
    count_pena += list_count_pena[i]
      
print(count_correct, count_pena)

Measured memory_bytes: 33688
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int w,h;
    cin >> w >> h;
    if(!w&&!h) return 0;
    vector<string> field;
    field.resize(h);
    REP(i,h) cin >> field[i];
    vector<vector<string> > dp;
    dp.resize(h+1);
    REP(i,h+1) dp[i].assign(w+1,"");
    REP(i,h) REP(j,w){
      if(0<=i&&i<h&&0<=j&&j<w){
	if(('1'<=field[i][j]&&field[i][j]<='9')||(field[i][j]=='0'&&dp[i][j]!=""))
	  dp[i][j]+=field[i][j];
	else
	  dp[i][j]="";
	if((dp[i+1][j].size()<dp[i][j].size())||(dp[i+1][j].size()==dp[i][j].size()&&dp[i+1][j]<dp[i][j]+field[i][j]))
	  dp[i+1][j]=dp[i][j];
	if((dp[i][j+1].size()<dp[i][j].size())||(dp[i][j+1].size()==dp[i][j].size()&&dp[i][j+1]<dp[i][j]+field[i][j]))
	  dp[i][j+1]=dp[i][j];
      }
    }
    string answer="0";
    REP(i,h+1) REP(j,w+1)
      if(dp[i][j].size()>answer.size() || (dp[i][j].size()==answer.size() && dp[i][j]>answer))
	answer=dp[i][j];
	
    cout << answer << endl;
  }
}

Measured memory_bytes: 1356
/*input
10 1 2



*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
#define trav(a,x) for(auto &a:x)
#define bits(n) __builtin_popcount(n)
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = pow(10,5)+5;
 

//standard input and output template
template<typename... T>
void in(T&... args) {
    ((cin >> args), ...);
}

template<typename... T>
void out(T&&... args) {
    ((cout << args << " "), ...);
}

template<typename... T>
void outl(T&&... args) {
    ((cout << args << endl), ...);
}


int fast_exp(int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp/=2;
    }
    return res%mod;
}



int32_t main() {
  IOS;

  int x,k,d;cin>>x>>k>>d;
  if(x>=0){
    int p = x/d;
    if(p>=k){
      cout<<x-k*d<<endl;
      
    }
    else if((k-p)%2==0)cout<<x-p*d<<endl;
    else
      cout<<min(abs(x-(p-1)*d),abs(x-(p+1)*d))<<endl;
  }
  else{
    x = -x;
    int p = x/d;
    if(p>=k){
      cout<<(x-k*d)<<endl;
    }
    else if((k-p)%2==0)cout<<(x-p*d)<<endl;
    else cout<<min(abs(x-(p-1)*d),abs(x-(p+1)*d))<<endl;
  }
  return 0;
}

Measured memory_bytes: 3648
void bsort(int a[], int n)
{

    int i, j, temp;

    for(i = 0; i < n - 1; i++) {
        for(j = n - 1; j > i; j--) {
            if (a[j - 1] > a[j]) {
                temp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = temp;
            }
        }
    }
}

int main(void)
{

    int n, m, h, p, k, g, a[200], i, c, j;

    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        scanf("%d %d", &h, &p);
        a[i] = h * 60 + p;
    }

    scanf("%d", &m);

    for(i = 0; i < m; i++) {
        scanf("%d %d", &k, &g);
        a[n + i] = k * 60 + g;
    }

    c = n + m;
    bsort(a, c);

    for(i = 0; i < c - 1; i++) {
        if(a[i] == a[i + 1]) {
            for(j = 0; j < c - i - 1; j++)
                a[i + j] = a[i + j + 1];
            c--;
            i--;
        }
    }

    for(i = 0; i < c; i++) {
        printf("%d:%.2d", a[i] / 60, a[i] % 60);
        if(i != c - 1)
            printf(" ");
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int N,K;
vi Rank,Tmp;

bool Comp(int i,int j){
	if(Rank[i]!=Rank[j]) return Rank[i]<Rank[j];
	int ri=i+K<=N?Rank[i+K]:-1,rj=j+K<=N?Rank[j+K]:-1;
	return ri<rj;
}

vi Suffix_Array(string s){
	N=s.size();
	vi sa(N+1);
	Rank=Tmp=vi(N+1);
	for(int i=0;i<=N;i++){
		sa[i]=i;
		Rank[i]=i<N?s[i]:-1;
	}
	for(K=1;K<=N;K*=2){
		sort(sa.begin(),sa.end(),Comp);
		Tmp[sa[0]]=0;
		for(int i=1;i<=N;i++) Tmp[sa[i]]=Tmp[sa[i-1]]+(Comp(sa[i-1],sa[i])?1:0);
		Rank=Tmp;
	}
	return sa;
}

int n,k,m;
string s;
vi a,sa;

bool f(int x){
	int t=0,I=0,num=n-(m-1)*(k+1);
	for(int i=0;i<=k;i++){
		if(a[I]<=x&&t<num) I+=m,t++;
		else I+=m-1;
	}
	return t==num;
}

int main(){
	cin>>k>>s;
	n=s.size(),m=(n+k)/(k+1);
	sa=Suffix_Array(s);
	a=vi(n-m+1);
	int l=-1,r=n-m,id=0;
	for(int i=0;i<=n;i++) if(sa[i]<=n-m) a[sa[i]]=id++;
	while(r-l>1){
		int mid=(l+r)/2;
		if(f(mid)) r=mid;
		else l=mid;
	}
	for(int i=0;i<n-m+1;i++) if(a[i]==r) cout<<s.substr(i,m)<<endl;
}

Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.CardCount = inpt[0];
        this.Heikin = inpt[1];
        this.Cards = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        long ans = this.GetAns(0, 0, 0);
        Console.WriteLine(ans);
    }


    Dictionary<int, Dictionary<int, Dictionary<int, long>>> dic = new Dictionary<int, Dictionary<int, Dictionary<int, long>>>();
    private long GetAns(int idx, int maisu, int total)
    {
        if (!dic.ContainsKey(idx))
        {
            dic.Add(idx, new Dictionary<int,Dictionary<int,long>>());
        }
        if (!dic[idx].ContainsKey(maisu))
        {
            dic[idx].Add(maisu, new Dictionary<int, long>());
        }
        if (dic[idx][maisu].ContainsKey(total))
        {
            return dic[idx][maisu][total];
        }

        if (idx >= this.CardCount)
        {
            if (maisu == 0)
            {
                return 0;
            }
            if (total % maisu == 0 && total / maisu == Heikin)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

        long ans = this.GetAns(idx + 1, maisu, total);
        ans += this.GetAns(idx + 1, maisu + 1, total + this.Cards[idx]);
        dic[idx][maisu].Add(total, ans);
        return ans;
        
    } 


    private int CardCount = 0;
    private int Heikin = 0;
    private int[] Cards;





    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


33 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 26960
import sys

input = sys.stdin.readline


def count(S, i, j):
    res = 0
    for x, y in [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1)]:
        if S[i + y][j + x] == "#":
            res += 1
    return res


def main():
    H, W = map(int, input().split())
    S = [None] * (H + 2)
    S[0] = S[-1] = "." * (W + 2)
    for i in range(1, H + 1):
        S[i] = "".join([".", input().rstrip(), "."])

    ans = [[None] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i + 1][j + 1] == "#":
                ans[i][j] = "#"
            else:
                ans[i][j] = count(S, i + 1, j + 1)

    for i in range(H):
        print("".join(map(str, ans[i])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=II()
    hp=[]
    for _ in range(n):
        X,L=MI()
        heappush(hp,(X+L,X-L))
    ans=0
    pr=-10**10
    while hp:
        r,l=heappop(hp)
        if l<pr:continue
        ans+=1
        pr=r
    print(ans)

main()

Measured memory_bytes: 16784
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;


#define ll long long int
#define vll vector<ll>tm#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	if(a[0]==0)
	{
		cout<<0;
		return;
	}
	ll ans=1;
	
	ll tm = 1e18;
	
	for(ll i=0;i<n;i++)
	{
		if((tm/ans) >= a[i]) 
		{
			ans*=a[i];
		}
		else
		{
			cout<<-1;
			return;
		}
	}
	cout<< ans << endl;
}
	

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4444
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,ans=0;
    cin>>n;
    vector<int> arr(n);
    map<int,int> data;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(all(arr));
    for(int i=0;i<n;i++){
        if(data.count(arr[i]))continue;
        data[arr[i]]=i;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int sum=arr[i]+arr[j];
            map<int,int>::iterator itr=data.lower_bound(sum);
            if(itr==data.end())ans+=n-j-1;
            else
            ans+=itr->second-j-1;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main()
{
  vector<int> dist(3,0);
  for(auto & x : dist){
    cin >> x;
  }
  sort(dist.begin(),dist.end());
  cout << dist[0] + dist[1];
  return 0;
}


Measured memory_bytes: 256
min_r = 10 ** 9
max_raise = (10 ** 9 * -1) + 1
n = int(input())
r = int(input())
min_r = min(min_r, r)
for n in range(n - 1):
    r = int(input())
    max_raise = max(max_raise, (r - min_r))
    min_r = min(min_r, r)
print(max_raise)


Measured memory_bytes: 5608
// Same Integers

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int num[3];
	cin >> num[0] >> num[1] >> num[2];

	sort(num, num+3);

	int res = 0;

	while (1){
		if (num[0] == num[2])
			break;

		if (num[1] - num[0] >= 2){
			num[0] += 2;
		}else{
			num[0] += 1;
			num[1] += 1;
		}

		res++;
	}

	// cout << num[0] << num[1] << num[2] << endl;

	// If num[0] is odd, num[1] is even. If num[0] is even, num[1] is odd.
	if (num[1] - num[0])
		cout << res + 1 << endl;
	// Both num[0] and num[1] are odds or evens.
	else
		cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n;
    cin >> n;
    for(ll i=1;i<=3500;++i)for(ll j=1;j<=3500;++j){
        ll base = 4*i*j-n*(i+j);
        if(base == 0)continue;
        // cout << base << endl;
        if((n*i*j)%base==0 && (n*i*j)/base>=0){
            cout << i << " " << j << " " << (n*i*j)/base << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func AbsInt(n1 int, n2 int) int {
	return int(math.Abs(float64(n1 - n2)))
}

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if AbsInt(x, a) < AbsInt(x, b) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}


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

using P = pair<ll,ll>;
#define v first
#define w second

// v高い順（vが同じならw軽い方優先）
bool comp(P a, P b){
    return a.v == b.v ? a.w < b.w : a.v > b.v;
}

int main(void){
    ll N,W;
    cin>>N>>W;
    vector<P> a(N);
    rep(i,N){
        ll v,w;
        cin>>v>>w;
        a[i] = {v,w};
    }
    vector<P> dp = {{0,0}};

    rep(i,N){
        vector<P> tmp;
        for(auto& s : dp){
            tmp.push_back(s);
            tmp.push_back({s.v + a[i].v, s.w + a[i].w});
        }

        sort(all(tmp),comp);
        dp.clear();
        ll w_border = W+1;
        for(auto& s : tmp){
            if( w_border > s.w){
                w_border = s.w;
                dp.push_back(s);
            }
        }
    }
    cout<<dp[0].v<<endl;
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)
using Graph=vector<vector<int>>;

int n;
// プリムのアルゴリズム
vector<int> included;
int Prim(const Graph &G,int v,int &cost){
    // 頂点vは木に含まれた
    included.push_back(v);
    // n頂点全てが木に含まれていれば終了
    if(included.size()==n) return cost;

    int min_=2001;
    int to=-1;
    for(int x:included){
        for(int y=0; y<n; y++){
            if(G[x][y]<min_ && G[x][y]!=-1){
                // yがincludedに含まれている場合，何もしない
                if(find(included.begin(),included.end(),y)!=included.end()){
                    continue;
                }
                min_=G[x][y];
                to=y;
            }
        }
    }

    // 頂点toを追加して，Primを呼び出す
    cost+=min_;
    return Prim(G,to,cost);
}

int main(){
    cin>>n;
    
    // 隣接行列を受け取る
    Graph G(n,vector<int>(n));
    REP(i,n){
        REP(j,n){
            cin>>G[i][j];
        }
    }

    int cost=0;

    cout<<Prim(G,0,cost)<<endl;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll h,n,ar[100005],sum=0,i;
    cin>>h>>n;
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        sum+=ar[i];
    }
    if(sum>=h)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    long long n,a,b,k,s,p;
    scanf("%lld",&n);
    scanf("%lld",&a);
    scanf("%lld",&b);

    if(a==0 && b==0)
    {
        printf("0");
    }
    if(a==0 && b!=0)
    {
        printf("0");
    }
    if(a!=0)
    {
        k=n/(a+b);
        s=n%(a+b);
    if(s<=a)
    {
        p=s;
    }
    else
    {
        p=a;
    }

    printf("%lld",(k*a)+p);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int n,cnt=0;
ll ret;
ll ans[20];
ll x[20],y[20],p[20],dist[20];
int mp[20];//yでsortした順番に出力してくれる
int train[20];//0:なし 1:東西 2:南北
void solve(){
    ret=0;
    For(i,0,n) dist[i]=min(abs(x[i]),abs(y[i]));
    //xで左から見る
    int left=-1e8;
    For(i,0,n){
        if(train[i]==2){
            left=x[i];
        }
        dist[i]=min(dist[i],x[i]-left);
    }
    //xで右から見る
    int right=1e8;
    for(int i=n-1;i>-1;i--){
        if(train[i]==2){
            right=x[i];
        }
        dist[i]=min(dist[i],right-x[i]);
    }
    //yで下から見る
    int down=-1e8;
    For(i,0,n){
        if(train[mp[i]]==1){
            down=y[mp[i]];
        }
        dist[mp[i]]=min(dist[mp[i]],y[mp[i]]-down);
    }
    //yで上から見る
    int up=1e8;
    for(int i=n-1;i>-1;i--){
        if(train[mp[i]]==1){
            up=y[mp[i]];
        }
        dist[mp[i]]=min(dist[mp[i]],up-y[mp[i]]);
    }
    For(i,0,n) ret += dist[i]*p[i];
    ans[cnt] = min(ans[cnt],ret);
    return;
}
void Main(){
    cin >> n;
    vector<pair<int,pair<int,int>>> vec(n);
    For(i,0,n){
        cin >> vec[i].first >> vec[i].second.first >> vec[i].second.second;
    }
    sort(ALL(vec));
    //xでsortした順に入れる
    For(i,0,n){
        x[i]=vec[i].first;
        y[i]=vec[i].second.first;
        p[i]=vec[i].second.second;
    }
    //yでsortし直す
    sort(ALL(vec),[&](auto &l, auto &r){
        return l.second.first<r.second.first;
    });
    //xsortとysortの対応関係を作る
    For(i,0,n){
        For(j,0,n){
            if(vec[i].first==x[j] && vec[i].second.first==y[j]){
                mp[i]=j;
                break;
            }
        }
    }
    int p3=1;
    fill(ans,ans+n+1,1e18);
    For(i,0,n)p3*=3;
    For(i,0,p3){
        int x=i;
        cnt=0;
        For(j,0,n){
            train[j]=x%3;
            x/=3;
            if(train[j]>0) cnt++;
        }
        solve();
    }
    For(i,0,n+1) cout << ans[i] << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main()
{
    ll n, m, x;
    cin >> n >> m >> x;
    vector<ll> c(n);
    vector<vector<ll>> a(n, vector<ll>(m, 0));
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m)
        {
            cin >> a[i][j];
        }
    }

    ll minCost = -1;
    for (int s = 0; s < (1 << n); s++)
    {
        ll cost = 0;
        vector<ll> aa(m, 0);
        rep(i, n)
        {
            if (s & (1 << i))
            {
                cost += c[i];
                rep(j, m)
                {
                    aa[j] += a[i][j];
                }
            }
        }
        bool isOk = true;
        rep(j, m)
        {
            if (aa[j] < x)
            {
                isOk = false;
                break;
            }
        }
        if (isOk)
        {
            if (minCost == -1 || minCost > cost)
            {
                minCost = cost;
            }
        }
    }

    cout << minCost << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,d,d1,d0,c=0,i,j,l;
    cin >> m >> d;
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=d;j++)
        {
        d1 = j%10;
        d0 = j/10;
        l = d1*d0;
        if(d1>=2&&d0>=2&&l==i)
            {c++;

            }
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
long long int s[1002];
std::vector<long long int> v;
int chk[550002];
int temp[550002];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld", &s[i]);
        s[i] += s[i-1];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            v.push_back(s[j]-s[i]);
        }
    }
    std::sort(v.begin(), v.end());
    long long int ans = 0;
    for(int k=39;k>=0;k--)
    {
        int cnt = 0;
        for(int i=0;i<v.size();i++)
        {
            if((!chk[i]) && ((1LL << (long long int)k) & v[i]))
            {
                cnt++;
                temp[i] = 0;
            }
            else temp[i] = 1;
        }
        if(cnt >= m)
        {
            ans += (1LL << (long long int)k);
            for(int i=0;i<v.size();i++)
            {
                chk[i] = temp[i];
            }
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 8428