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

using namespace std;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    int n;
    cin >> n;
    
    vector<int> vec(n);
    for (int i=0; i<n; i++)
    {
        cin >> vec[i];
    }
    
    sort(vec.begin(),vec.end());
    int num = vec[n/2]-vec[n/2-1];
    
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int sum(int i) {
    if (i == 0) return 1;
    else return (i+1)+sum(i-1);
}


int main()
{
    int a, b;
    cin>>a>>b;
    cout<<sum(b-a-2)-a<<endl;

  return 0;
}

Measured memory_bytes: 256
h,w,a,b = map(int,input().split())

if (2*b > h) or (2*a > w):
  print('No')

elif (a==0 and b==0):
  for hi in range(h):
    print('0'*w)    
    
elif a==0:
  for hi in range(h):
    if hi < b:
      print('1'*w)
    else:
      print('0'*w)

elif b==0:
  s = '1'*a + '0'*(w-a)
  for hi in range(h):
    print(s)  
    
else:
  s = '1'*a + '0'*(w-a)
  rs = ''.join(['0' if i=='1' else '1' for i in s])
  for hi in range(h):
    if hi < b:
      print(s)
    else:
      print(rs)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  bitset<101100> B;
  B.reset();
  B[0]=true;
  for(int i=0;i<100000;i++){
    B[i+100]=B[i+100]|B[i];
    B[i+101]=B[i+101]|B[i];
    B[i+102]=B[i+102]|B[i];
    B[i+103]=B[i+103]|B[i];
    B[i+104]=B[i+104]|B[i];
    B[i+105]=B[i+105]|B[i];
  }
  ll X;
  cin>>X;
  cout<<B[X]<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int c1,c5,c10,c50,c100,c500,a;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	a=c1+(c5*5)+(c10*10)+(c50*50)+(c100*100)+(c500*500);
	if(a<1000){
		printf("0\n");
	}
	else{
		printf("1\n");
	}
		
	return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
#define abs(x) (((x)<0)?(-1*(x)):(x))
#define TESTC lli TC; cin>>TC; while(TC--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;
typedef long long int lli;
typedef long int li;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int, int> pri;
typedef pair<long long int, long long int> prlli;

#include<iostream>
#include<math.h>
#include<limits>
using namespace std;

int main(){
	FASTIO;
    string s;
    cin>>s;
    bool f = false;
    for(int i = 2; i < 4; ++i){
        if(s[i] == s[i-1] && s[i-1] == s[i-2]){
            f = true;
        }
    }
    if(f != true){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }
	return 0;
}


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

int main() {

int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a<=c&&b>=d){cout<<d-c<<endl;}
  else if(c<=a&&d>=b){cout<<b-a<<endl;}
  else if(a<=c&&b>=c&&b<=d){cout<<b-c<<endl;}
  else if(c<=a&&d>=a&&d<=b){cout<<d-a<<endl;}
  else{cout<<0<<endl;}
  
}



Measured memory_bytes: 256
n,m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
l = 1
r = n
for i in range(m):
  l = max(l,s[i][0])
  r = min(r,s[i][1])
if r-l+1>0: print(r-l+1)
else: print(0)


Measured memory_bytes: 27336
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

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

  if((a*b)%2==0)cout << "No" << endl;
  else cout<<"Yes"<<endl;

  return 0;
}


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

int Harshad(int X) {
	int count = 0;
	while (1) {
		count += X % 10;
		X = (X - X % 10) / 10;
		if (X == 0)  break;
	}
	return count;
}

int main() {
	int N;
	cin >> N;
	if (N % Harshad(N) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        scanner.close();

        char[] c = input.toCharArray();

        if (c[2] == c[3] && c[4] == c[5]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

type item struct {
	v, w, d int
	t, s    string
}
type its []item

func (it its) Len() int {
	return len(it)
}
func (it its) Swap(i, j int) {
	it[i], it[j] = it[j], it[i]
}
func (it its) Less(i, j int) bool {
	if it[i].v < it[j].v {
		return true
	}
	if it[i].v == it[j].v && it[i].w < it[j].w {
		return true
	}
	if it[i].v == it[j].v && it[i].w == it[j].w && it[i].t < it[j].t {
		return true
	}
	if it[i].v == it[j].v && it[i].w == it[j].w && it[i].t == it[j].t &&
		it[i].d < it[j].d {
		return true
	}
	if it[i].v == it[j].v && it[i].w == it[j].w && it[i].t == it[j].t &&
		it[i].d == it[j].d && it[i].s < it[j].s {
		return true
	}
	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	n := nextInt(sc)
	items := make([]item, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		line := sc.Text()
		fmt.Sscanf(line, "%d %d %s %d %s",
			&items[i].v, &items[i].w, &items[i].t, &items[i].d, &items[i].s)
	}
	sort.Sort(its(items))
	wtr := bufio.NewWriter(os.Stdout)
	for i := range items {
		fmt.Fprintf(wtr, "%d %d %s %d %s\n", items[i].v, items[i].w, items[i].t, items[i].d, items[i].s)
	}
	wtr.Flush()
}



Measured memory_bytes: 17308
#include <stdio.h>
int main(void)
{
    
    int n;
    long a,max=-1000000,min=1000000,sum=0;
    
   scanf("%d",&n);
   
        for(int i=0;i<n;++i){
        scanf("%ld",&a);
        if(a>max) max=a;
        if(a<min) min=a;
        sum+=a;
    }
    
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  P p[n];
  rep(i,n) cin>>p[i].first>>p[i].second;
  sort(p, p + n);
  int ans = p[n-1].first + p[n-1].second;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
	long long x, y, n;
	while(cin >> x >> y){
		int count = 1;
		n = x;
		while(1){
			n *= 2;
			if(n > y) break;
			count++;
		}
		cout << count << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

K = int(input())
counter = 0

for i in range(K):
    for j in range(i, K):
        if (i % 2 == 0 and j % 2 != 0) or (i % 2 != 0 and j % 2 == 0):
            counter += 1

print (counter)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define N 100005
#define ll long long
using namespace std;
ll a[N],x,ans=0;
int n;
inline ll read(){
	ll ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int main(){
	n=read(),x=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=2;i<=n;++i){
		if(a[i-1]+a[i]<=x)continue;
		if(a[i-1]>=x)ans+=a[i-1]-x+a[i],a[i]=0;
		else ans+=a[i]-(x-a[i-1]),a[i]=(x-a[i-1]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

ll gcd(ll x,ll y)
{
    ll r;
    if(x < y){
        swap(x,y);
    }
    while(y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}


int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll g = a[0];
    ll m = a[0];
    for(int i = 0; i < n; i++){
        g = gcd(g,(ll)a[i]);
        if(m < a[i]){
            m = a[i];
        }
    }
    if(k % g == 0 && k <= m){
        cout << "POSSIBLE";
    }else{
        cout << "IMPOSSIBLE";
    }

}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
int N;
long long A[100010];
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
	}
	std::sort(A, A + N);
	int k = 0;
	int ans = 0;
	int tmp = 1;
	while (k < N) {
		if (A[k] == A[k + 1]) {
			tmp++;
		}
		else {
			if (tmp % 2 == 1) {
				ans++;
			}
			tmp=1;
		}
		k++;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'

int main() {
    int l, r;
    cin >> l >> r;
    if(r - l >= 2018){
        cout << 0 << endl;
        return 0;
    }
    int min = inf;
    REP(i, l, r){
        REP(j, i+1, r+1){
            int x = ((i % 2019) * (j % 2019)) % 2019;
            if(x < min) min = x;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const ld PI = (ld)acos(-1);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main() {
    ll N,A,B;cin>>N>>A>>B;
    if(abs(A-B)%2==0){
        cout<<abs(A-B)/2<<endl;return 0;
    }else{
        ll num=min(A-1,N-B);
        cout<<num+(abs(A-B)+1)/2<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    static void Main(string[] args){
        string s = Console.ReadLine();
        Dictionary<char, int> map = new Dictionary<char, int>();
        map['N'] = map['S'] = map['W'] = map['E'] = 0; 
        foreach(var e in s){
            map[e] = map[e] + 1;
        }
        bool b1 = (map['W']*map['E'] == 0 && (map['W']!=0 || map['E']!=0));
        bool b2 = (map['N']*map['S'] == 0 && (map['N']!=0 || map['S']!=0));
        if( b1 || b2){
            Console.WriteLine("No");
        } else {
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int x = 0;
        int y = 0;
        int z = 0;
        for(int i = 0; i < N; i++){
            int c = sc.nextInt();
            if(c <= A) x++;
            else if(c > A && c <= B) y++;
            else z++;
        }
        int ans = Math.min(x, Math.min(y, z));
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23252
def create_fact_mod(num_max)
    $fmod = Array.new(num_max + 1)
    $fmod[0] = 1
    $fmod[1] = 1
    (2..num_max).each do |i|
        $fmod[i] = ($fmod[i - 1] * i) % MOD
    end
end

def create_seq_inv_mod(num_max)
    $simod = Array.new(num_max + 1)
    $simod[0] = 1
    $simod[1] = 1
    (2..num_max).each do |i|
        $simod[i] = (MOD - MOD / i) * $simod[MOD % i] % MOD
    end
end

def create_fact_inv_mod(num_max)
    $fimod = Array.new(num_max + 1)
    $fimod[0] = 1
    $fimod[1] = 1
    (2..num_max).each do |i|
        $fimod[i] = ($fimod[i - 1] * $simod[i]) % MOD
    end
end

def create_mod_tables(n)
    create_fact_mod(n)
    create_seq_inv_mod(n)
    create_fact_inv_mod(n)
end

def comb_mod(n, k)
    return $fmod[n] * $fimod[n - k] * $fimod[k] % MOD
end

def perm_mod(n, k)
    return $fmod[n] * $fimod[n - k] % MOD
end

MOD = 10**9+7
N, K = gets.split.map(&:to_i)
create_mod_tables(2000)

if N == K
    puts 1, [0]*(K-1)
    exit
end

(1..K).each do |t|
    ans = 0
    if N-K >= t-1 && t > 1
        ans += comb_mod(N-K-1, t-2)
    end
    if N-K >= t+1
        ans += comb_mod(N-K-1, t)
    end
    if N-K >= t
        ans += comb_mod(N-K-1, t-1) * 2
    end
    ans = ans * comb_mod(K-1, t-1) % MOD
    puts ans
end

Measured memory_bytes: 1916
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector<int> a(4);
string s("+-*");

int f(int x, int y, int c) {
	switch (c) {
	case 0:
		return x + y;
	case 1:
		return x - y;
	case 2:
		return x * y;
	}
}

int main() {
	while (cin >> a[0] >> a[1] >> a[2] >> a[3], a[0] || a[1] || a[2] || a[3]) {
		sort(a.begin(), a.end());
		int flag = 1;
		do {
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					for (int k = 0; k < 3; k++) {
						if (f(f(f(a[0], a[1], i), a[2], j), a[3], k) == 10) {
							cout << "((" << a[0] << " " << s[i] << " " << a[1] << ")" << " " << s[j] << " " << a[2] << ")" << " " << s[k] << " " << a[3] << endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if (f(f(a[0], a[1], i), f(a[2], a[3], k), j) == 10) {
							cout << "(" << a[0] << " " << s[i] << " " << a[1] << ") " << s[j] << " (" << a[2] << " " << s[k] << " " << a[3] << ")" << endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if (f(f(a[0], f(a[1], a[2], j), i), a[3], k) == 10) {
							cout << "(" << a[0] << " " << s[i] << " (" << a[1] << " " << s[j] << " " << a[2] << ")) " << s[k] << " " << a[3] << endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
						if (f(a[0], f(f(a[1], a[2], j), a[3], k), i) == 10) {
							cout << a[0] << " " << s[i] << " ((" << a[1] << " " << s[j] << " " << a[2] << ") " << s[k] << " " << a[3] << ")" << endl;
							i = j = k = 3;
							flag = 0;
							break;
						}
					}
				}
			}
		} while (next_permutation(a.begin(), a.end()) && flag);
		if (flag) cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    Match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    
    dp = [(0, 0)] * (N + 1) # dp[i] = (i本のマッチで作れる最大の整数, その整数の桁数)
    for n in range(N + 1):
        for a in A:
            if n - Match[a] < 0: continue
            if n - Match[a] == 0:
                dp[n] = max(dp[n], (a, 1))
                continue
            number, l = dp[n - Match[a]]
            if number != 0: dp[n] = max(dp[n], (number + a * 10**l, l + 1))
    print(dp[N][0])

if __name__ == "__main__":
    main()


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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  string s;
  cin >> s;
  int a[4];
  for (int i = 0; i < 4; ++i) a[i] = s[i] - '0';
  char op[3];
  for (int i = 0; i < 8; ++i) {
    int t = a[0];
    for (int j = 0; j < 3; ++j) {
      if (((i >> j) & 1) == 0) t += a[1 + j], op[j] = '+';
      else t -= a[1 + j], op[j] = '-';
    }
    if (t == 7) break;
  }
  printf("%d%c%d%c%d%c%d=7\n", a[0], op[0], a[1], op[1], a[2], op[2], a[3]);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    for (int i=0; i<N; i++) {
      A[i] = sc.nextInt();
    }
    int M[] = new int[N];
    for (int i=1; i<=N-1; i++) {
      M[i] = gcd(M[i-1], A[i-1]);
    }
    int U[] = new int[N];
    for (int i=1; i<=N-1; i++) {
      U[i] = gcd(U[i-1], A[N-i]);
    }
    int out = 1;
    for (int i=0; i<=N-1; i++) {
      int outtemp = gcd(M[i], U[N-i-1]);
      if(out < outtemp){
        out = outtemp;
      }
    }
    System.out.println(out);
  }

  public static int gcd(int num1, int num2) {
    if(num2 == 0) {
      return num1;
    } else {
      return gcd(num2, num1 % num2);
    }
  }
}



Measured memory_bytes: 50004
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
#include<random>
#define compare(d, p, q) (d ? real(p.point) < real(q.point) : imag(p.point) < imag(q.point))
using namespace std;

const int INF = INT_MAX/3;

typedef complex<double> Point;

struct P{
    Point point;
    int id;
    P (const Point &point, int id)
        : point(point), id(id) {}
    bool operator<(const P &p)const{
        return id < p.id;
    }
};


struct node{
    P p;
    node *l, *r;
    node (const P &p)
        : p(p), l(NULL), r(NULL) {}
};

struct kDTree{
    node *root;
    kDTree() :root(NULL){}

    void insert(const P &p){
        root = insert(root, 0, p);
    }

    node *insert(node *t, int d, const P &p){
        if(t==NULL) return new node(p);
        if(compare(d, p, t->p)) t->l = insert(t->l, !d, p);
        else t->r = insert(t->r, !d, p);
        return t;
    }

    void find(const P &ld, const P &ru, vector<P> &out){
        find(root, 0, ld, ru, out);
    }

    void find(node *t, int d, const P &ld, const P &ru, vector<P> &out){
        if(t==NULL) return;
        const P &p = t->p;
        if(real(ld.point) <= real(p.point) && real(p.point) <= real(ru.point) && imag(ld.point) <= imag(p.point) && imag(p.point) <= imag(ru.point)){
            out.push_back(p);
        }
        if(!compare(d, p, ld)) find(t->l, !d, ld, ru, out);
        if(!compare(d, ru, p)) find(t->r, !d, ld, ru, out);
    }
};

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

    random_device rnd;
    mt19937 mt(rnd());
    uniform_real_distribution<> ran(-0.1, 0.1);

    vector<P> inputList;
    int n,q,x,y,sx, tx, sy, ty;
    cin >> n;
    kDTree k;
    for (int i=0;i<n;i++){
        cin >> x >> y;
        Point point(x + ran(mt), y + ran(mt));
        P p(point, i);
        inputList.push_back(p);
    }
    shuffle(inputList.begin(), inputList.end(), mt);
    for (int i=0;i<n;i++){
        k.insert(inputList[i]);
    }

    cin >> q;
    for (int i=0;i<q;i++){
        cin >> sx >> tx >> sy >> ty ;
        vector<P> result;
        Point ldPoint(sx-0.5, sy-0.5);
        P ld(ldPoint, INF);
        Point ruPoint(tx+0.5, ty+0.5);
        P ru(ruPoint, INF);
        k.find(ld, ru, result);
        sort(result.begin(), result.end());
        for (int j=0;j<result.size();j++){
            printf("%d\n", result[j].id);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 37228
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

typedef long long ll;

int main () {
	ll N;
	ll X, M;
	pair <int, ll> p[100001];
	cin >> N >> X >> M;
	for (int m=0; m<M; m++) {
		p[m].first = p[m].second = -1;
	}
	ll tmp = 0, ans;
	bool flag = true;
	ll i;
	for (i=0; i<N&&flag; i++) {
		tmp += X;
		p[X].first = i;
		p[X].second = tmp;
		X = X*X;
		X %= M;
		flag = (p[X].first == -1);
	}
	if (i==N) {
		ans = tmp;
	} else {
		ll steps = i - p[X].first;
		ll cnts = (N-i)/steps;
		ll v = (N-i)%steps;
		ll diff = tmp - p[X].second + X;
		for (ll j=0; j<v; j++) {
			tmp += X;
			X = X*X;
			X %= M;
		}
		ans = tmp + diff*cnts;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5196
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " ";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int n;
int m;
vector<vector<int>>adj;
int dist[100001];

int dfs(int node){
	if(dist[node]!=-1){
		return dist[node];
	}
	bool leaf = false;
	int count = 0;
	for(auto p : adj[node]){
		leaf = true;
		count = max(count,dfs(p));
	}
	if(leaf==false){
		return dist[node] = 0;
	}
	else{
		return dist[node] = count+1;
	}
	
}

int32_t main()
{
	cin >> n >> m;
	int x,y;
	adj.resize(n+1);
	int indegree[n+1]={0};
	for(int i = 0 ; i < m ; i++){
		cin >> x >> y;
		indegree[y]++;
		adj[x].push_back(y);
	}
	int ans = INT_MIN;
	memset(dist,-1,sizeof(dist));
	for(int i = 1 ; i<=n ; i++){
		if(indegree[i]==0)
		ans = max(ans,dfs(i));
	}
	
	cout << ans;
}


Measured memory_bytes: 14676
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();


	    for(int n=1; n<=N;n++) {
	    	long c=0;
	        for(int x=1; x<=Math.sqrt(n);x++) {
	        	if(x*x+2*x>=n) break;
	    	    for(int y=x; y<=Math.sqrt(n);y++) {
	    	    	if(x*x+y*y+x*y+x+y>=n)break;
	    		    for(int z=y; z<=Math.sqrt(n);z++) {
                        if(x*x+y*y+z*z+x*y+y*z+z*x==n) {
                        	if (x==y && y==z) {
                        		c++;
                        	}else if((x==y && y!=z) || (y==z && x!=y)) {
                        		c+=3;
                        	} else {
                        		c+=6;
                        	}
                        	break;
                        }
	    	        }
		        }
	        }
	        System.out.println(c);
	    }


        //System.out.print(c);

//        if (m%2==0) {
//        	System.out.println(m/2);
//        }else{
//        	System.out.println((m+1)/2);
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39564
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i< n ; i++){
            arr[i] = scanner.nextInt();
        }
        int maxMinus = arr[1] - arr[0];
        int minValue = arr[0];
        for (int i= 1; i< n ; i++){
           maxMinus = Math.max(maxMinus, arr[i] - minValue);
           minValue = Math.min(minValue, arr[i]);
        }
        System.out.println(maxMinus);
    }

}



Measured memory_bytes: 71440
#include <iostream>

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }
    return gcd(b, a % b);
}

int main()
{
    int n;
    std::cin >> n;

    int ans;
    std::cin >> ans;

    for (int i = 1; i < n; i++) {
        int temp;
        std::cin >> temp;

        ans = std::min(ans, gcd(ans, temp));
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,c,n;

	scanf("%d",&n);
	while(n--){
    scanf("%d %d %d",&a,&b,&c);
    a*=a;
    b*=b;
    c*=c;
    if(a+b==c || b+c==a || c+a==b){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
	}
    return 0;
}

Measured memory_bytes: 0
package main 

import (
  "fmt"
//  "sort"
)

func main() {
  var n, m int
  fmt.Scan(&n, &m)

/*
  s := make([]string ,n)
  for i := 0; i < n; i++ {
    fmt.Scan(&s[i])
  }
*/
  
  ans := (n*(n-1))/2 + (m*(m-1))/2

  fmt.Print(ans)
}

Measured memory_bytes: 512
import collections

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table

countdict = {}
counter = 0

for i in range(1, 10):
    a = int(i*(i+1)/2)
    b = int((i+1)*(i+2)/2)
    for j in range(a, b):
        countdict[j] = i

N = int(input())
primelist = prime_decomposition(N)
primedic = collections.Counter(primelist)
result = 0

for i in primedic.values():
    result += countdict[i]
print(result)

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

int main() {
    vector<string> s;
    string tmps;
    set<string> st;
    //int i = 0;
    size_t maxl = 0;
    while(cin >>tmps) {
        s.push_back(tmps);
        st.insert(tmps);
        //maxl = max(maxl, s.at(i).size());
        //i++;
        //cout << tmp;
    }
    
    int ans = 0, maxv = 0;
    string maxs ="";
    string maxL = "";
    for (auto ss : st) {
        int tmp = 0;
        rep(i, s.size()) {
            //int tmp = 0;
            if (ss == s.at(i)) {
                tmp++;
            }
        }
        if (maxv < tmp) {
            maxv = tmp;
            maxs = ss;
        }
        if (maxL.size() < ss.size()) {
            maxL = ss;
        }
    }

    cout << maxs << " " <<maxL << endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";


int main() {
    long long N, M;
    cin >> N >> M;

    vector<long long> A(N);

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

    long long sum = 0;

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

    long long count = 0;

    for (int i = 0; i < N; i++) {
        if (4 * M * A.at(i) - sum >= 0) {
            count++;
        }
    }

    if (count >= M) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  pair<pair<string,int>,int> p[120];
  for(int i=0;i<n;i++){
    string s;
    int k;
    cin >> s >> k;
    p[i]=make_pair(make_pair(s,-k),i+1);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    cout << p[i].second << endl;
  }
}

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

int main(){
    char s[4];
    int i,ans=0;
    cin >> s;
    for(i=0;i<4;i++){
        if(s[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define MAX_N 100000
#define INF 1234567890

int W;
int x[MAX_N];
int sum;
int loop;
int Left, Right;

int sum2;

int g;

int main() {
	cin >> W;
	for (int i = 0; i < W; i++) {
		cin >> x[i];
		sum2 += x[i];
	}
	if (sum2 == 999990000) { cout << "999990000" << endl; goto G; }
	for (int i = 0; i < W; i++) {
		Left = INF; Right = INF;
		if (x[i] > 0) {
			g = max(0, i - x[i] - 500);
			for (int j = i - 1; j >= g; j--) {
				if (x[j] < 0) {
					Left = min(Left, max(0, -x[j] - (i - j)));
				}
				if (x[j] == 0) {
					goto E;
				}
			}
			Left = 0;
		E:;
			g = min(W, i + x[i] + 500);
			for (int j = i + 1; j < g; j++) {
				if (x[j] < 0) {
					Right = min(Right, max(0, -x[j] - (j - i)));
				}
				if (x[j] == 0) {
					goto F;
				}
			}
			Right = 0;
		F:;
			sum += min(x[i], max(Left, Right));
		}
	}
	cout << sum << endl;
G:;
	return 0;
}

Measured memory_bytes: 1548
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,A,B = II()
h = Line(N,1)

left = -1
right = 10**9

while abs(right-left)>1:
    mid = (right+left)//2
    counter = 0
    for i in range(N):
        if h[i]>mid*B:
            counter += math.ceil((h[i]-mid*B)/(A-B))
    if counter<=mid:
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 44252
N,M=map(int,input().split())
l=1
r=N
for i in range(M):
  L,R=map(int,input().split())
  if L>l:
    l=L
  if R<r:
    r=R
    
if l<=r:
  print(r-l+1)
  
else:
  print(0)
  


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

 int main(){

       string str;
       cin>>str;

 int n = str.length();
    int digitSum = 0;
    for (int i=0; i<n; i++)
        digitSum += (str[i]-'0');

      if(digitSum%9 == 0)
  cout<<"Yes"<<endl;
  else if(digitSum%9 != 0)
      cout<<"No"<<endl;


 return 0;
 }


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[1000],n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int p;
  cin>>p;
  for(int i=0;i<p;i++){
    int x,y,z;
    cin>>x>>y>>z;
    rotate(a+x,a+y,a+z);
  }
  for (int i=0;i<n;i++){
    if(i!=0) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  
  return 0;
}



Measured memory_bytes: 3108
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	s := scanText()

	if s[:n/2] == s[n/2:] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int C = sc.nextInt();
			
			System.out.println(A == B && B == C ? "Yes" : "No");
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23252
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(size_t[]), h = rd[0], w = rd[1];
  foreach (_; 0..h) {
    auto c = readln.chomp;
    writeln(c);
    writeln(c);
  }
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int x = 0;
    int ans = 0;
    
    rep(i, n) {
        if (s[i] == 'I') {
            x++;
        }
        else {
            x--;
        }
        
        ans = max(ans, x);
    }
    
    cout << ans << endl;
    return 0;
}

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

int V,R;
vector<P> A;
vector< vector<double> > G;
double ans=0;

double calc_distance(int I,int J){
  P from=A[I];
  P to=A[J];
  P base=to-from;

  int left=0,right=0;
  for(int i=0;i<V;i++){
    if(i==I||i==J)continue;
    P p=conj(base)*(A[i]-from);
    if(p.imag()<0)left=1;
    if(p.imag()>0)right=1;
  }

  double res=abs(base);
  if(left==0||right==0){
    ans+=res;
    res=0;
  }
  return res;
}

int main(){

  cin>>V>>R;
  A.resize(V);
  for(int i=0;i<V;i++){
    double x,y;
    cin>>x>>y;
    A[i]=P(x,y);
  }

  G.resize(V);
  for(int i=0;i<V;i++){
    G[i].resize(V,0.0);
  }
  
  for(int i=0;i<V;i++){
    for(int j=0;j<i;j++){
      
      double value=calc_distance(i,j);
      if(value==0.0)G[i][j]=G[j][i]=0;
      else G[i][j]=G[j][i]=1e9;
    }
  }

  for(int i=0;i<R;i++){
    int I,J;
    cin>>I>>J;
    I--,J--;
    if(G[I][J]==0)continue;
    double value=calc_distance(I,J);
    G[I][J]=value;
    G[J][I]=value;
  }
  
  vector<double> d(V, 99999999.0 );
  vector<int> visited(V,0);
  d[0]=0;
  
  while(1){
    int pos=-1;
    for(int i=0;i<V;i++)
      if(visited[i]==0)
        if(pos==-1||d[i]<d[pos])
          pos=i;
    if(pos==-1)break;
    visited[pos]=1;
    ans+=d[pos];
    for(int to=0;to<V;to++){
      d[to]=min(d[to],G[pos][to]);
    }
  }

  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

typedef pair<ll,int> pii;
typedef priority_queue<pii,vector<pii>,greater<pii>> prpi;

int main(){
    int n,c;cin >> n >> c;
    vector<vector<int>> d(c,vector<int>(c)),col(n,vector<int>(n));
    rep(i,c)rep(j,c){
        cin >> d[i][j];
    }rep(i,n)rep(j,n){
        cin >> col[i][j];
    }
    //全探索するとcP3 * n^2=O(c^3*n^2)でぎり間に合う…？無理か
    //前処理的に、(i+j%3==0)の点に対して3番目までに最適な色変化を保持しておく
    //あとで組み合わせればok
    //大体n*n*c*3くらいの計算
    vector<prpi> ans(3);//<min,color>を保持する
    rep(aa,3){
        rep(co,c){
        ll cnt=0;//aaをcoに変えた時の違和感の総和
        rep(i,n)rep(j,n){
            if((i+j)%3!=aa)continue;
            cnt+=d[col[i][j]-1][co];
        }
        ans[aa].push(pii(cnt,co));
        }
    }
    
    ll val=-1;
    vector<vector<pii>> last(3,vector<pii>(3));
    rep(i,3){
        rep(j,3){
            last[i][j]=ans[i].top();
            ans[i].pop();
        }
    }
    
    rep(i,3)rep(j,3){
        if(last[0][i].second==last[1][j].second)continue;
        
        rep(k,3){
            if(last[0][i].second==last[2][k].second||last[2][k].second==last[1][j].second)continue;
            if(val==-1)val=last[0][i].first+last[1][j].first+last[2][k].first;
            else val=min(last[0][i].first+last[1][j].first+last[2][k].first,val);
        }
    }
    cout << val << '\n';
}

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

int bee(int a)
{
	if(a&1)
	{
		if(a<9)return 1;
		else return 2;
	}
	else if(a == 2)return 3;
	else if(a>6)return 1;
	else return 2;
}

int main()
{
	int x,y;
	scanf("%d %d",&x,&y);
	if(bee(x) == bee(y))printf("Yes");
	else printf("No");
	return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N, M;
  cin >> N >> M;
  string ans = "";
  vector<bool> mask(N, false);
  for (int i = 0; i < N; i++) {
    ans += 'x';
  }
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if (ans[s - 1] == 'x' || ans[s - 1] == c + '0') {
      ans[s - 1] = c + '0';
      mask[s - 1] = true;
    } else {
      cout << -1 << endl;
      return;
    }
  }
  for (int i = 0; i < N; i++) {
    if (ans[i] == 'x') {
      ans[i] = '0';
    }
  }
  if (ans[0] == '0' && !mask[0] && ans.size() > 1) {
    ans[0] = '1';
  }
  if (ans.size() > 1 && ans[0] == '0') {
    cout << -1 << endl;
    return;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const int INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N=IN;
    vector<int> a(N);
    cin>>a;
    int sum=accumulate(ALL(a),0ll);
    if(sum%(N*(N+1)/2)!=0) {
        cout<<"NO"<<endl;
        return 0;
    }
    int k=sum/(N*(N+1)/2);
    REP(i,N) {
        int d=a[(i+1)%N]-a[i]-k;
        if(d>0 || d%N!=0) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 1024
program sample
    implicit none
    character(100000)::s,t
    character::top,las
    integer(8) :: i,j,m,n,a,b,c,c1,k
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,k
    read(*,*) s
    a=0
    b=0
    do i=1,n-1
        if(s(i:i+1) .eq. 'RL')then
            b=b+2
        end if
    end do
    c=0
    if(s(1:1) .eq. 'L' .and. s(n:n) .eq. 'R')then
        c=2
    elseif(s(1:1) .eq. 'L' .or. s(n:n) .eq. 'R')then
        c=1
    end if

    if(b/2<=k)then
        m=0
        k=k-b/2
        if(c==0)then
            c=1
        endif
        
    else
        m=b-2*k
        k=0
    end if
        
    if(k>0 .and. c==2)then
        c=1
    end if
    m=m+c

    write(*,*)n-m


   


 end program sample

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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> count(m, 0);
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        for(int j = 0; j < x; j++)
        {
            int y;
            cin >> y;
            y--;
            count[y]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < m; i++)
    {
        if (count[i] == n)
        {
            ans++;
        }
    }

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

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

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        return 2.0 * (double)n * Math.PI;
    }
}


Measured memory_bytes: 27516
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int ans  = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int s;
    cin >> s;
    vector<int> a(1000005, 0);
    a[s] = 1;
    int m = 1;
    while(1){
        m++;
        if(s % 2 == 1){
            s = 3 * s + 1;
        }
        else{
            s = s / 2;
        }
        a[s]++;
        if(a[s] == 2){
            printf("%d\n", m);
            break;
        }

    }
    

    
}

Measured memory_bytes: 4096