akhauriyash/Code-Regression huggingface dataset:
grp = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]

i = list(map(int, input().split()))
flg = False
for g in grp:
    if (i[0] in g) and (i[1] in g):
        flg = True
        break
    else:
        continue

print('Yes') if flg else print('No')


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

int n;

int main()
{
	scanf("%d", &n);
	for (int i = 0; i <= n; i += 4)
		if ((n - i) % 7 == 0) { printf("Yes\n"); return 0; }
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n,m;
    while(cin >> n >> m){
        int ans[105][105] = {0};
        rep(i,n){
            rep(j,m){
                int inp;
                cin >> inp;
                ans[i][j] = inp;
                ans[i][m] += inp;
                ans[n][j] += inp;
            }
            ans[n][m] += ans[i][m];
        }
        rep(i,n+1){
            rep(j,m+1){
                if(j) cout << ' ';
                cout << ans[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1208
import math
from itertools import permutations

n = int(input())
ps = []

for i in range(n):
    v = list(map(int, input().split(" ")))
    ps.append(v)

indexes = [i for i in range(n)]
temp = 0
for order in permutations(indexes, n):
    i = 0
    prev = []
    for idx in order:
        x, y = ps[idx]
        if i > 0:
            temp += math.sqrt((x - prev[0]) ** 2 + (y - prev[1]) ** 2)
        prev = (x, y)
        i += 1
        
for i in range(1, n + 1):
    temp /= i
        
print(temp)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	double max, min, hight, result;
	
	scanf("%lf",&hight);
	
	max = hight;
	min = hight;
	
	while(scanf("%lf",&hight)!=EOF){
		if(hight>max){
			max = hight;
		}else if(hight<min){
			min = hight;
		}
	}
	
	result = max - min;
	
	printf("%lf\n",result);
	
	return 0;
	
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s[102] = {};
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) if (s[j] == s[i]) {
            cout << "No";
            return 0;
        }
        if (s[i][0] != s[i - 1].back()) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	int n,ans,tmp;
    int w[110];
    cin>>n;
    rep(i,n)cin>>w[i];
    rep(i,n-1){
        w[i+1]+=w[i];
    }
    ans=(w[n-1]-w[1])-w[1];
    ans=max(ans,-ans);
    rep(i,n-1){
        tmp=min(ans,w[n-1]-w[i]*2);
        tmp=max(tmp,-tmp);
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;

    

}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N, M;
  std::cin >> N >> M;

  if(N == M) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  long long ans = 1;
  for (int i = 0; i < N; i++){
    ans *= (i + 1);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    ll sum = 0;
    unordered_map<int, int> counts;

    for (int i = 0; i < N; ++i) {
        int Ai;
        cin >> Ai;

        sum += Ai;
        counts[Ai]++;
    }

    int Q;
    cin >> Q;

    for (int i = 0; i < Q; ++i) {
        int B, C;
        cin >> B >> C;

        sum = sum - B * counts[B] + C * counts[B];
        counts[C] += counts[B];
        counts[B] = 0;

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int n, m, tab[10][10], cnt[10][2];

int rec(int i, int j){
    if(i==n) return 1;
    if(j==n) return rec(i+1,0);
    if(tab[i][j] != -1) return rec(i,j+1);

    int res = 0;
    if(cnt[i][0] < n/2 && cnt[j][1] < n/2){
        cnt[i][0]++;
        cnt[j][1]++;
        tab[i][j] = 1;
        tab[j][i] = 0;
        res += rec(i,j+1);
        tab[i][j] = -1;
        tab[j][i] = -1;
        cnt[i][0]--;
        cnt[j][1]--;
    }
    if(cnt[i][1] < n/2 && cnt[j][0] < n/2){
        cnt[i][1]++;
        cnt[j][0]++;
        tab[i][j] = 0;
        tab[j][i] = 1;
        res += rec(i,j+1);
        tab[i][j] = -1;
        tab[j][i] = -1;
        cnt[i][1]--;
        cnt[j][0]--;
    }
    return res;
}

int main() {
    while(cin >> n, n){
        REP(i,n)fill(tab[i],tab[i]+n,-1);
        REP(i,n) tab[i][i] = 2;
        REP(i,n) cnt[i][0] = cnt[i][1] = 0;
        cin >> m;
        REP(i,m){
            int x, y;
            cin >> x >> y;
            x--; y--;
            tab[x][y] = 1;
            tab[y][x] = 0;
            cnt[x][0]++;
            cnt[y][1]++;
        }
        bool ok = true;
        REP(i,n){
            ok &= cnt[i][0] <= n/2 && cnt[i][1] <= n/2;
        }
        if(ok){
            cout << rec(0,0) << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3068
//code by parshuram_84
#include <bits/stdc++.h>
#define floop(i,a,n) for (int i=a;i<n;i++)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvl vector<vector<long long> >
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
#define mp make_pair
#define all(c) c.begin(),c.end()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin();it != container.end(); it++)
typedef std::numeric_limits< double > dbl;
using namespace std;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }

int32_t main() {
	IOS;
	ll t,m,i,j,k,n,x,y,z;
	string s;
	cin>>n>>m;
	ll a[n]={0};
	vll v[n];z=0;
	for(j=0;j<m;j++)
	{
		cin>>x>>y;
		v[x-1].pb(y);
		v[y-1].pb(x);
	}x=0;
	queue<ll> q;
	for(i=0;i<n;i++)
	{
		if(!a[i])
		{
			if(v[i].empty()) a[i]=1;
			else
			{
				q.push(i);
				while(!q.empty())
				{
					t=q.front();
					q.pop();
					a[t]=1;
					if(!v[t].empty())
					{
						for(auto it : v[t])
						{
							if(!a[it-1]) q.push(it-1);
							a[it-1]=1;
						}
					}
				}
			}
			z++;
		}
	}
	cout<<z-1;
	return 0;
}

Measured memory_bytes: 10424
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	////unsigned long long a;
	long double a, b;
	cin >> a >> b;
	long double prod = a * b;
	cout << (long long)prod;
}

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

int main(){
    int N, H, W;
    scanf("%d", &N);
    scanf("%d", &H);
    scanf("%d", &W);
    printf("%d\n", (N-H+1)*(N-W+1));

    return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::{cmp::Ordering, cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[derive(Clone, Copy)]
struct Data {
    x: usize,
    y: usize,
    wc: usize,
}

impl Eq for Data {}
impl PartialEq for Data {
    fn eq(&self, other: &Self) -> bool {
        self.wc == other.wc
    }
}

impl PartialOrd for Data {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(other.wc.cmp(&self.wc))
    }
}

impl Ord for Data {
    fn cmp(&self, other: &Self) -> Ordering {
        other.wc.cmp(&self.wc)
        // self.wc.cmp(&other.wc)
    }
}

#[fastout]
pub fn main() {
    input! {
        h: usize, w: usize,
        ch: Usize1, cw: Usize1,
        dh: Usize1, dw: Usize1,
        s: [Chars; h],
    }

    let mut q = BinaryHeap::new();
    let mut visited = vec![vec![false; w]; h];
    q.push(Data {
        x: cw,
        y: ch,
        wc: 0,
    });
    let mut result = 0;
    while let Some(Data { x, y, wc }) = q.pop() {
        if visited[y][x] {
            continue;
        }
        visited[y][x] = true;
        if x == dw && y == dh {
            result = wc;
            break;
        }
        if x + 1 < w && s[y][x + 1] == '.' && !visited[y][x + 1] {
            q.push(Data { x: x + 1, y, wc });
        }
        if x > 0 && s[y][x - 1] == '.' && !visited[y][x - 1] {
            q.push(Data { x: x - 1, y, wc });
        }
        if y + 1 < h && s[y + 1][x] == '.' && !visited[y + 1][x] {
            q.push(Data { x, y: y + 1, wc });
        }
        if y > 0 && s[y - 1][x] == '.' && !visited[y - 1][x] {
            q.push(Data { x, y: y - 1, wc });
        }
        for i in -2..=2 {
            let x = x as isize;
            let y = y as isize;
            for j in -2..=2 {
                if i == 0 && j == 0 {
                    continue;
                }
                if x + j < 0 || x + j >= (w as isize) || y + i < 0 || y + i >= (h as isize) {
                    continue;
                }
                if !visited[(y + i) as usize][(x + j) as usize]
                    && s[(y + i) as usize][(x + j) as usize] == '.'
                {
                    q.push(Data {
                        x: (x + j) as _,
                        y: (y + i) as _,
                        wc: wc + 1,
                    });
                }
            }
        }
    }
    if visited[dh][dw] {
        println!("{}", result);
    } else {
        println!("-1");
    }
}


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

vector<vector<pair<int, int>>> X;

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

    rep(i,n) {
        int ai;
        cin >> ai;
        vector<pair<int,int>> A;
        rep(j,ai) {
            int x, y;
            cin >> x >> y;
            A.push_back(make_pair(x,y));
        }
        X.push_back(A);
    }

    bool b[n]; // b = 正直者の仮定
    int c[n]; // 発言記録(-1:未  0:不親切 1:正直)
    
    auto isOk = [&]() {
        rep(i,n) c[i] = -1;
        rep(i,n){
            if (b[i] == false) continue;
            for (auto p : X[i]) {
                int x = p.first;
                int y = p.second;
                x--;
                if(y == 1) {
                    if(b[x] == false || c[x] == 0) return false;
                    c[x] = 1;       
                } else {
                    if(b[x] == true || c[x] == 1) return false;
                    c[x] = 0;
                }
            }
        }
        
        return true;
    };

    int maxv = 0;

    rep(bit,1<<n) {
        rep(i,n) {
            int tmp = bit;
            b[i] = ((tmp>>i)&1) == 0;
        }
        
        if(isOk()) {
            int sum = 0;
            rep(i,n) if(b[i]) ++sum;
            maxv = max(maxv, sum);
        }
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
m = max(a)
half_idx = bisect.bisect_left(a, m//2)

def ncr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p - 2, p)) % p
p=10**9+7 

if n == 2:
    print(a[1], a[0])
    exit()

if 1 <= half_idx < n-1:
    if min(a[half_idx-1], m-(a[half_idx-1])) >= max(min(a[half_idx], m-(a[half_idx])), min(a[half_idx+1], m-(a[half_idx+1]))):
        print(m, a[half_idx-1])
    elif min(a[half_idx], m-(a[half_idx])) >= max(min(a[half_idx-1], m-(a[half_idx-1])), min(a[half_idx+1], m-(a[half_idx+1]))):
        print(m, a[half_idx])
    elif min(a[half_idx+1], m-(a[half_idx+1])) >= max(min(a[half_idx], m-(a[half_idx])), min(a[half_idx-1], m-(a[half_idx-1]))):
        print(m, a[half_idx+1])
elif half_idx == 0:
    if min(a[half_idx], m-(a[half_idx])) >= min(a[half_idx+1], m-(a[half_idx+1])):
        print(m, a[half_idx])
    elif min(a[half_idx+1], m-(a[half_idx+1])) >= min(a[half_idx], m-(a[half_idx])):
        print(m, a[half_idx+1])
elif half_idx == n-1:
    if min(a[half_idx], m-(a[half_idx])) >= min(a[half_idx-1], m-(a[half_idx-1])):
        print(m, a[half_idx])
    elif min(a[half_idx-1], m-(a[half_idx-1])) >= min(a[half_idx], m-(a[half_idx])):
        print(m, a[half_idx-1])

Measured memory_bytes: 62704
#include <iostream>
#include <vector>
#include <algorithm>

#define INF (100000000000000L)

using namespace std;

long long int solve() {
  int N;
  vector<long long int> a;
  long long int sum = 0L;
  long long int ans = INF;

  cin >> N;
  for (int i=0;i<N;i++) {
    int t;
    cin >> t;
    a.push_back(t);
    sum += t;
  }

  long long int sunuke = a[0];
  ans = min(ans, abs(sunuke * 2 - sum));
  for (int i=1;i<N-1;i++) {
    sunuke += a[i];
    ans = min(ans, abs(sunuke * 2 - sum));
  }

  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int L,R,d,count=0;
    scanf("%lli %lli %lli",&L,&R,&d);
    for(int i=L;i<=R;i++)
    {
        if(i%d==0)
        {
            count++;
        }
    }
    cout <<count<<endl;
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <climits>
#include <bitset>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 5;

ll mod_pow(ll k, ll p)
{
    if (k == 0)
    {
        return 1 % p;
    }
    if (k == 1)
    {
        return 2 % p;
    }

    if (k % 2 == 0)
    {
        ll tmp = mod_pow(k / 2, p);
        return tmp * tmp % p;
    }
    else
    {
        ll tmp = mod_pow((k - 1) / 2, p);
        tmp *= tmp;
        tmp %= p;
        tmp *= 2;
        tmp %= p;
        return tmp;
    }
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2) % MOD;
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, (k - 1) / 2);
        return tmp * tmp * n;
    }
}
map<ll, ll> sosuu(ll n)
{
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            n /= i;
            mp[i] += 1;
        }
    }
    if (n != 1)
    {
        mp[n] += 1;
    }
    return mp;
}

class Tree
{
private:
    vector<vector<ll>> edge;
    vector<ll> counter;

public:
    Tree() : counter(1000000, 0), edge(1000000){};
    ~Tree(){};

    void add(ll n, ll k)
    {
        this->edge[n].push_back(k);
        this->edge[k].push_back(n);
    }

    void query(ll p, ll x)
    {
        this->counter[p] += x;
    }

    void create()
    {
        vector<vector<ll>> children(1000000);
        vector<bool> visited(1000000, false);

        // 木の生成
        {
            queue<ll> Q;
            Q.push(1);
            visited[1] = true;

            while (!Q.empty())
            {
                ll top = Q.front();
                Q.pop();
                vector<ll> dist = this->edge[top];

                for (ll j = 0; j < dist.size(); j++)
                {
                    ll c = dist[j];
                    if (visited[c])
                    {
                        continue;
                    }
                    children[top].push_back(c);
                    Q.push(c);
                    visited[c] = true;
                }
            }
        }
        // 探索開始
        {
            queue<ll> Q;
            Q.push(1);
            while (!Q.empty())
            {
                ll top = Q.front();
                Q.pop();

                vector<ll> child = children[top];
                for (auto &&e : child)
                {
                    this->counter[e] += this->counter[top];
                    Q.push(e);
                }
            }
        }
    }
    ll count(ll n)
    {
        return this->counter[n];
    }
};

int main()
{
    ll N, X;
    cin >> N >> X;

    vector<ll> city(N);
    ll ans;
    for (ll i = 0; i < N; i++)
    {        
        cin >> city[i];
        ll diff = abs(city[i] - X);

        if (i == 0) {
            ans = diff;
        } else {
            ans = __gcd(ans, diff);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt();
        int prev = readInt();
        long num = 0;
        long cache = 1000;

        for (int i = 1; i < n; i++) {
            int a = readInt();
            if (prev < a) {
                num += cache / prev;
                cache = cache % prev;
            }

            cache += num * a;
            num = 0;
            prev = a;
        }

        System.out.print(cache);
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32220
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  int n; cin >> n;
  vector<ll> s(n);
  rep(i,n) cin >> s[i];

  vector<ll> a;
  rep(i,n) {
    int j = n - 1 - i;
    a.push_back(s[i] + s[j]);
  }    
  ll res = 0;
  rep1(i,n) {
    int idx = 0;
    ll sum = 0;
    int cr = n;
    if((n - 1) % i == 0) cr = n/2;
    while(idx < cr && i < n - idx - 1) {
      sum += a[idx];
      chmax(res, sum);
      idx += i;
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 5088
#include<bits/stdc++.h>
using namespace std;
int main(){
      // #ifndef ONLINE_JUDGE
      //  // for getting input from input.txt
      //  freopen("input.txt", "r", stdin);
      //  // for writing output to output.txt
      //  freopen("output.txt", "w", stdout);
      // #endif
	int n;
  cin>>n;
  std::vector<int> v(1000,0);
  for (int i = 0; i <= 9; ++i)
  {
    for (int j= 0; j <= 9; ++j)
    {
      v.push_back(i*j); 
    }
  }

  for (int i = 0; i< 10000 ; ++i)
  {
      if(v[i] == n){
        cout<<"Yes"<<"\n";
        return 0;
      }
  }

  cout<<"No"<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  string s,p="",q="";
  s=to_string(a);
  for(int i=0;i<b;i++)
  {
    p+=s[0];
  }
  s=to_string(b);
  for(int i=0;i<a;i++)
  {
    q+=s[0];
  }
  if(a==b || a<b)
    cout<<p<<endl;
   else if(b<a)
     cout<<q<<endl;
    return 0;
}

Measured memory_bytes: 256
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[200100];
lint b[200100];
int main()
{
	int n;lint K;
	cin>>n>>K;
	rep(i,n){
		cin>>a[i];a[i]--;
	}
	memset(b,-1,sizeof(b));
	int now=0;lint s,g;
	rep(i,n+10){
		if(b[now]>=0){
			g=i;s=b[now];break;
		}
		b[now]=i;
		now=a[now];
	}
	lint t=K;
	if(s<t){
		t=s+(K-s)%(g-s);
	}
	rep(i,n){
		if(b[i]==t) cout<<i+1<<endl;
	}
}


Measured memory_bytes: 5996
import math

A,B,K=map(int,input().split())
length=B-A+1
 
if math.ceil(length/2)>K:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
else:
    for i in range(A,B+1):
        print(i)

Measured memory_bytes: 3060
A, B, C, X, Y = [int(x) for x in input().split()]

num_A = 0
num_B = 0
num_AB = 0
if A + B <= 2 * C:
    num_A = X
    num_B = Y
else: # A + B > 2 * C
    Z = min(X, Y)
    X = X - Z
    Y = Y - Z
    num_AB = 2 * Z

    if A >= 2 * C:
        num_AB += 2 * X
    else: # A < 2 * C

        num_A = X
    if B >= 2 * C:
        num_AB += 2 * Y
    else: # B < 2 * C
        num_B = Y

ans = A * num_A + B * num_B + C * num_AB
print(ans)

Measured memory_bytes: 9144
N, M = map(int, input().split())

drink = []
sum = 0
count = 0

for i in range(N):
    A, B = map(int, input().split())
    drink.append([A, B])

drink.sort()


for d in drink:
    if count >= M:
            break
    for i in range(d[1]):
        sum += d[0]
        count += 1
        if count >= M:
            break

print(sum) 

Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    double c=1.0/((double)(4.0*m));
    c*=(double)sum;
    // cout<<c;
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(v[i]>=c)
            count++;
    }

    if(count>=m)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    

    return 0;
    
}

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

int main() {
  int k, n;
  cin >> k >> n;
  
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  
  int a=v[0], b=v[n-1];
  int max = v[0]+k-v[n-1];
  for(int i=1; i<n; i++) {
    if(v[i]-v[i-1]>max) {
      max = v[i]-v[i-1];
      a = v[i], b = v[i-1];
    } 
  }
  
  if(a==v[0] && b==v[n-1]) cout << b-a << endl;
  else cout << b+k-a << endl;
  return 0;
}

Measured memory_bytes: 4016
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
const ll MAX_V = 310;

int main() {
    ll n;
    cin >> n;
    
    vvl A(n, vl(n));
    vvl dist(MAX_V, vl(MAX_V));
    rep(i, n) {
        rep(j, n) {
            cin >> A[i][j];
            dist[i][j] = A[i][j];
        }
    }
 
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
 
    ll ans = 0;
    rep(u, n-1) {
        exrep(v, u+1, n-1) {
            if(dist[u][v] < A[u][v]) {
                out(-1);
                re0;
            } 
            ll flag = 0;
            rep(w, n) {
                if(w != u && w != v && dist[u][v] == dist[u][w] + dist[w][v]) {
                    flag = 1;
                }
            }
            if(!flag) {
                ans += dist[u][v];
            }
        }
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 1792
import sys
n=int(input())
if n ==1:
    print("0")
    sys.exit()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l = factorization(n)
count =0
for i in l:
    cou = 0
    a = i[1]
    hiku = 1
    while a - hiku >=0:
        cou += 1
        a -= hiku
        hiku += 1
    count += cou
print(count)

Measured memory_bytes: 9344
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = a + b;
	int r = c + d;
	if (l > r)cout << "Left" << endl;
	else if (l < r)cout << "Right" << endl;
	else cout << "Balanced" << endl;
	

	return 0;
}





Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; string s; cin >> n >> s;
    int res = 1;
    for(int i=1; i<n; i++) {
        if(s[i] != s[i-1]) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ii d[MAXn];
bool cmp(const ii &a,const ii &b){
  return a.Y<b.Y || (a.Y==b.Y && a.X<b.X);
}
int main(){
  IOS();
  ll n,m;
  cin>>n>>m;
  REP(i,m) cin>>d[i].X>>d[i].Y;
  sort(d,d+m,cmp);
  REP(i,m) debug(d[i]);
  ll r=0,ans=0;
  REP(i,m){
    if( d[i].X>=r ){
      ans++;
      r = d[i].Y;
    }
  }
  cout<<ans<<endl;
}


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

int main () {
  int K , N;
  cin >> K >> N;
  int start, end;
  start = N - K +1;
  end = N + K - 1;
  for (int i = start; i <= end; i++ ){
    if (i < end){
      cout << i << " ";
    }
    else { cout << i;}
  }
  cout << endl;
}

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

int n, k;
int ans = 0;

void input(){
  cin >> n >> k;
}

void solve(){
  input();
  int tmp;
  rep(i, n){
    cin >> tmp;
    if(tmp >= k){
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n,a,b; cin>>n>>a>>b;
	string s; cin>>s;
	int pass=0,foreign=0;
	rep(i,n){
		string ans="No";
		if(s[i]=='a'){
			if(pass<a+b){
				ans="Yes"; pass++;
			}
		}else if(s[i]=='b'){
			foreign++;
			if(pass<a+b&&foreign<=b){
				ans="Yes"; pass++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int main(){
    int64_t N;
    cin >> N;
    if(N % 2 == 1) cout << 0 << endl;
    else{
        int64_t x = 10;
        int64_t ans = 0;
        while(true){
            int64_t count = N / x;
            ans += count;
            if(count == 0) break;
            else x *= 5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	string S; cin >> S;
	char tmp = '<';
	int i = 0;
	int sum = 0;
	vector<lli> rec;
	while (true) {
		if (tmp == S[i])sum++;
		else {
			rec.push_back(sum);
			sum = 1;
			tmp = S[i];
		}
		i++;
		if (i == S.length()) {
			rec.push_back(sum);
			break;
		}
	}
	if (tmp == '<')rec.push_back(0);

	//rep(i, 0, rec.size())cout << rec[i] << endl;
	lli ans = 0;
	for (int i = 0; i < rec.size() - 1; i += 2) {
		ans += rec[i] * (rec[i] - 1) / 2;
		ans += rec[i + 1] * (rec[i + 1] - 1) / 2;
		ans += max(rec[i], rec[i + 1]);
	}
	if (rec.size() % 2 == 1)ans += rec[rec.size() - 1];
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3068
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
	int W,H,x,y,r;
	
	cin>>W>>H>>x>>y>>r;
	
	if(x<W&&y<H&&0<x&&0<y)
		if(r<=(W-x)&&r<=(H-y))
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
	
}

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d;
  e = a + b;
  f = c + d;
  
  if (e > f){
    cout << "Left" << endl;
  }
  
  if (e < f){
    cout << "Right" << endl;
  }
  
  if (e == f){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <iterator>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef long double lld;
typedef pair<int,int> pi;
#define lli 			long long int
#define mod				(ll) 1000000007
#define pb 				push_back
#define f(i,s,n) 		for (int i=s;i<n;i++)
#define vii				vector<int>
#define seti      set<int>
#define mapi      map<int,int>
#define mapv      map<int,vii>
#define vll				vector<ll>
#define vpp				vector<pp>
#define vss				vector<string>
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define all(a)			a.begin(),a.end()
#define abs(a) 			a>0?a:-1*a
#define all(a)			a.begin(),a.end()
#define fo(i,a)       for(auto &i:a)
#define bs(v,x)			binary_search(all(v),x)
#define sort(ans)    sort(ans.begin(),ans.end());
#define sortrev(ans) sort(a.begin(), a.end(), greater<int>());
#define vii2d       vector<vector<int>>
#define ms          multiset<int>
void solve()
{
  int n;
  cin>>n;
  int a[100];
  int ans=0;
  f(i,0,n)
  {
    int y;
    cin>>y;
    a[i]=y;
  }
  f(i,0,n)
  {
    f(j,i+1,n)
    {
      f(k,j+1,n)
      {
        if ((a[i]!=a[j])&&(a[j]!=a[k])&&(a[i]!=a[k]))
        {
          int ma=max(max(a[i],a[j]),a[k]);
          if ((a[i]+a[j]+a[k]-ma)>ma)
          {
            ans+=1;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}
int main()
{
    int t=1;
    //cin>>t;
    int count=1;
    while(t--)
    {
      solve();
      count+=1;
    }
	return 0;
}


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

using namespace std;

int main()
{
    int arr[5];int ans=0;

    for(int i=0;i<5;i++)
       {
         cin>>arr[i];
       }
    for (int i=0;i<5;i++ )
    {
        if(arr[i]==0)
         {ans=i+1;break;}
    }
    cout<<ans;
}



Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(){
    int a=0,b=0,c=0;
    int k=1;
    
    int max=0;
    cin >> a >> b >> c >> k;

    if(k>=a){
        max=1*a;
    }else{
        max=1*k;
    }
    if(k-a>=0){
    max=max+0*(k-a);
    }
    if(k-a-b>=0){
    max=max+(-1)*(k-a-b);
    }

    cout << max << endl;

}


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

int main()
{
    int n,i,j;
    string s;
    cin>>n;
    int a[4];
    for (i = 0; i < 4; i++) a[i]=0;
    for (i = 0; i < n; i++)
    {
        cin>>s;
        if (s[0]=='A') a[0]++;
        else if (s[0]=='W') a[1]++;
        else if (s[0]=='T') a[2]++;
        else a[3]++;
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
}

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

typedef long long ll;
ll ans = 0;

void culc(string s, ll sum, ll x) {
	if (s.size() == 1) {
		ans += sum + x * 10LL + (s[0] - '0');
	} else {
		ll head = s[0] - '0';
		culc(s.substr(1), sum + x * 10LL + head, 0);
	   	culc(s.substr(1), sum, x * 10LL + head);
	}
}

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

	culc(s, 0, 0);
	cout << ans << endl;

	return 0;
}


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

int main(){
    int n, m, x;
    cin >> n >>  m >> x;

    int a[110];
    for ( int i = 0; i < m; i++) cin >> a[i];

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

    if ( ans < m/2 ) cout <<  ans << endl;
    else cout << m - ans << endl;
}

Measured memory_bytes: 256
N = int(input())

A = list(map(int,input().split()))


for i in range(N-1):

    print (" ".join(map(str,A)))

    i += 1
    v = A[i]

    j = i - 1

    while j >= 0 and A[j] > v:

        A[j+1] = A[j]
        j -= 1

    A[j+1] = v


print (" ".join(map(str,A)))



Measured memory_bytes: 5596
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    string s; cin>>s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; 
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> next(N);

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            next[nv]=v+1;
            que.push(nv);
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    bool flg =true;
    for (int v = 1; v < N; ++v){ 
        if(dist[v]==-1){
            flg=false;
            break;
        }
    }

    if(flg){
        cout<<"Yes"<<endl;
        for (int v = 1; v < N; ++v){ 
            cout << next[v] << endl;
        }
    }else{
        cout<<"No"<<endl;
    }
}

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

void fnInput(string& rsMaxNum)
{
  cin >> rsMaxNum;
}

int fnDgtDP(string sMaxNum)
{
  // dp[nPos][nSmall][nFlag] :=  nPos  : 上位 nPos 桁目まで決定
  //                             nSmall: small(数字を自由に選べる)か
  //                             nFlag : 上位 nPos 桁までで {3,5,7} を選択したかflag
  //                             ( 0:選択なし, 1: 3   選択, 2: 5   選択, 3: 3 5   選択, 
  //                               4: 7 選択 , 5: 3 7 選択, 6: 5 7 選択, 7: 3 5 7 選択)
  //                             の条件を満たす数値の数
  int dp[11][2][8] = {};
  dp[0][0][0] = 1;

  int nLen = sMaxNum.size();

  for (int nPos = 0; nPos < nLen; ++nPos)
    for (int nSmall = 0; nSmall < 2; ++nSmall)
      for (int nFlag = 0; nFlag < 8; ++nFlag)
      {
        if (!dp[nPos][nSmall][nFlag]) continue;

        if (nSmall == 1)               // small ([0, 9] から数字を選べる)か
        {
          if (!nFlag)
            dp[nPos + 1][1][0]       += dp[nPos][1][0];                    // nothing

          dp[nPos + 1][1][nFlag | 1] += dp[nPos][1][nFlag];                // +3
          dp[nPos + 1][1][nFlag | 2] += dp[nPos][1][nFlag];                // +5
          dp[nPos + 1][1][nFlag | 4] += dp[nPos][1][nFlag];                // +7
        }
        else                           // not small ([0, d] から数字を選べる)か
        {
          int nDgt = sMaxNum[nPos] - '0';

          if (!nFlag)    dp[nPos + 1][1][0]         += dp[nPos][0][0];     // nothing

          if (nDgt == 3) dp[nPos + 1][0][nFlag | 1] += dp[nPos][0][nFlag]; // +3
          if (3 < nDgt)  dp[nPos + 1][1][nFlag | 1] += dp[nPos][0][nFlag]; // +3
          if (nDgt == 5) dp[nPos + 1][0][nFlag | 2] += dp[nPos][0][nFlag]; // +5
          if (5 < nDgt)  dp[nPos + 1][1][nFlag | 2] += dp[nPos][0][nFlag]; // +5
          if (nDgt == 7) dp[nPos + 1][0][nFlag | 4] += dp[nPos][0][nFlag]; // +7
          if (7 < nDgt)  dp[nPos + 1][1][nFlag | 4] += dp[nPos][0][nFlag]; // +7
        }
      }
/*
  for (int nPos = 0; nPos <= nLen; ++nPos)
     for (int nSmall = 0; nSmall < 2; ++nSmall)
       for (int nFlag = 0; nFlag < 8; ++nFlag)
         if (dp[nPos][nSmall][nFlag])
         {
           cout << "dp[" << nPos << "][" << nSmall << "][" << nFlag << "] = (";
           cout << dp[nPos][nSmall][nFlag] << ")" << endl;
         }
*/
  return dp[nLen][0][7] + dp[nLen][1][7];
}

int main()
{
  string sMaxNum;

  fnInput(sMaxNum);
  cout << fnDgtDP(sMaxNum) << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

int main() {
    char s[11] = {0}, t[11] = {0}, u[11] = {0};
    int ns, nt;
    scanf("%s %s", s, t);
    scanf("%d %d", &ns, &nt);
    scanf("%s", u);

    if (strcmp(s, u) == 0) {
        printf("%d %d", ns - 1, nt);
    } else {
        printf("%d %d", ns, nt - 1);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

long long n,k;

void solve(){
    if(((((n-1)*(n-2))/2 < k))){
        cout << -1 << endl;
    }
    else{
        long long cur=((n-1) * (n-2))/2;
        cout << n-1 + cur-k << endl;
        for(int i=2;i<=n;i++){
            cout << 1 << ' ' << i << endl;
        }
        if(cur==k){

        }
        else{
            for(int i=2;i<=n;i++){
                for(int j=i+1;j<=n;j++){
                    cout << i << ' ' << j << endl;
                    cur--;
                    if(cur==k){
                        break;
                    }
                }
                if(cur==k){
                    break;
                }
            }
        }
    }
}

int main(){
    cin >> n >> k;
    solve();
}

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

int main(){
	string a[]={"apple", "peach"};
	string s;
	
	getline(cin, s);
	for(int i=0; i<s.size()-4; ++i){
		if(s.substr(i,5)==a[0]){
			for(int j=0; j<5; ++j) s[i+j]=a[1][j];	
			i+=4;
		}
		if(s.substr(i,5)==a[1]){
			for(int j=0; j<5; ++j) s[i+j]=a[0][j];	
			i+=4;
		}
	}
	
	cout << s <<endl;
	return 0;
}

Measured memory_bytes: 1188
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		//StringTokenizer st = new StringTokenizer(br.readLine());
	//	for(int k=1;k<=n;k++){
			//int j=k;
		String s="";
		while(n>0)
		{
			int x = (int)(n%26);
			n = n/26;
			if(x==0){
				x=26;
				n--;
			}
			s=s+(char)(97+x-1);
		}
		for(int i=s.length()-1;i>=0;i--)
			System.out.print(s.charAt(i));
		System.out.println();//}
		//System.out.println((char)(97+26-1));

	}
}

Measured memory_bytes: 36984