akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    ll o=0;
    rep(i,n){
        ll a;
        cin>>a;
        if(a%2==1)o++;
    }
    YES(o%2==0);
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  int ans=0;
  rep(i,n){
    ans=ans+a[i]-1;
  }
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
int main() {
	int H, A, i=1;
	scanf("%d%d", &H, &A);
	if(H <= A) printf("1\n");
	if(H > A) {
		while(H > A * i) {
			i++;
		}	
	printf("%d\n", i);
	}
	return 0;
}


Measured memory_bytes: 128
n, k = [int(i) for i in input().split()]

def cnt_mod(i):
    if n % k >= i:
        cnt_i = n // k + 1
    else:
        cnt_i = n // k

    a = pow(cnt_i, 3)
    return a

def cnt_mode_zero():
    cnt_zero = n // k
    a = pow(cnt_zero, 3)
    return a


cnt = 0
cnt += cnt_mode_zero()
if k % 2 == 0:
    ans = cnt_mod(k/2)
    cnt += ans
print(cnt)

Measured memory_bytes: 3064
void main(){
	( 2*PI*_scan() ).writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2960
#include<iostream>
#include<math.h>
#include<algorithm>

using namespace std;

int main(void)
{
	long long xs,ys,xt,yt;
	cin >> xs >> ys >> xt >> yt;
	long long n;
	cin >> n;
	long long x[n+2],y[n+2],r[n+2];
	for(int i=1;i<=n;i++)
		cin >> x[i] >> y[i] >> r[i];
	x[0]=xs;
	y[0]=ys;
	r[0]=0;
	x[n+1]=xt;
	y[n+1]=yt;
	r[n+1]=0;

	long double dis[n+2][n+2];
	for(int i=1;i<=n+2;i++)
	{
		for(int j=1;j<=n+2;j++)
		{
			long long disx=x[i-1]-x[j-1];
			long long disy=y[i-1]-y[j-1];
			dis[i-1][j-1]=(sqrt(disx*disx+disy*disy)-r[i-1]-r[j-1]);
			if(dis[i-1][j-1]<0)
				dis[i-1][j-1]=0;
//cout << dis[i-1][j-1] << endl;
		}
	}

	bool search[n+2];
	for(int i=1;i<=n+2;i++)
		search[i-1]=false;
	search[0]=true;
	long double mingo[n+2];
	for(int i=1;i<=n+2;i++)
		mingo[i-1]=10000000010;
	mingo[0]=0;

	int now=1;
	

	//dijkstra
	while(true)
	{
		if(now==n+2)
		{
			break;
		}
		long double nowmin = 10000000010;
		int next=0;
		for(int i=1;i<=n+2;i++)
		{
			if(search[i-1]==true)
				continue;
			mingo[i-1]=min(mingo[i-1],mingo[now-1]+dis[now-1][i-1]);
			if(mingo[i-1]<nowmin)
			{
				next=i;
				nowmin=mingo[i-1];
//cout <<  now << i << "nowmin:" << nowmin << endl;
			}
		}

		now = next;
		search[next-1]=true;
	}

	printf("%.10Lf\n",mingo[n+2-1]);
//	cout << mingo[n+2-1] << endl;
}


Measured memory_bytes: 16000
from collections import deque
import sys
def bfs(graph, N, start):
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        for n in graph[node]:
            if not visited[n]:
                visited[n] = node + 1
                que.append(n)
    return visited

input = sys.stdin.readline

def main():
    N, M = map(int, input().split())

    graph = [[] for _ in range(N)]
    for i in range(M):
        A, B = map(lambda n: int(n) - 1, input().split())
        graph[A].append(B)
        graph[B].append(A)

    visited = bfs(graph, N, 0)[1:]
    if all(visited):
        print("Yes")
        print(*visited, sep="\n")
    else:
        print("No")


main()

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

using namespace std;

int main (void)
{
  string S, T;
  cin >> S;
  cin >> T;
  int count = 0;
  for (int i = 0; i < 3; i++) {
	if ( S[i] == T[i] )
      count++;
  }
  cout << count;
  return 0;
}

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

int main() {
    string t;
    cin >> t;
    rep(i,t.size()) {
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}

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

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

int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  int A_max = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A_max = max(A_max, A[i]);
  }
  int g = A[0];
  for (int i = 0; i < N; i++) {
    g = gcd(g, A[i]);
  }
  cout << (A_max >= K && (A_max - K) % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;

  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;


bool primes[246913];
int max_num = 246912;
void set_primes(){
  primes[0] = false;
  primes[1] = false;
  int top_prime, count;
  top_prime = 2;
  for (int i = 2; i < max_num+1; ++i)
  {
    primes[i] = true;
  }
  while(true){
    count = top_prime;
    count += top_prime;
    for (int i = 0; count < max_num+1; ++i)
    {
      primes[count] = false;
      count += top_prime;
    }
    for (int i = top_prime+1; i < max_num+1; ++i)
    {
      if (primes[i])
      {
        top_prime = i;
        break;
      }
    }
    if (top_prime * 2 > max_num){
      break;
    }
  }
}

int primes_count(int n){
  int count;
  count = 0;
  for (int i = n+1; i <= 2*n; ++i)
  {
    if (primes[i]){
      count ++;
    }
  }
  return count;
}

int main(){
  int n;
  set_primes();
  while(cin >> n, n){
    cout << primes_count(n) << endl;
  }
  return 0;
}

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

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

	int x[4];
	for(int j = 0; j < 4; j++){
	x[j] = 0;
		for(int i = 0; i < 4; i++){
			if(s[j] == s[i]){
				x[j] += 1;
			}
		}
	}

	if(x[0] == 2 && x[1] == 2 && x[2] == 2 && x[3] == 2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,c;
    cin>>n>>c;
    int s=0;
    rep(i,c){
        int p;
        cin>>p;
        s+=p;
    }
    n++;
    cout<<s/n+!!(s%n)<<endl;
}


Measured memory_bytes: 3216
N = int(input())
s = []

for _ in range(N):
    s.append(int(input()))
    
s.sort()
ans = sum(s)

i = 0
temp = 0

while ans%10 == 0:
    ans += temp
    temp = s[i]
    ans -= temp
    i += 1
    if i == N:
        ans = 0
        break

print(ans)

Measured memory_bytes: 3064
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	// ------ ここまでテンプレ ------ //
	
	long a = read.to!long;
	long b = read.to!long;
	long c = read.to!long;
	
	long ans = b / a;
	if(ans > c) ans = c;
	
	ans.writeln;
	
	
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS

main = BS.getLine >>= print . compute

compute :: BS.ByteString -> Int
compute = (2 *) . BS.foldl' step 0

-- (Sの余っている数)
step :: Int -> Char -> Int
step s 'S' = succ s
step s 'T' = 0 `max` pred s


Measured memory_bytes: 892
N = int(input())
from itertools import product
S = ["3", "5", "7"]

ans = 0
for i in range(3, len(str(N)) + 1):
  for P in list(product(S, repeat=i)):
    if "3" in P and "5" in P and "7" in P:
      if int("".join(P)) <= N:
        ans += 1

print(ans)

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

int main() {
	int H, W;
	cin >> H >> W; 
	vector<string>S(H);	
	for (int i = 0;i<H;++i) {
		cin >> S[i];
	}
	vector<string>ansS(H + 2);	
	for (int i = 0;i<W+2; ++i) {
		ansS[0] += "#";
		ansS[H + 1] += "#";
	}
	for (int i = 0;i<H;++i) {
		ansS[i + 1] += "#";
		ansS[i + 1] += S[i];
		ansS[i + 1] += "#";
	}
	for (int i = 0;i<H+2;++i) {
		cout << ansS[i] << endl;
	}
}

Measured memory_bytes: 3592
#include<iostream>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];
    int l = p[0];
    int r = p[2];
    int ans = 0;
    for(int i = 1; i < n - 1; i++){
        if (l < p[i] && r > p[i]) {
            ans++;
        }else if (l > p[i] && r < p[i]) {
            ans++;
        }
        if (i == n - 2) {
            break;
        }
        
        l = p[i];
        r = p[i+2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_158_a
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            string S = ReadString();

            if (S == "AAA" || S == "BBB")
            {
                Write("No");
            }
            else
            {
                Write("Yes");
            }
        }


        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#if !TEST
    }
}
#endif

Measured memory_bytes: 11092
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
Volume0-0001
=end
class Main

  def initialize
    fh=STDIN 
    f=[]
    0.upto(9){|i|
      f.push(fh.gets.to_i)
    }
    puts f.sort{|a,b|b<=>a}.take(3).map{|x|x.to_s}

  end

end


if $0 == __FILE__ then
  Main.new
end

Measured memory_bytes: 8656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef double db;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 1e5 + 7;
int n, k;
pii a[N];
ll solve(int K) {
	ll ret = 0;
	rep(i, 0, n) if ((K & a[i].fi) == a[i].fi) 
		ret += a[i].se;
	return ret;
}
int main() {
	scanf("%d%d", &n, &k);
	rep(i, 0, n) scanf("%d%d", &a[i].fi, &a[i].se);
	ll ans = solve(k);
	rep(i, 1, 30) if (k >> i & 1) {
		int nk = (k ^ (1 << i)) | ((1 << i) - 1);
		ans = max(ans, solve(nk));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
import Data.List
import Data.Char
import Text.Printf
import Control.Monad
main = do
    n <- readLn
    input <- replicateM n $ map (read :: String -> Int) . words <$> getLine
    putStrLn $ if analyze input then "Yes" else "No"

analyze [] = True
analyze (x:xs)= if (x!!1 + x!!2 <= x!!0) && (sum x `mod` 2 == 0) then analyze xs else False

Measured memory_bytes: 81276
n=int(input())
px,py,pt=0,0,0
import sys
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(x-px)+abs(y-py)<=t-pt and (t-pt-abs(x-px)-abs(y-py))%2==0:
        px,py,pt=x,y,t
    else:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 46312
#include <stdio.h>
#include <string.h>
int main(){
	char s[200001];
	char t[200001];
	int i;
	int l;
	int r;
	
	r = 0;
	scanf("%s", s);
	scanf("%s", t);
	l = strlen(s);
	
	for(i = 0; i < l; i++){
		if(s[i] != t[i]){
			r++;
		}
	}
	printf("%d\n", r);
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

const int ALPHA_NUM = 26;

set<char> st;

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

    if ((signed)S.length() == ALPHA_NUM)
    {
        if (S.compare("zyxwvutsrqponmlkjihgfedcba") == 0)
        {
            cout << -1 << endl;
        }
        else
        {
            bool flg = false;

            string ans = S;

            for (int i = (signed)S.length() -1; 0 < i; i--)
            {
                if (flg) break;

                st.insert(S[i]);
                ans.pop_back();

                if (S[i - 1] < S[i])
                {
                    ans.pop_back();

                    for (auto s : st)
                    {
                        if (S[i - 1] < s)
                        {
                            ans += s;
                            flg = true;
                            break;
                        }
                    }
                }
            }

            cout << ans << endl;
        }
    }
    else
    {
        char x = 'a';

        REP(i, ALPHA_NUM)
        {
            st.insert(x++);
        }

        REP(i, (signed)S.length())
        {
            st.erase(S[i]);
        }

        cout << S + *st.begin() << endl;
    }

    return 0;
}


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

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		long x=in.nextLong(),y=in.nextLong();
		printBin(fillZero(Long.toBinaryString(x & y)));
		printBin(fillZero(Long.toBinaryString(x | y)));
		printBin(fillZero(Long.toBinaryString(x ^ y)));
	}
	
	static void printBin(String str) {
		for(int i=str.length()-32;i<str.length();i++)System.out.print(str.charAt(i));
		System.out.println();
	}
	
	static String fillZero(String str) {
		String zero="";
		if(str.length()<32) {
			for(int i=0;i<32-str.length();i++)zero+="0";
		}
		return zero.concat(str);
	}

}



Measured memory_bytes: 26292
use std::io;

fn main() {
    let mut _n: i32;
    let mut _s = String::new();
    io::stdin().read_line(&mut _s).ok();
    _n = _s.trim().parse().ok().unwrap();
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let f: f32 = s.split_whitespace().map(|c| (c.parse::<i32>().ok().unwrap() as f32).recip()).sum::<f32>();
    println!("{}", f.recip());
}

Measured memory_bytes: 4352
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

int main(void) {

  char s[100010];
  cin >> s;
  
  int n = strlen(s);

  for (int i = 'a'; i <= 'z'; i++) {
    
    int f[100010];
    f[0] = 0;
    rep(j, n) {
      f[j + 1] = f[j] + (int(s[j]) == i ? 1 : 0);
    }

    int mi[100010];
    mi[0] = 0;
    rep(j, n) {
      if (2 * f[mi[j]] - mi[j] > 2 * f[j + 1] - (j + 1)) mi[j + 1] = j + 1;
      else mi[j + 1] = mi[j];
    }

    for (int j = 0; j + 2 <= n; j++) {
      if (2 * f[mi[j]] - mi[j] < 2 * f[j + 2] - (j + 2)) {
	cout << mi[j] + 1 << " " << j + 2 << endl;
	return 0;
      }
    }
  }

  cout << -1 << " " << -1 << endl;

  return 0;

}
    

  


Measured memory_bytes: 1152
import math
while True:
    x=[]
    y=0
    n=int(input())
    if n==0:
        break
    for i in range(n):
        s=int(input())
        x+=[s]
    #print(x)
    
    x.remove(max(x))
    #print(x)
    x.remove(min(x))
    #print(x)
    
    
    for j in range(n-2):
        y+=x[j]
    
    #print(y)
    
    print(
        math.floor(y/(n-2))
        )
    
    



Measured memory_bytes: 5660
#include<cstdio>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#define LL long long int
#define M 2100000000
using namespace std;
int main(void)
{
	LL n,m,i,j,x1[51],x2[51],y1[51],y2[51],get,ss;
	cin>>n>>m;
	//1は人の座標、2はcheckpointの座標
	for(i=0;i<n;i++) cin>>x1[i]>>y1[i];
	for(i=0;i<m;i++) cin>>x2[i]>>y2[i];
	for(i=0;i<n;i++) {
		ss=M,get=0;
		for(j=0;j<m;j++) {
			if((abs(x1[i]-x2[j]))+(abs(y1[i]-y2[j]))<ss) {
				get=j,ss=(abs(x1[i]-x2[j]))+(abs(y1[i]-y2[j]));
			}
		}
		cout<<get+1<<endl;
	}
}
	

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


int main() {
    ll n,u,v;
    std::cin >> n>>u>>v;
    u--;v--;
    vector<vector<ll>> edges(n);
    vector<ll> dist1(n,-1);
    vector<ll> dist2(n,-1);

    for (int i = 0; i < n-1; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    
    queue<ll> q1;
    q1.push(u);
    dist1[u] = 0;
    
    while(q1.size()){
        ll now = q1.front();q1.pop();
        for (auto e : edges[now]) {
            if(dist1[e]==-1){
                dist1[e] = dist1[now]+1;
                q1.push(e);
            }
        }
    }
    
    queue<ll> q2;
    q2.push(v);
    dist2[v] = 0;
    
    while(q2.size()){
        ll now = q2.front();q2.pop();
        for (auto e : edges[now]) {
            if(dist2[e]==-1){
                dist2[e] = dist2[now]+1;
                q2.push(e);
            }
        }
    }
    ll res = 0;
    
    if(edges[u].size()==1 && dist2[u]==2){
        std::cout << 1 << std::endl;
        return 0;
    }
    
    for (int i = 0; i < n; i++) {
        // cerr<<dist1[i]<<" "<<dist2[i]<<endl;
    }
    
    for (int i = 0; i < n; i++) {
        if(dist1[i]<dist2[i]){
            if((dist1[i]-dist2[i])%2==0){
                res = max(res,dist2[i]-1);                
            }else{
                res = max(res,dist2[i]-1);    
            }
        }
    }
    
    std::cout << res << std::endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


signed main(){
	int a,b;
	cin>>a>>b;
	cout<<max(0ll,a-2*b)<<endl;
	return 0;
}

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

def main():
    N=int(input())
    flag = 0
    for i in range(1, 10):
        q = N // i
        mod = N % i
        if mod == 0:
            #print("MMM")
            if q < 10:
                #print("FFF")
                flag = 1
    if flag == 1:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
//https://atcoder.jp/contests/abc141/tasks/abc141_a
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string x;
	cin>>x;
	if(x=="Sunny")
	{
		cout<<"Cloudy"<<"\n";
	}
	else if(x=="Cloudy")
	{
		cout<<"Rainy"<<"\n";
	}
	else
	{
		cout<<"Sunny"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};



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

    ll n;
    string s;
    cin >> n >> s;
    ll r = 0,g = 0,b = 0;
    rep(i,n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }
    ll ans = r*g*b;
    rep(i,n){
        for(ll j = i;j < n;++j){
            ll k = 2*j-i;
            if(k < 0 || k >= n) continue;
            if(i == j || i == k || j == k) continue;
            if(s[i] == s[j]) continue;
            if(s[i] == s[k]) continue;
            if(s[j] == s[k]) continue;
            ans--;
        }
    }
    cout << ans << endl;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main(){
  int n,l,r,a,b;
  while(cin>>n,n){
    a=b=0;
    while(n--){
      cin>>l>>r;
      if(l>r) a+=l+r;
      else if(r>l) b+=l+r;
      else{
	a+=l;b+=r;
      }
    }
    cout<<a<<' '<<b<<endl;
  }
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        double x[];
        double y[];
        double p1=0;
        double p2=0;
        double p3=0;
        double pm=0;
        double a;
        x=new double[n];
        y=new double[n];
        for(int i=0;i<n;i++){
            x[i]=sc.nextDouble();
        }
        for(int i=0;i<n;i++){
            y[i]=sc.nextDouble();
        }
        for(int i=0;i<n;i++){
            a=Math.abs(x[i]-y[i]);
            p1+=a;
            p2+=a*a;
            p3+=a*a*a;
            if(pm<a) pm=a;
        }
        System.out.println(p1);
        System.out.println(Math.sqrt(p2));
        System.out.println(Math.cbrt(p3));
        System.out.println(pm);
    }
}



Measured memory_bytes: 28908
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> A(1000000);
  for(int i=1;i<=100;i++)
    for(int j=1;j<=100;j++)
      for(int k=1;k<=100;k++)
        A[i*i+j*j+k*k+i*j+i*k+j*k]++;
  for(int i=1;i<=N;i++)cout<<A[i]<<endl;
}

Measured memory_bytes: 7216
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int con(char str[16]){
  int ret = 0;
  stack<int> s;
  rep(i, strlen(str)){
    if( '0' <= str[i] && str[i] <= '9'){s.push(str[i]-'0');}
    else if(str[i] == 'm'){
      if(s.empty()) ret += 1000;
      else{ ret += 1000 * s.top(); s.pop();}
    }
    else if(str[i] == 'c'){ 
      if(s.empty()) ret += 100;
      else{ ret += 100 * s.top(); s.pop();}
    }
    else if(str[i] == 'x'){
      if(s.empty()) ret += 10;
      else{ ret += 10 * s.top(); s.pop();}
    }
    else if(str[i] == 'i'){
    if(s.empty()) ret += 1;
    else{ ret += s.top(); s.pop();}
    }
  }
  return ret;
}


int main(){
  int n;
  scanf("%d", &n);
  while(n--){
    char s1[16], s2[16];
    scanf("%s%s", s1, s2);
    int sum = con(s1) + con(s2);
    vector<char>res;
    if(sum/1000){
      if(sum/1000>1) res.push_back((sum/1000)+'0');
      res.push_back('m');
    }
    sum %= 1000;
    if(sum/100){
      if(sum/100>1) res.push_back((sum/100)+'0');
      res.push_back('c');
    }
    sum %= 100;
    if(sum/10){
      if(sum/10>1) res.push_back((sum/10)+'0');
      res.push_back('x');
    }
    sum %= 10;
    if(sum){
      if(sum>1) res.push_back((sum)+'0');
      res.push_back('i');
    }
    
    rep(i, res.size()) printf("%c", res[i]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
int solve(int, int);
int m,p,G[2000];
int main()
{
  int i,k;

  scanf("%d",&m);
  for(i=0; i<m; i++){
    scanf("%d",&G[i]);
  }
  scanf("%d",&p);
  for(i=0; i<p; i++){
    scanf("%d",&k);
    if(solve(0, k)==1)
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}
int solve(int o, int t)
{
  if(t==0) return 1;
  if(o>=m) return 0;
  if(solve(o+1,t)) return 1;
  if(solve(o+1,t-G[o])) return 1;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>

int main()
{
  std::string s;
  std::cin >> s;
  int len = s.size();
  
  bool kaibun = true;
  int i;
  int N = len/2;
  for (i = 0; i < N; i++) {
    if (s[i] != s[len - 1 - i]) kaibun = false;
  }
  
  N = (len - 1)/2;
  for (i = 0; i < N/2; i++) {
    if (s[i] != s[N - 1 - i]) kaibun = false;
  }
  
  N = (len + 3)/2;
  int j = 1;
  for (i = N - 1; i < (N + len)/2; i++) {
    if (s[i] != s[len - j]) kaibun = false;
    j++;
  }
  
  if (kaibun) std::cout << "Yes";
  else std::cout << "No";
  return 0;
}

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

using namespace std;

int main()
{
	const int max_v = 86;
	vector<long long> Lucas(max_v + 1);

	Lucas[0] = 2;
	Lucas[1] = 1;

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

	int N;
	cin >> N;

	cout << Lucas[N] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int k, a, b;
	cin >> k >> a >> b;
	bool ok = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0)ok = true;
	}
	if (ok)puts("OK");
	else puts("NG");*/


	ll x;
	cin >> x;
	ll a = 100;
	ll ans = 0;
	while (a < x) {
		ans++;
		a *= 1.01;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int f(string s) {
    rep(i, s.size() / 2) {
        if (s[i] == s[s.size() - 1 - i])
            continue;
        else
            return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (n % 2 == 0) {
        cout << "No" << endl;
        return 0;
    }
    int res = f(s);
    res = res && f(s.substr(0, (n - 1) / 2));
    res = res && f(s.substr((n + 3) / 2 - 1, (n - 1) / 2));
    cout << (res ? "Yes" :  "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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 long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	char a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if(a==f&&b==e&&c==d)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	return 0;
}

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

void algorithm() {
    int n, a, alice=0, bob=0;
    vector<int> cards;
    cin >> n;
    cin >> a;
    cards.push_back(a);
    while(cin >> a) {
        for(auto i=cards.begin(); i <= cards.end(); i++){
            if(*i < a || i == cards.end()){
                cards.insert(i, a);
                break;
            }
        }
    }
    for(int i=0; i<cards.size(); i++){
        if(i%2==0) alice+=cards[i];
        else bob += cards[i];
    }
    cout << alice - bob << endl;
}

int main()
{   
    algorithm();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a;
  cin >> a;
  long b[a],f[a];
  long c=0,d=0,e=2;
  cin >> b[0];
  c = b[0];
  for(int i=1;i<a;i++){
    cin >> b[i];
    f[i]=c-b[i];
    c=b[i];
    if(e==0){
      if(f[i]<=0){
      }else{
        d++;
        e=2;
      }
    }else if(e==1){
      if(f[i]>=0){
      }else{
        d++;
        e=2;
      }
    }else{
     if(f[i]>0){
       e=1;
     }else if(f[i]<0){
      e=0; 
     }
    }
  }
  cout << d+1 << endl;
}

Measured memory_bytes: 1792
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

#define ll long long
#define ld long double
#define F first
#define S second

#define ONLINE_JUDGE 1

using namespace std;

const int mod = 1e9+7;

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> r(n),g(n),b(n);
	for(int i = 0; i < n; i++){
		if(s[i]=='R'){
			r[i] = 1;
		}else if(s[i]=='G'){
			g[i] = 1;
		}else{
			b[i] = 1;
		}
	}
	for(int i = 1; i < n; i++){
		r[i] += r[i-1];
		g[i] += g[i-1];
		b[i] += b[i-1];	
	}
	ll cnt = 0;

	auto get = [](vector<int> &a, int l, int r){
		if(l>r) return 0;
		if(l==0) return a[r];
		else     return a[r] - a[l-1];
	};
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(s[i]==s[j]) continue;
			set<char> w{'R','B','G'};
			w.erase(s[i]);
			w.erase(s[j]);
			char lk = *w.begin();
			if(lk=='R'){
				cnt+=(ll)get(r,j,n-1);
			}else if(lk=='G'){
				cnt+=(ll)get(g,j,n-1);
			}else{
				cnt+=(ll)get(b,j,n-1);
			}
			if( (2 * j - i < n) &&  s[2 * j - i]==lk) cnt--;
		}
	}
	cout << cnt << "\n";
}

int main(){
	#ifndef ONLINE_JUDGE	
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);		
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

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

int a, b, c, d, e, f;
int tw, ts, answ = 0, anss = 0;
double ma = -1;

set<int> water, sugar;

int main(void){
    // Here your code !
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

    for (int i = 0; i <= f; ++i) for (int j = 0; j <= f; ++j) {
      tw = 100 * (a * i + b * j);
      ts = (c * i + d * j);

      if (tw <= f) water.insert(tw);
      if (ts <= f) sugar.insert(ts);
    }

    for (auto i = water.begin(); i != water.end(); ++i) for (auto j = sugar.begin(); j != sugar.end(); ++j) {
      tw = *i; ts = *j;
      if (((tw + ts) <= f) && tw != 0) {
        if (((double)ts / (double)tw) <= ((double)e / (double)100)) {
          if (((double)ts / (double)(tw + ts)) > ma) {
            answ = tw; anss = ts;
            ma = ((double)ts / (double)(tw + ts));
          }
        }
      }
    }

    printf("%d %d\n", answ + anss, anss);
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, a, b, c, x, tmp, frame;
  while (cin >> n >> a >> b >> c >> x, n|a|b|c|x) {
    vector<int> y;
    frame = 0;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      y.push_back(tmp);
    }
    if (y[0] == x) y.erase(y.begin());
    while (!y.empty() && frame <= 10000) {
      frame++;
      x = (a*x+b)%c;
      if (x == y[0]) y.erase(y.begin());
    }
    if (frame == 10001) cout << "-1" << el;
    else cout << frame << el;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct CumulativeSum{
    vector<int> data;
    CumulativeSum(int sz) : data(sz, 0) {};
    void add(int k, int x){
        data[k] += x;
    }
    void build(){
        for(int i = 1; i < data.size(); i++){
            data[i] += data[i - 1];
        }
    }
    int query(int k){
        if(k < 0) return 0;
        return (data[min(k, (int)data.size() - 1)]);
    }
    int query(int l, int r){
        return query(r - 1) - query(l - 1);
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    CumulativeSum cs(n);
    rep(i, 0, n){
        cin >> a[i];
        cs.add(i, a[i]);
    }
    cs.build();
    int ans = INF;
    rep(i, 0, n - 1){
        int l = cs.query(0, i + 1);
        int r = cs.query(i + 1, n);
        ans = min(ans, abs(l - r));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
  $stdin = fopen('php://stdin', "r");

  fscanf($stdin, "%d", $q);
  $r = [];
  for ($i=0; $i<$q; $i++) {
      fscanf($stdin, "%d %d", $a, $b);
      $tr = [$a, $b];
      sort($tr);
      $r[] = $tr;
  }

  foreach ($r as $tr) {
    $a = $tr[0];
    $b = $tr[1];
    $ab = $a*$b;
    $cnt = 0;

    if ($a == $b || $a+1 == $b) {
      $cnt = 2*$a-2;
    } else {
      $c = (int)sqrt($a*$b);
      if ($c*$c == $a*$b) {
        $c--;
      }
      if ($c*($c+1) >= $a*$b) {
        $cnt = 2*$c-2;
      } else {
        $cnt = 2*$c-1;
      }
    }

    echo $cnt.PHP_EOL;
  }


Measured memory_bytes: 4856
#include <bits/stdc++.h>
using i64 = long long;

int n;
std::vector<std::vector<int>> g;
std::vector<int> s, d;

int get(int i, int j) {
    if (i > j) std::swap(i, j);
    return i * n + j;
}

int dfs(int v) {
    if (s[v] == 2) return d[v];
    if (s[v] == 1) {
        std::cout << -1 << std::endl;
        exit(0);
    }
    s[v] = 1;
    int ret = 0;
    for (auto to : g[v]) {
        ret = std::max(ret, dfs(to) + 1);
    }
    s[v] = 2;
    return d[v] = ret;
}

int main() {
    std::cin >> n;
    g.resize(n * n); s.resize(n * n); d.resize(n * n);
    for (int i = 0; i < n; i++) {
        int p;
        std::cin >> p;
        p--;
        for (int j = 2; j < n; j++) {
            int q;
            std::cin >> q;
            q--;
            g[get(i, p)].push_back(get(i, q));
            p = q;
        }
    }

    int ret = 0;
    for (int i = 0; i < n; i++) for (int j = 0; j < i; j++) {
        ret = std::max(ret, dfs(get(i, j)));
    }
    std::cout << ret + 1 << std::endl;

    return 0;
}


Measured memory_bytes: 47232
#include<stdio.h>
#define AMAX 2000
#define MMAX 2000

void solve(int,int);
 
int A[AMAX];
int n,judge=0;

int main()
{
  int q,M[MMAX];
  int i,j;

  scanf("%d",&n);

  for(i = 0; i < n ;i ++)
    {
      scanf("%d",&A[i]);
    }


  scanf("%d",&q);

  for(i = 0; i < q ;i ++)
    {
      scanf("%d",&M[i]);
    }
  
  for(i = 0; i < q; i ++)
    {
      solve(0,M[i]);
      if(judge == 0) printf("no\n");
      else  printf("yes\n");
      judge = 0;
    }
  return 0;
}

void solve(int i,int m)
{
  if(m == 0) judge = 1;
  else if(i != n)
    {
      solve(i+1, m-A[i]);
      solve(i+1, m);
    }
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int n,k;
        cin>>n>>k;
        double pre[n+1];
        pre[0] = 0;
        int x;
        rep(i,1,n+1)
        {
            pre[i] = 0;
            cin>>x;
            double xxx = (x+1)/2.0;
            pre[i]+= pre[i-1]+xxx;
        }
        
        double maxx = 0;
        rep(i,k,n+1)
        maxx = max(maxx,pre[i]-pre[i-k]);
        cout<<fixed<<setprecision(7);
        cout<<maxx<<el;
    }
   return 0;
}


Measured memory_bytes: 1792
# ABC95_C
a,b,c,x,y = map(int,input().split())

ans = 0
if c * 2 > a + b:
    ans += a * x + b * y
else:
    if x > y:
        ans += c * 2 * y
        if a > c * 2:
            ans += (x - y) * c * 2
        else:
            ans += (x - y) * a
    else:
        ans += c * 2 * x
        if b > c * 2:
            ans += (y - x) * c * 2
        else:
            ans += (y - x) * b
        
print(ans)

Measured memory_bytes: 3064
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <climits>
#include <deque>
#include <map>
#include <deque>
#include <iomanip>
#include <cmath>
#include <functional>
#include <set>
#include <list>
#include <bitset>
#include <stack>
#include <stdio.h>
#define endl '\n'
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
typedef pair<ll,ll> pll;
int main()
{
    /*
for reading from input.txt and writing on output.txt
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
*/
    cin.sync_with_stdio(false);
    ll n;cin>>n;
    string a,b;cin>>a>>b;
    string ans="";
    for(ll i=0;i<n;i++)
    {
        ans+=a[i];
        ans+=b[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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

int main() {
	int N, L;
	cin >> N >> L;
	int eat = abs(L);
	int index = 0;
	rep(i, N) {
		int tmp = abs(L + i);
		if(eat>tmp){
			eat = tmp;
			index = i;
		} 
	}
//cout << eat << ' ' << index << endl;
	int ans = N*(2*L+N-1)/2 - (L+index);
	cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int a[N],mx[N],res[N];
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int n; sf(n); n = pow(2, n);
	f(i, 0, n - 1)sf(a[i]);
	f(i, 0, n-1)for (int j = i; j <= n-1; j = (j + 1) | i)res[j]=max(res[j],a[i]+mx[j]),mx[j]=max(mx[j],a[i]);
	f(i, 1, n - 1)res[i] = max(res[i - 1], res[i]);
	f(i, 1, n - 1)cout << res[i] << '\n';
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin >> a >> b >> c;
  cout << a+b+c-max(max(a,b),c) << endl;
  return 0;
    

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define h 100100
int t[h];
	int main(){
	int n;
	cin>>n;
	int i=1;
	while(n --){
		cin>>t[i];
		i++;
	}
	int m;
	cin>>m;
	while(m--){
		int p,x;
		cin>>p>>x;
		int c;
		c=t[p];
		t[p]=x;
		int sum=0;
		for(int j=1;j<i;j++){
			sum+=t[j];
		}
		cout<<sum<<endl;
		t[p]=c;
	}
	return 0;
}

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

int min_cost(int* h , int n , int k)
{
    int*dp = new int[n];
    //Base Case
    dp[0] = 0;

    for(int i=1 ; i<n; ++i)
    {
        dp[i] = INT_MAX;
        for(int j = max(0 , i-k) ; j<i ; ++j)

            dp[i] = min( dp[i], 
                    dp[j] + abs(h[i] - h[j]));
    }
    return dp[n-1];
} 

int main()
{
    int n,k;
    cin>>n>>k;
    int* h = new int[n];
    for(int i = 0 ;i<n ;++i)
        cin>>h[i];
    cout << min_cost (h,n,k) <<endl;
    return 0;
}

Measured memory_bytes: 1024