akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100010;

ll N,M,x[MAX_N];
bool no_in[MAX_N];


int main(){
  cin>>N>>M;
  vector<P> graph[N];
  queue<ll> q;
  for(ll i=0;i<N;i++){
    no_in[i]=true;
  }
  ll ltmp,rtmp,dtmp;
  for(ll i=0;i<M;i++){
    cin>>ltmp>>rtmp>>dtmp;
    ltmp--;
    rtmp--;
    graph[ltmp].push_back(P(rtmp,dtmp));
    no_in[rtmp]=false;
  }
  for(ll i=0;i<N;i++){
    x[i]=-1;
  }
  for(ll i=0;i<N;i++){
    if(no_in[i]){
      x[i]=0;
      q.push(i);
    }
  }
  bool fl=true;
  while(!q.empty()){
    ll pos=q.front();q.pop();
    for(ll i=0;i<graph[pos].size();i++){
      ll to=graph[pos][i].first;
      if(x[to]==-1){
        x[to]=x[pos]+graph[pos][i].second;
        q.push(to);
      }
      else{
        if(x[to]!=x[pos]+graph[pos][i].second){
          fl=false;
        }
      }
    }
  }
  for(ll i=0;i<N;i++){
    if(x[i]==-1)fl=false;
  }
  if(fl) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;
using tTree=__gnu_pbds::tree< ll , __gnu_pbds::null_type, less< ll >, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );

int main(void){

  ll n;
  cin>>n;
  map<ll,ll,greater<ll>> m;
  rep(i,n){
    ll a;
    cin>>a;
    m[a]++;
  }
  ll ans=0;
  while(!m.empty()){

    auto p=*(begin(m));
    m[p.first]--;
    if(m[p.first]==0) m.erase(p.first);

    auto target=(1LL<<(64-__builtin_clzll(p.first)));
    auto rest=target-p.first;

    //cout << p.first << "," << rest << endl;

    auto itr=m.lower_bound(rest);
    if(itr!=end(m) ){
      //cout << "not end" << endl;
      //cout << itr->first << endl;
      if( itr->first==rest){
        //cout << "found" << endl;
        ans++;
        m[rest]--;
      if(m[rest]==0) m.erase(rest);
      }
    }
    

  }
  
  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 12800
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;

#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)

long long t, n, m, u, v, q, k, s;
const int N = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

long long arr[N];
string str, ss;

set <int> colors;
int main() {
   csl;
   cin >> n;
   for (int i = 1; i <= n; ++i) {
      cin >> arr[i];
      colors.insert(arr[i]);
   }
   sort(arr + 1, arr + 1 + n);
   if (colors.size() > 2) {
      cout << "No\n";
      return 0;
   }
   if (colors.size() == 1) {
      if (2 * arr[1] <= n || arr[1] == n - 1)
         cout << "Yes\n";
      else cout << "No\n";
   } else {
      if (arr[n] - arr[1] >= 2) {
         cout << "No\n";
      } else {
         int cnt = 0;
         for (int i = 1; i <= n; ++i)
            if (arr[i] == arr[1])
               cnt++;
         if (cnt > arr[1]) {
            cout << "No\n";
            return 0;
         }
         if (n - cnt < 2 * (arr[1] - cnt + 1)) cout << "No\n";
         else cout << "Yes\n";
      }
   }
   return 0;
}




























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


int main()
{
	char s_mark[4] = { 'S', 'H', 'C', 'D' };
	int s_num[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
	char g_mark[52];
	int g_num[52];
	int count;
	int m, n, i;
	int tf = 0;

	cin >> count;
	for (int i = 0; i <count; i++)
	{
		cin >> g_mark[i] >> g_num[i];
	}
	for (m = 0; m < 4; m++)
	{
		for  (n = 0; n < 13; n++)
		{
			tf = 1;
			for (i = 0; i < count; i++)
			{
				if (s_mark[m] == g_mark[i] && s_num[n] == g_num[i])
				{
					tf = 0;
				}
			}
			if (tf == 1)
			{
				cout << s_mark[m] << ' ' << s_num[n] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3100
N = int(input())

mod = 10**9+7
so = [0]*N

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

for i in range(2, N+1):
    arr = factorization(i)
    for a in arr:
        so[a[0]-1] += a[1]

ans = 1
for s in so:
    ans *= s+1
    ans %= mod

print(ans)

Measured memory_bytes: 9312
/**
 *
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author b
 *
 */
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner();
		PrintWriter writer = new PrintWriter(System.out);
		solve(scanner, writer);
		writer.close();
	}

	private static void solve(Scanner scanner, PrintWriter writer) {

		int n = scanner.nextInt();
		int[] as = scanner.nextIntArr(n);

		long res = 0;
		int currMax = 0;
		for (int i = 0; i < n - 1; i++) {
			currMax = Math.max(currMax, as[i]);
			res += Math.max(0, currMax - as[i + 1]);
		}
		writer.println(res);
	}

	// Props to SecondThread
	static class Scanner {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tokenizer = new StringTokenizer("");

		String next() {
			while (!tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return tokenizer.nextToken();
		}

		long[] nextLongArr(int num) {
			long[] vals = new long[num];
			for (int i = 0; i < num; i++)
				vals[i] = nextLong();
			return vals;
		}

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

		int[] nextIntArr(int numberOfElements) {
			int[] values = new int[numberOfElements];
			for (int i = 0; i < numberOfElements; i++)
				values[i] = nextInt();
			return values;
		}

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

}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
vector<int>v;
int main()
{
   LL a,b,c,d;
   cin>>a>>b>>c>>d;
   LL x=max(a*c,b*d);
   LL y=max(a*d,b*c);
   x=max(x,y);
   cout<<x;
}


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

int main(){
    string s1;
    string p;
    cin >> s1 >> p;
    string s2 = s1 + s1;
    if(s2.find(p) != std::string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0; 
}   

Measured memory_bytes: 3196
K = gets.to_i
A, B = gets.split.map {|item| item.to_i}
flg = false

(A..B).each do |x|
    if x % K == 0 then
        flg = true
        break
    end
end

if flg == true then
    puts "OK"
else
    puts "NG"
end


Measured memory_bytes: 14376
def examA():
    S, W = LI()
    if S<=W:
        print("unsafe")
    else:
        print("safe")
    return

def examB():
    A, B, C, D = LI()
    while(True):
        C -= B
        if C<=0:
            print("Yes")
            break
        A -= D
        if A<=0:
            print("No")
            break
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10108
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        boolean[] nonPrime = new boolean[50022]; // default false, 50021 is prime number

        for (int i = 2; i <= 25011; i++) {
            if (nonPrime[i])
                continue;

            for (int j = i + i; j <= 50021; j += i) {
                nonPrime[j] = true;
            }
        }

        String line;
        while ((line = br.readLine()) != null) {
            int num = Integer.parseInt(line);
            int tmp = num;
            while (nonPrime[--tmp]) {
            }
            System.out.print(tmp + " ");
            tmp = num;
            while (nonPrime[++tmp]) {
            }
            System.out.println(tmp);
        }

    }
}


Measured memory_bytes: 24200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int a,b,sum,cnt;
  while(cin>>a>>b){
    sum=a+b;cnt=0;
    while(sum){
      cnt++;
      sum/=10;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
N=int(input())
X = [0]+list(map(int,input().split()))+[0]
SUMX = 0
for i in range(1,len(X)):
    SUMX += abs(X[i-1] - X[i])
for i in range(1,N+1):
    print(SUMX + abs(X[i-1] - X[i+1]) - abs(X[i] - X[i-1]) - abs(X[i+1] - X[i]))

Measured memory_bytes: 65004
#include <stdio.h>		/*gets(),puts()¾ÆRpCG[ÆWbW³ê½H*/

int main(){
	char str[21],henkan[21];		/*20¶ÈàÅAÅãÉÍ'\0'ªÜÜêéÌÅ*/
	int i=0,j=0;
	scanf("%s",str);
	while(str[i]){	/*¶ñÌ·³Í¢­ç©ÈH*/
		i++;
	}
	henkan[i]='\0';	/*¶ñÌ·³ðwè*/
	i--;			/*ÅãÌ¶ÉÚ®·é*/
	while(str[j]){
		henkan[i]=str[j];		/*Ï·*/
		i--;
		j++;
	}
	printf("%s\n",henkan);
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

const long long MOD = 1e9 + 7;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main() {
    long long s;
    cin >> s;
    long long len = 1;
    long long ans = 0;
    COMinit();
    while (len * 3 <= s) {
        long long num = s - (len * 3);

        ans += COM(num + len - 1, len - 1);
        ans %= MOD;
        len++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15508
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a, b;
        scanf("%d%d", &a, &b);
        if(a + b == 15)
        {
            printf("+\n");
        }
        else if(a * b == 15)
        {
            printf("*\n");
                   }
                   else
                   {
                       printf("x\n");
                   }
}


Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"7 3"# => "3",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: usize,
        b: usize,
    }
    ((a - 1) * (b - 1)).to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int t=(b+c-1)/b;
  int A=(a+d-1)/d;
  if(t<=A) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3624
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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 n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z;
    cin >> x>>y>>z;
    x-=z;
    cout<<x/(y+z)<<"\n";
}


Measured memory_bytes: 256
n, d = list(map(int, input().split()))
x_li = []
for i in range(n):
    x = list(map(int, input().split()))
    x_li.append(x)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        dis = 0
        for k in range(d):
            dis += (x_li[i][k] - x_li[j][k]) ** 2
        dis = dis ** 0.5
        if dis == float(int(dis)):
            count += 1
print(count)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int[] nums  = new int[3];
        
        for(int i = 0; i < 3; i++){
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        
        System.out.println(nums[0] + " " + nums[1] + " " + nums[2]);
    }
}



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

int main( void )
{
  string S;
  cin >> S;
  int max = 0;
  int count = 0;

  for( int i = 0; i < 3; i++ ) {
    if( S.at( i ) == 'R' ) {
      count++;
    }
    else {
      if( max < count ) {
	max = count;
      }
      count = 0;
    }
  }
  
  if( max < count )
    max = count;

  cout << max << endl;
}
      

Measured memory_bytes: 3624
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


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

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


void solve(std::string s){
    cout << (s[1] == 'R' ? "ABC" : "ARC") << endl;
}


signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3584
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;
use std::cmp::Ordering;

fn main() {
    let (mut a, mut b): (usize, usize);
    input!(a, b);
    if a == 1 {
        a = 99;
    }
    if b == 1 {
        b = 99;
    }
    println!(
        "{}",
        match a.cmp(&b) {
            Ordering::Greater => "Alice",
            Ordering::Less => "Bob",
            _ => "Draw",
        }
    );
}


Measured memory_bytes: 4352
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,a,b;
    cin>>n>>a>>b;
    long long ans=0;
    if((b-a)%2==0)
        ans=(b-a)/2;
    else{
        long long temp=b-1;
        long long temp2=n-a;
        ans=min(temp,temp2);
        long long ans1=a-1+(b-(a-1)-1)/2+1;
        long long ans2=n-b+(n-(a+(n-b)))/2+1;
        ans=min(ans,ans1);
        ans=min(ans,ans2);
    }
    cout<<ans;
    return 0;
}



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

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

    li n;
    cin >> n;
    vector<li> ls(n);
    for (int i = 0; i < n; ++i) {
        cin >> ls[i];
    }
    sort(ls.begin(), ls.end());

    li ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            const li mc = ls[i] + ls[j];
            li p = lower_bound(ls.begin(), ls.end(), mc) - ls.begin();
            ans += max(0LL, p - j - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long 
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,x[200000],y[200000],ma = 0,mi = INF,ans = INF;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x[i] >> y[i];
		if(x[i] > y[i]) swap(x[i],y[i]);
		ma = max(ma,y[i]);
		mi = min(mi,x[i]);
	}
	int maf = -1;
	for(int i = 0;i < n;i++){
		if(ma == y[i] && mi == x[i]) maf = i;
	}
	int tmi,tma;
	if(maf == -1){
		vector<P> vec;
		for(int i = 0;i < n;i++) vec.push_back(P(y[i],x[i]));
		sort(all(vec),greater<P>());
		tma = vec[0].first;
		tmi = vec[n - 1].first;
		int lim = 0;
		ans = min(ans,(ma - mi) * (tma - tmi));
		for(P p : vec){
			tma = max(lim,p.first);
			ans = min(ans,(ma - mi) * (tma - tmi));
			lim = max(lim,p.second);
			tmi = min(tmi,p.second);
		}
	}
	tmi = mi;
	tma = ma;
	for(int i = 0;i < n;i++){
		tmi = max(tmi,x[i]);
		tma = min(tma,y[i]);
	}
	cout << min(ans,(tmi - mi) * (ma - tma)) << endl;
	return 0;
}

Measured memory_bytes: 9584
H,N = list(map(int,input().split()))

M = []

for i in range(N):
    a,b = list(map(int,input().split()))
    M.append([a,b])

DP = [[10**9]*(N+1) for i in range(H+1)]

DP[H][0] = 0

for i in range(N):
    m = 10**9
    for j in range(H+1):
        h = H-j
        DP[h][i+1] = DP[h][i]
        if h+M[i][0] <= H and h!=0:
            DP[h][i+1] = min(DP[h][i], DP[h+M[i][0]][i+1]+M[i][1])
        elif h==0:
            DP[h][i+1] = min(DP[h][i],m + M[i][1])
        if h<=M[i][0]:
            m = min(m,DP[h][i+1])
            
#print(DP)
print(DP[0][N])

Measured memory_bytes: 121308
#include <iostream>
#include <cmath>

using namespace std;

int const NMAX = 1e5;
int const INF = 2e9;

int nStones;
int dp[NMAX+1];
int h[1+NMAX]; //this is an indication that your array is starting from index 1

int costOfHop(int from, int to) {
  return abs(h[from]-h[to]);
}

int main() {
  cin >> nStones;
  for(int i=1; i<=nStones; i++) {
    cin >> h[i];  //stones are 1..nStones
  }

  /*
    dp[i] = minimum cost of getting to ith stone
  */
  //Bottom-up: we process the most complex solved (we know is optimal) subproblem.
  //Top-down:  we solve the least complex subproblem for which we have prerequisites.
  dp[1] = 0; //the initial case is an abstract case
  dp[2] = dp[1] + costOfHop(1, 2);
  for(int i=3; i<=nStones; i++) { //you start from an UNSOLVED problem in top-down
    int pretender1 = dp[i-1] +  costOfHop(i-1, i);
    int pretender2 = dp[i-2] +  costOfHop(i-2, i);
    dp[i] = min(pretender1, pretender2);
  }
  cout << dp[nStones];
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N,D;
cin>>N>>D;
int range;
range=2*D+1;
int ans=((N-1)/range)+1;
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        char b = sc.next().charAt(0);
        char ans = 'x';
        if ( b == 'A' ) ans = 'T';
        if ( b == 'C' ) ans = 'G';        
        if ( b == 'G' ) ans = 'C';                
        if ( b == 'T' ) ans = 'A';
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}


fn main() {
    let (a, b, x) = input_tuple();
    if x <= a + b && a <= x {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

int calc(int x){
  int ret = 0;
  while(x%100==0){
    x /= 100;
    ret++;
  }
  return ret;
}

int main()
{
  int d, n;
  cin >> d >> n;

  int cnt = 0, val = 0;
  while(cnt<n){
    val++;
    if(calc(val)==d)
      cnt++;
  }

  cout << val << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <bitset>

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;

using namespace std;

const llint inf = pow(10,12);

int main(void) {
	llint n;
	cin >> n;

	llint ans = inf; 
	for (llint i = sqrt(n); i >= 1; i--) {
	  llint j;
	  if (n % i == 0) {
		  j = n / i;
			ans = min(ans, i + j - 2);
		}
	}

	cout << ans << endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> button(N);//0から始まることに注意；；
  rep(i,N){
    int n;
    cin >> n;
    button.at(i) = n-1;
  }
  //button(i)がai+1に対応
  vector<int> route(N);
  int idou=0,now=0;//now：現在地
  route.at(0) = 1;
  while(1){
    now = button.at(now);
    route.at(now)++;
    idou++;
    if(now == 1)
      break;
    else if(route.at(now) == 2){
      idou = -1;
      break;
    }
  }
  cout << idou << endl;
}







Measured memory_bytes: 1024
#include <stdio.h>

int a[100][100];
int b[100][100];
double c[100][100];

int main() {
  int n, m, l;
  scanf("%d %d %d", &n, &m, &l);
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for(int i=0; i<m; i++) {
    for(int j=0; j<l; j++) {
      scanf("%d", &b[i][j]);
    }
  }

  for(int i=0; i<n; i++) {
    for(int j=0; j<l; j++) {
      c[i][j] = 0;
    }
  }

  for(int bi=0; bi<n; bi+=16) {
    for(int bj=0; bj<l; bj+=16) {
      for(int bk=0; bk<m; bk+=16) {
        for(int i=bi; i<bi+16 && i<n; i++) {
          for(int j=bj; j<bj+16 && j<l; j++) {
            for(int k=bk; k<bk+16 && k<m; k++) {
              c[i][j] += a[i][k] * b[k][j];
            }
          }
        }
      }
    }
  }

  for(int i=0; i<n; i++) {
    for(int j=0; j<l; j++) {
      if(j != 0) {
        printf(" ");
      }
      printf("%.0lf", c[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2852
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    ans = 1
    if 0 in A:
        ans = 0
    else:
        for a in A:
            ans *= a
            if (10**18 < ans):
                ans = -1
                break
        if (10**18 < ans):
            ans = -1

    print(ans)


if __name__ == '__main__':
    main()


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

using ull = unsigned long long;
using ui = unsigned int;

struct card {
	char mark;
	int n,index;
	auto operator<(const card&c)->bool {
		return this->n < c.n;
	}

	friend 
		auto operator>>(std::istream& is, card&c)->std::istream& {
		return is >> c.mark >> c.n;
	}

	friend
		auto operator<<(std::ostream& os, const card&c)->std::ostream& {
		return os << c.mark <<" "<< c.n;
	}
	card() = default;
};

/*
template<class F>
class fixture:  F {
public :
	explicit constexpr fixture(F&& f)noexcept
		:F(std::forward<F>(f)){}

	template<class ... Arg>
	constexpr decltype(auto)
		operator()(Arg&&...arg)const {
		return F::operator()(*this, std::forward<Arg>(arg)...);
	}
};

template<class F>
constexpr decltype(auto)
make(F&&f)noexcept {
	return fixture<F>{std::forward<F>(f)};
}
*/
template<class A,class Pertition>
auto qs(A&a,ui p, ui r, Pertition f)->void {
	if (p < r) {
		auto q = f(a, p, r);
		qs(a, p, q, f);
		qs(a, q + 1, r, f);
	}
}
int main() {
	ui n;
	std::cin >> n;

	std::vector<card> v;
	v.resize(n);

	for (ui i{}; i < n; ++i) {
		std::cin >> v[i];
		v[i].index = i;
	}

	/*
		A => 配列。subscriptable。
		p => パーティションしたい配列の先頭
		r => 基準値
	*/
	auto partition = [](auto& A, ui p, ui r) {
		auto& x = A[r - 1];
		ui i = p - 1;
		/*
			基準値より小さいものを前に送って
			その個数（位置）を++する( = i )
		*/
		for (ui j{ p }; j < r - 1; ++j)
			if (  !(x < A[j] ) ) {
				++i;
				std::swap(A[i], A[j]);
			}

		/*
			この時点で[p,i)には基準値以下、
			[i,r]には基準値以上しかない。
			最後に基準値を[i,r]の先頭(=i)に持ってくれば
			仕切りにできる。
		*/
		++i;
		std::swap(A[i], A[r - 1]);

		return i;

	};

	qs(v, 0, v.size(),partition);


	bool stable{ true };
	for (ui i{ 1 }; i < n; ++i) {
		auto& a = v[i - 1];
		auto& b = v[i];

		if (a.n == b.n) {
			stable &= a.index < b.index;
		}
		if (!stable)
			break;
	}

	std::cout << (stable ? "Stable" : "Not stable") << "\n";
	for (const auto&e : v) {
		std::cout << e << "\n";
	}

	return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

const int N = 1e6;
int pref[N];
int suf[N];
int a[N];

int main(){

	int n;
	cin >> n;
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=1;i<=n;i++){
		pref[i] = __gcd(a[i],pref[i-1]);
	}
	for(int i=n;i>=1;i--){
		suf[i] = __gcd(a[i],suf[i+1]);
	}
	int best=0;
	for(int i=1;i<=n;i++){
		best = max(best, __gcd(pref[i-1], suf[i+1]));
	}
	cout << best << endl;

	return 0;
}

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

using namespace std;

int main(){
    char s[100];
    cin>>s;
    int len=strlen(s);
    char x[100];
    for(int i=0;i<len;i++)
        x[i]='x';
    x[len]='\0';
    cout<<x<<endl;     
}

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


class Program {

	static long mod = 1000000007;
	//static long mod =998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";





		int[] vals = parseAry(Console.ReadLine().Split(cs));

		int res = vals[0] - ( vals[1] * 2 );

		res = Math.Max(res, 0);
		Console.WriteLine(res);

		return;

	}




	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			sb.Append(a[i] + " "); 
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 11220
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main() {

	int n, a, b; cin >> n >> a >> b;
	int x = n * a < b ? n * a : b;
	cout << x<< endl;


	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
inline int read(){
	int x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

const int N = 200005;

int a[N],b[N];
int bina[N],binb[N];
int n,ans;

int main(){
	n = read();
	for(int i = 1;i <= n;i++) a[i] = read();
	for(int i = 1;i <= n;i++) b[i] = read();
	for(int i = 0;i <= 29;i++){
		int s1 = 0,s2 = 0,sum = 0;
		for(int j = 1;j <= n;j++){
			s1 ^= ((a[j]>>i)&1);
			s2 ^= ((b[j]>>i)&1);
		}
		sum = (s1+s2)*n%2;
		if(i == 0){
			ans += sum;
			continue;
		}
		for(int j = 1;j <= n;j++)
			bina[j] = a[j]&((1<<i)-1);
		for(int j = 1;j <= n;j++)
			binb[j] = b[j]&((1<<i)-1);
		sort(bina+1,bina+n+1);
		sort(binb+1,binb+n+1);
		int r = n;
		for(int j = 1;j <= n;j++){
			while(binb[r]+bina[j] >= (1<<i)) --r;
			sum ^= (n-r)&1;
		}
		ans += (sum<<i);
	}
	printf("%d\n" ,ans);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define N (int)2e5
using namespace std;
int n;
int a[N];

int l[N], r[N];
int main () {
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		int x;
		cin >> x;
		a[x] = i;
	}
	
	for (int i = 1; i <= n; i ++) {
		l[i] = i - 1;
		r[i] = i + 1;
	}
	
	ll ans = 0;
	
	for (int i = 1; i <= n; i ++) {
		int x = l[a[i]], y = l[x];
		int xx = r[a[i]], yy = r[xx];
		if (x != 0) {
			ans += 1ll * (x - y) * (xx - a[i]) * i;
		}
		if (xx != n+1) {
			ans += 1ll * (yy - xx) * (a[i] - x) * i;
		}
		r[l[a[i]]] = r[a[i]];
		l[r[a[i]]] = l[a[i]];
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) //cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
//1,2,...,aでbがない時のc番目
ll f(ll a, ll b, ll c){
    if(c< b)return min(a,c);
    else return min(a,c+1);
}
//a,a-1,...,1でbがない時のc番目
ll g(ll a, ll b, ll c){
    ll res = a-c+1;
    if(b>a or res>b)return max(1LL,res);
    else return max(1LL,res-1);
}
int main(){
    int q;
    cin >> q;
    while(q--){
        ll a,b;
        cin >>a >> b;
        show(a*b);
        ll l = 0;
        ll r = 1LL<<31;
        while(r-l>1){
            ll mid = (l+r)/2;
            ll x = (mid+1)/2;
            ll ma = 0;
            if(x-1>=1)ma = max(ma, f(mid,a,x-1)*g(mid,b,x-1));
            ma = max(ma, f(mid,a,x)*g(mid,b,x));
            ma = max(ma, f(mid,a,x+1)*g(mid,b,x+1));
            show(mid);
            show(ma);
            if(ma >= a*b){
                r = mid;
            }else{
                l = mid;
            }
        }
        {
            ll ma = 0;
            ll n = l;
            ll m = l;
            if(a<=n)n++;
            if(b<=m)m++;
            ll x = (n+1)/2;
            if(x-1>=1)ma = max(ma, f(n,a,x-1)*g(m,b,x-1));
            ma = max(ma, f(n,a,x)*g(m,b,x));
            ma = max(ma, f(n,a,x+1)*g(m,b,x+1));
            if(ma >= a*b)l--;
        }
        cout << l << endl;
    }
}

Measured memory_bytes: 256
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    N = iRaw()
    G = [[] for _ in range(N)]
    dp = [0]*N
    sizs = [0]*N
    CONV = CONV_TBL(N+1)

    for _ in range(N-1):
        a,b = isRaw()
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    
    def dfs(cur, pre):
        val = 1
        siz = 0
        for v in G[cur]:
            if v == pre:
                continue
            dfs(v, cur)
            siz += sizs[v]
            val = val * dp[v] * CONV.ncr(siz, sizs[v]) % DIV
        dp[cur] = val
        sizs[cur] = siz + 1
    
    def reroot(cur,pre):
        for v in G[cur]:
            if v == pre:
                continue
            val = dp[cur] * sizs[v]%DIV
            #val = val * CONV.fac[sizs[v]] * CONV.finv[sizs[v]-1]%DIV
            res = sizs[0]-sizs[v]
            dp[v] = val * CONV.finv[res] * CONV.fac[res-1] %DIV
            reroot(v,cur)
    
    dfs(0,-1)
    reroot(0,-1)
    return "\n".join([str(d) for d in dp])

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


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

using namespace std;

int cnt;
char str[15];
map<string, int> f;

int main() {
	int n; scanf("%d", &n);
	string s;
	for(int i = 1; i <= n; ++i) {
		scanf("%s", str);
		s = str;
		++f[s];
	}
	
	int ans = 0;
	for(map<string, int>::iterator it = f.begin(); it != f.end(); ++it)
		ans = max(ans, it->second);
	for(map<string, int>::iterator it = f.begin(); it != f.end(); ++it)
		if(ans == it->second) {
			s = it->first;
			for(string::iterator sit = s.begin(); sit != s.end(); ++sit)
				putchar(*sit);
			putchar('\n');
		}
	return 0;
}

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

const int N = (1 << 17);

int n, a, b, ans[N];

void f(int l, int r, int s, int e, int x){
	ans[l] = s;
	ans[r] = e;
	if(l + 1 == r) return;
	int t = (s ^ e) & x;
	int u = t & -t;
	int m = (l + r) / 2;
	int v;
	while(1){
		v = (rand() & x) | (s & ~x);
		if((s ^ v) & u) continue;
		if(__builtin_popcount(s ^ v) % 2 == 0) continue;
		if(__builtin_popcount(e ^ v ^ u) % 2 == 0) continue;
		if(v == e || (v ^ u) == s) continue;
		break;
	}
	f(l, m, s, v, x - u);
	f(m + 1, r, v ^ u, e, x - u);
}

int main(){
	scanf("%d%d%d", &n, &a, &b);
	if(__builtin_popcount(a ^ b) & 1){
		puts("YES");
		f(0, (1 << n) - 1, a, b, (1 << n) - 1);
		for(int i = 0; i < (1 << n); i++) printf("%d ", ans[i]);
		puts("");
	}
	else puts("NO");
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int c[3];
bool ss[11];
	while(!cin.eof()){
		rep(i,11) ss[i] = true;
		rep(i,3){
			cin >> c[i];
			ss[c[i]] = false;
		}
		if( cin.eof()  ) break;
		
		int cnt = 0;
		rep2(i,1,11) 
			if(ss[i]  && (c[0] + c[1] + i <= 20) ) cnt++;
		string ans = "YES";
		if(cnt < 4) ans = "NO";
		
		cout << ans  <<endl;
	}
	return 0;
	
	
}

Measured memory_bytes: 1196
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int a = int.Parse(Console.ReadLine());
			int b = int.Parse(Console.ReadLine());
			int c = int.Parse(Console.ReadLine());
			int d = int.Parse(Console.ReadLine());
			int ans = 0;
			if (a < b) {
				ans += a;
			} else {
				ans += b;
			}
			if (c < d) {
				ans += c;
			} else {
				ans += d;
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 27336