akhauriyash/Code-Regression huggingface dataset:
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    V<PLL> changes(3);
    for(auto &ele : changes) cin >> ele.first;
    for(auto &ele : changes) cin >> ele.second;

    ll max_d = N;

    for(ll loops = 0; loops <= 1; loops++) {
        V<ll> dp(max_d + 10, 0);
        for(ll i = 0; i < max_d; i++) {
            chmax(dp[i + 1], dp[i] + 1);
            for(ll j = 0; j < 3; j++) {
                ll a, b;
                tie(a, b) = changes[j];
                if(loops) swap(a, b);
                if(i + a > max_d) continue;
                chmax(dp[i + a], dp[i] + b);
            }
        }
        max_d = dp[max_d];
    }

    cout << max_d << endl;
    return 0;
}


Measured memory_bytes: 195584
#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, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<P> lr(q);
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    lr[i] = make_pair(l, r);
  }

  vector<int> sum(n, 0);
  for (int i = 0; i < n - 1; ++i) {
    string cur = s.substr(i, 2);
    if (cur == "AC") {
      if (i == 0) {
        sum[i] = 1;
      } else {
        sum[i] = sum[i - 1] + 1;
      }
    } else {
      sum[i] = sum[i - 1];
    }
//    cout << "sum[" << i << "] = " << sum[i] << endl;
  }
  rep(i, q) {
    int l = lr[i].first;
    int r = lr[i].second;
    int res = sum[r - 1] - sum[l - 1];
    cout << res << endl;
  }

  return 0;
}


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

using namespace std;

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

    int s1 = 0;
    int s2 = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        s1 += a;
        s2 += a * a;
    }

    int x1 = s1 / n;
    int x2 = x1 + 1;

    if (abs(n * x2 - s1) < abs(n * x1 - s1)) x1 = x2;

    int ans = (n * x1 - 2 * s1) * x1 + s2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


ll gcd(ll a, ll b) {
    ll r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}





int main() {

    int N; cin >> N;
    ll T[N];
    rep(i,N) cin >> T[i];
    ll ans = T[0];
    rep(i,N) ans = lcm(ans, T[i]);
    out(ans);

    

    return 0;
}






Measured memory_bytes: 256
from fractions import gcd
N, M = map(int, input().split())
A = list(map(lambda x: int(x)//2, input().split()))


def num_of_2(x):  # xがもつ素因数2の個数を返す
    c = 0
    while x % 2 == 0:  # まだ2で割り切れるようなら続ける
        c += 1
        x //= 2
    return c


a0 = num_of_2(A[0])
if all([num_of_2(a) == a0 for a in A]):  # 素因数2の個数が全て等しいなら処理をする
    def lcm(x, y):
        return (x*y) // gcd(x, y)  # 2つの数字の積を2つの数字の最大公約数で割ると2つの数字の最小公倍数が分かる

    c = 1
    for a in A:
        c = lcm(a, c)
        if c >= 10**18:
            break

    ans = M // c
    print((ans+1)//2)  # 奇数倍のものだけ欲しいから？

else:  # 素因数2の個数が等しくないものがある場合は0を出力
    print(0)


Measured memory_bytes: 16348
//I love Nanami Chiaki
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if (a>b) swap(a,b);
	if (a%2==b%2) cout<<(b-a)/2<<endl;
	else{
		ll ans1=a;
		ans1+=(b-ans1-1)/2;
		ll ans2=(n-b+1);
		ans2+=(n-(a+ans2))/2;
		cout<<min(ans1,ans2);
	}
	return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n, m, k = map(int, input().split())

MOD = 10 ** 9 + 7
N = n * m + 10
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
    fact[i] = fact[i - 1] * i % MOD

invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)

for i in range(N - 2, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % MOD
def nCk(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return fact[n] * invfact[k] * invfact[n - k] % MOD
        
ans = 0
for i in range(n-1, 0, -1):
    ans += m * m * (i + 1) * i // 2 
    ans %= MOD
for i in range(m - 1, 0, -1):
    ans += n * n * (i + 1) * i // 2
    ans %= MOD

ans *= nCk(n * m - 2, k - 2)
ans %= MOD
print(ans)

Measured memory_bytes: 24656
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

階級	体重（kg）
light fly	48.00kg 以下
fly	48.00kg 超51.00kg 以下
bantam	51.00kg 超54.00kg 以下
feather	54.00kg 超57.00kg 以下
light	57.00kg 超60.00kg 以下
light welter	60.00kg 超64.00kg 以下
welter	64.00kg 超69.00 kg 以下
light middle	69.00kg 超75.00 kg 以下
middle	75.00kg 超81.00 kg 以下
light heavy	81.00kg 超91.00 kg 以下
heavy	91.00kg 超

*/
const double bclass[] = { 0., 48.00, 51.00, 54.00, 57.00, 60.00, 64.00, 69.00, 75.00, 81.00, 91.00, 1e100 };
const string bname[] = { "light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy" };

int main()
{
//	cut here before submit 
//	freopen ("testcase.class", "r", stdin );
	double w;
	int n = sizeof (bclass ) / sizeof (bclass[0] );

	while (scanf ("%lf", &w ) != EOF ){
		rep (i, n-1 ){
			if (w > bclass[i] && w <= bclass[i+1] ){
				cout << bname[i] << endl;
				break;
			} // end if
		} // end rep
	} // end loop
		
	return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;


int main()
{
    ll* A = new ll[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);
    cout << A[2] * 10 + A[1] + A[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        double X = scanner.nextDouble();

        double doubleSqrt = Math.sqrt(X);
        int sqrt = (int) Math.floor(doubleSqrt);

        int ans = 1;

        if (sqrt<2){
            System.out.println(ans);
            return;
        }

        for (int i = 2; i <= sqrt; i++) {
            int accum = i;
            while (true){
                accum*=i;
                if (accum>X){
                    break;
                }
                if (ans<accum) ans = accum;
            }
        }
        System.out.println(ans);

        scanner.close();
    }
}


Measured memory_bytes: 23124
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        a: i64
    }

    println!("{}", a + a*a + a*a*a);
}


Measured memory_bytes: 2124
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N;
	cin >> N;
	string W[101];
	bool ans = true;
	for (int i = 0; i < N; ++i) {
		cin >> W[i];
	}
	for (int i = 0; i < N-1; ++i) {
		if (W[i][W[i].size() - 1] != W[i + 1][0])
			ans = false;
		for (int j = i + 1; j < N; ++j) {
			if (W[i] == W[j])
				ans = false;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

namespace ConsoleApplication1
{    

    class Program
    {
        const int Inf = int.MaxValue;

        static void Solve(int first)
        {
            int cnt = 0;
            int u = first;
            int v = 0;
            int s = 0;
            int m = Inf;             

            while (true)
            {
                V[u] = true;
                v = A[u];              
                cnt++;
                s += v;
                u = T[v];
                m = Math.Min(m, v);
                
                if (V[u])
                {                    
                    break;
                }
            }          
            ans += Math.Min(s + (cnt - 2) * m, s + m + (cnt + 1) * x);          
        }

        static int[] T; 
        static bool[] V;
        static int[] B;
        static int[] A; 
        static int ans;
        static int x;
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            A = new int[n];
            B = new int[n];
            V = new bool[n];
            int maxindex = 0;
            x = Inf;

            string[] input = Console.ReadLine().Split(' ');

            int a = 0;
            for(int i = 0; i < n; i++)
            {
                a = int.Parse(input[i]);
                A[i] = a;
                B[i] = a;
                V[i] = false; 
                if(maxindex < a)
                {
                    maxindex = a;
                }
                if(x > a)
                {
                    x = a;
                }
            }

            T = new int[maxindex + 1];

            Array.Sort(B);
           
            for(int i = 0; i < n; i++)
            {
                T[B[i]] = i;
            }

            
            ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (!V[i])
                {
                    Solve(i);
                }           
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 18016
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int c[4] = {};
	for (int i = 0; i < n; i++) {
		string test;
		cin >> test;
		if (test == "AC") {
			c[0]++;
		}
		else if (test == "WA") {
			c[1]++;
		}
		else if (test == "TLE") {
			c[2]++;
		}
		else if (test == "RE") {
			c[3]++;
		}
	}
	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;

    return 0;
}

Measured memory_bytes: 3564
h,w,m=map(int,input().split())
h=[]
w=[]
for i in range(m):
  h_,w_=map(int,input().split())
  h.append(h_)
  w.append(w_)
from collections import Counter
dic_h=Counter(h)
dic_w=Counter(w)
max_h=max(dic_h.values())
max_w=max(dic_w.values())

h_set=set()
w_set=set()
for i in dic_h:
  if dic_h[i]==max_h:
    h_set.add(i)
for j in dic_w:
  if dic_w[j]==max_w:
    w_set.add(j)

cnt=0
for i in range(m):
  if h[i] in h_set and w[i] in w_set:
    cnt+=1
if len(h_set)*len(w_set)>cnt:
  print(max_h+max_w)
else:
  print(max_h+max_w-1)
  
  


Measured memory_bytes: 220640
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

using Graph = vector<vector<int>>;

int re[100];
int ans = 0;
void dfs(Graph& G,int a,int n){
    if(re[a] == 1 ) return;
    re[a] = 1;
    int sum = 0;
    rep(i,n){
        if(re[i] == 1){
            sum++;
        }
    }
    if(sum == n) ans++;
    for(auto x : G[a]){
        if(re[x] == 1) continue;
        dfs(G,x,n);
        re[x] = 0;
    }
}

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

    int n;
    cin >> n;
    vector<P> p(n);
    rep(i,n){
        int x,y;
        cin >> x >> y;
        p[i] = make_pair(x+y,x-y);

    }
    sort(all(p));
    int ans = 0;
    int cur = -INF;
    rep(i,n){
        if(cur <= p[i].second){
            ans++;
            cur = p[i].first;
        }
    }
    cout << ans << endl;

    cout << endl;
    return 0;
}


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

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


		if( a < b )
		{
		cout << "a < b" << endl;
		}else{
			if( a > b)
			{
			cout << "a > b" << endl;
			}else{
			
		    cout << "a == b" << endl;
			
			
			}
		}


}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include<ctime>
#define ll long long
using namespace std;
const int maxn=3e5+5;
ll a[maxn],xsum[maxn],sum[maxn];
int main(){
	srand((unsigned)time(0));
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		//xsum[i]=xsum[i-1]^a[i];
		//sum[i]=sum[i-1]+a[i];
	}
	
	
	ll l=1,r=1,sum=a[1],ans=0;
	while (r<=n){
		while (r<n&&(sum^a[r+1])==(sum+a[r+1]) ) r++,sum+=a[r];
		ll len=r-l+1;
		ans+=len*(len+1)/2;
		r++;
		if (r>n) break;
		while (l<=r && (sum^a[r])!=(sum+a[r])) sum-=a[l],l++;
		sum+=a[r];
		if (l<r){
			len=r-l;
			ans-=len*(len+1)/2;
		}//减去重合的区间，避免重复计算 
	}
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
    if (a < b)
        return gcd(b, a);
    else if (a % b)
        return gcd(b, a % b);
    else
        return b;
}
int main()
{
    int n;
    cin>>n;
    int V[n],C[n];
    for(int i=0; i<n; i++){
        cin>>V[i];
    }
    for(int i=0; i<n; i++){
        cin>>C[i];
    }
    int sum=0;
    for(int i=0; i<n; i++){
        if(V[i]-C[i]>0)sum+=(V[i]-C[i]);
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<map>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include <time.h>
#include<cmath>
#include<limits.h>
#include<unordered_map>
#include <set>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#define PI 3.14159265
using namespace std;
const int N = 1e6 + 1;


int main() {
    int k; string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;
        return 0;
    }
    string res = "";
    for (int i = 0; i < k; i ++) {
        res += s[i];
    }
    cout << res + "..." << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  vector<int> vec(n);
  int p=1;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
    p*=3;
  }
  int ans=1;
  for(i=0;i<n;i++){
    if(vec.at(i)%2==0){
      ans=ans*2;
    }
  }
  cout << p-ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
int hoge,how,cara,red=0,green=0,blue=0,white=0;

scanf("%d",&how);

for(hoge=0;hoge<how;hoge++){
scanf("%s",&cara);
switch(cara){
case 'P':red= 1;break;
case 'W':green = 1;break;
case 'G':blue = 1;break;
case 'Y':white = 1;break;
}
}

switch(red+green+blue+white){
case 1:printf("One");break;
case 2:printf("Two");break;
case 3:printf("Three");break;
case 4:printf("Four");break;
}
return 0;
}

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


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  int count = 0;
  rep(i,n) cin >> h[i];
  for (int x : h){
    if (x >= k) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
vector<int> Tree[100005];
int dp1[100005], dpN[100005];
typedef pair<int, int> P;

void bfs(int start, int dp[100005]) {
  queue<P> que;
  que.push(P(start, 0));
  while(!que.empty()) {
    P q = que.front();que.pop();
    dp[q.first] = q.second;
    for (auto p: Tree[q.first]) {
      if (dp[p]<0) que.push(P(p, q.second+1));
    }
  }
}



int main() {
  INCANT;
  cin >> N;
  int a,b;
  rep(i, N-1) {
    cin >> a >> b;
    a--;b--;
    Tree[a].push_back(b);
    Tree[b].push_back(a);
  }
  rep(i, N) {
    dp1[i]=-1;
    dpN[i]=-1;
  }
  bfs(0, dp1);
  bfs(N-1, dpN);
  bool flag = false;
  int cnt=0;
  rep(i, N) {
    if (dp1[i]<=dpN[i]) cnt++;
  }
  string ans = cnt > N-cnt?"Fennec":"Snuke"; //-1番目の人の勝敗
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 6784
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
ll vis[100001];
vector<ll> adj[100001];
ll ans[100001];
void solve()
{
    ll n,m;cin>>n>>m;
    for(ll i=1;i<=m;i++)
    {
        ll a,b;cin>>a>>b;
//        cout<<"a= "<<a<<" b= "<<b<<endl;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    queue<ll> q;
    vis[1]=1;
    q.push(1);
    while(q.size()!=0)
    {
        ll parent=q.front();q.pop();
        for(auto it:adj[parent])
        {
            if(vis[it]==0)
            {
                vis[it]=1;
                ans[it]=parent;
                q.push(it);
            }
        }
    }
    bool flag=false;
    for(ll i=1;i<=n;i++)
    if(vis[i]==0){
        flag=true;
        break;
    }
    if(flag)
        cout<<"No\n";
    else
    {
        cout<<"Yes\n";
        for(ll i=2;i<=n;i++)
            cout<<ans[i]<<endl;
    }
    return;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//    ios_base::sync_with_stdio(false);
        solve();
    return 0;
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool IsPrime[300050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 1; i <= 300000; i++) IsPrime[i] = true;
    for(int i = 2; i <= 300000; i++) {
        if(!IsPrime[i]) continue;
        if(i % 7 != 1 && i % 7 != 6) continue;
        for(int j = i * 2; j <= 300000; j += i) IsPrime[j] = false;
    }
    while(true) {
        int n;
        cin >> n;
        if(n == 1) break;
        cout << n << ":";
        for(int i = 2; i <= n; i++) {
            if(i % 7 != 1 && i % 7 != 6) continue;
            if(!IsPrime[i]) continue;
            if(n % i != 0) continue;
            cout << " " << i;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3364
package main

import "fmt"

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

	l := make([]int, m)
	r := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&l[i], &r[i])
	}

	lmax := 0
	rmin := n + 1
	for i := 0; i < m; i++ {
		if l[i] > lmax {
			lmax = l[i]
		}
		if r[i] < rmin {
			rmin = r[i]
		}
	}

	cnt := 0
	for i := 1; i <= n; i++ {
		if lmax <= i && i <= rmin {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 7168
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main() {
    ll n,k; cin >> n >> k;
    vl a(n),f(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n) cin >> f[i];
    sort(all(a));
    sort(rall(f));
    ll left = -1;
    ll right = 1e12;
    while(right - left > 1){
        ll mid = (left + right) / 2;
        ll cnt = 0;
        rep(i,n){
            cnt += max(0LL,(a[i]*f[i]-mid+f[i]-1)/f[i]);
        }
        if(cnt > k){
            left = mid;
        }else {
            right = mid;
        }
    }
    cout << right << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<vector<ll>> as(2, vector<ll>(N));
  for (auto i = 0; i < 2; i++) {
    for (auto j = 0; j < N; j++) {
      cin >> as[i][j];
    }
  }

  for (auto i = 1; i < N; i++) {
    as[0][i] += as[0][i-1];
  }
  as[1][0] += as[0][0];
  for (auto i = 1; i < N; i++) {
    as[1][i] += max(as[1][i-1], as[0][i]);
  }

  cout << as[1][N-1] << endl;

  return 0;
}


Measured memory_bytes: 256
O=->*a{$>.<<("%s %d\n"%a).flush};A=->n{O[??,n];gets.chop=='Y'};P=->n{O[?!,n];exit};A[i=10**9]?(i=1;loop{A[i*2]&&P[i];i*=10}):loop{A[i]&&P[(i+1..i*10-1).bsearch{|e|A[e*10+9]}];i/=10}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::string s, long long k){
    Vi a;
    int now=1,ans=0;
    if(s.size()==1){cout<<k/2<<endl;return;}
    REP(i,1,s.size()){
        if(s[i]==s[i-1]){
            now++;
        }else{
            a.pb(now);
            now=1;
        }
        if(i==s.size()-1) a.pb(now);
    }
    if(a.size()==1){
        cout<<(s.size()*k)/2<<endl;
        return;
    }
    if(s[0]!=s[s.size()-1]) REP(i,0,a.size()) ans += (a[i]/2)*k;
    else{
        REP(i,1,a.size()-1) ans += (a[i]/2)*k;
        ans += a[0]/2;
        ans += a[a.size()-1]/2;
        ans += (a[0]+a[a.size()-1])/2*(k-1);
    }
    cout<<ans<<endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::string S;
    std::cin >> S;
    long long K;
    scanf("%lld",&K);
    solve(S, K);
    return 0;
}


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

typedef long long ll;
int N;
int A[16][16];
ll SA[1<<17];
ll dp[1<<17];

int main()
{
    cin >> N;
    for(int y = 0; y < N; y++)
    for(int x = 0; x < N; x++) cin >> A[y][x];
    int mask;
    memset(SA, 0, sizeof(SA));
    for(mask = 0; mask < 1<<N; mask++)
    {
        for(int y = 0; y < N; y++)
        for(int x = y + 1; x < N; x++) 
        if((mask&(1 << y)) && (mask&(1 << x))) SA[mask] += A[y][x];
        dp[mask] = -1LL<<60;
    }
    dp[0] = 0;
    for(mask = 0; mask < 1<<N; mask++)
    {
        int first;
        for(first = 0; first < N; first++) if((mask&(1<<first)) == 0) break;
        int submask =((1<<N)-1)^mask^(1<<first);
        for(int sm2=submask; sm2 >= 0; sm2--)
        {
            sm2 &= submask;
            dp[mask | sm2 | (1<<first)] = max(dp[mask | sm2 | (1<<first)], dp[mask] + SA[sm2 | (1<<first)]);
        }
    }
    cout << dp[(1<<N)-1] <<endl;
}

Measured memory_bytes: 1792
/*
    WRITER:kakitamasziru/OxOmisosiru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    //n!はi = 1;i<=nでする
    for (long long i = n-r+1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    string S;cin >> S;
    if(S.at(0) == '7' || S.at(1) == '7' || S.at(2) == '7' ){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    vector<vector<int>> v(n+1, vector<int>(10));

    for(int i=n-1; i>0; i--){
        int t = s[i] - '0';
        v[i-1][t]++;
        rep(j, 10) v[i-1][j] += v[i][j];
    }

    //debug
    /*
    rep(i, n){
        cout << "i = " << i << endl;
        rep(j, 10){
            cout << v[i][j] << ", ";
        }
        cout << endl;
    }
    */

    int ans = 0;

    vector<bool> used(10);
    rep(i, n-2){
        int t = s[i] - '0';
        if(used[t]) continue;
        used[t] = true;

        vector<bool> used2(10);
        for(int j=i+1; j<n-1; j++){
            int u = s[j] - '0';
            if(used2[u]) continue;
            used2[u] = true;
            rep(k, 10) ans += (v[j][k] != 0);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2432
// Copyright lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair<long long, long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, j, k)  for (register int i = (int)(j); i <= (int)(k); i++)
#define rrep(i, j, k) for (register int i = (int)(j); i >= (int)(k); i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}

const int maxn = 100100;
int n, mod;
vector<int> G[maxn];
int f[maxn], g[maxn];
int pre[maxn], suf[maxn];

inline void dfs(int u, int pa) {
  f[u] = 1;
  rep(i, 0, G[u].size() - 1) {
    int v = G[u][i];
    if (v == pa) continue;
    dfs(v, u);
    f[u] = f[u] * 1ll * (f[v] + 1) % mod;
  }
}

inline void dfs2(int u, int pa) {
  int m = 0;
  pre[0] = 1;
  rep(i, 0, G[u].size() - 1) {
    int v = G[u][i];
    if (v == pa) continue;
    m++; pre[m] = pre[m - 1] * 1ll * (f[v] + 1) % mod;
  }
  suf[m + 1] = 1;
  rrep(i, G[u].size() - 1, 0) {
    int v = G[u][i];
    if (v == pa) continue;
    suf[m] = suf[m + 1] * 1ll * (f[v] + 1) % mod;
    m--;
  }
  m = 0;
  rep(i, 0, G[u].size() - 1) {
    int v = G[u][i];
    if (v == pa) continue;
    m++;
    g[v] = (g[u] * 1ll * pre[m - 1] % mod * suf[m + 1] + 1) % mod;
  }
  rep(i, 0, G[u].size() - 1) {
    int v = G[u][i];
    if (v == pa) continue;
    dfs2(v, u);
  }
}

void work() {
  n = read(), mod = read();
  rep(i, 1, n - 1) {
    int x = read(), y = read();
    G[x].pb(y); G[y].pb(x);
  }
  dfs(1, 0);
  g[1] = 1;
  dfs2(1, 0);
  rep(i, 1, n) cout<<f[i] * 1ll * g[i] % mod<<endl;
}

int main() {
  #ifdef LZT
    freopen("in", "r", stdin);
  #endif

  work();

  #ifdef LZT
    Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
  #endif
}


Measured memory_bytes: 10496
#include <stdio.h>

static int lcm (int a, int b) {
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a % b) !=0 ) {
            a = b;
            b = tmp;
        }
        return (int)(c / b);
}

int main(void){
  		int X = 0;
		scanf("%d", &X);
  		int K = 0;
  
        if (360 % X == 0){
            K = 360 / X;
        } else {
            K = lcm(360, X);
            K /= X;
        }
        

        printf("%d", K);
}

Measured memory_bytes: 1732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String num = br.readLine();

		String[] words ;

		int player1_score =0;

		int player2_score =0;

		for(int i=0; i<Integer.parseInt(num); i++){

			words = br.readLine().split(" ");
			if((words[0].compareTo(words[1])) < 0){

				player2_score += 3;
			}else if ((words[0].compareTo(words[1])) > 0) {
				player1_score +=3;
			}else {
				player1_score +=1;
				player2_score +=1;
			}
		}

		System.out.println(player1_score+" "+player2_score);


	}

}

Measured memory_bytes: 25668
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int X = sc.nextInt();
  int A = sc.nextInt();
  int B = sc.nextInt();
  int C = (X-A)/B;
  System.out.println(X-A-B*C);
}
}

Measured memory_bytes: 21716
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 400;
using B = bitset<N>;
int n,m;
B b[N];
bool err[N];

int main(){
    scanf("%d%d",&n,&m);
    rep(i,0,m) {
        int x,y;
        scanf("%d%d",&x,&y);
        --x;--y;
        err[y] |= err[x];
        err[x] |= err[y];
        if(b[x].test(y) || (b[x] & b[y]).count()) err[x] = 1;
        if(b[y].test(x) || (b[x] & b[y]).count()) err[y] = 1;
        b[x] |= b[y];
        b[y] |= b[x];
        b[x][y] = b[y][x] = 1;
    }
    int ans=0;
    rep(i,0,n) rep(j,i+1,n) if(!err[i]&&!err[j]&&!b[i][j]&&!b[j][i])
        ans+=(b[i]&b[j]).count()==0;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import math

K = int(input())
X = [0]*(K+1)

for a in range(1, K+1):
    for b in range(1, K+1):
        g = math.gcd(a, b)
        X[g] += 1


Y = [0]*(K+1)
for x in range(1, K+1):
    for c in range(1, K+1):
        g = math.gcd(x, c)
        Y[g] += X[x]

print(sum(i*Y[i] for i in range(1, K+1)))





Measured memory_bytes: 9200
#include <bits/stdc++.h>
using Int = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define MP make_pair
#define PUTS(x) cout << (x) << endl;
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    auto s = set<int>();
    s.insert(a);
    s.insert(b);
    s.insert(c);
    puts(s.size() == 2 ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 cin >> N;
 if(N%10==3){
   cout << "bon" << endl;
 }
 else if(N%10==0||N%10==1||N%10==6||N%10==8){
   cout << "pon" << endl;
 }
 else{
   cout << "hon" << endl;
 }
}


Measured memory_bytes: 3528
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
#include<regex>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')ans++;
		else ans--;
	}
	if (ans > 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}



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

using namespace std;

const int INF = 1 << 30;
const std::vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  int sy, sx;
  cin >> sy >> sx;
  int gy, gx;
  cin >> gy >> gx;
  sy--, sx--;
  gy--, gx--;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  vector<vector<int>> G(H, vector<int>(W, INF));
  G[sy][sx] = 0;
  priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
                 greater<pair<int, pair<int, int>>>>
      que;
  que.push(make_pair(0, make_pair(sy, sx)));
  while (!que.empty()) {
    auto q = que.top();
    que.pop();
    int c = q.first, y = q.second.first, x = q.second.second;
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
      if (S[ny][nx] == '#') continue;
      if (chmin(G[ny][nx], c)) {
        que.push(make_pair(c, make_pair(ny, nx)));
      }
    }
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        int ny = y + i, nx = x + j;
        if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
        if (S[ny][nx] == '#') continue;
        if (chmin(G[ny][nx], c + 1)) {
          que.push(make_pair(c + 1, make_pair(ny, nx)));
        }
      }
    }
  }
  if (G[gy][gx] == INF) {
    cout << -1 << '\n';
  } else {
    cout << G[gy][gx] << '\n';
  }
  return 0;
}


Measured memory_bytes: 8616
#include<bits/stdc++.h>
const int N=2e3+10;
using namespace std;
void read(int &x){
	char c=getchar();
	int f=1;
	x=0;
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	x*=f;
}
int t[4000000+10];
int sum;
int cnt;
bitset<N*N>f;
int main(){
	int n,a;
	cin>>n;
	f[0]=1;
	for(register int i=1;i<=n;i++){
		read(a);
		f|=f<<a;
		sum+=a;
	}
	for(register int i=1;i<=sum;i++){
		if(f[i])t[++cnt]=i;
	}
	printf("%d",t[(cnt+1)/2]);
	return 0;
}

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

int main(){

	int input[1000][3], num, i, j, temp;
	
	cin >> num;
	
	for(i = 0; i < num; i++){
	
		cin >> input[i][0] >> input[i][1] >> input[i][2];
		
		if(input[i][0] < input[i][1]){
			temp = input[i][0];
			input[i][0] = input[i][1];
			input[i][1] = temp;
			}

		if(input[i][0] < input[i][2]){
			temp = input[i][0];
			input[i][0] = input[i][2];
			input[i][2] = temp;
			}
		
		if(input[i][0] * input[i][0] == input[i][1] * input[i][1] + input[i][2] * input[i][2])
			cout << "YES" << endl;
		
		else cout << "NO" << endl;
	}
	
	return 0;
}

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

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

  map<int, int> p;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    if (p.count(k))
      p.erase(k);
    else
      p[k] = 1;
  }

  cout << p.size() << endl;
}

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

int tim[2][60][60],sig[60][60],size[101],q[101][10000][3],mk[20][20][4][101];
int M,N,FR,TO,GX,GY,ANS,SET;

void mark(int x,int y,int dir,int t){
	int tx=x-(dir%2)*((dir/2)*2-1);
	int ty=y-((dir+1)%2)*((dir/2)*2-1);

	if(tx<0 || tx>=M || ty<0 || ty>=N)return;

	int ttt=tim[dir%2][x-(dir%2)*(dir/2)][y-((dir+1)%2)*(dir/2)];
	if(ttt<0)return;
	ttt+=t;

	if(mk[tx][ty][dir][ttt]==SET)return;
	if(ttt>100)return;
	if(sig[tx][ty]!=0 && (ttt/sig[tx][ty])%2==dir%2)return;

	q[ttt][size[ttt]][0]=tx;
	q[ttt][size[ttt]][1]=ty;
	q[ttt][size[ttt]][2]=dir;
	size[ttt]++;
	if(tx==GX && ty==GY && ANS>ttt)ANS=ttt;
	mk[tx][ty][dir][ttt]=SET;
}

void check(int i,int j){
	int x=q[i][j][0];
	int y=q[i][j][1];
	int d=q[i][j][2];
	int k;
	for(k=-1;k<=1;k++)mark(x,y,(d+k+4)%4,i);
}

int main(){
    int i,j,k,ay,by,val;
	char ax,bx;

    while(scanf("%d %d",&M,&N)*M*N){
		SET++;

		scanf("%d",&k);
		for(i=0;i<M;i++){
			for(j=0;j<N;j++){
				tim[0][i][j]=k;
				tim[1][i][j]=k;
				sig[i][j]=0;
			}
		}

		scanf("%d%*c",&k);
		for(i=0;i<k;i++){
			scanf("%c%*c%d %d%*c",&ax,&ay,&val);
			sig[ax-'a'][ay-1]=val;
		}

		scanf("%d%*c",&k);
		for(i=0;i<k;i++){
			scanf("%c%*c%d %c%*c%d%*c",&ax,&ay,&bx,&by);
			if(bx==ax && by-ay==1)tim[0][ax-'a'][ay-1]=-1;
			else if(bx-ax==1 && by==ay)tim[1][ax-'a'][ay-1]=-1;
		}

		scanf("%d%*c",&k);
		for(i=0;i<k;i++){
			scanf("%c%*c%d %c%*c%d %d%*c",&ax,&ay,&bx,&by,&val);
			if(bx==ax && by-ay==1)tim[0][ax-'a'][ay-1]+=val;
			else if(bx-ax==1 && by==ay)tim[1][ax-'a'][ay-1]+=val;
		}

		scanf("%c%*c%d %c%*c%d%*c",&ax,&ay,&bx,&by);

		q[0][0][0]=ax-'a';
		q[0][0][1]=ay-1;
		q[0][0][2]=0;
		size[0]=1;
		GX=bx-'a';GY=by-1;
		FR=0;TO=1;ANS=101;
		
		for(i=1;i<101;i++)size[i]=0;

		for(i=0;i<ANS;i++){
			for(j=0;j<size[i];j++){
				check(i,j);
			}
		}

		printf("%d\n",ANS);

    }
 
    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,m;
int a[1001][1001];
vi adj[1001];
void solve(){
    cin>>n>>m;
    memset(a,1,sizeof a);
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        a[x][y]=1;
    }
    rep(k,1,n+1){
        rep(i,1,n+1){
            rep(j,1,n+1){
                a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
            }
        }
    }
    int root=1,mx=a[1][1];
    rep(i,1,n+1){
        if(a[i][i]<mx){
            mx=a[i][i];
            root=i;
        }
    }
    if(mx>2002){
        cout<<-1<<endl;
        return;
    }
    cout<<mx<<endl;
    vi v;
    int cur=root;
    rep(i,0,mx){
        v.pb(cur);
        for(auto j:adj[cur]){
            if(a[j][root]+1==mx-i){
                cur=j;
                break;
            }
        }
    }
    for(auto i:v) cout<<i<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
using namespace std;
int main(void){
    
    int K, X;
    cin >> K >> X;
    int start = X - (K - 1);
    int gool = X + (K - 1);
    
    for(int i = start; i <= gool; i++){
        cout << i << (i != gool ? " " : "\n");
    }
    
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;

int main() {


	int n;
	ll k;
//	int r[51]={};
	cin>>n>>k;
	int a,b;
	ll t=0;
	P ab[100001]={};
	for(int i=0;i<n;++i){
		cin>>a>>b;
		ab[i].first=a;
		ab[i].second=b;
	}
	sort(ab,ab+n);
	for(int i=0;i<n;++i){
		a=ab[i].first;
		b=ab[i].second;
		if(t+b>=k){
			cout<<a<<endl;
			return 0;
		}
		t+=b;
	}
//	if(a<=c&&b>=c){
//		cout<<"Yes"<<endl;
//	}else{
//		cout<<"No"<<endl;
//	}
	//
//	cin>>n;
//	int total=1;
//	for(int i=0;i<n;i++)total=(total*2)%1000000007;
//	for(int i=1;i<n+1;i++){
//		cin>>p[i];
//		R[p[i]].push_back(i);
//	}
//	queue<int> que;
//	que.push(0);
//	while(!que.empty()){
//		int p=que.front();que.pop();
//		int sum=0;
//		for(auto it:R[p]){
//			sum+=R[it].size();
//		}
//		int k=n-sum;
//	}
	return 0;
}


Measured memory_bytes: 1024