akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
	int kanri[4][3][10]={0};
	int count,counter=0;
	int b,f,r,v;
	
	scanf("%d",&count);
	while(counter<count){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		kanri[b-1][f-1][r-1]+=v;
		counter++;
	}
	for(b=0;b<4;b++){
		for(f=0;f<3;f++){
			for(r=0;r<10;r++){
				printf(" %d",kanri[b][f][r]);
			}
			printf("\n");
		}
		if(b!=3){
			printf("####################\n");
		}
	}
	return 0;
}

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

int main(void){
    string S;
    cin >> S;
    ll a=0,b=0;
    
    rep(i,S.length()){
        if(S[i]%2 != i%2)a++;
        else  b++;
    }
    cout << min(a,b) << endl;
    
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

struct Node {
    Node *p;
    int d;
};

Node nodes[100002];

Node *find_root(int i) {
    Node *nd = &nodes[i];
    while(nd->p != nd) nd = nd->p;
    return nd;
}

void unite(int i, int j) {
    Node *xr = find_root(i);
    Node *yr = find_root(j);
    if(xr->d < yr -> d){
        xr->p = yr;
    } else {
        yr->p = xr;
        if(xr->d == yr -> d){
            (xr->d)++;
        }
    }
}

bool same(int x, int y) {
    auto xr = find_root(x);
    auto yr = find_root(y);
    return xr == yr;
}
int main() {
    int n,m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        nodes[i].p = &nodes[i];
        nodes[i].d = 0;
    }
    int p[100002];
    for (int j = 1; j <=n ; ++j) {
        cin >> p[j];
    }
    for (int k = 0; k < m; ++k) {
        int x, y;
        cin >> x >> y;
        unite(x,y);
    }
    int cnt = 0;
    for (int l = 1; l <= n; ++l) {
        if(same(p[l], p[p[l]])) cnt++;
    }
    cout << cnt <<endl;


    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    if(n == 22) cout << "Christmas Eve Eve Eve" << endl;
    else if(n == 23) cout << "Christmas Eve Eve" << endl;
    else if(n == 24) cout << "Christmas Eve" << endl;
    else cout << "Christmas" << endl;
}

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

using namespace std;

int main(){
    int D;
    string Eve=" Eve";
    string Eves="";
    Eve=" Eve";
    cin >>D;
    for(int i=25;21<i;i--){
        if(D==i){
            cout <<"Christmas"+Eves;
            return 0;
        }
        Eves+=Eve;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(void){
    int a[1000],b[1000],c[1000],i,j,r[1000],n,ans[303],abc;
    for(j=0;j<6;j++){
        scanf("%d%d%d%d",&a[0],&b[0],&c[0],&n);
        if(a[0]==0) return 0;
        abc=a[0]+b[0]+c[0];
        for(i=0;i<=abc+1;i++) ans[i]=2;
        for(i=0;i<n;i++) scanf("%d%d%d%d",&a[i],&b[i],&c[i],&r[i]);
        for(i=0;i<n;i++) if(r[i]){
            ans[a[i]]=ans[b[i]]=ans[c[i]]=1;
        }
        for(i=0;i<n;i++) if(r[i]-1) if(ans[a[i]]+ans[b[i]]+ans[c[i]]==4&&(ans[a[i]]==1||ans[b[i]]==1)){
            if(ans[a[i]]-1){
                ans[a[i]]=0;
            }else if(ans[b[i]]-1){
                ans[b[i]]=0;
            }else ans[c[i]]=0;
        }
        for(i=1;i<=abc;i++) printf("%d\n",ans[i]);
    }
}

Measured memory_bytes: 2768
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, m;
	long long k;
	cin >> n >> m >> k;

	vector<long long> a(n, 0), b(m, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	vector<long long> cumul_a(n + 1, 0);
	for (int i = 0; i < n; i++) {
		cumul_a[i+1] = cumul_a[i] + a[i];
	}
	vector<long long> cumul_b(m + 1, 0);
	for (int i = 0; i < m; i++) {
		cumul_b[i+1] = cumul_b[i] + b[i];
	}

	int ans = 0;
	int ib = m;
	for (int ia = 0; ia < cumul_a.size(); ia++) {
		if (cumul_a[ia] > k) {
			break;
		}

		while (ib > 0 && cumul_a[ia] + cumul_b[ib] > k) {
			ib--;
		}
		// printf("a %2d %4lld,  ib %2d %4lld\n", ia, cumul_a[ia], ib, cumul_b[ib]);

		if (cumul_a[ia] + cumul_b[ib] <= k) {
			ans = max(ans, ia+ib);
		} else {
			ans = max(ans, ia);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9156
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
    int x , a ;
    cin >> x >> a ;
    if(x>=a)
        cout << 10 ;
    else
        cout << 0 ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[30001];
long long a[10001];
long long b[10001];
int n,h;
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>h>>n;
    for(int i=1 ; i<=n ; i++)cin>>a[i]>>b[i];
    int i;
    long long ans=1e18;
    for(i=1 ; i<=30000 ; i++)dp[i]=1e18;
    for(i=1 ; i<=30000 ; i++){
        for(int j=1 ; j<=n ; j++){
            if(a[j]<=i)dp[i]=min(dp[i-a[j]]+b[j],dp[i]);
        }
        if(i>=h)ans=min(ans,dp[i]);
    }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
  char input[100];
  int ans;
 
  fgets(input, sizeof(input), stdin);
 
  ans = atoi(input) * atoi(input) * atoi(input);
  printf("%d\n", ans);
 
  return 0;
}

Measured memory_bytes: 528
#include <stdio.h>
int main()
{
	
	int M,N,x,y=0;
	//1<=N<=100
 
    scanf("%d",&N);
	
    if(N<15)
	{
		x=800*N;
		y=0;
		M=x-y;
		printf("%d",M);
	}
	else
	{
		x=800*N;
		y=200*(N/15);
		M=x-y;
		printf("%d",M);
		
	}
	
	
	
	
	
	
	
	
	
	return 0;
 } 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == '0')
            {
                cnt++;
            }
        }
        else
        {
            if (s[i] == '1')
            {
                cnt++;
            }
        }
    }
    int ans = cnt;
    cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == '1')
            {
                cnt++;
            }
        }
        else
        {
            if (s[i] == '0')
            {
                cnt++;
            }
        }
    }
    ans = min(ans, cnt);
    cout << ans << endl;
}


Measured memory_bytes: 512
def main():
    A, B, C, D = input()
    for i in range(2**3):
        op = ['+', '+', '+']
        for j in range(len(op)):
            if (i >> j) & 1:
                op[j] = '-'
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
            break
    
                
                
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n,m; cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
# Problem: https://atcoder.jp/contests/agc012/tasks/agc012_a
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(eachPoints):
    result = 0
    menbers = len(eachPoints)
    group = menbers // 3
    eachPoints.sort(reverse=False)
#    print(eachPoints)
    useSkillList = []
    #  最初のグループ個だけカットしたリストを新規作成[0,1,2,3,4,5]->[2,3,4,5]
    for ui in range(group, menbers, +1):
        useSkillList.append(eachPoints[ui])
#    print("UseListOnly {}".format(useSkillList))
    # for pi in range(0, menbers):
    #    if pi // group == 1:
    #        print("Get Position -> {}={}".format(pi, eachPoints[pi]))
    #        result = result + eachPoints[pi]
    # algorithm
    for sum2pos in range(0, len(useSkillList), +2):
        result = useSkillList[sum2pos] + result
    return result


if __name__ == "__main__":
    _ = II()
    AI = LI()
    print("{}".format(solver(AI)))


Measured memory_bytes: 37212
A,B,C,D=input()
digits=3
op=[""]*digits
for i in range(1<<digits):
    for j in range(digits):
        if (i>>j)&1:
            op[j]="+"
        else:
            op[j]="-"
    if eval(A+op[0]+B+op[1]+C+op[2]+D)==7:
        print(A+op[0]+B+op[1]+C+op[2]+D+"=7")
        break

Measured memory_bytes: 3064
mod = 2019
# l, r = 2020, 2040
l, r = map(int, input().split())

r1, r2 = (l-1)//mod, r//mod

if r1==r2:
	c1, c2 = l%mod, r%mod
	ans = min((i*j)%mod for i in range(l, r) for j in range(i+1, r+1))
	print(min(ans, 2018))
else:
	print(0)

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

int main() {
    string a;
    cin >> a;
    for (int i = 1; i < 4; i++) {
        if (a[i] == a[i-1]) {
            cout << "Bad"; return 0;
        }
    }
    cout << "Good";
    return 0;
}


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

signed main() {
  int H, W;
  cin >> H >> W;
  char A[10][10];

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      if (A[i][j] == '#') {
        ans++;
      }
    }
  }
  
  if (ans == H + W - 1) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
type val struct {
	cp       float64
	capacity int64
	cost     int64
}
type vSlice []val

func (v vSlice) Len() int {
	return len(v)
}
func (v vSlice) Less(i, j int) bool {
	return v[i].cp < v[j].cp
}
func (v vSlice) Swap(i, j int) {
	v[i], v[j] = v[j], v[i]
}

func main() {
	defer stdout.Flush()

	vs := make([]val, 4)
	capa := []int64{1, 2, 4, 8}

	for i := range vs {
		vs[i].capacity = capa[i]
		vs[i].cost = readInt64()
		vs[i].cp = float64(vs[i].cost) / float64(capa[i])
	}
	N := readInt64() * 4
	sort.Sort(vSlice(vs))
	var ans, sum int64
	for i := 0; i < len(vs) && sum < N; i++ {
		x := (N - sum) / vs[i].capacity
		ans += x * vs[i].cost
		sum += x * vs[i].capacity
	}
	println(ans)
}


Measured memory_bytes: 640
import java.util.*;
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();
		sc.close();
		int ans = Math.min(n*a,b);
		System.out.println(ans);
	}
}

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

int main(){
	string a, b;
	int ans = 0;
	cin >> a >> b;
	for(int i = 0;i < a.size();i++){
		char c = a[i];
		char d = b[i];
		if(c != d){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);

	if(n & 1) {
		for(int i = 0; i < m; i++) printf("%d %d\n", 1 + i, n - i);
	} else {
		for(int i = 0; i < (m + 1) / 2; i++) printf("%d %d\n", 1 + i, n - i);
		for(int i = (m + 1) / 2; i < m; i++) printf("%d %d\n", 2 + i, n - i);
	}
	return 0;
}


Measured memory_bytes: 3840
from collections import Counter

dic_str = {}
strings = input().split()
dic_str = Counter(strings)

key_max = 0
val_max = 0
key_str = ''
val_str = ''
for k,v in dic_str.items():
  if len(k) > key_max:
    key_max = len(k)
    key_str = k
  if v > val_max:
    val_max = v
    val_str = k

print(val_str, key_str)


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

int main() {
	int N;
	cin >> N;
	cout << N * (N - 1) / 2 - N / 2 << endl;
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (i + j == N + (N % 2 == 0)) continue;
			cout << i << " " << j << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2 * acos (0.0)
int main()
{
    ll a,b,c,d,e,f,g,h,ct;
    string s1,s2,s3,s4;
    ll n,k,t,x,y,x1,x2,y1,y2,m;
    //ct=0;
    cin>>t;
    //ll i=1;
    ct=(t*t+t)/2;
     //cout<<ct<<endl;
    for(ll i=1;i<=t;i++)
    {
        if(i%3==0 && i%5==0) ct-=i;
        else if(i%3!=0 && i%5==0) ct-=i;
        else if(i%3==0 && i%5!=0) ct-=i;
    }
     cout<<ct<<endl;
}







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

int main(){
    int N; cin >> N;
    cout << (N+1)/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <ll , ll>;
void in(ll &x);
const ll N = 55;
#define singleCase
// #define multipleCase
ll n,p,a[N],dp[N][2];

ll f(ll cur , ll md) {
   if (cur > n) return md == p;
   ll &sol = dp[cur][md];
   if (sol != -1) return sol;
   return sol = f(cur + 1 , (md + a[cur]) % 2) + f(cur + 1 , md);
}

void work() {
   memset (dp , -1 , sizeof dp);
   in(n); in(p);
   for (ll i = 1 ; i <= n ; i++) {
      in(a[i]);
   }
   printf("%lld\n" , f(1 , 0));
   return;
}

int main() {
   #ifdef multipleCase
      ll nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(ll &x) {
	bool neg = false;
	register ll c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 3724
#include <iostream>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    char *S = new char[N+1];
    for (int i = 0; i < N; i++) cin >> S[i];
    S[N+1] = 'L';

    char prev = S[0];
    int count = 0;
    for (int i = 1; i < N; i++) {
        if (prev == 'R' && S[i] == 'L') {
            count++;
        }

        prev = S[i];
    }

    int edge_count = 0;
    if (S[0] == 'L') edge_count ++;
    if (S[N-1] == 'R') edge_count++;



    while (K != 0) {
        if (count > 0) {
            count--;
        } else if (edge_count > 1) {
            edge_count--;
        }
        K--;
        
        if (count == 0 && edge_count == 0) {
            edge_count = 1;
        }
    }

    cout << N - (2 * count + edge_count) << endl;


    return 0;
}

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

// Optimization

//#pragma GCC optimize("O3")
// #define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int ans, cnt, tmp, idx, mx = -inf, mn = inf;
int x, y, z;
string s, t;
int a[N], b[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#define square(x) ((x) * (x))

int hexa(char s);

int main(void) {
    int red,green,blue,num,i,color[8][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},{255,0,0},{255,0,255},{255,255,0},{255,255,255}};
    char temp[8],colorname[9][8]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
    double min,dis;
    while (scanf(" %s",temp)!=EOF&&temp[0]!='0') {
        min=221952.0;
        red=hexa(temp[1])*16+hexa(temp[2]);
        green=hexa(temp[3])*16+hexa(temp[4]);
        blue=hexa(temp[5])*16+hexa(temp[6]);
        for (i=0; i<8; i++) {
            dis = square(color[i][0]-red)+square(color[i][1]-green)+square(color[i][2]-blue);
            if (dis<min) {
                min=dis;
                num=i;
            }
        }
        printf("%s\n",colorname[num]);
    }
    return 0;
}

int hexa(char s) {
    if (isalpha(s)) {
        return s-'a'+10;
    } else {
        return s-'0';
    }
}

Measured memory_bytes: 520
#include <stdlib.h>
#include <stdio.h>

#define N 100

int compare_int(const void *a,const void *b) {
	int arg_1 = *(const int*)a;
	int arg_2 = *(const int*)b;
	if (arg_1 > arg_2) return 1;
	if (arg_1 < arg_2) return -1;
	return 0;
}

int main(void) {
	int n;
	int problem[N];
	int i;
	int sum;

	while (scanf("%d",&n) != EOF) {
		for (i = 0;i < n;++i) {
			scanf("%d",&problem[i]);
		}
		qsort(problem,n,sizeof(int),compare_int);
		sum = 0;
		for (i = 0;i < n;++i) {
			sum += problem[i]*(n- i);
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string s = "";
  std::cin >> s;
  std::vector<bool> alph(26, false);
  for (char c : s) {
    if (alph.at(c-'a')) {
      std::cout << "no" << std::endl;
      return 0;
    }
    else {
      alph.at(c-'a') = true;
    }
  }
  std::cout << "yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

type binHeap struct {
	heap []int
	size int
}

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

func (bh binHeap) printNodes() {
	buf := bufio.NewWriter(os.Stdout)
	for i := 1; i < bh.size+1; i++ {
		buf.Write([]byte(fmt.Sprintf("node %d: ", i)))
		buf.Write([]byte(fmt.Sprintf("key = %d, ", bh.heap[i])))

		if parent := i / 2; bh.isInRange(parent) {
			buf.Write([]byte(fmt.Sprintf("parent key = %d, ", bh.heap[parent])))
		}

		if left := 2*i; bh.isInRange(left) {
			buf.Write([]byte(fmt.Sprintf("left key = %d, ", bh.heap[left])))
		}

		if right := (2*i)+1; bh.isInRange(right) {
			buf.Write([]byte(fmt.Sprintf("right key = %d, ", bh.heap[right])))
		}
		buf.Write([]byte("\n"))
		buf.Flush()
	}
}

func (bh binHeap) isInRange(i int) bool {
	return 1 <= i && i <= bh.size
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	h := nextInt(sc)

	bh := binHeap{make([]int, h+1), h}

	for i := 1; i < h+1; i++ {
		bh.heap[i] = nextInt(sc)
	}

	bh.printNodes()
}


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
using namespace std;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) break;

    vector<vector<string> > mem(n); 
    for(int i=0; i<n; i++){
      string str;
      cin >> str;
      int s=0;
      for(int j=0; j<(int)str.length(); j++){
        if(str[j]==':' || str[j]==',' || str[j]=='.'){
          mem[i].push_back( str.substr(s, j-s) );
          s = j+1;
        }
      }
    }

    map<string, int> group;
    set<string> group_e;
    for(int i=0; i<n; i++){
      group[mem[i][0]] = i;
    }
    queue<string> onsearch;
    for(int i=1; i<(int)mem[0].size(); i++){
      onsearch.push(mem[0][i]);
    }
    set<string> member;
    while(!onsearch.empty()){
      string looking = onsearch.front();
      onsearch.pop();
      map<string,int>::iterator itm = group.find(looking);
      if(itm == group.end()){
        member.insert(looking);
        continue;
      }
      int gidx = itm->second;
      set<string>::iterator its = group_e.find(looking);
      if(its != group_e.end()){
        continue;
      }
      group_e.insert( looking );
      for(int i=1; i<(int)mem[gidx].size(); i++){
        onsearch.push(mem[gidx][i]);
      }
    }
    
    cout << member.size() << endl;
  }
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N); 
	F0R(i, N) cin >> arr[i];
	map<ll, int> occ;
	occ[0] = 1;
	ll ans = 0;
	ll total = 0;
	F0R(i, N) {
		total += arr[i];
		ans += occ[total];
		occ[total]++;
	}
	print(ans);
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define M 100007
using namespace std;
int n,m,ans,p,f[M];
struct mo {
	int x,y;
	bool operator<(mo _)const {
		return y==_.y?x<_.x:y>_.y;
	}
} a[M];
int F(int x) {
	return f[x]==x?x:f[x]=F(f[x]);
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)
		scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+n+1);
	for(int i=0; i<=m; i++)f[i]=i;
	for(int i=1; i<=n; i++) {
		int p=m-a[i].x+1;
		if(p<=0)continue;
		int A=F(p);
		if(A>0)ans+=a[i].y,f[A]=A-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
ll pwr(ll x, ll e){
    if(e==0)
        return 1;
    ll tmp=pwr(x, e/2);
    tmp*=tmp;
    tmp%=mod;
    if(e%2){
        tmp*=x;
        tmp%=mod;
    }
    return tmp;
}
ll fc[1000010], ifc[1000010];
ll cmb(ll x, ll y){
    ll tmp = fc[x]*ifc[x-y];
    tmp%=mod;
    tmp*=ifc[y];
    tmp%=mod;
    return tmp;
}
int main(){
    int n;
    fc[0]=1;
    ifc[0]=1;
    for(ll i=1; i<=1000010; ++i){
        fc[i]=fc[i-1]*i;
        fc[i]%=mod;
        ifc[i]=pwr(fc[i], mod-2);
    }
    int x, y;
    while(cin>>x>>y){
        ll ans=0;
        int tmp;
        for(int i=0; i<=x; ++i){
            if((x-i)%2)
                continue;
            tmp=(x-i)/2;
            if(tmp+i*2==y){
                ans+=cmb(i+tmp, i);
                ans%=mod;
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 16000
#include <stdio.h>

int main () {
	
	int i, j, N, a[1000], v, k;
	j = 1 ;

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

	for (i = 0 ; i < N ; i++ ) {
		v =a[i] ;
		j = i - 1 ;
		while (( j >= 0) && ( a[j] > v )) {
			a[j+1] = a[j] ;
			j-- ;
		}
		a[j+1] = v ;
	
		for ( k = 0 ; k < N ; k++ ) {
			printf("%d",a[k] ) ;
				if (k != N-1)
					printf(" ");
					else 
					printf("\n");
		}
	}
	
	
	

return 0;
}

Measured memory_bytes: 608
#include <iostream>
using namespace std;
int main(void){
   string s,p;
   cin>>s>>p;
   
   string ans="No";
   for(int i=0;i<(int)s.length();i++){
       bool flag=true;
       for(int j=0; j<(int)p.length();j++){
           if(s[(i+j)%(int)s.length()]!=p[j]){
               flag=false;
               break;
           }
       }
       if(flag){
           ans="Yes";
           break;
       }
   }
   cout<<ans<<endl;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  long long ans = 0,w = 0;
  for(int i = 0 ; i < S.size() ; i++){
    if(S[i] == 'W'){
      ans +=i;
      w++;
    }
  }
  cout << ans-(w-1)*w/2 << endl;
}


Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
using namespace std;
#define ll long long
int main(){
	double R1, R2;
	cin >> R1 >> R2;
	double ans = R1*R2/(R1 + R2);
	cout << setprecision(14) << ans << endl;
}

Measured memory_bytes: 256
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

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

    while (sc.hasNextLine())
    {
      String[] input = sc.nextLine().split(" ");

      if (input.length == 1)
      {
        if (Integer.valueOf(input[0]) == 0)
        {
          break;
        }
      }

      final int dataset = Integer.valueOf(input[0]);

      Map<Long, Long> dataMap = new LinkedHashMap<>();
      for (int i = 0; i < dataset; i++)
      {
        String[] inputDataset = sc.nextLine().split(" ");
        final long empNum = Long.valueOf(inputDataset[0]);
        final long price = Long.valueOf(inputDataset[1]);
        final long count = Long.valueOf(inputDataset[2]);

        if (!dataMap.containsKey(empNum))
        {
          dataMap.put(empNum, price * count);
        }
        else
        {
          dataMap.put(empNum, dataMap.get(empNum) + (long) (price * count));
        }

      }
      Object[] keySet = dataMap.keySet().toArray();
      Object[] valueSet = dataMap.values().toArray();

      boolean zeroData = true;
      for (int j = 0; j < keySet.length; j++)
      {
        if ((long) valueSet[j] >= 1000000)
        {
          zeroData = false;
          System.out.println(keySet[j]);
        }
      }

      if (zeroData)
      {
        System.out.println("NA");
      }

    }

    sc.close();
  }
}



Measured memory_bytes: 32484
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    rep(i, n / 2)
    {
        if (s[i] != s[i + n / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int C=0;
int A[500000];

void merge(int *A, int l, int m, int r){
  int i, j, k;
  int n1= m - l, n2= r - m; 
  int L[n1], R[n2];
  for(i = 0; i < n1; i++){
    L[i] = A[l + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[m + i];
  }
  L[n1] = 1000000001;
  R[n2] = 1000000001;
  i = 0;
  j = 0;
  for(k = l; k < r; k++){
    C++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{ 
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int *A, int l, int r){
  int m;
  if(l+1 < r){
    m = (l + r)/2;
    mergeSort(A, l, m);
    mergeSort(A, m, r);
    merge(A, l, m, r);
  }
}


int main(){
  int n, i;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  mergeSort(A, 0, n);
  for(i = 0; i < n-1; i++) printf("%d ", A[i]);
  printf("%d", A[i]);
  printf("\n%d\n", C);

  return 0;
}


Measured memory_bytes: 5632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = ReadLine().Split().Select(int.Parse).ToArray();
		WriteLine(Abs(n[1] - n[0]) < Abs(n[2] - n[0]) ? "A" : "B");
	}
}


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

void call(int n) {
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}
		else if (i % 10 == 3) {
			cout << " " << i;
		}
		else if (i / 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 10) % 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 100) % 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 1000) % 10 == 3) {
			cout << " " << i;
		}
		else if ((i / 10000) % 10 == 3) {
			cout << " " << i;
		}
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	call(n);

}


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

#define pb push_back
#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 2e5 + 10;

int n, m;
int dega[N], degb[N];
bool bad[N];
char S[N];
vector<int> G[N];

int main() {

	scanf("%d%d", &n, &m);
	scanf("%s", S + 1);
	For(i, 1, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[v].pb(u), G[u].pb(v);
		if (S[v] == 'A') ++dega[u];
		else ++degb[u];
		if (S[u] == 'A') ++dega[v];
		else ++degb[v];
	}

	queue<int> q;
	For(i, 1, n) if (!dega[i] || !degb[i]) {
		bad[i] = true;
		q.push(i);
	}

	while (!q.empty()) {
		int o = q.front(); q.pop();
		for (int v : G[o]) if (!bad[v]) {
			if (S[o] == 'A') --dega[v];
			else --degb[v];
			if (!dega[v] || !degb[v]) q.push(v), bad[v] = true;
		}
	}

	For(i, 1, n) if (!bad[i]) {
		puts("Yes");
		return 0;
	}
	puts("No");

	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; 
    cin >> n;
    long long v[n];
    for(int i = 0; i < n; i++ ) {
        cin >> v[i];
    }
    long long ans = 0;
    for( int i = 0; i < n; i++ ) {
        for( int j = i+1; j < n; j++ ) {
            ans += v[i]*v[j];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A[3];
int ans = 500;

int main()
{
  rep( i, 3 )
    scanf( "%d", A+i );

  rep( i, 3 ) rep( j, 3 ) rep( k, 3 ) if( i != j && j != k && i != k )
    ans = std::min( ans, abs(A[j]-A[i])+abs(A[k]-A[j]) );

  printf( "%d\n", ans );
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i=0;i<a.size()-1;i++){
    if(a.at(i)==a.at(i+1)){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main() {
  std::string S, T;
  std::cin >> S >> T;
  int q;
  std::cin >> q;
  std::vector<int > a(q), b(q), c(q), d(q);
  for (int i=0; i<q; i++) {
    std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
    c[i]--;
    d[i]--;
  }
  std::vector<int > AnumS(S.length()+4);
  std::vector<int > BnumS(S.length()+4);
  std::vector<int > AnumT(T.length()+4);
  std::vector<int > BnumT(T.length()+4);
  AnumS[0] = 0;
  BnumS[0] = 0;
  for (int i=0; i<S.length(); i++) {
    AnumS[i+1] = AnumS[i];
    BnumS[i+1] = BnumS[i];
    if (S[i]=='A') {
      AnumS[i+1]++;
    } else {
      BnumS[i+1]++;
    }
  }
  AnumT[0] = 0;
  BnumT[0] = 0;
  for (int i=0; i<T.length(); i++) {
    AnumT[i+1] = AnumT[i];
    BnumT[i+1] = BnumT[i];
    if (T[i]=='A') {
      AnumT[i+1]++;
    } else {
      BnumT[i+1]++;
    }
  }
  for (int i=0; i<q; i++) {
    int ABdiffS = (AnumS[b[i]+1] - AnumS[a[i]]) - (BnumS[b[i]+1]-BnumS[a[i]]);
    int ABdiffT = (AnumT[d[i]+1] - AnumT[c[i]]) - (BnumT[d[i]+1]-BnumT[c[i]]);
    int diff = abs(ABdiffS - ABdiffT);
    printf("%s\n", (diff%3==0)?"YES":"NO");
  }
  return 0;
}

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

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

typedef long long ll;

int n;
int d[1252];
string S;

int main(){
  cin>>n;
  REP(i,n)cin>>d[i];
  REP(i,n)S += string(1,'0'+d[i]);
  int it = 0;
  while(true){
    string s = to_string(it);
    bool found = false;
    REP(i,S.size()-s.size()+1){
      if(S.substr(i,s.size())==s){
        found = true;
        break;
      }
    }
    if(!found)break;
    it++;
  }
  cout<<it<<endl;
  return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;


#define MAXN  1000001 
   
int spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i;  
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i)  
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

unordered_set<int> st[1000001];

void fact(int x,int i){
	while (x != 1) 
    { 
    	st[spf[x]].insert(i);
        x = x / spf[x]; 
    } 
}


void test(){
	int n;
	cin>>n;
	int a[n];
	f(i,n)cin>>a[i];
	f(i,n){
		fact(a[i],i);
	}
	bool ty1 = true, ty2 = true, ty3 = true;
	f(i,1000001){
		if(st[i].size()>1)ty1 = false;
		if((int)st[i].size()==n)ty2 = false;
	}
	if(ty1)cout<<"pairwise coprime\n";
	else if(ty2)cout<<"setwise coprime\n";
	else cout<<"not coprime\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	sieve();
	int tests=1;
	// cin>>tests;
	while(tests--){
		test();
	}
}


Measured memory_bytes: 268216
#include <bits/stdc++.h>
using namespace std;
const long double pi=3.14159265358979323846;
long double modul(long double x){
  if(x<0)
    x=-x;
  return x;
}
int main(){
  int a, b, h, m;
  cin>>a>>b>>h>>m;
  long double disthour, distminute, x;
  x=30*h;
  x+=0.5*m-6*m;
  long double angle=modul(x);
  angle=angle*pi/180;
  long double ans=sqrt(a*a+b*b-2*a*b*cos(angle));
  cout<<fixed<<setprecision(20)<<ans;
  return 0;
}


Measured memory_bytes: 4160
#include <iostream>
#include <complex>


using namespace std;

typedef long long ll;

#define NMAX 100001

bool is_prime[NMAX];
int pnum[NMAX] = {};

int main()
{
    int Q;
    cin >> Q;

    for (int i = 0; i < NMAX; ++i) is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i < NMAX; ++i)
    {
        if (is_prime[i])
        {
            for (int j = 2*i; j < NMAX; j += i)
            {
                is_prime[j] = false;
            }
        }
    }

    for (int i = 2; i < NMAX; ++i)
    {
        pnum[i] = pnum[i-1];
        if (is_prime[i] && is_prime[(i+1)/2]) ++pnum[i];
    }

    for (int i = 0; i < Q; ++i)
    {
        int l, r;
        cin >> l >> r;
        cout << pnum[r] - pnum[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    set<char> s;
    for(int i = 0; i < n; i++){
        char c; cin >> c;
        s.insert(c);
    }
    cout << (s.size() == 3 ? "Three" : "Four") << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n;
  cin>>n;
  long long a[n];
  REP(i,n){
    cin>>a[i];
  }
  long long cnt[n] = {};
  long long ans = 1;
  cnt[0] = 3;
  REP(i,n){
    ans *= cnt[a[i]];
    ans = mod(ans);
    cnt[a[i]]--;
    cnt[a[i]+1]++;
  }
  cout<<ans<<endl;
  
  return 0; 
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int f[N],c[N],n,m,x,y;

int main(){
	read(n),read(m);
	rep(i,1,n){
		f[i]=(i==1);
		c[i]=1;
	}
	rep(i,1,m){
		read(x),read(y);
		if(c[x]==1){
			f[y]|=f[x];
			c[y]++,c[x]--;
			f[x]=0;
		}
		else{
			f[y]|=f[x];
			c[y]++,c[x]--;
		}
	}
	int ans=0;
	rep(i,1,n)
		ans+=f[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7)

#import math
#import numpy as np
#= int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
def dfs(num):
    if dp[num] != -1:
        return dp[num]

    res = 0
    for obj in G[num]:
        res = max(res, dfs(obj) + 1)

    dp[num] = res
    return res


N, M = map(int, input().split())

dp = [-1] * N
G = {i:[] for i in range(N)}

for _ in range(M):
    x, y = map(int, input().split())
    G[x - 1].append(y - 1)

res = 0
for i in range(N):
    res = max(res, dfs(i))

print(res)

Measured memory_bytes: 68752
n = int(input())
a = [int(input()) for _ in range(n)]
cur = 1
cnt = 0
while True:
    if cur == 2:
        print(cnt)
        exit()
    elif cnt > n:
        print(-1)
        exit()
    else:
        cur = a[cur - 1]
        cnt += 1


Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long N;
  int K;
  cin >> N >> K;
  vector<int>L(K);
  vector<int>R(K); 
  for(int i = 0; i < K; i++){
    cin >> L[i] >> R[i];
  }
  vector<long long>dp(N+1,0);
  vector<long long>dpsum(N+1,0);
  dp[1] = 1;
  dpsum[1] = 1;

  for(int i = 2; i <= N; i++){
    for(int j = 0;j < K; j++){
      //if(i < R[j])continue;
      dp[i] += dpsum[max(i-L[j],0)] - dpsum[max(i-R[j]-1,0)];
      dp[i] %= 998244353;
    }
    dpsum[i] = dpsum[i-1] + dp[i];
    dpsum[i] %= 998244353;
    //cout << dp[i] << endl;
    //cout << dpsum[i] << endl;
  }
  
if(dp[N] < 0) dp[N] += 998244353;
 cout << dp[N]  << endl;
}
  


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

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    int b[n];
    int c[n-1];
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    for(int i=0;i<n-1;i++) scanf("%d",&c[i]);
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(i!=0 && a[i]==a[i-1]+1) ans+=c[a[i-1]-1];
    }
    printf("%d\n",ans);

}

Measured memory_bytes: 256
def main():
    N, M = map(int, raw_input().split())
    PY = [{"Year": 0, "Pre": 0, "id": idx, "ans": ""} for idx in xrange(1, M + 1)]
    cnt = [0] * (N + 1)
    for i in xrange(M):
        PY[i]["Pre"], PY[i]["Year"] = map(int, raw_input().split())

    PY = sorted(PY, key=lambda ele: ele["Year"])

    for i in xrange(M):
        cnt[PY[i]["Pre"]] += 1
        PY[i]["ans"] = str(PY[i]["Pre"]).zfill(6) + str(cnt[PY[i]["Pre"]]).zfill(6)

    PY = sorted(PY, key=lambda ele: ele["id"])
    for ele in PY:
        print(ele["ans"])


if __name__ == "__main__":
    main()


Measured memory_bytes: 49800