akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, a[SIZE];
  
  scanf("%d", &n);

  for(int i=0;i<n;i++){
    scanf("%d", a+i);
  }

  int r = 0;
  ll curSum = 0, curXor = 0;
  ll ans = 0;
  for(int i=0;i<n;i++){
    while(r < n && curSum + a[r] == (curXor ^ a[r])){
      curSum += a[r];
      curXor ^= a[r];
      r++;
    }
    
    ans += (ll)(r-i);
    curSum -= a[i];
    curXor ^= a[i];
  }

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



Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int n, a;
    cin >> n >> a;
    cout << (n*n) - a;
    
    cout << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;
using PIC = pair<int32, char>;

int main(void){
	int32 T;
	cin >> T;
	REP(_, T){
		int32 N, A;
		cin >> N >> A;
		int64 res = 127*(N-1);
		if(N%2){
			cout << res+A << endl;
		}else{
			cout << res+(A^127) << endl;
		}
	}
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

first = [0] * (N + 1)
second = [0] * (N + 1)
roop1 = []
roop2 = []

now = 1
while True:
    if not first[now]:
        first[now] = 1
        roop1.append(now)
        now = A[now]
    elif not second[now]:
        second[now] = 1
        roop2.append(now)
        now = A[now]
    else:
        break


if K < len(roop1):
    print(roop1[K])
else:
    K -= len(roop1)
    m = K % len(roop2)
    print(roop2[m])

Measured memory_bytes: 32384
#include<stdio.h>

 int main(){
 int a,b,c,d;
 
 scanf("%d %d %d",&a,&b,&c);

 if(a > b){
 d=a;
 a=b;
 b=d;
}if(b > c){
    d = c;
    c = b;
    b = d;
}if(a > b){
 d=a;
 a=b;
 b=d;
}

 printf("%d %d %d\n",a ,b ,c);
 return 0;
}


Measured memory_bytes: 2028
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct coordinate{
  int x;
  int y;
};

int n,m,dir;
struct coordinate walk(int d,int num,int n,int m,struct coordinate p);

int main(void){
  int i,j,go;
  char order[16];
  struct coordinate point;
  while(scanf("%d %d",&m,&n)&&(n!=0||m!=0)){
    point.x=point.y=1;
    dir=0;
    while(scanf("%s",order)&&order[0]!='S'){
      scanf("%d",&go);
      if(order[0]=='B'){
	dir=(dir+2)%4;
	point=walk(dir,go,n,m,point);
	dir=(dir+2)%4;
      }else if(order[0]=='F') point=walk(dir,go,n,m,point);
      else if(order[0]=='R') dir=(dir+1)%4;
      else if(order[0]=='L') dir=(dir+3)%4;
    }
    printf("%d %d\n",point.x,point.y);
  }
  return 0;
}

struct coordinate walk(int d,int num,int n,int m,struct coordinate p){
  switch(d){
  case 0:
    p.y+=num;
    break;
  case 1:
    p.x+=num;
    break;
  case 2:
    p.y-=num;
    break;
  case 3:
    p.x-=num;
    break;
  }
  if(p.x>m) p.x=m;
  else if(p.x<1) p.x=1;
  if(p.y>n) p.y=n;
  else if(p.y<1) p.y=1;
  return p;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long long ll;

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

	int n, k;

	cin>>n>>k;

	ll res = (ll) (n / k);
	ll ans = 0;

	ans += res;
	ans += ((res * (res - 1)) / 2) * 6;
	ans += ((res * (res - 1) * (res - 2)) / 6) * 6;

	if(k % 2 == 0){
		res = n / (k / 2) - res;
		ans += res;
		ans += ((res * (res - 1)) / 2) * 6;
		ans += ((res * (res - 1) * (res - 2)) / 6) * 6;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
a = list(str(input()))
counter = 0
if len(a) == 1:
    counter = 0
else:
    for i in range(1,len(a)):
        if a[i] == a[i-1]:
            if a[i-1] == '0':
                a[i] = '1'
            else:
                a[i] = '0'     
            counter = counter + 1
print(counter) 

Measured memory_bytes: 3956
int main(void)
{
	int S;
	int h;
	int m;
	int s;
	int a;
	scanf("%d",&S);
	h=S/3600;
	a=S%3600;
	m=a/60;
	s=a%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let S: Vec<Vec<char>> = (0..H).map(|_| {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    }).collect();

    let mut c = std::collections::HashMap::new();
    for i in 0..H { for j in 0..W { *(c.entry(S[i][j]).or_insert(0)) += 1; } }
    let mut dp = vec![0, 0, 0, 0];
    for (_, &v) in &c { dp[v % 4] += 1; }

    let ans = if (H % 2 == 0 && W % 2 == 0 && dp[1] == 0 && dp[2] == 0 && dp[3] == 0) ||
        (H % 2 == 0 && W % 2 == 1 && dp[1] == 0 && dp[3] == 0 && dp[2] <= H / 2) ||
        (H % 2 == 1 && W % 2 == 0 && dp[1] == 0 && dp[3] == 0 && dp[2] <= W / 2) ||
        (H % 2 == 1 && W % 2 == 1 && dp[1] + dp[3] <= 1 && dp[2] + dp[3] <= H / 2 + W / 2) { "Yes" }
        else { "No" };

    println!("{}", ans);
}

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


int main(){
    int N;
  cin >>N;
  int countA=0;
  int countB=0;
  int ans=0;
  int A;
  int c;
for(int a=1;a<10;a++){
for(int b=a;b<10;b++){

  if(a==b){if(a<=N){countA=countA+1;countB=countB+1;c=1;}}
  else{c=2;}
           
  if(10*a+b<=N){countA=countA+1;}
   if(10*b+a<=N){countB=countB+1;}
  
  if(100*a+b<=N){
    A=(N-(100*a+b))/10;
    if(A>9)A=9;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countA=countA+A;}
     if(100*b+a<=N){
    A=(N-(100*b+a))/10;
    if(A>9)A=9;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countB=countB+A;}
    
   if(1000*a+b<=N){
    A=(N-(1000*a+b))/10;
    if(A>99)A=99;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countA=countA+A;}   
              if(1000*b+a<=N){
    A=(N-(1000*b+a))/10;
    if(A>99)A=99;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countB=countB+A;} 

       if(10000*a+b<=N){
    A=(N-(10000*a+b))/10;
    if(A>999)A=999;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countA=countA+A;}  
                  if(10000*b+a<=N){
    A=(N-(10000*b+a))/10;
    if(A>999)A=999;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countB=countB+A;}  
 
           if(100000*a+b<=N){
    A=(N-(100000*a+b))/10;
    if(A>9999)A=9999;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countA=countA+A;}      
                      if(100000*b+a<=N){
    A=(N-(100000*b+a))/10;
    if(A>9999)A=9999;
    if(A>=0)A=A+1;
    if(A<0)A=0;
    countB=countB+A;}    
           
           

  ans=ans+countA*countB*c;
//cout<<countA<<countB<<c<<"("<<a<<","<<b<<")"<<",";
  countA=0;
  countB=0;
  
}  
}
  
  
  
 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++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B;
    cin>>A>>B;

    cout << A*B/__gcd(A,B)<<endl;

    



}


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

int main(){
    int n; cin >> n;
    vector<int> a(n), ans(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans[0] += ((i%2) ? -a[i] : a[i]);
    }
    cout << ans[0];
    for(int i = 1; i < n; i++){
        ans[i] = 2 * a[i-1] - ans[i-1];
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (n % 2) {
    cout << "No" << endl;
    return 0;
  }
  string s;
  cin >> s;
  for (int i = 0; i < n / 2; i++) {
    if (s.at(i) != s.at(i + n / 2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
n = int(input())
li_h = list(map(int, input().split()))
sum_ = 0
if len(li_h) == 1:
  print('Yes')
else:
  b = True
  max_ = li_h[0]
  for i in range(len(li_h)):
    if li_h[i] > max_:
      max_ = li_h[i]
    if max_ - li_h[i] > 1:
      b = False
  if b:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,x;
signed main()
{
	cin>>n>>m;
	int ans=1,xu=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		xu+=x;
		if(xu>m)break;
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int ary[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		System.out.println(ary[sc.nextInt() - 1]);
	}
}


Measured memory_bytes: 23632
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int l = scn.nextInt();
		String[] s = new String[n];
		for(int i=0; i<n; i++){
			s[i] = scn.next();
		}
      	Arrays.sort(s);
      	for(int i=0; i<n; i++) System.out.print(s[i]);
	}
}

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

using namespace std;

#define int long long

const int maxn = 1e5 + 10;
const int inf = 1e13;

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

    int n, w;
    cin >> n >> w;
    vector<int> ww(n), v(n);
    for (int i = 0; i < n; i++) {
        cin >> ww[i] >> v[i];
    }
    vector<int> dp(maxn, inf);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = maxn - 1; j >= v[i]; j--) {
            if (j == v[i] || dp[j - v[i]]) dp[j] = min(dp[j], dp[j - v[i]] + ww[i]);
        }
    }
    int ans = 0;
    for (int i = 0; i < maxn; i++) {
        if (dp[i] > 0 && dp[i] <= w) ans = i;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m;
  scanf("%lld%lld", &n, &m);
  ll p[n], dp[n];
  for(i = 0; i < n; ++i) p[i] = i, dp[n] = 0;
  for(k = 0; k < m; ++k) {
    ll l, r, d, rl = 0, rr = 0, dr = 0, dl = 0;
    scanf("%lld%lld%lld", &l, &r, &d);
    l--, r--;
    while(p[l] != l) rl++, dl += dp[l], l = p[l];
    while(p[r] != r) rr++, dr += dp[r], r = p[r];
    if(l != r) {
      if(rl > rr) {
        p[r] = l;
        dp[r] = dl - d - dr;
      } else {
        p[l] = r;
        dp[l] = dr - dl + d;
      }
    } else {
      if(-dr + dl != d) {
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 1664
#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>

using namespace std;

int main() {
    int n;
    cin >> n;
    bool alleven = true;;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2)
            alleven = false;
    }
    cout << (alleven ? "second" : "first") << endl;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char str[1024],*p;
	int n;
	
	scanf("%d", &n);
	getchar();
	while(n--)
	{
		fgets(str,1024,stdin);
		p = str;
		for(;;)
		{
			p = strstr(p,"Hoshino");
			if(!p)
				break;
			p[6] = 'a';
			p += 7;
		}
		printf("%s", str);
	}
	return 0;
}

Measured memory_bytes: 0
from functools import reduce
from fractions import gcd
from collections import defaultdict,Counter
import copy

n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7

dic = defaultdict(int)

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

for i in a:
    c = Counter(prime_factorize(i))
    for j,k in c.items():
        if dic[j] < k:
            dic[j] = k

l = 1

for i,j in dic.items():
    l *= pow(i,j,mod)
    l %= mod

point = 0

for i in a:
    point += l*pow(i,mod-2,mod)
    point %= mod

print(point%mod)

Measured memory_bytes: 6588
#include<stdio.h>
int main(){
    int r0,w0,c,r,x,y,i,a,y1,c0;
    a=0;
    for(;;){
    scanf("%d%d%d%d", &r0,&w0,&c,&r);

    if((r0<=0 || 100<r0) && (w0<=0 || 100<w0) && (c<=0 || 100<c) && (r<=0 || 100<r))return 0;

    if(r0/w0 >= c){
        x = 0;
    }else{
        y=w0*c;
        y1=y-r0;
        for(x=0;;){
            a=r*x;
            if(a>=y1)break;
            x++;
        }
    }
    printf("%d\n",x);
    }
return 0;
}


Measured memory_bytes: 2048
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int w,h;
int main()
{
  while(cin>>w>>h,w||h){
    unsigned int dp[101][101][2];//0で横向き1で縦向き
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= 100; i++){
      dp[i][1][0] = dp[1][i][0] = dp[i][1][1] = dp[1][i][1] = 1;
    }
    for(int i = 2; i <=h;i++){
      for(int j = 2;j <=w;j++){
        dp[i][j][0] =(dp[i][j-1][0]+dp[i-2][j][1])%100000;
	dp[i][j][1] =(dp[i-1][j][1]+dp[i][j-2][0])%100000;
      }
    }
    cout <<(dp[h][w-1][0]+dp[h-1][w][1])%100000<<endl;
  }
  return 0;
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        vector<_i64> mountain(10);
        _foreach(e, mountain) { cin >> e; }
        sort(_all(mountain), greater<_i64>());
        _rep(i, 3) { cout << mountain[i] << endl; }
    }
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100;
static const int INF=(1<<21);
static const int WHI=0;
static const int GRA=1;
static const int BLA=2;
int n,M[MAX][MAX];
int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=WHI;
  }
  d[0]=0;
  while(1){
    minv=INF;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLA){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLA; //ここで訪問に記録
    for(int v=0;v<n;v++){
      if(color[v]!=BLA&&M[u][v]!=INF){
	if(M[u][v]<d[v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRA;
	}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      cin>>e;
      if(e==-1){
	M[i][j]=INF;
      }else{
	M[i][j]=e;
      }
    }
  }
  cout<<prim()<<endl;
  return(0);
}



Measured memory_bytes: 3128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");
var N1 = Number(Arr[0])
var arr1 = Arr[1].split(" ").map(Number);
var arr2 = Arr[3].split(" ").map(Number);

const linearSearch = (key, arr) => {
  let i = 0
  arr[N1] = key;
  while (true) {
      if (arr[i] === key) break;
      i++;
  }
  return i !== N1 ? 1 : 0;
}
console.log(arr2.map(e => linearSearch(e, arr1)).reduce((a, b) => a + b, 0));



Measured memory_bytes: 17808
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  using Pos = pair<int, int>;
  vector<Pos> p(4);
  for(size_t i = 0; i < 2; ++i) cin >> p[i].first >> p[i].second;
  
  for(size_t i = 2; i < 4; ++i)
  {
    auto dx = p[i - 1].first - p[i - 2].first;
    auto dy = p[i - 1].second - p[i - 2].second;
    p[i].first = p[i - 1].first + (0 - 1*dy);
    p[i].second = p[i - 1].second + (1*dx + 0);
  }
  cout << p[2] << SPACE << p[3];
  return;
}

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

  solve();

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  int s=0;
  for(int i=0;i<n;i++){
    cin >> x.at(i);
    s+=x.at(i);
  }
  int a;
  if((s%n)*2>=n){
    a=(s/n)+1;
  }else{
    a=s/n;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=(x.at(i)-a)*(x.at(i)-a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int64, int64> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int64 n, x, d;
  scanf("%lld%lld%lld", &n, &x, &d);
  if (d == 0) {
    printf("%lld\n", x == 0 ? 1 : n + 1);
    return 0;
  }
  map<int, vector<ii>> a;
  d *= 2;
  for (int64 k = 0; k <= n; ++k) {
    int64 L = (2 * k - n) * x + k * (k - 1) / 2 * d;
    int64 R = (2 * k - n) * x + (k * n - k * (k + 1) / 2) * d;
    if (L > R) swap(L, R);
    // L += d * n * (n - 1) / 2;
    // R += d * n * (n - 1) / 2;
    // trace(L, R);
    int r = L % abs(d);
    if (r < 0) r += abs(d);
    a[r].emplace_back(L, R);
  }
  d = abs(d);
  int64 ret = 0;
  vector<ii> B;
  for (auto& it : a) {
    auto& A = it.second;
    // for (auto& it : A) {
    //   trace(it.first, it.second);
    // }
    // cout << "===" << endl;
    B.clear();
    for (auto& it : A) {
      B.emplace_back(it.first, -1);
      B.emplace_back(it.second, 1);
    }
    sort(B.begin(), B.end());
    int cnt = 0;
    for (int i = 0; i < B.size(); ++i) {
      // trace(B[i].first, B[i].second);
      if (cnt < 0) {
        ret += (B[i].first - B[i - 1].first) / d;
      } else if (cnt == 0) {
        ret += 1;
      }
      cnt += B[i].second;
    }

  }
  printf("%lld\n", ret);
  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        String w;
        int list[] = new int[26];

        w = sc.nextLine();
        
        for (int i = 0; i < w.length(); i++) {
            //char a=97 b=122
            list[w.charAt(i) - 97]++;
        }

        for (int i = 0; i < 26; i++) {
            if(list[i]%2 != 0) {
                out.println("No");

                sc.close();
                return;
            }
        }

        out.println("Yes");
        sc.close();
    }
}

Measured memory_bytes: 23632
import itertools
import copy
H, W, K = map(int, input().split())

tbl = [[0 for i in range(W)] for j in range(H)]
for h in range(H):
    row = input()
    # print(row)
    for i, w in enumerate(row):
        # print(w)
        if w == '.':
            tbl[h][i] = 0
        else:
            tbl[h][i] = 1

# 縦の組み合わせ
hc_list = []
for i in range(H):
    ht = list(itertools.combinations(range(H), i))
    for hc in ht:
        hc_list.append(hc)
# print(hc_list)
# 横の組み合わせ
wc_list = []
for i in range(W):
    wt = list(itertools.combinations(range(W), i))
    for wc in wt:
        wc_list.append(wc)
# print(wc_list)
# 縦横の組み合わせで数字を求める

def count_tbl(tbl):
    cnt = 0
    for t in tbl:
        cnt += sum(t)
    return cnt

# print(count_tbl(tbl))
res = 0
for ht in hc_list:
    thc = copy.deepcopy(tbl)
    for i in ht:
        for j in range(W):
            thc[i][j] = 0
    # print('thc', thc)
    for wt in wc_list:
        # print(wt)
        hwc = copy.deepcopy(thc)
        for k in wt:
            for l in range(H):
                hwc[l][k] = 0
        # print(hwc)
        if count_tbl(hwc) == K:
            # print(hwc)
            res += 1
print(res)

Measured memory_bytes: 9304
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()

using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int fibonacci(int n){
    double phi = (1LL + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}

signed main(){

    fastIO

    int n , k;
    cin >> n >> k;
    int c =0 ;
    while(n > 0){
        n /= k;
        c++;
    }
    cout << c;

    return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
    ll n, m; cin >> n >> m;
    static vector<ll> x(n), y(m);
    for(int i = 0; i < n; ++i){cin >> x[i];}
    for(int i = 0; i < m; ++i){cin >> y[i];}
    
    ll w = 0, h =0;
    for(int i = 0; i < n-1; ++i){
    	ll nx = (n-1-i)*(i+1) % MOD;
        w += (x[i+1]-x[i]) * nx % MOD;
        w %= MOD;
    }
    w %= MOD;
    for(int i = 0; i < m-1; ++i){
    	ll ny = (m-1-i)*(i+1) % MOD;
        h += (y[i+1]-y[i]) * ny % MOD;
        h %= MOD;
    }
    h %= MOD;
    
    ll ans = w * h % MOD;
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for (int i=0; i<N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
typedef long long ll;
int main()
{
	int num;
	ll a, b, c, d;
	scanf("%d%lld%lld%lld%lld", &num, &a, &b, &c, &d);
	num--;
	for (int i = 0; i <= num; i++)
	{
		if (a + c*i - d*(num - i) <= b&&b <= a + d*i - c*(num - i))
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

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

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int A, B;
  cin >> A >> B;
  if(A < 10 && B < 10) {
    cout << A*B << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
#define lowbit(x) x&-x
int c[N*10];
int n,a[N],s[N*10];
void add(int x){
	for(int i=x;i<=2*N;i+=lowbit(i))c[i]++;
}
ll query(int x){
	ll sum=0;
	for(int i=x;i>0;i-=lowbit(i))sum+=c[i];
	return sum;
}
bool check(int x){
	for(int i=1;i<=2*N;i++)c[i]=0;
	s[0]=0;
	for(int i=1;i<=n;i++)
		s[i]=s[i-1]+(a[i]>=x?1:-1);
	ll sum=0;
	for(int i=0;i<=n;i++){
		sum+=query(s[i]+N);
		add(s[i]+N);
	}
	return sum>=1ll*n*(n+1)/4;
}
int main(){
	in1(n);
	int l=0,r=0;
	for(int i=1;i<=n;i++){
		in1(a[i]);
		r=max(r,a[i]);
	}
	int ans=0;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
}

Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	if( (s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]) ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=1e6+5;
const int inf=1e7;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int h, w, l;
vector< string > str;
vector< vector<pair<int,int>> > dis[5];

struct info{
     int x, y, dir, d, cnt;
     bool operator<(const info& s) const{
          return !(d<s.d || (d==s.d && cnt<s.cnt));
     }
};

bool valid(int x, int y){ return x>=0 && x<h && y>=0 && y<w; }

int dijkstra(int x1, int y1, int x2, int y2){
     int i, j, k;
     priority_queue< info > pq;
     for(i=0; i<4; ++i) dis[i][x1][y1]={0,0};
     info s;
     s.x=x1, s.y=y1, s.dir=0, s.d=0, s.cnt=0;
     pq.push(s);
     while(!pq.empty()){
          s=pq.top(); pq.pop();
          if(s.x==x2 && s.y==y2) return s.d+(s.cnt!=0);
          for(i=0; i<4; ++i){
               int tx=s.x+dx[i], ty=s.y+dy[i];
               //double cur_dis=1.0/double(l)+(s.dir==i?s.d:ceil(s.d));
               int cur_d=s.d+(s.dir==i?0:(s.cnt!=0));
               int cur_cnt=(s.dir==i)?s.cnt+1:1;
               if(cur_cnt>=l) cur_d++, cur_cnt-=l;
               if(valid(tx, ty) && str[tx][ty]!='@' && (dis[i][tx][ty].first>cur_d  || (dis[i][tx][ty].first==cur_d && dis[i][tx][ty].second>cur_cnt))){
                    dis[i][tx][ty]={cur_d, cur_cnt};
                    info ts;
                    ts.x=tx, ts.y=ty, ts.d=cur_d, ts.cnt=cur_cnt, ts.dir=i;
                    pq.push(ts);
               }
          }
     }
     return -1;
}

int main(){
     int i, j, k;
     int x1, y1, x2, y2;
     cin >> h >> w >> l;
     cin >> x1 >> y1 >> x2 >> y2;
     x1--, y1--, x2--, y2--;
     str.resize(h);
     for(i=0; i<4; ++i) dis[i].resize(h, vector<pair<int,int>>(w, make_pair(inf, inf)));
     for(i=0; i<h; ++i) cin >> str[i];
     cout << dijkstra(x1, y1, x2, y2) << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> x(n), y(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        for (int j = 0; j < a.at(i); j++) {
            int xi, yi;
            cin >> xi >> yi;
            xi--;
            x.at(i).push_back(xi);
            y.at(i).push_back(yi);
        }
    }

    int maxi = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        bool ok = true;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            //正直者だったら
            if (bit & (1 << i)) {
                cnt++;

                for (int j = 0; j < a.at(i); j++) {
                    int xi = (bit & (1 << x.at(i).at(j)) ? 1 : 0);

                    if (xi != y.at(i).at(j)) {
                        ok = false;
                        break;
                    }
                }
            }
        }

        if (ok) maxi = max(maxi, cnt);
    }
    cout << maxi << endl;
}

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

int main() {
    int K, N;
    cin >> K >> N;

    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }

    int dis = A.at(0);

    for (int i = 1; i < N; i++){
        if ((A.at(i) - A.at(i - 1)) > dis){
            dis = A.at(i) - A.at(i - 1);
        }
    }

    if (A.at(0) + (K - A.at(N - 1)) > dis){
        dis = A.at(0) + K - A.at(N - 1);
    }

    cout << K - dis << endl;

    
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdint.h>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  uint32_t N;
  cin >> N;
  
  vector<uint32_t> A;
  A.reserve(N);
  
  for (uint32_t n = 0; n < N; ++n) {
    uint32_t a;
    cin >> a;
    A.push_back(a);
  }

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

  uint32_t max = A.back();
  double true_half = max/2.;
  
  auto itr_half = lower_bound(A.begin(), A.end()-2, true_half);

  uint32_t half;
  
  if (itr_half == A.end()-2)
    half = *itr_half;
  else {
    uint32_t half1 = *(itr_half-1), half2 = *(itr_half);
    half = (((double)half2 - true_half) > (true_half - (double)half1)) ? half1 : half2;
  }
  
  cout << max << ' ' << half << endl;
  
  return 0;
}

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
    return 0;
}


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

int main(){
  int a;
  cin >> a;
  if(a == 25){
    cout << "Christmas" << endl;
  }else if(a == 24){
    cout << "Christmas Eve" << endl;
  }else if(a == 23){
 cout << "Christmas Eve Eve" << endl;
  }else{
 cout << "Christmas Eve Eve Eve" << endl;
  }



}


Measured memory_bytes: 256
def input_int():
    return(int(input()))

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

def input_int_map():
    return(map(int,input().split()))

import heapq

def run():
    n, ticket_count = input_int_map()

    nums = input_int_list()


    nums = list(map(lambda x: x * (-1), nums))  # 各要素を-1倍

    heapq.heapify(nums)



    for _ in range(ticket_count):
        num = (heapq.heappop(nums) * (-1))

        num = num // 2

        heapq.heappush(nums, num * (-1))

    nums = list(map(lambda x: x * (-1), nums))
    print(sum(nums))

run()

# 2 4 3

# 3 4 3

# 2 6 3

















Measured memory_bytes: 85096
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  int x = stoi(a+b);
  (sqrt(x)-floor(sqrt(x)) == 0) ? cout << "Yes" << endl : cout << "No" << endl;
  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);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (n - m < 0) {
            System.out.println(0);
        } else {
            System.out.println(n - m);
        }
    }
}


Measured memory_bytes: 20564
#include<stdio.h>
#include <math.h>
#define true 1
#define false -1

int isprime(int num){
  int i;
  int n=sqrt(num);
  if(num<0)return false;
  if(num==2)return true;
  if(num%2==0)return false;

  for(i=3;i<=n;i+=2){
    if(num%i==0)return false;
  }
  return true;
}
int main(){
  int i,n,num,cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num);
    if(isprime(num)==true)
      cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2104
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    count = [0 for _ in range(N)]

    for i in A:
        count[i-1] += 1

    cmb = 0

    for i in range(N):
        M = count[i]
        cmb += M * (M-1) // 2

    for i in A:
        s = count[i-1]
        if s <= 1:
            dec = 0
        else:
            dec = s - 1
        temp = cmb - dec
        print(temp)



main()


Measured memory_bytes: 24988
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Numerics;

class Program {
    static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        int n = TOI(input[0]);
        int k = TOI(input[1]);
        int[] p = new int[n];
        for(int i=0;i<n;i++) {
            p[i] = TOI(input2[i]);
        }
        Array.Sort(p);

        int result = 0;
        for(int i=0;i<k;i++) {
            result += p[i];
        }

        CWL(result);
    }

    public static List<int> PrimeFactors (int n) {
        var tmpList = new List<int>();
        int i = 2;
        int tmp = n;

        while(i * i <= n) {
            if(tmp % i == 0) {
                tmp /= i;
                tmpList.Add(i);
            } else {
                i++;
            }
        }

        if(tmp != 1) tmpList.Add(tmp);

        return tmpList;
    }

    static string[] INP () {
        return Console.ReadLine().Split(' ');
    }

    static void CWL (string value) {
        Console.WriteLine(value);
    }

    static void CWL (int value) {
        Console.WriteLine(value);
    }

    static void CWL (long value) {
        Console.WriteLine(value);
    }

    static void CWL (float value) {
        Console.WriteLine(value);
    }

    static void CWL (double value) {
        Console.WriteLine(value);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }

    /*static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        var input3 = INP();

        CWL("dummy");
    }*/
}

Measured memory_bytes: 27584
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
      let s1 = sub s 0 i in
      doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)
  in doit str []

let read_ints () = List.map int_of_string (split (read_line ()) ' ')

let dfs g n =
  let v = Array.make n (-1) in
  let rec doit i =
    if i < n then (if v.(i) = (-1) then dudu i i; doit (i + 1))
  and dudu i j =
    v.(i) <- j;
    wa j g.(i)
  and wa j = function
    | [] -> ()
    | hd :: tl when v.(hd) = (-1) -> (dudu hd j; wa j tl)
    | _ :: tl -> wa j tl
  in doit 0;
  v

let solve n m =
  let g = Array.make n [] in
  let rec read i =
    if i < m then
      begin match read_ints () with
      | [s;t] ->
        g.(s) <- t :: g.(s);
        g.(t) <- s :: g.(t);
        read (i + 1)
      | _ -> exit 1
      end in
  read 0;
  let v = dfs g n in
  let q = read_int () in
  let rec read_q i =
    if i < q then
      begin match read_ints () with
      | [s;t] ->
        print_endline (if v.(s) = v.(t) then "yes" else "no");
        read_q (i + 1)
      | _ -> exit 1
      end in
  read_q 0

let () =
  match read_ints () with
  | [n;m] -> solve n m
  | _ -> exit 1

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

int main(void) {
	int a, b, c, i, count = 0;
	cin >> a >> b >> c;
	for (i = a; i <= b; i++) {
		if (c % i == 0)
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1164
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=int) #0~Wまでのリストを作る
for i in range(N):
  w, v = map(int, input().split())
  dp[w:] = np.maximum(dp[:-w] + v, dp[w:])
print(dp[W])

Measured memory_bytes: 17824
#include <stdio.h>

using namespace std;

int calcMax(int a,int b){
	int tmp;
	if(a > b){
		while(b != 0){
			tmp = b;
			b = a%b;
			a = tmp;
		}
		return a;
	}else{
		while(a != 0){
			tmp = a;
			a = b%a;
			b = tmp;
		}
		return b;
	}
}



int calcMin(int a,int b){
	int max_common = calcMax(a,b);
	return (a/max_common)*b;
}

int main(){
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		printf("%d %d\n",calcMax(a,b),calcMin(a,b));
	}

    return 0;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
 
using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int md = (int)1e9+7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
 
 
int gd(int n, int p){
	int rt =0, e =1;
	for(; e*p <=n; e*=p);
	for(;e>=1;e /=p){
		for(;e<=n && n>0;n -=e) rt++;
	}
	return rt;
}
 
int main(){
	int n;
	cin >>n;
	
	int ans = 1<<30;
	rep(i,n+1){
		int w = gd(i, 6) + gd(n-i, 9);
		ans = min(ans, w);
	}
	cout << ans <<"\n";
	
	return 0;
}

Measured memory_bytes: 256
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;
int main()
{
    int n;
    cin >> n;

    long long ans = 0;

    for (int i = 1; i <= n; i++) {

        if (i % 3 == 0 || i % 5 == 0) {
            continue;
        }
        else {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3632
n = int(input())
s = input()

def insertRecursively(string):
    for i in range(0, len(string)):
        part = string[0:i + 1]
        if 2 * part.count(')') > len(part):
            return insertRecursively('(' + string)
    if 2 * string.count('(') > len(string):
        return insertRecursively(string + ')')
    return string

print(insertRecursively(s))

Measured memory_bytes: 3060
main(){
  int i,j,s,p[5];
  scanf("%d %d %d %d %d",&p[0],&p[1],&p[2],&p[3],&p[4]);
  for(i=0;i<4;i++) {
    for(j=i+1;j<5;j++)
      if(p[i]<p[j]) {
        s=p[i];
        p[i]=p[j];
        p[j]=s;
      }
    printf("%d ",p[i]);
  }
  printf("%d\n",p[4]);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF{numeric_limits<int>::max()/3};
int N,M,ans;
pair<int,int> e[50];
int main(){
    cin>>N>>M;
    vector<vector<int>> v(N,vector<int>(N,INF));
    for(int i{};i<M;++i){
        int s,d;cin>>s>>d;
        --s,--d;
        e[i].first=s,e[i].second=d;
        v[s][d]=1;
        v[d][s]=1;
    }
    for(int i{};i<M;++i){
        int s{e[i].first},d{e[i].second};
        auto w=v;
        w[s][d]=w[d][s]=INF;
        for(int k{};k<N;++k)
            for(int j{};j<N;++j)
                for(int l{};l<N;++l)
                    w[j][l]=min(w[j][l],w[j][k]+w[k][l]);
        bool f{};
        for(int i{1};i<N;++i)
            if(w[0][i]>=INF){
                f=true;
                break;
            }
        if(f)ans++;
    }
    cout<<ans<<endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let s = Array.fold_left (+) 0 a_s
let ans, m = ref 0, ref max_int
let _ = Array.iteri (fun i a -> let d = abs @@ s - n * a in if d < !m then (ans := i; m := d)) a_s; Printf.printf "%d\n" !ans

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

typedef pair<int, int> Pii;

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

signed main(){

    string s;
    cin >> s;
    int K;
    cin >> K;
    
    vector<string> lis(0);

    REP(i, K){
        REP(j, s.size() - i){
            lis.push_back(s.substr(j, i + 1));
        }
    }

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

    int count = 1;
    int i = 1;
    string ans = lis[0];
    while(count < K){
        if(lis[i] != ans){
            count++;
            ans = lis[i];
        }
        i++;
    }

    cout << ans;

    return 0;
}

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

using namespace std;
map<int,  map<char, int> > q;
int main()
{
    string s, su;
    int n, i, len=59, j, cnt=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> s;
        for(j=0;j<s.size();j++) q[i][s[j]]++;
        if(s.size()<len)
        {
            su=s;
            len=su.size();
        }
    }
    sort(su.begin(), su.end());
    for(i=0;i<len;i++)
    {
        for(j=0;j<n;j++)
        {
            if(q[j][su[i]]) q[j][su[i]]-- ;
            else break;
        }
        if(j==n) printf("%c",su[i]);
    }
    cout<<endl;
}


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

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

Measured memory_bytes: 3592