akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  A.pb(A[0]);
  int sum=0;
  rep(i,0,N) sum+=A[i];
  int P=(N+1)*N/2;
  if(sum%P!=0){
    cout<<"NO"<<endl;
    return 0;
  }
  sum/=P;
  REP(i,1,N){
    int X=A[i]-A[i-1];
    if(!((sum-X)%N==0&&0<=(sum-X)/N&&(sum-X)/N<=sum)){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  }



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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const long long MOD = 1e9 + 7;
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;
}

///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll H,W;
    cin >> H >> W;
    ll ans = 0;
    if ((H == 1) or (W == 1)){
        ans = 1;
    }else if ((H * W) % 2 == 0){
        ans = H * W / 2;
    }else{
        ans = H * W / 2 + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
S = list(input())

AK = list('AKIHABARA')

if S == AK:
    ans = 'YES'
elif len(S) >= len(AK):
    ans = 'NO'
else:
    for i in range(len(S)):
        if S[i] != AK[i]:
            S.insert(i, AK[i])
    if len(S) > len(AK):
        ans = 'NO'
    else:
        for i in range(len(S)):
            if S[i] != AK[i]:
                S.insert(i, AK[i])

        if len(S) > len(AK):
            ans = 'NO'
        else:
            if len(S) != len(AK):
                S.append('A')

            if S == AK:
                ans = 'YES'
            else:
                ans = 'NO'

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    ll r=0;
    ll g=0;
    ll b=0;
    rep(i,n){
        if(s[i]=='R'){r++;}
        else if(s[i]=='G'){g++;}
        else b++;
    }
    //cout<<r<<g<<b<<endl;

    ll ans = r*g*b;

    rep(i,n){
        repk(j,i+1,n){
            if(s[i]==s[j])continue;
            int k = 2*j-i;
            if(k >=n ||s[i]==s[k] || s[j] == s[k] ) continue;
            ans--;
            //if(ok)cout << s[i] << s[j]<<s[2*j-i]<<endl;
        }
    }
    cout << ans <<endl;
    return 0;
}

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

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

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

    cout << r * r << endl;
}

Measured memory_bytes: 888
def floor_linear_sum(n,m,a,b):
    res = 0
    if a >= m:
        res += (n-1)*n*(a//m)//2
        a %= m
    if b >= m:
        res += n * (b//m)
        b %= m
    y_max = (a*n+b)//m

    while y_max:
        x_max = y_max*m-b
        res += (n - (x_max + a - 1)//a)*y_max
        n,m,a,b = y_max, a, m, (a-x_max)%a
        if a >= m:
            res += (n-1)*n*(a//m)//2
            a %= m
        if b >= m:
            res += n * (b//m)
            b %= m

        y_max = (a*n+b)//m
    return res

T = int(input())
for _ in range(T):
    print(floor_linear_sum(*map(int,input().split())))


Measured memory_bytes: 9280
#include <iostream>
#include<string>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#define endl '\n'
#define Bedoazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

const long long mod = 1e9 + 7, N = 1e6 + 5;

long long fact[N], inv[N],  mix = 0, numbers[N];

map<long long, long long>factors;


long long fastpower(int base, int power) {

	if (power == 0)
		return 1;

	long long halfpower = fastpower(base, power / 2) ;

	long long ret = (halfpower * halfpower) % mod;

	if (power % 2) {

		ret = (ret * base) % mod;
	}
	return ret;


}


void primeFactors(long long n) {

	long long fact;

	for (int i = 2; i*i <= n; i++) {

		fact = 0;

		while (n % i == 0) {

			fact++;

			n /= i;


		}
		if (factors[i] < fact) {

			factors[i] = fact;

		}




	}
	
	if (n > 1 && factors[n] < 1 ) {

		factors[n] = 1;

	}


	return;


}


int main() {

	Bedoazim

		long long n;

	cin >> n;

	for (int i = 0; i < n; i++) {


		cin >> numbers[i];

		primeFactors(numbers[i]);

	}


	long long lcm = 1;

	for (auto x : factors) {

		lcm =((lcm%mod)*(fastpower(x.first, x.second)%mod))%mod;
		

	}

	long long ans = 0;

	for (int i = 0; i < n; i++) {

		ans = ((ans%mod) + ((lcm * fastpower(numbers[i], mod - 2)) % mod)) % mod;

	}

	cout << ans%mod;


}

Measured memory_bytes: 1024
n,q = map(int,input().split())

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

w = [A[0]]
for i in range(1,n):
    w.append(w[-1]+A[i])

w1 = [0]*n
for i in range(n):
    if (n-1-i)%2 == 0:
        w1[i] = A[i]
    if i > 0:
        w1[i] += w1[i-1]

def solve(x):
    l = 0
    r = n+1
    while r-l > 1:
        m = (r+l)//2
        if A[n-m] <= x:
            r = m
        else:
            if 2*m-1 > n:
                r = m
            else:
                if A[n-m]-x >= x-A[n-2*m+1]:
                    l = m
                else:
                    r = m
    ans = w[-1]-w[n-l-1]
    if n-2*l-1 >= 0:
        ans += w1[n-2*l-1]
    print(ans)

for _ in range(q):
    solve(int(input()))

Measured memory_bytes: 24240
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

const ll MOD = 1000000007;

vector<ll> fac(800001); //n!(mod M)
vector<ll> ifac(800001);


ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}


int main()
{
	ll x,y;
	cin >> x>>y;
	if(((x+y)%3)!=0)
	{
		
		cout<<0<<endl;
		return 0;
	}

	ll now = (x+y)/3;
	
	ll zure =abs(x-y);
	if(now<zure)
	{
		cout<<0<<endl;
		return 0;
	}
	
	ll ans = 1;
	ll ansb= 1;
	ll m = (2*x-y)/3;
	ll n = (2*y-x)/3;
	
	//cout<<m<<':'<<n<<endl;
	 fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<800000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }


	cout<<comb(m+n,n)%MOD<<endl;


	//cout << now <<endl;
	return 0;
}

Measured memory_bytes: 12800
import java.util.*;

public class Main {
    public static void main(String[] args){

        int count=0;
        Scanner sc=new Scanner(System.in);
        String s1=sc.next();
        String s2=sc.next();
        if(s2.startsWith(s1)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35672
#include <stdio.h>

int main()
{
	int K,L,M,N;

	scanf("%d",&N);
	K = (int)(N / 100);
	M = N % 10;
	L = (N - K * 100 - M) / 10;

	if (K == 7 || L == 7 || M == 7){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}


Measured memory_bytes: 1640
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 21 13:52:24 2019

@author: Yamazaki Kenichi
"""

A,B,C = map(int,input().split())

if A < C and C < B:
    print('Yes')
elif A > C and C > B:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#define GENDO 200001
using namespace std;
int main()
{
	int n;
	long i, j, tmp, all;

	cin >> n;
	long *in = new long[n];
	long *a = new long[GENDO];
	long *b = new long[GENDO];

	for (i = 0; i < GENDO; i++) {
		a[i] = b[i] = 0;
	}
	all = 0;

	for (i = 0; i < n; i++) {
		cin >> in[i];
		a[in[i]]++;
	}
	

	for (i = 0; i < GENDO; i++) {
		b[i] =  a[i] * (a[i] - 1) / 2;
		all += b[i];
	}

	for (i =0; i < n; i++) {
		tmp = (a[in[i]] - 1) * (a[in[i]] - 2) / 2;
		cout << all - b[in[i]] + tmp << endl;
	}
	return 0;
}


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

int main(){
    int n,i;
    cin >>n;
    int a[n];
    for (i=0;i<n;i++){
    cin >> a[i];
    }
    for(i=n-1;i>-1;i--){
        if(i != n-1){
            cout << " "<<a[i];
        }else{
            cout << a[i];   
        }
    }cout << endl;
    return 0;
}


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

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

int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 1;
    rep(i, N)
        ans = lcm(ans, A[i]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3108
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int sum = 10;
vector<ll> L;
void dfs(vector<ll> &L,int v){
    if(L[v]%10==9){
        L[sum] = L[v]*10 + L[v]%10 - 1;
        L[sum+1] = L[v]*10 + L[v]%10;
        sum += 2;
    }else if(L[v]%10==0){
        L[sum] = L[v]*10;
        L[sum+1] = L[v]*10 + L[v]%10 + 1;
        sum += 2;
    }else{
        L[sum] = L[v]*10 + L[v]%10 - 1;
        L[sum+1] = L[v]*10 + L[v]%10;
        L[sum+2] = L[v]*10 + L[v]%10 + 1;
        sum += 3;
    }
}

int main(void){
    int K;cin>>K;
    L.assign(100001,0);
    int v = 1; 
    for(int i=1;i<=9;i++){
        L[i] = i;
    }
    while(sum<=100000){
        dfs(L,v);
        v++;
    }
    cout << L[K] << endl;
    return 0;
}

Measured memory_bytes: 1024
// ※※※ 解答不能 ※※※
// j_taka_z 氏.
// https://atcoder.jp/contests/ddcc2020-qual/submissions/8594243
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    LL m, D = 0, S = 0, d, c;
    scanf("%d", &m);
    rep(i, m){
        scanf("%lld %lld", &d, &c);
        D += c;
        S += d * c;
    }
    printf("%lld\n", D - 1 + (S - 1) / 9);
    return 0;
}

Measured memory_bytes: 384
from math import gcd

def divisors(M):#Mの約数列 O(n^(0.5+e))
    d=[]
    i=1
    while M>=i**2:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    return d

mod=10**9+7
N,K=map(int,input().split())
div=divisors(N)

res=[0 for i in range(len(div))]
ans=0
if N%2==0:
    for i in range(len(div)):
        d=div[i]
        g=gcd(2*d,N)
        res[i]+=pow(K,g//2,mod)
        res[i]%=mod
        ans+=d*res[i]
        ans%=mod
        for j in range(i+1,len(div)):
            if div[j]%d==0:
                res[j]-=res[i]
                res[j]%=mod

    print(ans%mod)
else:
    for i in range(len(div)):
        d=div[i]
        g=gcd(2*d,N)
        res[i]+=pow(K,(g+1)//2,mod)
        res[i]%=mod
        ans+=d*res[i]
        ans%=mod
        for j in range(i+1,len(div)):
            if div[j]%d==0:
                res[j]-=res[i]
                res[j]%=mod

    print(ans%mod)


Measured memory_bytes: 80424
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, l, su;

	cin>> n >> l;

	su=n*(n+1)/2+n*(l-1);

	if(1<=l){
		su-=l;
	}
	if(l<=1-n){
		if(su<0) su-=l+n-1;
		else su-=l;
	}
	
	cout<< su << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll f(ll x) {
	return x * (x + 1) / 2;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	ll n;
	cin >> n;
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		res += f(n / i) * i;
	}
	cout << res;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define _USE_MATH_DEFINES
#define LL long long
#define UN unsigned
using namespace std;
const double PI = acos(-1.0);

int max_num(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_ord(int ary[], int length) {
	int max;
	max = max_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_num(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_ord(int ary[], int length) {
	int min;
	min = min_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

void dfs(int rest, string s) {
	if (rest == 0)
		cout << s << endl;
	else
		for (char c = 'a'; c <= 'c'; c++)
			dfs(rest - 1, s + c);
}

int main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, inf = 1e9 + 7;
int n, k, h[N], dp[N];
int main()
{
    fill(dp, dp + N, inf);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j <= i + k; ++j)
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
    cout << dp[n - 1];
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define ALL(v) (v).begin(), (v).end()

typedef pair<int, int> P;
ll n;
int ans = 0;

int dfs(ll cnt, int san, int go, int nana) {
    if(n < cnt) {
        return 0;
    } else {
        if(san > 0 && go > 0 && nana > 0) {
            ans++;
        }
    }

    dfs(10*cnt + 3, 1, go, nana);
    dfs(10*cnt + 5, san, 1, nana);
    dfs(10*cnt + 7, san, go, 1);

    return 0;
}

int main(){
    cin >> n;

    dfs(0, 0, 0, 0);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int G[100][100];
int f[100];
int time,n;
int d[100];
int c[100];


void visit(int u){
  int v;
  c[u] = 1;
  d[u] = ++time;
  for(v=0;v<n;v++){
    if(!G[u][v])continue;
    if(!c[v])visit(v);
  }
  c[u] = 2;
  f[u] = ++time;
}


void dfs(){
  int u;
  for(u=0;u<n;u++){
    c[u] = 0;
  }
  time = 0;
  for(u=0;u<n;u++){
    if(!c[u])visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int i,j,u,v,k;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&v);
    for(j=0;j<v;j++){
      scanf("%d",&k);
      G[u-1][k-1] = 1;
    }
  }

  dfs();
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n; cin >> n;
  string ct, ch;
  int tarou =0,hanako =0;
  for(int i=0;i<n;i++){
      cin >> ct >> ch;
      if ( ct == ch ){
          tarou +=1,hanako +=1;
      }else if ( ct < ch ){
          hanako+=3;
      }else tarou +=3;
  }
  cout << tarou <<" "<< hanako << endl;
  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  char answer[2];
  int number;
  cin >> s;
  answer[0] = s[0];
  answer[1] = s[s.size() - 1];
  cout << answer[0] << (s.size() - 2) << answer[1];
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;

int main(){
long N, D;
cin >> N;
vector<long> p(N+1);
erep(i, N) cin >> p[i];
long cnt = 0;
erep(i, N){
    if(p[i] != i) cnt++;
}
if((cnt == 2) || (cnt == 0)){
     show("YES");
}
else show("NO");

return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int S = scan.nextInt();
        int[] Sarray = new int[4];
      	for(int i=0;i<4;i++){
        	Sarray[i] = (S/(int)Math.pow(10,i))%10;
        }
      	boolean f = false;
      	 for(int i= 1;i<4;i++){
            if(Sarray[i-1]==Sarray[i]){
                f = true;
            }
        }
        if(f==true){
            System.out.println("Bad");
        }else{
            System.out.println("Good");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int dp[3005][3005];
string get_s(string &s,string &t,int len){
    string ans;
    int i=0;
    int j=0;
    while(len>0){
            if(s[i]==t[j]){
                ans.push_back(s[i]);
                i+=1;
                j+=1;
                len-=1;
            }
            else{
                if(dp[i+1][j]>dp[i][j+1]){
                    i+=1;
                }
                else{j+=1;}
            }
        }
        return ans;
    }

int len_lcs(string &s,string &t,int i,int j){
  if(s.length()<=i || j>=t.length()){
      return 0;
  }
  if(dp[i][j]!=-1){
      return dp[i][j];
  }
  if(s[i]==t[j]){
      return dp[i][j]=1+len_lcs(s,t,i+1,j+1);
  }
  else{
      return dp[i][j]=max(len_lcs(s,t,i+1,j),len_lcs(s,t,i,j+1));
  }
}
int main(){
    string s,t;
    cin>>s>>t;
    memset(dp,-1,sizeof(dp));
    int x=len_lcs(s,t,0,0);
    //cout<<dp[3][4]<<endl;
    //cout<<x<<endl;
    cout<<get_s(s,t,x);

    return 0;
}

Measured memory_bytes: 35968
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int i,ans[5],n,m,s,c,sum=0;
  scanf("%d %d\n",&n,&m);
  for(i=0;i<n;i++){
    ans[i]=-1;
  }
  for(i=0;i<m;i++){
    scanf("%d %d\n",&s,&c);
    s--;
    if(ans[s]!=-1 && ans[s]!=c){
      printf("-1\n");
      return 0;
    }
    ans[s]=c;
  }
  if((n==1 && ans[0]==0) || (n==1 && ans[0]==-1)){
    printf("0\n");
    return 0;
  }
  int k=1;
  if(ans[0]==-1){
    ans[0]=1;
  }
  if(ans[0]==0){
    printf("-1\n");
    return 0;
  }
  for(i=n-1;i>=0;i--){
    if(ans[i]>=0){
    sum=sum+k*ans[i];
    }
    k=k*10;
  }
  printf("%d\n",sum);
  return 0;
}

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

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];

	sort(a.begin(), a.end());

	int cnt = 0;
	cnt += a[0];
	cnt += a[1];

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<"="<<(x)<<endl;
template<typename T>
void read(T &x)
{
	char ch=getchar();
	for (x=0;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
}
int n,m,q,xa,ya,xb,yb,ans;
char st[2010][2010];
int h[2010][2010],f[2010][2010],g[2010][2010];
int main()
{
	read(n),read(m),read(q);
	for (int i=1;i<=n;i++)
		scanf("%s",st[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			h[i][j]=st[i][j]-'0';
	for (int i=1;i<=n;i++)
		for (int j=1;j<m;j++)
			if (h[i][j]==1 && h[i][j+1]==1)
				f[i][j]=1;
	for (int i=1;i<=n;i++)
		for (int j=1;j<m;j++)
			f[i][j]+=f[i][j-1];
	for (int i=1;i<=n;i++)
		for (int j=1;j<m;j++)
			f[i][j]+=f[i-1][j];
	for (int i=1;i<n;i++)
		for (int j=1;j<=m;j++)
			if (h[i][j]==1 && h[i+1][j]==1)
				g[i][j]=1;
	for (int i=1;i<n;i++)
		for (int j=1;j<=m;j++)
			g[i][j]+=g[i][j-1];
	for (int i=1;i<n;i++)
		for (int j=1;j<=m;j++)
			g[i][j]+=g[i-1][j];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			h[i][j]+=h[i][j-1];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			h[i][j]+=h[i-1][j];
	
	for (int i=1;i<=q;i++)
	{
		read(xa),read(ya),read(xb),read(yb);
		ans=h[xb][yb]-h[xa-1][yb]-h[xb][ya-1]+h[xa-1][ya-1];
		ans-=f[xb][yb-1]-f[xb][ya-1]-f[xa-1][yb-1]+f[xa-1][ya-1];
		ans-=g[xb-1][yb]-g[xb-1][ya-1]-g[xa-1][yb]+g[xa-1][ya-1];
		printf("%d\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 53120
#include <cstdio>
#include <cstdlib>

#define NIL -1
#define MAX 200000

int gcd(long int a, long int b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

void multipleGcd(long int A[], int i, long int A0, long int *ans)
{
	if(A[i+1] == NIL){
		*ans = A0;
		return;
	}
	A0 = gcd(A0, A[i+1]);
	multipleGcd(A, i+1, A0, ans);
}

int main()
{
	int N;
	long int A[MAX], ans;
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%ld", &A[i]);
	}
	A[N] = NIL;
	multipleGcd(A, 0, A[0], &ans);
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 896
package main

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

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

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	S := next()
	if S[2] == S[3] && S[4] == S[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

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

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int k , n ; 
  cin >> k >>  n ;
  int ans = INF ;
  vector<int> v(2*n) ;
  
  rep(i,n) {
    int x ; 
    cin >> x ;
    v.at(i) = x ;
    v.at(n+i) = x + k   ;
   
  }
    
  
  rep(i,n+1){
    ans = min(ans,max(v.at(n+i-1),v.at(i)) - min(v.at(n+i-1),v.at(i))) ;
  }
  
  cout << ans ;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
int a[205][205];
int sum;
int n,m,r;
bool vis[10];
int bis[10];
void dfs(int pre,int ans,int deep){
//	cout<<pre<<"  "<<ans<<"  "<<deep<<endl;
	if(deep==r){	
		sum=min(sum,ans);
		return ;
	}
	for(int i=1;i<=r;i++){
		if(vis[i]==0){
			vis[i]=1;
			dfs(i,ans+a[bis[pre]][bis[i]],deep+1);
			vis[i]=0;
		}
	}
}
int main(){
	for(int i=1;i<=205;i++){
		for(int j=1;j<=205;j++){
			if(i==j) a[i][j]=0;
			else a[i][j]=INF;
		}
	}
	cin>>n>>m>>r;
	int aa,bb,cc;
	memset(vis,0,sizeof(vis));
	bis[0]=0;
	for(int i=1;i<=r;i++) {
	cin>>bis[i];a[0][bis[i]]=0;
}
	for(int i=1;i<=m;i++){
		cin>>aa>>bb>>cc;
		a[aa][bb]=cc;a[bb][aa]=cc;
	}
	int i,j,k;
	 for(k=1;k<=n;k++)  
      for(i=1;i<=n;i++)  
        for(j=1;j<=n;j++)  
          if(a[i][j]>a[i][k]+a[k][j])  
            a[i][j]=a[i][k]+a[k][j];  
            sum=INF;
        dfs(0,0,0);
        cout<<sum<<endl;
        return 0;
}

Measured memory_bytes: 384
a, b, c, d, e, f = list(map(int, input().split()))
ans1, ans2 = 100*a, 0
t = 0
for i in range(31):
  for j in range(31):
    if i==j==0:
      break
    w = (a*i+b*j)*100
    if w>f:
      break
    for k in range((f-w)//c+1):
      for l in range((f-w)//d+1):
        s = c*k+d*l
        if w+s>f:
          break
        if w/100*e<s:
          break
        if t<100*s/(w+s):
          ans1 = w+s
          ans2 = s
          t = 100*s/(w+s)
print(ans1, ans2)

Measured memory_bytes: 3064
S = input()
ans = 0
tmp = 0
preR = 0
if S == "SSS":
    print(0)
elif S == 'RSS' or S == 'SRS' or S == 'SSR' or S ==  'RSR':
    print(1)
elif S == 'RRS' or S == 'SRR':
    print(2)
elif S == 'RRR':
    print(3)

Measured memory_bytes: 61604
d = int(input())
c = list(map(int,input().split()))
ans = []
fin = [1]*d
pen = [0]*26
sattemp = 0
sat = 0
sl = [list(map(int,input().split())) for i in range(d)]
for k in range(1,20):
    for i in range(d):
        s = sl[i]
        sp = sum(pen)
        temp = -(10**9)
        for j in range(26):
            if s[j]-(sp-pen[j])**k > temp:
                temp = s[j]-(sp-pen[j])**k
                tempans = j+1
        ans += [tempans]
        sattemp += s[tempans-1]-sp+pen[tempans-1]
        for j in range(26):
            pen[j] += c[j]
            pen[tempans-1] = 0
    if sattemp > sat:
        sat = sattemp
        fin = ans
    ans = []
    sattemp = 0
for i in fin:
    print(i)
# print(sat)

Measured memory_bytes: 9520
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int X,Y,A,B,C; cin >> X >> Y >> A >> B >> C;
    int P[A],Q[B],R[C];
    rep(i,A) cin >> P[i];
    rep(i,B) cin >> Q[i];
    rep(i,C) cin >> R[i];
    sort(P,P+A,greater<int>());
    sort(Q,Q+B,greater<int>());
    sort(R,R+C,greater<int>());
    priority_queue<int,vi,greater<int>> PP,QQ;
    rep(i,X) PP.emplace(P[i]);
    rep(i,Y) QQ.emplace(Q[i]);
    rep(i,C) {
        if(PP.top()>QQ.top()){
            if(R[i]>QQ.top()){
                QQ.pop();
                QQ.emplace(R[i]);
            }
        } else {
            if(R[i]>PP.top()){
                PP.pop();
                PP.emplace(R[i]);
            }
        }
    }
    int ans=0;
    while(!PP.empty()){
        ans+=PP.top();
        PP.pop();
    }
    while(!QQ.empty()){
        ans+=QQ.top();
        QQ.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC140A
{
	class Program
	{
		static void Main(string[] args)
		{
			int N;
			N = int.Parse(Console.ReadLine());
 
            Console.WriteLine(N * N * N);
 
            Console.ReadKey();
		}
	}
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, K);

    i64 ans = 0;
    rep(i, 1, K + 1) rep(j, 1, K + 1) rep(k, 1, K + 1) {
        ans += gcd(i, gcd(j, k));
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  string a;
  cin>>a;
  if(a[0]-'0'+a[1]-'0'+a[2]-'0'+a[3]-'0'==7){
    cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if((a[0]-'0')+(a[1]-'0')+(a[2]-'0')-(a[3]-'0')==7){
    cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if((a[0]-'0')+(a[1]-'0')-(a[2]-'0')+(a[3]-'0')==7){
    cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if((a[0]-'0')+(a[1]-'0')-(a[2]-'0')-(a[3]-'0')==7){
    cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if((a[0]-'0')-(a[1]-'0')+(a[2]-'0')+(a[3]-'0')==7){
    cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if((a[0]-'0')-(a[1]-'0')+(a[2]-'0')-(a[3]-'0')==7){
    cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if((a[0]-'0')-(a[1]-'0')-(a[2]-'0')+(a[3]-'0')==7){
    cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"="<<7<<endl;
    return 0;
  }
  if((a[0]-'0')-(a[1]-'0')-(a[2]-'0')-(a[3]-'0')==7){
    cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"="<<7<<endl;
    return 0;
  }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <queue>

using std::priority_queue;

const int MAXN=100011;

int abs(int a){
	return (a>0)?a:(-a);
}

int N, K;

struct Vert{
	int FE;
	int Val;
	bool Vis;
} V[MAXN];

struct Edge{
	int y, next;
} E[MAXN<<1];

int Ecnt;

void addE(int a, int b){
	++Ecnt;
	E[Ecnt].y=b;E[Ecnt].next=V[a].FE;V[a].FE=Ecnt;
}

struct Pair{
	int p, v;
	Pair(){}
	Pair(int _p, int _v){p=_p;v=_v;}
};

bool operator < (Pair A, Pair B){
	return A.v<B.v;
}

priority_queue<Pair> PQ;



int main(){
	
	scanf("%d", &N);
	
	for(int i=1, a, b;i<N;++i){
		scanf("%d %d", &a, &b);
		addE(a, b);addE(b, a);
	}
	
	scanf("%d", &K);
	
	for(int i=1, p, v;i<=K;++i){
		scanf("%d%d", &p, &v);
		V[p].Val=v;V[p].Vis=true;
		PQ.push(Pair(p, v));
	}
	
	for(Pair P;!PQ.empty();){
		P=PQ.top();PQ.pop();
		int &at=P.p;
		for(int k=V[at].FE, to;k;k=E[k].next){
			to=E[k].y;
			if(V[to].Vis)	continue;
			V[to].Val=V[at].Val-1;
			V[to].Vis=true;
			PQ.push(Pair(to, V[to].Val));
		}
	}
	
	bool ret=true;
	for(int i=1;i<=Ecnt;i+=2){
		ret&=abs(V[E[i].y].Val-V[E[i+1].y].Val)==1;
	}
	
	if(!ret)	puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=N;++i)	printf("%d\n", V[i].Val);
	}
	
	
	return 0;
}

Measured memory_bytes: 4596
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
      	 	int a = 0;
      		int b = 0;
			for(int i=0; i<n;i++){
              a++;
              int lengthA = String.valueOf(a).length();
              if(lengthA%2!=0){
                b++;
              }
            }
			System.out.println(b);    
	}
}

Measured memory_bytes: 31828
import re

def get_value(expr, array_size, array):
    seq = expr.replace(']', '').split('[')
    seq[-1] = int(seq[-1])
    while len(seq) > 1:
        ind = seq.pop()
        arr = seq.pop()
        if arr not in array or ind not in array[arr]:
            raise KeyError

        seq.append(array[arr][ind])

    return seq[0]

def testcase_ends():
    array_size = {}
    array = {}

    decl_prog = re.compile(r'(\w)\[(\d+)\]')

    line = input().strip()
    if line == '.':
        return True

    i = 1
    while True:
        if line == '.':
            print(0)
            return False

        if '=' in line:
            # assignment
            lhs, rhs = line.split('=')

            name = lhs[0]
            try:
                ind = get_value(lhs[2:-1], array_size, array)
                value = get_value(rhs, array_size, array)
                if name not in array or ind >= array_size[name]:
                    raise KeyError

                array[name][ind] = value
            except KeyError:
                print(i)
                break
        else:
            # declaration
            m = decl_prog.fullmatch(line)
            assert m is not None

            name = m.group(1)
            size = int(m.group(2))
            array_size[name] = size
            array[name] = {}

        line = input().strip()
        i += 1

    line = input().strip()
    while line != '.':
        line = input().strip()

    return False

while not testcase_ends():
    pass



Measured memory_bytes: 6692
#include <iostream>
#include <bitset>
using namespace std;
int main(){
	int i;
	int N;
	int A;
	int S = 0;
	bitset<2000 * 2000> bs;
	bs[0] = 1;
	cin >> N;
	while (N--){
		cin >> A;
		bs |= (bs << A);
		//bs |= A;
		S += A;
	}	
	S = (S >> 1) + (S & 1);
	while (!bs[S]) S++;
	cout << S;

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
set<pair<int,int> >seto[26];
char s[mx];
int f[mx];
int main(){
   scanf("%s",s);
   int n=strlen(s);
   set<pair<int,int> >::iterator it;
   for(int i=0;i<n;i++){
      int ch=s[i]-'a';
      f[ch]++;
      int x=2*f[ch]-i;
      it=seto[ch].upper_bound(make_pair(x,int(1e9)));
      if(it!=seto[ch].begin()){
         it--;
         int from=it->second;
         printf("%d %d\n",from+1,i+1);
         return 0;
      }
      seto[ch].insert(make_pair(x,i));
   }
   puts("-1 -1");
   return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
#define endl '\n'
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int cnt[100003];
int main()
{
   ll n;
    cin>>n;
    ll sum=0;
    for(ll i=0; i<n; i++)
    {
        int x;
        cin>>x;
        sum+=x;
        ++cnt[x];
    }
    ll q;
    cin>>q;
    while(q--)
    {
       ll b,c;
        cin>>b>>c;
        sum-=cnt[b]*b;
        sum+=cnt[b]*c;
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout<<sum<<endl;
    }

}




Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, ti, yox, yoy, bax, bay, tiy;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ti >> yox >> yoy;
		if (abs(bax - yox) + abs(bay - yoy) > ti - tiy || abs(abs(bax - yox) - abs(bay - yoy)) % 2 != abs(tiy - ti) % 2) {
			cout << "No" << endl;
			end;
		}
		bax = yox, bay = yoy, tiy = ti;
	}
	cout << "Yes" << endl;
	end;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a > b) {
		d = a;
		a = b;
		b = d;
	}
	if (b > c) {
		d = b;
		b = c;
		c = d;
	}
	if (a > b) {
		d = a;
		a = b;
		b = d;
	}
	
	printf("%d %d %d\n", a, b, c);
	
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>

int main() {
	long double a, b, c;
	scanf("%Lf%Lf%Lf",&a,&b,&c);
	if (2 * sqrtl(a*b) + a + b < c) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
n, m = (int(_) for _ in input().split())  
l = [list(int(_) for _ in input().split()) for i in range(m)]
p = list(map(int, input().split()))
l = [i[1:] for i in l]

res = 0
for i in range(2**n):
    x = bin(i)[2:][-n:].zfill(n)
    if all([sum([int(x[ii-1]) for ii in l[i]]) % 2 == p[i] for i in range(len(l))]):
        res += 1
print(res)


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

using namespace std;

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

const long long INF = 1LL << 60;
const int MAX_V = 100100;

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

    int MAX_N = N + 2;

    vector<long long> weight(MAX_N), value(MAX_N);
    for (int i = 0; i < N; ++i)
        cin >> weight[i] >> value[i];

    vector<vector<long long>> dp(MAX_N, vector<long long>(MAX_V, INF));

    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
        {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0)
                chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i + 1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 81152
n,k,s=map(int,input().split())

arr = []

for i in range(k):
    arr.append(str(s))

for j in range(n-k):
    if s+1 >= 10*9 +1:
        arr.append(str(s-1))
    else:
        arr.append(str(s+1))
#print(arr)
print(" ".join(arr))

Measured memory_bytes: 53488
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    //入力と準備
    int c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];
    int a[3],b[3];
    int x2[3],x3[3];

    int tmp = min(c[0][0],c[1][0]); //c[0][~]の最小値をb1とおく。
    b[0] = min(tmp,c[2][0]);        //b1 を固定

    rep(i,3) a[i] = c[i][0] - b[0]; //b1 を頼りに a1,a2,a3 を固定

    rep(i,3) x2[i] = c[i][1] - a[i]; //b2 候補を選出
    rep(i,3) x3[i] = c[i][2] - a[i]; //b3 候補を選出
    if(x2[0] != x2[1] || x2[1] != x2[2] || x2[0] != x2[2]) cout << "No" << endl;    //b2 が決まらないとき
    else{
        if(x3[0] != x3[1] || x3[1] != x3[2] || x3[2] != x3[0]) cout << "No" << endl;    //b3 が決まらないとき
        else cout << "Yes" << endl; //b1,b2,b3 が決まるとき
    }
}

Measured memory_bytes: 256