akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n;
   cin>>n;
   ll i,j;
   ll a[n];
   ll xx=0;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       xx^=a[i];
   }

   for(i=0;i<n;i++)
   {
       cout<<(xx^a[i])<<" ";
   }


    



}
 

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 5224
import java.util.*;

//dpらしい…
class Main {
	Scanner sc = new Scanner(System.in);

	public boolean inmap(int x, int y) {
		return 0 <= x && x < 8 && 0 <= y && y < 8;
	}

	public void dfs(int x, int y) {
		if(inmap(x,y) && map[y][x]=='1'){
			map[y][x]='0';
			for(int[] d :dlist){
				dfs(x+d[0],y+d[1]);
			}
		}
	}

	int[][] dlist = new int[][] {
			new int[] { 1, 0 }, new int[] { 2, 0 },
			new int[] { 3, 0 }, new int[] { -1, 0 }, new int[] { -2, 0 },
			new int[] { -3, 0 },
			new int[] { 0, 1}, new int[] { 0, 2 }, new int[] { 0, 3 }
			, new int[] { 0, -1 }, new int[] { 0, -2 }, new int[] { 0, -3 }};

	char[][] map;

	public void run() {
		int size = sc.nextInt();
		for (int s = 1; s <= size; s++) {
			map = new char[8][8];
			for (int i = 0; i < 8; i++)
				map[i] = sc.next().toCharArray();
			dfs(sc.nextInt() - 1,sc.nextInt() - 1);
			ln("Data "+s+":");
			for(int y=0;y<8;y++){
				for(int x=0;x<8;x++){
					pr(map[y][x]);
				}
				ln();
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mo=998244353;
string s;
map<string,ll> f;
ll calc(string s){
	if (f[s])return f[s];
	int n=s.length();
	ll ans=(s[0]-'0'+1)*calc(s.substr(1,n-1))%mo;
	string z="";
	for (int i=1;i<=n/2;i++){
		z.append(1,s[i-1]);
		string T=z;
		for (int j=2,t=i;i*j<=n;j++){
			for (;t<i*j;t++)
				T[t%i]=min(T[t%i],s[t]);
			ans=(ans+calc(T)*calc(s.substr(t,n-i*j)))%mo;
		}
	}
	return f[s]=ans;
}
int main(){
	f[""]=f["0"]=1;f["1"]=2;
	cin>>s;
	cout<<calc(s)<<endl;
}

Measured memory_bytes: 5632
#!/usr/bin/perl
use Data::Dumper;

my ($h,$w,$m) = map { $_ - 0 } split(/\s+/,<STDIN>);

my @r_c = (); $#r_c = $h - 1;
my @c_c = (); $#c_c = $w - 1;
my @r_h = (); $#r_h = $h - 1;
my @c_h = (); $#c_h = $w - 1;

for(my $i=0;$i<$h;$i++){
  $r_c[$i] = +[$i,0];
}
for(my $i=0;$i<$w;$i++){
  $c_c[$i] = +[$i,0];
}

for(my $i=0;$i<$m;$i++){
  my ($h1,$w1) = map { $_ - 1 } split(/\s+/,<STDIN>);
  $r_c[$h1]->[1] ++;
  $r_h[$h1]->{$w1} = 1;
  $c_c[$w1]->[1] ++;
  $c_h[$w1]->{$h1} = 1;
}

my @s_r_c = sort { $b->[1] <=> $a->[1] } @r_c ;
my @s_c_c = sort { $b->[1] <=> $a->[1] } @c_c ;

#print &Dumper(\@s_r_c);
#print &Dumper(\@s_c_c);

my $cnt = 0;
if( $s_r_c[0]->[1] > $s_c_c[0]->[1] ){
  $cnt += $s_r_c[0]->[1];
  my $row = $s_r_c[0]->[0];
  my @s_c_c2 = sort { ($b->[1] - $c_h[$b->[0]]->{$row}) <=> ($a->[1] - $c_h[$a->[0]]->{$row}) } @c_c ;
  $cnt += $s_c_c2[0]->[1] - $c_h[$s_c_c2[0]->[0]]->{$row};
} else {
  $cnt += $s_c_c[0]->[1];
  my $col = $s_c_c[0]->[0];
  my @s_r_c2 = sort { ($b->[1] - $r_h[$b->[0]]->{$col}) <=> ($a->[1] - $r_h[$a->[0]]->{$col}) } @r_c ;
  #print &Dumper(\@s_r_c2);
  $cnt += $s_r_c2[0]->[1] - $r_h[$s_r_c2[0]->[0]]->{$col};
}
print "$cnt\n";



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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)

def prime_fact(n):
	p = {}
	for i in range(2, int(-(-n**0.5//1))+1):
		if n % i == 0:
			while n % i == 0:
				n //= i
				p[i] = p.get(i, 0) + 1
	if n != 1:
		p[n] = p.get(n, 0) + 1
	return p

fact_memo = [1, 1]
def fact(n):
	if len(fact_memo) > n:
		return fact_memo[n]
	else:
		for i in range(len(fact_memo), n+1):
			fact_memo.append(fact_memo[i-1] * i)
		return fact_memo[n]  

def miniComb(n, r):
	a = 1
	for i in range(r):
		a *= n - i
	return a // fact(r)


def main():
	log = Logger(1)
	n, m = map(int, sys.stdin.readline().split())
	p = prime_fact(m)
	ans = 1
	for i in p:
		ans *= miniComb(n + p[i] - 1, p[i])
		ans %= 10 ** 9 + 7
	print(ans)


main()

Measured memory_bytes: 38896
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let asum = a.iter().sum::<i64>();
    let mut xs = vec![0; n];
    xs[0] = (0..n).filter(|&x| x % 2 == 0).map(|x| a[x]).sum::<i64>() - asum / 2;
    // debug!(xs[0]);
    for i in 0..n - 1 {
        xs[i + 1] = a[i] - xs[i];
    }
    // debug!(xs);
    for x in xs {
        print!("{} ", x * 2);
    }
    println!("");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4216
from collections import namedtuple
plan = namedtuple('plan', ['time', 'x', 'y'])

def main():
    with open(0) as f:
        N = int(f.readline())
        plans = []
        for _ in range(N):
            t, x, y = map(int, f.readline().split())
            plans.append(plan(t, x, y))
    current = plan(0, 0, 0)
    for p in plans:
        t = p.time - current.time
        way = abs(p.x-current.x) + abs(p.y-current.y)
        if t < way:
            print('No')
            return None
        if (t - way) & 1:
            print('No')
            return None
        current = p
    else:
        print('Yes')

main()

Measured memory_bytes: 24056
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#define mp make_pair
using namespace std;
int main() {
    long long n, k;
    cin >> n >> k;
    long long a = k, b = n - k;
    long long ans = n;
    while (a && b) {
        if (a < b) {
            long long r = b % a;
            ans += a * (b / a) * 2;
            b = r;
            if (r == 0) ans -= a;
        } else {
            long long r = a % b;
            ans += b * 2 * (a / b);
            a = r;
            if (r == 0) ans -= b;
        } 
    }
    cout << ans << endl;
}


Measured memory_bytes: 504
def main():
    a =[]
    for i in range(3):
        aa =list(map(int,input().split()))
        a.append(aa)
    n = int(input())
    b = []
    for _ in range(n):
        bb = int(input())
        b.append(bb)

    ans = [[0] * 3 for i in range(3)]
    # print(ans)
    for i, bb in enumerate(b):
        f = 0
        for j , aa in enumerate(a):
            if bb in aa:
                f = 1
                break
        if f ==1:
            ans[j][aa.index(bb)] = 1
    if sum(ans[0]) == 3 or sum(ans[1]) == 3 or sum(ans[2]) == 3 :
        print('Yes')
        return
    if ans[0][0] + ans[1][0] + ans[2][0] == 3 or ans[0][1] + ans[1][1] + ans[2][1] == 3 or ans[0][2] + ans[1][2] + ans[2][2] == 3:
        print('Yes')
        return
    if ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3:
        print('Yes')
        return
    print('No')
    # print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
H,P = np.array([[int(x) for x in input().split()] for _ in range(N)],dtype=np.int64).T

i = (H+P).argsort()
H = H[i]; P = P[i]

# 人数 -> 最小高さ
INF = 10**18
dp = np.full(N+1,INF,dtype=np.int64)
dp[0] = 0
for h,p in zip(H,P):
    prev = dp
    dp = prev.copy()
    can_add = (prev[:-1] <= h)
    np.minimum(dp[1:], np.where(can_add, prev[:-1]+p, INF), out=dp[1:])

answer = np.where(dp < INF)[0][-1]
print(answer)

Measured memory_bytes: 12920
#include <iostream>
using namespace std;
#define MOD long(1e9+7)
int ans[100001] = {};
int main() {
//   int n; cin >> n;
//   int a[101] = {}, t[101] = {}; 
//   for(int i = 1; i <= n; i++) cin >> a[i]; sort(a, a + n);
//   for(int i = 1; i <= n; i++) t[i] = a[i] + t[i - 1];
//   for(int i = 1; i <= n; i++){

//   }
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x; cin >> x; ans[x] = -1;
	}
	ans[0] = 1;
	if (ans[1] == 0) ans[1] = 1;
	for(int i = 2; i <= n; i++){
		if (ans[i] == -1) continue;
		if (ans[i - 1] != -1) ans[i] += ans[i - 1], ans[i] %= MOD;
		if (ans[i - 2] != -1) ans[i] += ans[i - 2], ans[i] %= MOD;
		// cout << ans[i] << endl;
	}
	cout << ans[n];
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL X,K,D;
	cin>>X>>K>>D;

	if (X<0){
		X=-X;
	}
	LL K1=X/D;
	LL V=X%D;
	if (K<K1){
		cout<<X-K*D<<endl;
		return 0;
	}
	X=X-K1*D;
	K=K-K1;
	if (K%2==0){
		cout<<V<<endl;
	}else{
		LL X1=X-D;
		if (X1<0){
			X1=-X1;
		}
		LL X2=X+D;
		if (X2<0){
			X2=-X;
		}
		LL MinX=min(X1,X2);
		cout<<MinX;
	}
	return 0;
}

Measured memory_bytes: 3196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ITP1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] s = new Int32[26];
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) { break; }
                for (int i = 0; i < a.Length; i++)
                {
                    if (char.IsLetter(a[i]))
                    {
                        char x = char.ToLower(a[i]);
                        s[x - 'a']++;
                    }
                }
            }
            for(int i = 0; i < 26; i++)
            {
                Console.Write((char)('a' + i));
                Console.WriteLine(" : "+s[i]);
            }Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9264
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	String S = sc.next();
	String s[] = S.split("");

	boolean bl = true;
	for (int i = 0; i < s.length; i++) {
	    if (i % 2 == 1) {
		if (s[i].equals("R")) {
		    bl = false;
		    break;
		}
	    } else {
		if (s[i].equals("L")) {
		    bl = false;
		    break;
		}
	    }
	}

	if (bl)
	    System.out.println("Yes");
	else
	    System.out.println("No");
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void DFS(int X,priority_queue<int, vector<int>, greater<int> >& q,int TH = 10000000000)
{
  if(X > TH)return;
  q.push(X);
  string str = to_string(X);
  int B = (int)(str.back() - '0');
  if(B != 0)DFS(stol(str + to_string(B-1)),q,TH);
  if(B != 9)DFS(stol(str + to_string(B+1)),q,TH);
  DFS(stol(str + to_string(B)),q,TH);
  return;
}
void solve(void)
{
  int K;cin>>K;
  priority_queue<int, vector<int>, greater<int> > q;
  for (int i = 1; i <= 9; i++)
  {
    DFS(i,q);
  }
  for (int i = 0; i < K-1; i++)
  {
    q.pop();
  }
  cout<<q.top()<<endl;  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 5460
x,y=map(int,input().split())
a=set(list(map(int,input().split())))
if y==0:
    print(x)
else:
    b=[i for i in range(-5,105)]
    b=set(b)
    c=list(b-a)
    c.append(x)
    c.sort()

    r=c.index(x)
    
    p=abs(c[r]-c[r-1])
    q=abs(c[r]-c[r+1])
    if p==q:
            print(min(c[r-1],c[r+1]))
    elif p>q:
            print(c[r+1])
    else:
            print(c[r-1])
   

Measured memory_bytes: 61968
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int sum(int a) {
    int ret = 0;
    while (a > 0) {
        ret += a%10;
        a /= 10;
    }
    return ret;
}

int main() {
    int n = 0;
    int mini = 1000000;
    cin >> n;
    int a = 0, b = 0;
    for (int i=1; i<n; i++) {
        a = i;
        b = n - i;
        int buf = sum(a) + sum(b);
        if (buf < mini) mini = buf;
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s; cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

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

#define pb push_back
#define mp make_pair
#define st first
#define nd second

const int MOD = 1000000007;

char S[222222];
int main() {
  // ios_base::sync_with_stdio(0);
  scanf("%s", S);
  int N = strlen(S);

  int k = N-1;
  int BCs = 0;
  LL result = 0;
  while (k >= 0) {
    if (S[k] == 'A') {
      result += BCs;
      --k;
    } else if (S[k] == 'C' && k > 0 && S[k-1] == 'B') {
      BCs += 1;
      k -= 2;
    } else {
      BCs = 0;
      --k;
    }
  }
  printf("%lld\n", result);
}


Measured memory_bytes: 384
s=list(input())
s=[int(i) for i in s]
now=0
c=[0]*2019
c[0]=1
for n,i in enumerate(s[::-1]):
    now+=i*pow(10,n,2019)
    c[now%2019]+=1
ans=0
for k in range(2019):
    ans+=c[k]*(c[k]-1)//2
print(ans)

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

# 整数の入力
N = int(raw_input())

# 空白区切りの整数を取得
li = map(int, raw_input().split())

# 降順ソート
li.sort(reverse=True)

# 最小値同士を計算した結果を末尾に格納
for i in xrange(N-1,0,-1):
    tmp = float(li.pop(i) + li.pop(i-1))/2
    li.append(tmp)

print tmp

Measured memory_bytes: 2568
#include<cstdio>
#define int long long
int base=1,ans,n;
double calc(int x){
	int res=0,y=x;
	while(x)res+=x%10,x/=10;
	return (1.0*y)/(1.0*res);
}
signed main(){
	scanf("%lld",&n);
	while(n--){
		while(1){
			if(calc(ans+base)>calc(ans+base*10))
				base*=10;
			else break;
		}
		ans+=base;
		printf("%lld\n",ans);
	}
}

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

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

	long long var;
	for (int i = 1; i<=5 ; ++i) {
		cin >> var;
		if (var == 0)
		cout << i  <<"\n";
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  double s = (w * h) / 2.0;
  fix10;
  cout << s << " ";
  if(w / 2.0 == x && h / 2.0 == y) cout << 1;
  else cout << 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define vi vector<long long>
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(max(a, d), max(b, c))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e18+1;

ll n, b, m;
int a[100001];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    if(n==1) cout << "Yes";
    else
    {
        for(int i=0; i<n-1; i++)
        {
            if(a[i]==a[i+1]+1) a[i+1]++;
            else if(a[i]>a[i+1]+1)
            {
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<math.h>
int f(char*p);
int main(void)
{
	char a[10],b[10];
	int X,i,x;
	scanf("%s %s",a,b);
	strcat(a,b);
	X=f(a);
	x=sqrt(X);
    if((x*x)==X)
	printf("Yes");
	else
	printf("No"); 
	return 0;
}
int f(char*p)
{
	int result=0;
	while(*p)
	{
		result=result*10+(*p-'0');
		p++;
	}
	return result;
 } 

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

using namespace std;
int main(){
	long long n,a[100000],dp[100000];
	scanf("%lld", &n);
	for(long long i=0;i<n;i++){
		scanf("%lld", &a[i]);
	}
	dp[1]=abs(a[0]-a[1]);
	dp[2]=abs(a[0]-a[2]);
	for(long long i=3;i<n;i++)
	dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	printf("%lld", dp[n-1]);
}


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

using namespace std;

int main(void){
  string w[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string S;
  cin >> S;
  for(int i = 0; i < 7; i++){
    if(S == w[i]){
      cout << 7 - i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
  int n; cin >> n;
  int a[3*n+1];
  for(int i=1;i<=3*n;i++) cin >> a[i];
  priority_queue<int> S;
  priority_queue<int,vector<int>,greater<int> > F;
  long long sumF=0,sumS=0;
  long long sf[n+1],ss[n+1];
  for(int i=1;i<=n;i++){
    F.push(a[i]);
    sumF=sumF+a[i];
  }
  sf[0]=sumF;
  for(int k=1;k<=n;k++){
    F.push(a[n+k]);
    int x=F.top(); F.pop();
    sumF=sumF+a[n+k]-x;
    sf[k]=sumF;
  }
  for(int i=2*n+1;i<=3*n;i++){
    S.push(a[i]);
    sumS=sumS+a[i];
  }
  ss[n]=sumS;
  for(int k=n-1;k>=0;k--){
    S.push(a[n+k+1]);
    int x=S.top(); S.pop();
    sumS=sumS+a[n+k+1]-x;
    ss[k]=sumS;
  }
  long long ans=sf[0]-ss[0];
  for(int k=1;k<=n;k++){
    ans=max(ans,sf[k]-ss[k]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3832
#include<stdio.h>
 
int main()
{
  int room[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  
for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
  room[b-1][f-1][r-1]+=v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",room[i][j][k]);
      }
      printf("\n");
    }
    if(i<3)printf("####################\n");
  }
  return 0;
}



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

#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define itr vi:iterator
#define vpll vector < pair<long long,long long> >
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define pdd pair<double, double>

#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)

using namespace std;

int main(){

    //ios::sync_with_stdio(0);
    //cin.tie(0); cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //    freopen("input.txt", "r", stdin);
     //   freopen("output.txt", "w", stdout);
    //#endif

    int n;
    cin >> n;
    vi v(n);
    int sum1 = 0, sum2 = 0;
    rep(i, n){
        cin >> v[i];
        if(i<n/2) sum1 += v[i];
        else sum2 += v[i];
    }
    int x, y;
    x = sum1;
    y = sum2;
    int diff = abs(sum1-sum2);
    if(diff == 0){
        cout << 0;
        return 0;
    }
    int tmp = 0;
    int i = n/2;
    while(i < n){
        sum1 += v[i];
        sum2 -= v[i];
        tmp = abs(sum1-sum2);
        if(tmp < diff) diff = tmp;
        else break;
        i++;
    }
    sum1 = x;
    sum2 = y;
    i = n/2-1;
    while(i >= 0){
        sum1 -= v[i];
        sum2 += v[i];
        tmp = abs(sum1-sum2);
        if(tmp < diff) diff = tmp;
        else break;
        i--;
    }
    cout << diff;



    //cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (inputString)
{
  const stringArray = inputString.split(' ');
  const a = Number(stringArray[0]);
  const b = Number(stringArray[1]);
  const c = Number(stringArray[2]);
  let result = 'No';
  
  if (a < b && b < c) {
      result = 'Yes';
  } 
  
  console.log(result);
});


Measured memory_bytes: 15244
#200426B
A, B, C, D = map(int, input().split())
x = C//B
y = A//D

if C%B ==0:
    x = x-1
if A%D ==0:
    y = y-1
#print(x)
#print(y)
if x <= y:
    
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9112
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MOD = 1e9 + 7;

int power(int n, int p)
{
    if (p == 0)
        return 1;
    long long res = 1;
    long long add = n;
    while (p > 0)
    {
        if (p & 1)
            res = (res * add) % MOD;
        p >>= 1;
        add = add*add%MOD;
    }
    return res;
}

      
int getinv(int n) {
    static int invtable[200001];
    if (invtable[n])
        return invtable[n];
    return invtable[n] = power(n, MOD - 2);
}

int comb(int n, int r) {
    long long res = 1;
    for (int i = n - r + 1; i <= n; i++)
        res = (res * i) % MOD;
    for (int i = 1; i <= r; i++)
        res = (res * getinv(i)) % MOD;

    return res;
}
      

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = power(2, n) - 1;

    ans = (ans + MOD - comb(n, a)) % MOD;
    ans = (ans + MOD - comb(n, b)) % MOD;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int mod=10e8+7;

 int getmax(int n, int ar[], int k)
{
  
     int i,j;
    vector< int>dp(n,INT_MAX);
    dp[0]=0;
     for(i=0;i<n;i++)
     {
         for(j=i+1;j<=i+k;j++)
         {if(j<n)
         dp[j]=min(dp[j],dp[i]+abs(ar[j]-ar[i]));
     }}

  
    return dp[n-1];

    

}
int main()
{
     int n,k;
    
    
   
        cin>>n>>k;
         int ar[n];
        for( int i=0;i<n;i++)
        cin>>ar[i];
        cout<<getmax(n,ar,k)<<"\n";
    
}

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

void main()
{
  readln;
  const s = readln.chomp;
  if (s.length%2 == 0 && s[0..$/2] == s[$/2..$]) {
    "Yes".writeln;
    return;
  }
  "No".writeln;
}

Measured memory_bytes: 256
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
h_i = [int(x) for x in sys.stdin.readline().rstrip().split()]
ab = [list(map(int, sys.stdin.readline().rstrip().split())) for _ in range(M)]
 
J = [1 for i in range(N)]
#print(ab,J)

for li in ab:
  #print(li)
  if h_i[li[0]-1] < h_i[li[1]-1]:
    J[li[0]-1] = 0
  elif h_i[li[0]-1] == h_i[li[1]-1]:
    J[li[0]-1] = J[li[1]-1] = 0
  else:
    J[li[1]-1] = 0
print(J.count(1))

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n;
    string s;
    cin >> n >> s;
    deque<char> deque;

    int wait = 0;
    for (int i = 0; i < n; i++) {
        if (wait == 0) {
            if (s[i] == '(') {
                deque.push_back('(');
                wait += 1;
            } else {
                deque.push_front('(');
                deque.push_back(')');
            }
        } else {
            if (s[i] == '(') {
                deque.push_back('(');
                wait++;
            } else {
                deque.push_back(')');
                wait--;
            }
        }
    }
    rep(i, wait) { deque.push_back(')'); }
    string ans = "";
    for (auto c : deque) {
        ans.push_back(c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long temp = 0;
		if(N % (A + B) > A) {
			temp = A;
		} else {
			temp = N % (A + B);
		}
		System.out.println(A * (N / (A + B)) + temp);
	}
}


Measured memory_bytes: 23508
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
res = prime_factorize(n)
if len(res) == 1:
  print(1)
else:
  cnt = 0
  c = None
  p = 0
  l = set()
  for r in res:
    if c == r:
      p += 1
      if not p in l:
        l.add(p)
        p = 0
        cnt += 1
    else:
      l.clear()
      p = 0
      l.add(1)
      cnt += 1
      c = r
  print(cnt)

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

using namespace std;

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

int32_t main(){
	ld a, b, c;
	cin >> a >> b >> c;
	if (c > a + b + 2 * sqrt(a * b)){
		cout << "Yes";
	}else
		cout << "No";
}

Measured memory_bytes: 256
n = int(input())
def factorization(n): #素因数分解のプログラム([素因数,指数]のリストのリストで出力→24→[[2, 3], [3, 1]])
    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
            for _ in range(cnt):
                arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
ls = factorization(n)
mn = float("inf")
for i in range(2**len(ls)):
    a = 1
    for j in range(len(ls)):
        if (i>>j)&1:
            a *= ls[j]
    if a <= n**(1/2):
        b = int(n/a)
        m = max(len(str(a)),len(str(b)))
        if m < mn:
            mn = m
print(mn)

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

const long long N = 2e5 + 100, MOD = 1e9 + 7;

long long fac[N], inv[N];
long long n, m, k, ans;

long long sum(long long a, long long b) {
    return (a + b + MOD) % MOD;
}

long long mul(long long a, long long b) {
    return 1LL * a * b % MOD;
}

long long power(long long a, long long p) {
    long long res = 1;
    for (; p; p /= 2) {
	if (p % 2)
	    res = mul(res, a);
	a = mul(a, a);
    }
    return res;
}

long long C(long long k, long long n) {
    return 1LL * fac[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    fac[0] = 1;
    for (long long i = 1; i < N; i++)
	fac[i] = mul(fac[i - 1], i);
    for (long long i = 0; i < N; i++)
	inv[i] = power(fac[i], MOD - 2);
    cin >> n >> m >> k;
    long long dp[n + 10][m + 10] = {};
    for (long long i = 1; i <= m; i++)
	dp[1][i] = dp[1][i - 1] + i - 1;
    for (long long i = 2; i <= n; i++) {
	dp[i][1] = sum(sum(dp[i - 1][1], mul(i - 2, m)), m * (m + 1) / 2 % MOD);
	for (long long j = 2; j <= m; j++)
	    dp[i][j] = sum(dp[i][j - 1], sum(mul(j - 1, i), -mul(i - 1, m - j + 1)));
    }
    for (long long i = 1; i <= n; i++)
	for (long long j = 1; j <= m; j++)
	    ans = sum(ans, dp[i][j]);
    cout << mul(ans, C(k - 2, m * n - 2));
    return 0;
}


Measured memory_bytes: 20608
use std::cmp;

fn main(){
  loop {
    let pn: Vec<u32> = read_vec();
    let p = pn[0];
    
    if p == 0 { break; }
    
    let vnc:Vec<_> = pn.iter().skip(1).rev().collect();
  
    let vvc:[u32;6] = [500, 100, 50, 10, 5, 1];

    let mut ct: u32 = 20000;
    
    for tp in p .. p+500 {
      if let Some(tc) = pay(tp, &vvc, &vnc) {
        ct = cmp::min(ct,  tc + change(tp - p, &vvc));
      }
    }
    println!("{:?}", ct);
  }
}

fn change(p: u32, vvc: &[u32]) -> u32 {
  let mut ct: u32 = 0;
  let mut x: u32 = p;

  for vc in vvc.iter() {
    let q = x / vc;
    let r = x % vc;
    ct += q;
    x = r;
  }
  ct
}

fn pay(p: u32, vvc: &[u32], vnc: &Vec<&u32>) -> Option<u32> {
  let mut ct: u32 = 0;
  let mut x: u32 = p;

  for (vc, nc) in vvc.iter().zip(vnc.iter()) {
    let q = x / vc;
    ct += cmp::min(**nc, q);
    x -= cmp::min(**nc, q) * vc;
  }
  
  if x == 0 { Some(ct) } else { None }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5024
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(s: str, K: int):
    l = []
    for i in range(1, K+1):
        for j in range(len(s)):
            l.append(s[j:j+i])
    l = sorted(list(set(l)))
    print(l[K-1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7008
#include<stdio.h>
int main(){
    int d;
    scanf("%d",&d);
    if(d==22)
	printf("Christmas Eve Eve Eve\n");
    if(d==23)
	printf("Christmas Eve Eve\n");
    if(d==24)
	printf("Christmas Eve\n");
    if(d==25)
	printf("Christmas\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    else if (b == c ) cout << a << endl;
    else cout << b << endl;
}

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

int main(){
  int X,Y,Z;
  cin>>X>>Y>>Z;
  cout<<Z<<" "<<X<<" "<<Y<<endl;



}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

typedef pair<int,int> P;

int main() {
    int N; cin >> N;
    vector<P> time(N);
    REP(i,N){
        int a,b; cin >> a >> b;
        time[i] = {b,a};
    }
    sort(ALL(time));

    int now = 0;
    REP(i,N){
        now += time[i].second;
        if(now > time[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 4848
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // sqrt
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define _x first
#define _y second

struct line {
    pdd base;
    pdd inc;
};

double inner_prod(pdd p1, pdd p2) {
    return (p1._x * p2._x) + (p1._y * p2._y);
}

double norm(pdd p) {
    return sqrt((p._x * p._x) + (p._y * p._y));
}

pdd unit(pdd p) {
    double len = norm(p);
    return make_pair(
        p._x / len,
        p._y / len
    );
}

pdd get_incline(pdd p1, pdd p2) {
    pdd diff = make_pair(
        p2._x - p1._x,
        p2._y - p1._y
    );
    return unit(diff);
}

int main(void) {
    pdd p1;
    pdd p2;
    cin >> p1._x >> p1._y;
    cin >> p2._x >> p2._y;
    struct line lin = (struct line){p1,
        get_incline(p1, p2)
    };

    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        pdd p;
        cin >> p._x >> p._y;
        pdd inc = make_pair(
            p._x - lin.base._x,
            p._y - lin.base._y
        );
        // a \dot b
        double len = inner_prod(inc, lin.inc);
        // p1 + diff * lin.inc
        pdd ans = {
            lin.base._x + len * lin.inc._x,
            lin.base._y + len * lin.inc._y
        };
        printf("%.10lf %.10lf\n", ans._x, ans._y);
    }
    return 0;
}



Measured memory_bytes: 3280
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


signed main(){
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	map<int, int> a[2];
	for(int i = 0; i < n; ++i) {
		a[i % 2][v[i]]++;
	}
	vector<pair<int,int>> p[2];
	for(int k = 0; k < 2; ++k){
		EACH(i, a[k]) {
			p[k].push_back(make_pair(i->second, i->first));
		}
		sort(ALL(p[k]));
		reverse(ALL(p[k]));
	}
	int res = 0;
	if(p[0][0].second != p[1][0].second) {
		res = n - p[0][0].first - p[1][0].first;
	} else if(p[0].size() == 1 && p[1].size() == 1) {
		res = n/2;
	} else if(p[0].size() == 1 || p[1].size() == 1) {
		if(p[0].size() != 1) swap(p[0], p[1]);
		res = n - p[0][0].first - p[1][1].first;
	} else {
		res = n - max(p[0][0].first + p[1][1].first, p[0][1].first + p[1][0].first);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 0x1fffffffffffffff;

ll n,m,l;
void warshall_floyd(vector<vector<ll>>& cost){
  for(ll k = 0; k < n; k++) for(ll i = 0; i < n; i++) for(ll j = 0; j < n; j++) cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
}
int main(){
  cin >> n >> m >> l;
  vector<vector<ll>> cost(n, vector<ll>(n, INF));
  for(ll i = 0; i < m; i++){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    cost[a][b] = cost[b][a] = c;
  }
  warshall_floyd(cost);
  for(ll i = 0; i < n; i++) for(ll j = 0; j < n; j++) cost[i][j] = (cost[i][j] <= l ? 1 : INF);
  warshall_floyd(cost);
  for(ll i = 0; i < n; i++) for(ll j = 0; j < n; j++) if(cost[i][j] == INF) cost[i][j] = 0;
  ll q;
  cin >> q;
  for(ll i = 0; i < q; i++){
    ll s, t;
    cin >> s >> t;
    cout << cost[s - 1][t - 1] - 1 << endl;
  }
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll n = in();
    vector<pair<ll, ll>>v(n);
    REP(i, n) {
        ll a = in(), b = in();
        v[i] = make_pair(b, a);
    }
    sort(ALL(v));
    ll now = 0;
    REPC(p, v) {
        if ((now += p.second) > p.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 1001001001;
	sort(all(h));
	rep(i, n-k+1) {
		int now = h[i+k-1] - h[i];
		ans = min(now, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(raw_input())
A = map(int, raw_input().split())

c = [0, 0, 0]
for a in A:
    if a % 4 == 0:
        c[2] += 1
    elif a % 2 == 0:
        c[1] += 1
    else:
        c[0] += 1
if c[2] >= c[0]:
    print "Yes"
elif c[2] == c[0] - 1  and c[1] == 0:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 11296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,b,r,total;
  cin>>n>>b>>r;
  if(n%(b+r)>=b)
  total=((n/(b+r))*b)+b;
  else total=((n/(b+r))*b)+(n%(b+r));
  cout<<total;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
ll a1[100005],b1[100005],c1[100005];
bool cmp(ll a,ll b){
	return a>b;
}
int main()
{
	int x,y,a,b,c;
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	rep(i,1,a)scl(a1[i]);
	rep(i,1,b)scl(b1[i]);
	rep(i,1,c)scl(c1[i]);
	sort(a1+1,a1+a+1,cmp);
	sort(b1+1,b1+b+1,cmp);
	sort(c1+1,c1+c+1,cmp);
	c1[c+1]=0;
	int bega=1,begb=1,begc=1;
	ll cout=0;
	while(x+y>=begc){
		if(x>0&&y>0){
			if(c1[begc]>a1[bega]&&c1[begc]>b1[begb]){
				cout+=c1[begc++];
			}else if(a1[bega]>=b1[begb]){
				cout+=a1[bega++];x--;
			}else {
				cout+=b1[begb++];y--;
			}
		}else if(x>0){
			if(c1[begc]>a1[bega]){
				cout+=c1[begc++];
			}else {
				cout+=a1[bega++];x--;
			}
		}else {
			if(c1[begc]>b1[begb]){
				cout+=c1[begc++];
			}else {
				cout+=b1[begb++];y--;
			}
		} 
	}pf("%lld\n",cout);
}


Measured memory_bytes: 2688
a, b = map(int, input().split())
c = [13,1,2,3,4,5,6,7,8,9,10,11,12]

if c[a-1] > c[b-1]:
    print('Alice')
elif c[a-1] < c[b-1]:
    print('Bob')
else:
    print('Draw')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    string s; cin >> s;
    int ans = 0;
    for(size_t i=0; i<s.size(); ++i) {
        if(s[i] == '+') ++ans;
        else --ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = INF;
    for (int i = 0; i + 2 != s.length(); ++i) {
        int a = stoi(s.substr(i, 3));
        if (abs(a - 753) < abs(ans - 753)) ans = a;
    }
    cout << abs(ans - 753) << endl;
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    var L1 = input[0].split(' ')
    var N = parseInt(L1[0], 10)
    var M = parseInt(L1[1], 10)
    if (N >= M) {
        console.log(0)
        return;
    }
    var L2 = input[1].split(" ");
    var list = []
    for (var i = 0; i < M; i++) {
        var l = parseInt(L2[i], 10)
        list.push(l)
    }
    list.sort((a, b) => a - b);
    var list2 = []
    for (var i = 0; i < M; i++) {
        if (i !== 0) {

            list2.push(list[i] - list[i - 1])
        }

    }

    var ans = list2.sort((a, b) => a - b).slice(0, M - N).reduce((prev, current) => prev + current)
    console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27540
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
int main(){
	string s;
	cin>>s;
	int a=0;
	for(int i=0;i<s.size();i++){
		a+=(s[i]-'0');
		a%=9;
	}
	if(a==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3524