akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7;


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  


    int r;
    cin >> r;
    cout << fixed << setprecision(12);
    double ans = 2 * (3.14159 * r);
    cout << ans;
}

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

int main(){
    char s[3][3];
    int i;
    for(i=0;i<3;i++){
        scanf("%s", s[i]);
    }
    for(i = 0; i < 3; i++)
    {
        printf("%c", s[i][i]);
    }
    
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MIN(a,b) (a<b?a:b)



int main()
{
    long long int i,len,count=0,ans=0;
    char s[200001];
    scanf("%s",&s);
    len = strlen(s);

    //printf("len = %d\n",len);

    for(i=len-1; i>=0; i--) {
        if(s[i]=='B') {
            ans += len-count-i-1;
            //printf("i = %d\n",i);
            //printf("add = %d\n",len-count-i-1);
            count++;
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 384
s = input()
def YYMM(s):
    p = int(s[2:])
    if 1 <= p <= 12:
        return True
    return False

def MMYY(s):
    p = int(s[:2])
    if 1 <= p <= 12:
        return True 
    return False

if YYMM(s) and MMYY(s):
    print('AMBIGUOUS')
elif YYMM(s):
    print('YYMM')
elif MMYY(s):
    print('MMYY')
else:
    print('NA')

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

using namespace std;

long long mpow(long long a, long long b);

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	int ans = 0;
	int s;
	int t;
	for (int i = 0; i < mpow(3, n); i++) {
		s = i;
		t = 1;
		for (int j = 0; j < n; j++) {
			switch (s % 3) {
			case 0:
				t *= a[j] - 1;
				break;
			case 1:
				t *= a[j];
				break;
			case 2:
				t *= a[j] + 1;
				break;
			}
			s /= 3;
		}
		if (t % 2 == 0) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

long long mpow(long long a, long long b)
{
	long long ans = 1;
	while (b != 0) {
		if ((b & 1) == 1) {
			ans *= a;
		}
		a *= a;
		b >>= 1;
	}

	return ans;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

	int n;
	cin >> n;
	vector<int> s(n, 0);

	for (int i = 1; i < n; i++) {
		int a;
		cin >> a;
		a--;
		s[a]++;
	}

	rep(i, n) {
		out(s[i]);
	}


	return 0;
}

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

using namespace std;

const int N = 20;

int main() {
	int n, m = 0;
	int a[N + 1] = { 0 };
	int x, y;
	cin >> n;
	for(int i = 0;i < n;++i) {
		cin >> x >> y;
		a[x] = y;
		m = y > m ? y : m;
	}
	for(int i = 1;i <= N;++i) {
		if(a[i] == m) {
			cout << i << " " << a[i] << endl;
			break;
		}
	}
	return 0;
}



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

int ok(int x,int y,int z){
  if(x<y && y<z){
    return 1;
  }else if(x>y && y>z){
    return 1;
  }else{
    return 0;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  int sum = 0;
  for(int i=1;i<N-1;i++){
    sum += ok(P.at(i-1),P.at(i),P.at(i+1));
  }
  cout << sum << endl;
}

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

using namespace std ;

int n , k ;
int a[1000000] ;
int main ()
{
    cin >> k >> n ;
    for ( int i = 0 ; i < n ; i++ )
    {
        cin >> a[i] ;
    }
    a[n] = a[0] + k ;
    int l = -1 ;
    for ( int i = 0 ; i < n ; i++ )
        l = max ( l , a[i+1] - a[i] ) ;
    cout << k - l ;
    return 0 ;
}


Measured memory_bytes: 1024
from itertools import accumulate

n = int(input())
s = input()

black = [0] * n
white = [0] * n

for i, c in enumerate(s):
    if c == '#':
        black[i] = 1
    else:
        white[i] = 1


black = [0] + black
black = list(accumulate(black))
white = white[::-1]
white = list(accumulate(white))[::-1] + [0]

# print(black, white)

ans = 1e10
for i in range(n+1):
    ans = min(ans, black[i] + white[i])

print(ans)

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

using namespace std;

pair<long, long> d[111111];
long x[111111];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		scanf("%ld%ld", &d[i].first, &d[i].second);
	sort(d, d + n);
	for (int i = 0; i < n; i++) {
		if (i + 1 == n || d[i].first != d[i + 1].first) {
			x[d[i].first - 1] = d[i].second;
			d[i] = {};
		}
		swap(d[i].first, d[i].second);
	}
	sort(d, d + n, greater<pair<long, long>>());
	sort(x, x + n, greater<long>());
	for (int i = 1; i < n; i++)
		d[i].first += d[i - 1].first;
	partial_sum(x, x + n, x);
	long m = 0;
	for (int i = 1; i <= k; i++) {
		if (i > 1 && x[i - 1] == x[i - 2])
			break;
		m = max(m, long(i)*i + x[i - 1] + (i < k ? d[k - i - 1].first : 0));
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int minn=INT_MAX;
int a,b,c,f1[101010],f2[101001],f3[101101];
int n;
 
main()
{
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a >> b >> c;
        f1[i]=max(f2[i-1],f3[i-1])+a;
        f2[i]=max(f1[i-1],f3[i-1])+b;
        f3[i]=max(f1[i-1],f2[i-1])+c;
    }
    cout << max(f1[n],max(f2[n],f3[n]));
}
 

Measured memory_bytes: 1408
s=input().replace("BC","X").replace("B","Y").replace("C","Y")
a=False
ans=0
c=0
for i in "Y"+s+"Y":
	if i=="A":
		a=True
		c+=1
	if i=="X":
		if a:
			ans+=c
	if i=="Y":
		a=False
		c=0
print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> res(n + 1);
	rep(i, n - 1) {
		int a;
		cin >> a;
		a--;
		res[a]++;
	}
	rep(i, n) cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
#define int long long
#define debug(x) cerr << #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<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  ll a,b;
  cin>>a>>b;
  ll n = 0;
  ll dig[1000] = {-1};
  while(true) {
    if((ll)pow(2,n) > b) {
      break;
    }
    ll na = (a >> n) & 1;
    ll nb = (b >> n) & 1;
    if(n == 0) {
      if(na != nb) {
        dig[n] = (b-a+1) / 2 % 2;
      } else {
        if(na == 0) {
          dig[n] = (b-a+1) / 2 % 2;
        } else {
          dig[n] = ((b-a+1) / 2 + 1) % 2;
        }
      }
      n++;
      continue;
    }
    ll cnt = 0;
    if(na == 1) {
      ll tmp = (ll)pow(2,n+1);
      cnt += tmp - (a & (tmp - 1));
    }
    if(nb == 1) {
      ll tmp = (ll)pow(2,n);
      cnt += b - tmp + 1;
    }
    if(cnt % 2 == 0) {
      dig[n] = 0;
    } else {
      dig[n] = 1;
    }
    n++;
  }
  ll ans = 0;
  rep(i,1000) {
    if(dig[i] == -1) break;
    ll num = (ll)pow(2, i);
    ans += num * dig[i];
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 512
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[]a = new int[M];
		int[]b = new int[M];
		Map<Integer, Set<Integer>> map = new HashMap<Integer, Set<Integer>>();
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		sc.close();
		for(int i = 0; i < M; i++) {
			if(map.containsKey(a[i])) {
				map.get(a[i]).add(b[i]);
			}else {
				Set<Integer> set = new HashSet<Integer>();
				set.add(b[i]);
				map.put(a[i], set);
			}
		}
		if(!map.containsKey(1)) {
			System.out.println("IMPOSSIBLE");
			System.exit(0);
		}
		Set<Integer> set = map.get(1);
		for(int i : set) {
			if(map.containsKey(i)) {
				if(map.get(i).contains(N)) {
					System.out.println("POSSIBLE");
					System.exit(0);
				}
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}

Measured memory_bytes: 104164
package main

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

func main() {
	for i := 1; i <= 5; i++ {
		x := nextInt()

		if x == 0 {
			fmt.Println(i)
		}
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 1788
#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 <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
double ans;
double x[101010];
ll y[101010];
ll a[201010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
string u[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;


int main() {
	cin>>N;
	rep(i,0,N){
		cin>>x[i]>>u[i];
		if(u[i][0]=='J'){
			ans+=x[i];
		}else{
			ans+=x[i]*380000;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int a,b,c,d[100005] = {},n,m;
string s,t;

int main(){
    cin >> a >> b;
    
    rep(i,1,4){
        if((a*b*i)&1){
            Yes;
            ret 0;
        }
    }
    No;
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A, B;
    cin >> A;
    B=1000;
    int C;
    while(1){
    C=B-A;
    if(C>=0)break;
    B+=1000;
    }
    cout << C << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A[4],B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(A[0]+A[1]+A[2]+A[3] == 7){
		printf("%d+%d+%d+%d=7\n",A[0],A[1],A[2],A[3]);
	}else if(A[0]+A[1]+A[2]-A[3] == 7){
		printf("%d+%d+%d-%d=7\n",A[0],A[1],A[2],A[3]);
	}else if(A[0]+A[1]-A[2]+A[3] == 7){
		printf("%d+%d-%d+%d=7\n",A[0],A[1],A[2],A[3]);
	}else if(A[0]+A[1]-A[2]-A[3] == 7){
		printf("%d+%d-%d-%d=7\n",A[0],A[1],A[2],A[3]);
	}else if(A[0]-A[1]+A[2]+A[3] == 7){
		printf("%d-%d+%d+%d=7\n",A[0],A[1],A[2],A[3]);
	}else if(A[0]-A[1]+A[2]-A[3] == 7){
		printf("%d-%d+%d-%d=7\n",A[0],A[1],A[2],A[3]);
	}else if(A[0]-A[1]-A[2]+A[3] == 7){
		printf("%d-%d-%d+%d=7\n",A[0],A[1],A[2],A[3]);
	}else{
		printf("%d-%d-%d-%d=7\n",A[0],A[1],A[2],A[3]);
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N;
	A[0] = N/1000;
	A[1] = (N%1000)/100;
	A[2] = (N%100)/10;
	A[3] = N%10;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  ll GCD = gcd(A[0], A[1]);
  for (int i = 2; i < N; i++) {
    GCD = gcd(GCD, A[i]);
  }

  cout << GCD << endl;
  return 0;
}

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

int main() {
	int N;
	string S;
	cin >> N>>S;
	if(N%2==1){
		cout<<"No"<<endl;
	}
	
	else{
		bool pro =true;
		for(int i=0;i<N/2;i++){
			if(S.at(i)!=S.at(i+N/2)){
				pro =false;
				break;
			}
		}
		if(pro){
			cout<<"Yes"<<endl;
		}
		else{
			cout<< "No"<<endl;
		}
	}
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t L[3];
	int N;
	cin >> N;
	L[1] = 2; L[2] = 1;
	for(int i = 0; i < N - 1; i++) {
		L[0] = L[1];
		L[1] = L[2];
		L[2] = L[1] + L[0];
	}
	cout << L[2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

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

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

    if(n == "Sunny")
        cout << "Cloudy" << endl;
    else if(n == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class ABlackjack {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int a, b, c; cin >> a >> b >> c;
      if (a+b+c>=22) {
        cout << "bust" << endl;
      } else {
        cout << "win" << endl;
      }
    }
};

signed main() {
  ABlackjack solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int arr[1000005];
int dp[1000005];
int func(int idx) {
    if(idx==n-1) return 0;
    
    if(idx>=n) return INT_MAX;

    if(dp[idx]!=-1) return dp[idx];
    
    int left=abs(arr[idx]-arr[idx+1])+func(idx+1);
    int right=INT_MAX;
    if(idx+2<n){
        right=abs(arr[idx]-arr[idx+2])+func(idx+2);
    }
    
    return dp[idx]=min(left,right);
}
int main() {
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i{};i<n;i++)
    {
        cin>>arr[i];
    }
    cout<<func(0)<<'\n';
}

Measured memory_bytes: 12552
fun main(args: Array<String>) = IO().exec {
    val x = int()
    println(Math.pow(2.0, x+2.0).toLong()-2)
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31396
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> vec = {a, b, c};
  sort(vec.begin(),vec.end());
  int i = 3;
  if (vec.at(0) == vec.at(1)) {
    i--;
  }
  if (vec.at(1) == vec.at(2)) {
    i--;
  }
  cout << i;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve(){
	string s; cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	long long int ans = 0;
	map<int, int>mp;
	mp[0] = 1;
	long long int cnt = 0;
	int num = 0;
	for (auto i : s) {
		cnt += power(10, num, 2019)*(i - '0');
		cnt %= 2019;
		ans += mp[cnt];
		mp[cnt]++;
		num++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3720
using System;
using System.Linq;
using System.Collections.Generic;
public class Program
{
	public static void Main()
	{
		int[] arr = Console.ReadLine().Split().Select(i => int.Parse(i))
		.ToArray();
		int n = arr[0];
		int t = arr[1];
		var queue = new Queue<Process>();
		for (int i = 0; i < n; i++)
		{
			string[] input = Console.ReadLine().Split();
			queue.Enqueue(new Process(input[0], int.Parse(input[1])));
		}
		int time = 0;
		while (queue.Any())
		{
			var q = queue.Dequeue();
			int distance = Math.Min(t, q.Time);
			time += distance;
			q.Time -= distance;
			if (q.Time == 0)
			{
				Console.WriteLine("{0} {1}", q.Name, time);
			}
			else
			{
				queue.Enqueue(new Process(q.Name, q.Time));
			}
		}
	}
}

public class Process
{
	public Process(string name, int time)
	{
		this.Name = name;
		this.Time = time;
	}
	
	public string Name;
	public int Time;
}

Measured memory_bytes: 17860
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        try (PrintWriter writer = new PrintWriter(System.out); InputReader reader = new InputReader(System.in)) {
            int[] inputs = reader.readIntsSplitByDelimiter(" ");
            int tmp = inputs[2] - inputs[0];
            if (tmp >= 0 && tmp <= inputs[1]) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.br.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.br.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.br.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.br.readLine().split(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

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

Measured memory_bytes: 22484
#include<iostream>
using namespace std;
long long mas[5005];
void getZarr(string str)
{
    long long n = str.length();
    long long L, R, k;
    L = R = 0;
    for (long long i = 1; i < n; ++i)
    {
        if (i > R)
        {
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            mas[i] = R-L;
            R--;
        }
        else
        {
            k = i-L;
            if (mas[k] < R-i+1)
                mas[i] = mas[k];
            else
            {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                mas[i] = R-L;
                R--;
            }
        }
    }
}
bool srch(string concat,long long r)
{
    long long l = concat.length();
    getZarr(concat);
    for (long long i = 0; i < l; ++i)
    {
        if (mas[i] == r)
            return 1;
    }
    return 0;
}
int main()
{
    long long n,ans=0;
    string a,b;
    cin>>n>>a;
    for(long long i=0; i<n; i++){
        for(long long j=ans;; j++){
            if(j>=a.size()) break;
            b=a;
            b.insert(b.begin()+j+1,'#');
            if(srch(b,j+1)){
                ans++;
            }else{
                break;
            }
        }
        a.erase(a.begin());
    }
    cout<<ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;
typedef long long ll;
const int maxn = 1e7+5;
int a[5][5],b[13],vis[5][5];
int main(){
	int n,flag=0;
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			cin>>a[i][j];
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=3;j++)
			for(int k=1;k<=3;k++)
				if(b[i]==a[j][k]) vis[j][k]=1;
	for(int i=1;i<=3;i++)
		if(vis[i][1]==1&&vis[i][2]==1&&vis[i][3]==1) flag=1;
	for(int i=1;i<=3;i++)
		if(vis[1][i]==1&&vis[2][i]==1&&vis[3][i]==1) flag=1;
	if(vis[1][1]==1&&vis[2][2]==1&&vis[3][3]==1) flag=1;
	if(vis[1][3]==1&&vis[2][2]==1&&vis[3][1]==1) flag=1;
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

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

  if(n % 2 == 1) { cout<<"No"<<endl; return 0; }
  for(int i = 0;  i < n/2; i++){
     if(s[i] != s[i+n/2]) {cout<<"No"<<endl; return 0;}
  }

  cout << "Yes" << endl;

  return 0;
}
    

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

int asc(const void* a, const void* b) {
    return *(int*)b - *(int*)a;
}
int main() {
    char str[110] = { 0 };
    int flag = 1;
    scanf("%s", str);
    for (int i = 0; i < strlen(str); i++) {
        if ((i + 1) % 2 == 1) {
            if (str[i] == 'L') {
                //printf("No");
                //return 2;
                flag = 0;
                break;
            }
        }
        else {
            if (str[i] == 'R') {
               // printf("No");
                //return 2;
                flag = 0;
                break;
            }
        }
    }
    if (flag) printf("Yes");
    else printf("No");
    return 0;
}



Measured memory_bytes: 128
n=int(input())
ans=1
MO=10**18
c=0
l=list(map(int,input().split()))
for i in range(n):
  ans*=l[i]
  if ans>MO:
    c=1
    break
if 0 in l:
  print(0)
elif c==0:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 21668
#include<iostream>
using namespace std;
int main()
{
    long long x,a,b,ans,c;
    cin>>x>>a>>b;
    ans=x-a;
    c=ans/b;
    if(ans%b==0)
    cout<<"0"<<endl;
    else cout<<x-a-b*c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    ll a;cin>>a;
    map<ll,ll>m;
    map<ll,ll>m2;
    vector<ll>c(0);
    ll sum=a;
    m[a]=1;
    m2[a]=0;
    c.pb(a);
    rep(i,n-1){
        ll b;cin>>b;
        sum+=b;
        if(m.find(b)==m.end()){
            m[b]=1;
            m2[b]=i+1;
            c.pb(b);
        }else{
            m[b]++;
        }
    }
    sort(all(c));
    reverse(all(c));
    vector<ll>ans(n);
    ll cnt=0;
    ll cnt2=0;
    c.pb(0);
    m2[0]=inf;
    rep(i,c.size()-1){
        cnt+=m[c[i]];
        ll s=m2[c[i]];
        ll t=m2[c[i+1]];
        ans[s]+=(c[i]-c[i+1])*cnt;
        m2[c[i+1]]=min(s,t);
        cnt2+=(c[i]-c[i+1])*cnt;
    }
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 15092
import java.util.*;

public class Main {

    static boolean hasCycle = false;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int p = sc.nextInt();
        int[][] e = new int[m][3];
        for (int i = 0; i < m; i++) {
            e[i][0] = sc.nextInt()-1;
            e[i][1] = sc.nextInt()-1;
            e[i][2] = -sc.nextInt() + p;
        }
        long[] d = bellmanFord(n, e, 0);
        System.out.println(hasCycle || d[n-1] == Long.MAX_VALUE ? -1 : Math.max(-d[n-1], 0));
        sc.close();

    }

    public static long[] bellmanFord(int n, int[][] edge, int s){
        long d[] = new long[n];
        Arrays.fill(d, Long.MAX_VALUE);
        d[s] = 0L;
        for (int i = 0; i < n-1; i++) {
            for(int j = 0; j < edge.length; j++){
                int[] e = edge[j];
                if(d[e[0]] != Long.MAX_VALUE && d[e[1]] > d[e[0]] + e[2]){
                    d[e[1]] = d[e[0]] + (long)e[2];
                }
            }
        }
        long[] dCopy = Arrays.copyOf(d, n);
        for (int i = 0; i < n-1; i++) {
            for(int j = 0; j < edge.length; j++){
                int[] e = edge[j];
                if(d[e[0]] != Long.MAX_VALUE && d[e[1]] > d[e[0]] + e[2]){
                    d[e[1]] = d[e[0]] + (long)e[2];
                }
            }
        }
        if(d[n-1] < dCopy[n-1]) hasCycle = true;
        return dCopy;
    }

}


Measured memory_bytes: 40348
#include <stdio.h>
#include <string.h>
 
int main(){
  char str[256];
  char put[256];
  int  a,b,i,n, length;
     
  scanf("%d ", &n);
     
  while(n--){
    for(a = 0; a < 256; a++)
      str[a] = 0;
     
    fgets(put, sizeof(put), stdin);
         
    length = strlen(put);
         
    for(a = 1; a < 26; a += 2){
      if(a%13==0)
	continue;
      for(b = 0; b < 26; b++){
	for(i = 0; i < length; i++){
	  if(put[i] >= 'a' && put[i] <= 'z')
	    str[i] = ((a * (put[i] - 'a') + b) % 26) + 'a';
	  else
	    str[i] = put[i];
	}
	if(strstr(str,"that")||strstr(str,"this")){
   printf("%s", str);
	  goto end;
	}
      }
    }
  end:;
  }
  return 0;
}

Measured memory_bytes: 1744
a,b=map(int,input().split())
c=[0]+list(map(int,input().split()))

d=set()
e=[]
mir=1
while 1:
  if mir in d:
    g=e.index(mir)
    f=e[g:]
    e=e[:g]
    break
  else:
    d.add(mir)
    e.append(mir)
    mir=c[mir]
if b<len(e):
  print(e[b])
else:
  b=b-len(e)
  print(f[b%(len(f))])
  

Measured memory_bytes: 127768
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,d,m,c;

int main(){
  while(1){
    vector<int> v[N];
    cin>>n>>d;
    if(!n&&!d)break;
    for(int i=0;i<n;i++){
      cin>>m;
      int sum=0;
      for(int j=0;j<m;j++){
	cin>>c;
	sum+=c;
	v[i].push_back(sum);
      }
      v[i].push_back(sum);
    }
    bool ans=true;
    for(int i=0;i<n;i++){
      for(int j=0;j<v[i].size()-1;j++){
	for(int k=0;k<n;k++){
	  if(i==k)continue;
	  vector<int>::iterator r;
	  r=lower_bound(v[k].begin(),v[k].end(),v[i][j]);
	  if(r==v[k].end())r--,r--;
	  if(abs(v[i][j]-(*r))>d&&abs(v[i][j+1]-(*(r-1)))>d)
	    ans=false;
	}
      }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        int g = 0;
        for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
            g = __gcd(g, x);
        }
        cout << g << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list()
for i in range(N):
    S.append(input())

sorted_S = sorted(S)
count = [0]*N

index_str = sorted_S[0]
index_num = 0

for i in range(N):
    if sorted_S[i] == index_str:
        count[index_num] += 1
    else:
        index_str = sorted_S[i]
        index_num = i

        count[i] += 1

max_num = max(count)

tousen = list()
for i in range(N):
    if count[i] == max_num:
        tousen.append(sorted_S[i])

sorted_tousen = sorted(tousen)
num_of_tousen = len(sorted_tousen)

for i in range(num_of_tousen):
    print(sorted_tousen[i])

Measured memory_bytes: 25412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
struct edge{
    ll p;//点
    ll w;//辺の重み*-1
};
vector<vector<edge> > graph(100000);
vector<ll> res(100000);
ll v,e,r;//vは頂点,eは辺,rは始点
void dijkstra(){
  for(int i = 0;i < v;i++)res[i] = pow(10,18);
    res[r] = 0;
    priority_queue<pair<ll,ll> > que;//重み、頂点
    que.push(make_pair(0,r));
    while(!que.empty()){
        edge now;
        now.p = que.top().second;
        now.w = que.top().first * -1;
        que.pop();
        if(res[now.p] < now.w)continue;
        for(int i = 0;i < (int)graph[now.p].size();i++){
            if(res[graph[now.p][i].p] > now.w + graph[now.p][i].w){
                res[graph[now.p][i].p] = now.w + graph[now.p][i].w;
                que.push(make_pair(res[graph[now.p][i].p] * -1,graph[now.p][i].p));
            }
        }
    }
}
int main(){
  cin >> v;
  e = v - 1;
    for(int i = 0;i < e;i++){
        ll a,b;
        cin >> a >> b;//マイナスするか?気をつける
        a--,b--;
        edge memoa = {b,1};
        edge memob = {a,1};
        graph[a].push_back(memoa);
        graph[b].push_back(memob);//無向グラフのときはこれを追加
    }
  
  r = 0;
  dijkstra();
  vector<ll> fennec(v);
  for(int i = 0;i < v;i++)fennec[i] = res[i];
  
  r = v - 1;
  dijkstra();
  vector<ll> snuke(v);
  for(int i = 0;i < v;i++)snuke[i] = res[i];
  
  ll fk = 0;
  ll sk = 0;
  for(int i = 0;i < v;i++){
    if(fennec[i] <= snuke[i])fk++;
    else sk++;
  }
  //cout << fk << " " << sk << endl;
  if(fk > sk)cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
}

Measured memory_bytes: 12740
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int n,q,c[500010],ans[500010],pos[500010],bit[500010];
vector<pair<int,int> > v[500010];

inline int sum(int p)
{
	int s=0;
	while(p>0){
		s+=bit[p];
		p-=p&(-p);
	}
	return s;
}

inline void add(int p,int v)
{
	while(p<=n){
		bit[p]+=v;
		p+=p&(-p);
	}
}

signed main()
{
	cin>>n>>q;
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	for(int i=1;i<=q;i++){
		int l,r;scanf("%d%d",&l,&r);
		v[r].push_back(make_pair(l,i));
	}
	for(int i=1;i<=n;i++) pos[i]=-1;
	for(int i=1;i<=n;i++){
		if(pos[c[i]]==-1){
			add(i,1);
			pos[c[i]]=i;
		}
		else{
			add(pos[c[i]],-1);
			add(i,1);
			pos[c[i]]=i;
		}
		for(int j=0;j<v[i].size();j++){
			ans[v[i][j].second]=sum(i)-sum(v[i][j].first-1);
		}
	}
	for(int i=1;i<=q;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 33208
import collections

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

n = int(input())
s = p(n)
c = collections.Counter(s)
t = list(c.values())
m = 0

for x in t:
    
    a = 1

    for j in range (100):
        if (x - a >= 0):
            x = x - a
            m = m + 1
            a = a + 1
        else:
            break

print(m)

Measured memory_bytes: 9468
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;
	pair<long long,long long> p[n];
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		p[i]=(make_pair(a,1));
	}
	sort(p,p+n);
	pair<long long,long long> tmp=p[0];
	for(int i=1;i<n;i++){
		if((tmp.first+p[i].first*tmp.second)%2==0){
			tmp=(make_pair((tmp.first+p[i].first*tmp.second)/2,tmp.second));
		}
		else{
			tmp=(make_pair((tmp.first+p[i].first*tmp.second),tmp.second*2));
		}
	}
	long double ans=tmp.first;
	ans=ans/tmp.second;
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a, b, x,z=0;
	cin>>a>>b>>x;

		
 			if (1<=x){
				
					for(int i=a;i<=b;i++)
					z=(b/x)-(a/x);
					if(a%x==0){
						z++;
						cout<<z;
					}
				
				else {
					cout<<z;
				}

			}
		
	return 0;		
}

Measured memory_bytes: 256
require "matrix"
  iR,iC=$stdin.gets.split.map(&:to_i)
  arr=[]
  iR.times do |n|
    arr<<$stdin.gets.split.map(&:to_i)
  end
  mx=Matrix.rows(arr)
  total=0
  iR.times do |n|
    r=mx.row(n).to_a
    print r.join(" ") + " " + r.sum.to_s + "\n"
    total+=r.sum
  end
  iC.times do |n|
    c=mx.column(n).to_a
    print c.sum.to_s + " "
  end
  puts total


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,L;
vector<pair<int,int>> E[303];

ll dp[303][303];
int cost[303][303];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>N>>M>>L;
	FOR(x,N) FOR(y,N) dp[x][y]=(x==y?0:1LL<<60);
	FOR(i,M) {
		cin>>x>>y>>r;
		dp[x-1][y-1]=dp[y-1][x-1]=r;
	}
	
	FOR(r,N) FOR(x,N) FOR(y,N) dp[x][y]=min(dp[x][y],dp[x][r]+dp[r][y]);
	FOR(x,N) FOR(y,N) cost[x][y]=(x==y)?0:(dp[x][y]<=L?1:(1LL<<20));
	FOR(r,N) FOR(x,N) FOR(y,N) cost[x][y]=min(cost[x][y],cost[x][r]+cost[r][y]);
	
	int Q;
	cin>>Q;
	while(Q--) {
		cin>>x>>y;
		x--,y--;
		if(cost[x][y]>=1000) cout<<-1<<endl;
		else cout<<cost[x][y]-1<<endl;
		
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

void trace(int A[], int N){
  int i;
  for(i = 0; i< N; i++){
    if(i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N){
  int j, i, v;
  for(i = 1; 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;
    trace(A, N);
  }
}

int main(){
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for(i = 0; i < N; i++) scanf("%d", &A[i]);
  
  trace(A, N);
  insertionSort(A, N);

  return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    int a,b;
    cin>>a>>b;

    if((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<((a+b)/2+1)<<endl;
}

Measured memory_bytes: 256