akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    if (s.equals("abc")||
        s.equals("acb")||
        s.equals("bac")||
        s.equals("bca")||
        s.equals("cab")||
        s.equals("cba")) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21588
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

const ll MAX = 200100;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(ll n, ll k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll bpow(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b & 1)
            res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;

    ll ans = 0;
    ll i;
    COMinit();
    for(i = 0; i <= K; i++) {
        ll tmp = M;
        tmp = tmp * COM(N - 1, i) % MOD;
        tmp = tmp * bpow(M - 1, N - 1 - i) % MOD;
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7852
#include"bits/stdc++.h"

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main()
{
	vector<int> a(3);
	rep(i, 3){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	rep(i, 3){
		cout << a[i];
		if(i != 2){
			cout << ' ';
		}
	}
	cout << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi odd, even, b;
    rep(i, n) {
        if (i&1) {
            odd.push_back(a[i]);
        } else {
            even.push_back(a[i]);
        }
    }
    if (n&1) {
        reverse(even.begin(), even.end());
        for (int x : even) b.push_back(x);
        for (int x : odd) b.push_back(x);
    } else {
        reverse(odd.begin(), odd.end());
        for (int x : odd) b.push_back(x);
        for (int x : even) b.push_back(x);
    }
    rep(i, n) printf("%d%c", b[i], i==n-1?'\n':' ');
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    ll x;
    cin >> x;

    ll now = 100;
    int res = 0;

    while(1){
        res++;
        now += now / 100;
        if (now >= x) break;
    }
    cout << res << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

#ifdef DEBUG_MODE
    #define DBG(n) n;
#else
    #define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

bool dp[777][777];

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

	vector<vector<int>> tmpv(n);
	vector<vector<int>> v(n);

	REP(i,m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		tmpv[a].PB(b);
		tmpv[b].PB(a);
	}

	REP(i,n) {
		vector<bool> used(n);
		used[i] = true;
		REP(j,tmpv[i].size()) {
			used[tmpv[i][j]] = true;
		}
		REP(j,n) {
			if(!used[j]) v[i].PB(j);
		}
	}

	vector<int> color(n);
	vector<pair<int, int>> rkt;
	REP(i,n) {
		if(color[i] == 0) {
			pair<int, int> hoge = MP(0,0);
			color[i] = 1;
			queue<int> q;
			q.push(i);
			while(! q.empty()) {
				int now = q.front();
				q.pop();
				if(color[now] == 1) hoge.FI++;
				else hoge.SE++;
				REP(j,v[now].size()) {
					if(color[v[now][j]] == 0) {
						color[v[now][j]] = -color[now];
						q.push(v[now][j]);
					}
					else if(color[v[now][j]] == color[now]) {
						cout << -1 << endl;
						return 0;
					}
				}
			}
			rkt.PB(hoge);
		}
	}

	dp[0][0] = true;
	REP(i,rkt.size()) {
		REP(j,777) {
			if(dp[i][j]) {
				dp[i + 1][j + rkt[i].FI] = true;
				dp[i + 1][j + rkt[i].SE] = true;
			}
		}
	}

	ll ans = LLINF;
	REP(i,777) {
		if(dp[rkt.size()][i]) {
			ll tmp = (i*(i-1) + (n-i)*(n-i-1))/2;
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n, m, a[114514], b[114514],ans = 0;
int main() {
	cin >> n >> m;
	REP(i, n) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n, greater<ll>());
	sort(b, b + n, greater<ll>());
	REP(i, n) {
		if (m <= 0)break;
		if (a[0] < b[i]) {
			m -= b[i];
			ans++;
		}
	}
	m = max(0ll, m);
	cout << ans + (m + a[0] - 1) / a[0] << endl;
}



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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a * b }) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,pre = -1;

	int tmp,ans = 0,count = 0;

	scanf("%d",&N);

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

		scanf("%d",&tmp);
		if(pre >= tmp){

			count++;
			ans = max(ans,count);

		}else{

			count = 0;
		}
		pre = tmp;
	}

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

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        if(k % 2 == 0){
            System.out.println(a-b);
            return;
        }
        System.out.println(b-a);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int nya(string s){
  set<char> u;
  rep(i, s.size()) u.insert(s[i]);
  return u.size();
}

int main() {
  int n;
  cin >> n;
  vector<queue<string>> v(10);
  v[0].push("a");
  rep(i, n-1){
    while(!v[i].empty()){
      string tmp = v[i].front();
      v[i].pop();
      rep(j, nya(tmp)+1){
        string t = tmp;
        t += (char)'a'+j;
        v[i+1].push(t);
      }
    }
  }
  while(!v[n-1].empty()){
    cout << v[n-1].front() << endl;
    v[n-1].pop();
  }
  return 0;
}

Measured memory_bytes: 7936
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str;
    cin>>str;
    if(str[0]=='7' || str[1]=='7' || str[2]=='7')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3644
from collections import Counter
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
su=sum(v[:a])
avg=su/a
tot=0
inside=0
c=[ [0]*51 for _ in range(51)]
for i in range(n+1):
    for j in range(i+1):
        if j==0 or j==i:
            c[i][j]=1
        else:
            c[i][j]=c[i-1][j]+c[i-1][j-1]
for i in range(n):
    if v[i]==v[a-1]:
        tot+=1
        if i<a:
            inside+=1
cnt=0
if inside==a:
    for i in range(a,b+1):
        cnt+=c[tot][i]
else:
    cnt+=c[tot][inside]
print(avg)
print(cnt)

        




Measured memory_bytes: 3316
# DP(貰うDP)
INF = float('inf')

N = int(input())

c = [1]
t = 6
while t <= N:
    c.append(t)
    t *= 6
t = 9
while t <= N:
    c.append(t)
    t *= 9

dp = [0] * (N + 1)
for i in range(1, N + 1):
    t = INF
    for j in c:
        if i - j >= 0 and t > dp[i - j] + 1:
            t = dp[i - j] + 1
    dp[i] = t
print(dp[N])


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

int calc(int a, int k) {
    int n = a / k;
    if (n <= 0) return 0;
    if (a % k == 0) return n;
    if ((a - n - 1) / k != n) return calc(a-n-1, k);
    int m = a / k * k + (a % k) % (n+1); 
    return calc(m, k);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a, k;
        cin >> a >> k;
        ans ^= calc(a, k);
    }
    if (ans) cout << "Takahashi\n";
    else cout << "Aoki\n";
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	var msg string
	if isDistinct(as) {
		msg = "YES"
	} else {
		msg = "NO"
	}

	fmt.Print(msg)
}

func isDistinct(as []int) bool {
	m := make(map[int]int)
	for _, a := range as {
		if m[a] == 0 {
			m[a]++
		} else {
			return false
		}
	}
	return true
}

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

int main(){

    long long a,b,c,d;
    cin >> a >> b >> c >> d;

    long long ac,ad,bc,bd;
    ac = a*c;
    ad = a*d;
    bc = b*c;
    bd = b*d;

    cout << max(ac,max(ad,max(bc,bd)));
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<map>
//#include<iostream>
using namespace std;

int n;
#define maxn 100011
int a[maxn];
int main()
{
	scanf("%d",&n);
	int cnt=0,ans=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]==i) cnt++;
		else ans+=(cnt+1)/2,cnt=0;
	}
	ans+=(cnt+1)/2;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main(void)
{
  int k;
  string s,l; cin>>k>>s;
  
  if(s.length()<=k){cout<<s<<endl;}
  else{l=s.substr(0,k); cout<<l<<"..."<<endl;}
  
  return 0;
}

Measured memory_bytes: 3632
/************************************************
*Author        :  lrj124
*Created Time  :  2018.11.01.19:08
*Mail          :  1584634848@qq.com
*Problem       :  b
************************************************/
#include <bits/stdc++.h>
using namespace std;
int n,t,a,ans,h;
double Min = 999999999,k;
inline double f_abs(double x) { return x < 0 ? -x : x; }
int main() {
	scanf("%d%d%d",&n,&t,&a);
	for (int i = 1;i <= n;i++) {
		scanf("%d",&h);
		k = t-1.0*h*0.006;
		if (f_abs(a-k) < Min) {
			Min = f_abs(a-k);
			ans = i;
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main()
{
	string S,T;
	bool diff;
	int ansi=-1;
	string ans="UNRESTORABLE";
	
	cin >> S >> T;
	
	for(int i=S.size()-T.size();i>=0;i--)
	{
		diff=false;
		for(int j=0;j<T.size();j++)
		{
			if(S[i+j]=='?' || S[i+j]==T[j])
				continue;
			diff=true;
			break;
		}
		if(diff==true)
			continue;
		ansi=i;
		break;
	}
	
	if(ansi==-1)
	{
		cout << ans << endl;
		return 0;
	}
	
	ans=S;
	for(int i=0;i<T.size();i++)
	{
		if(ans[ansi+i]=='?')
			ans[ansi+i]=T[i];
	}
	for(int i=0;i<ans.size();i++)
	{
		if(ans[i]=='?')ans[i]='a';
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c ;
    
    if ( a < b ) {
        if ( b < c ) {
            cout << "Yes" << endl ;
        } else {
            cout << "No" << endl ;
        }
    } else {
        cout << "No" << endl;
    }
    return 0 ;
}



Measured memory_bytes: 3044
#include <iostream>
#include <cstdlib>
#include <cassert>
const static int R_MAX = 12;
const static int C_MAX = 10012;
using namespace std;

int bt( int s[ R_MAX ][ C_MAX ], int r, int c, int depth ) {
  if( depth == r ) {
    int sum = 0;
    for( int cj = 0; cj < c; cj++ ) {
      int cnt_1 = 0;
      int cnt_m1 = 0;
      for( int ri = 0; ri < r; ri++ ) {
        if( s[ ri ][ cj ] == 1 ) {
          cnt_1++;
        } else {
          cnt_m1++;
        }
      }
      sum += max( cnt_1, cnt_m1 );
    }
    return sum;
  }

  int na = bt( s, r, c, depth + 1 );
  for( int cj = 0; cj < c; cj++ ) {
    s[ depth ][ cj ] = -s[ depth ][ cj ];
  }
  int nb = bt( s, r, c, depth + 1 );
  for( int cj = 0; cj < c; cj++ ) {
    s[ depth ][ cj ] = -s[ depth ][ cj ];
  }

  return max( na, nb );
}

int main() {
  int r, c;
  int s[ R_MAX ][ C_MAX ] = {0}; // ura: -1, omote: 1, none: 0

  while( 1 ) {
    cin >> r >> c;
    if( !r && !c ) { break; }
    for( int ri = 0; ri < r; ri++ ) {
      for( int cj = 0; cj < c; cj++ ) {
        int tmp;
        cin >> tmp;
        s[ ri ][ cj ] = !tmp ? -1 : 1;
      }
    }

    cout << bt( s, r, c, 0 ) << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1636
import numpy as np
import copy


def main():
    N = int(input())

    t = 0
    for i in range(int(N**0.5), 0, -1):
        if N % i == 0:
            t = N // i
            break

    assert t > 0
    n_digits = len(str(t))

    print(n_digits)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12424
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }

    if (a as i64 - c as i64).abs() <= d as i64 || 
      ((a as i64 - b as i64).abs() <= d as i64 && 
       (b as i64 - c as i64).abs() <= d as i64){
        println!("Yes");
    } else {
        println!("No");
    }

}


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

int mod(const int& a)
	{
		if(a>=0)return a%1000000007;
		return mod(a+1000000007);
}


int main()
{

	int n,k;
	cin>>n>>k;
	int a[101];
	for(int i=0;i<n;i++)
	{
		cin>>a[i+1];
	}
	int dp[101][100001]={};
	for(int i=0;i<=k;i++)
	{
		dp[0][i]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(j)
				dp[i][j]=dp[i][j-1];
			dp[i][j]=mod(dp[i][j]+=(dp[i-1][j]-((j-a[i]-1)>=0?dp[i-1][j-a[i]-1]:0)));
		}
	}
	cout<<mod(dp[n][k]-dp[n][k-1])<<endl;
}
	


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

int main() {
	int N, M, C;

	cin >> N >> M >> C;

	vector<int> B(M);

	vector<vector<int>> A(N, vector<int>(M));

	for (int i = 0; i < M; ++i) {
		cin >> B[i];
	}

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> A[i][j];
		}
	}

	int ans = 0;
	
	for (int i = 0; i < N; ++i) {
		int sum = 0;
		for (int j = 0; j < M; ++j)  sum += B[j] * A[i][j];
		if (sum + C > 0) ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
 
#define int long long
#define MOD7 1000000007
#define MOD9 1000000009
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
 
using namespace std;
 
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };
 
int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}
 
template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
 
signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
 
    cout << max(a * b, c * d) << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
   int n;
   cin >> n;
   map<int,int>ma;
   for(int i=0;i<n-1;i++){
      int z;
      cin >> z;
      z--;
      if(ma.count(z))ma.at(z)++;
      else ma[z]=1;
   }

   for(int i=0;i<n;i++){
      if(ma.count(i)){

         cout << ma.at(i)<<endl;
      }
      else cout<<0<<endl;
   }

}
    



Measured memory_bytes: 13000
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N, X, M;
    cin >> N >> X >> M;

    long long a = X;
    vector<long long> A;
    map<int, int> reached;
    A.push_back(a);
    reached.insert(make_pair(a, 0));
    long long beforeLoop = -1;
    long long loopSteps = 0;
    for (long long i = 1; i < N; ++i) {
        a = (a * a) % M;
        if (reached.count(a) == 0) {
            A.push_back(a);
            reached.insert(make_pair(a, i));
        }
        else {
            loopSteps = i - reached[a];
            beforeLoop = reached[a];
            break;
        }
    }

    if (beforeLoop < 0) {
        long long ans = 0LL;
        for (long long i = 0; i < A.size(); ++i) {
            ans += A[i];
        }
        cout << ans << endl;
        return;
    }

    long long ans = 0LL;
    for (long long i = 0; i < beforeLoop; ++i) {
        ans += A[i];
    }
    long long loopTotal = 0LL;
    for (long long i = 0; i < loopSteps; ++i) {
        loopTotal += A[i + beforeLoop];
    }
    long long nloop = (N - beforeLoop) / loopSteps;
    ans += loopTotal * nloop;
    if ((N - beforeLoop) % loopSteps > 0) {
        int n = (N - beforeLoop) % loopSteps;
        for (long long i = 0; i < n; ++i) {
            ans += A[i + beforeLoop];
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5820
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())
    if n % 2 == 0:
        print(n*(n-2)//2)
        for i in range(1,n//2+1):
            leave = [k for k in range(n+1)]
            leave.pop(n-i+1)
            for j in leave[i+1:]:
                print(str(i) + ' ' + str(j))
        for i in range(n//2+1,n+1):
            for j in range(i+1,n+1):
                print(str(i) + ' ' + str(j))
    else:
        print(((n-1)**2)//2)
        for i in range(1,(n+1)//2):
            leave = [k for k in range(n)]
            leave.pop(n-i)
            for j in leave[i+1:]:
                print(str(i) + ' '+ str(j))
        for i in range((n+1)//2,n):
            for j in range(i+1,n):
                print(str(i)+ ' ' + str(j))
        for i in range(1,n):
            print(str(i)+ ' ' + str(n))


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    lint N;
    cin >> N;

    set<lint> favs;
    for (lint p = 1;p <= N / p; p++)
        if (N % p == 0) {
            lint m = N / p - 1;
            if (m > 0 && N / m == N % m)
                favs.insert(m);
            m = p - 1;
            if (m > 0 && N / m == N % m)
                favs.insert(m);
        }

    lint total = accumulate(ALL(favs), 0LL);
    cout << total << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    string s;
    cin >> s;
    if(s=="SSS") cout << 0 << endl;
    else if(s=="SRR"||s=="RRS") cout << 2 << endl;
    else if(s=="RRR") cout << 3 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << ", ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << " ]" ;
}

#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
#define sz(a) (ll)(a).size()
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll d, t, s;
    cin >> d >> t >> s;
    if(t * s >= d){
        print("Yes");
    }
    else print("No");
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


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

using namespace std;

const double EPS = 1e-10;
bool equals(double a, double b){ return (fabs(a) - fabs(b)) < EPS;};

class Point{
public:
	double x, y;
	
	Point(double x = 0, double y = 0): x(x), y(y) {}
	Point(const Point &p) { x = p.x; y = p.y;};
	
	Point operator + (const Point &p) { return Point(x + p.x, y + p.y); }
	Point operator - (const Point &p) { return Point(x - p.x, y - p.y); }
	Point operator * (const double &a) { return Point(x * a, y * a); }
	Point operator / (const double &a) { return Point(x / a, y / a); }
	
	Point & operator = (const Point& p) {x = p.x; y = p.y; return *this;};
	Point & operator += (const Point& p) {x += p.x; y += p.y; return *this;};
	Point & operator -= (const Point& p) {x -= p.x; y -= p.y; return *this;};
	Point & operator *= (const Point& p) {x *= p.x; y *= p.y; return *this;};
	Point & operator /= (const Point& p) {x /= p.x; y /= p.y; return *this;};
	
	bool operator < (const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}
	
	bool operator > (const Point &p) const {
		return x != p.x ? x > p.x : y > p.y;
	}
	
	bool operator == (const Point &p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
	
	double abs() { return sqrt(norm()); };
	double norm() { return x * x + y * y;};
};

typedef Point Vector;


double norm(Vector a){
	return a.x * a.x + a.y * a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

struct Segment{
	Point p1, p2;
};

typedef Segment Line;


bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a,b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2){
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}


bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
	return isParallel(a1 - a2, b1 - b2);
}

bool isPrallel(Segment s1, Segment s2){
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}


Point project(Segment s, Point p){
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base * r;
}

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef vector<Point> Polygon;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int q;
	Segment s;
	
	
	cin>>s.p1.x>>s.p1.y>>s.p2.x>>s.p2.y;
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		Point p, ans;
		
		cin>>p.x>>p.y;
		
		ans = project(s, p);
		
		cout<<ans.x<<" "<<ans.y<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3304
n=int(input())
c=[]
for i in range(n-1):
    x,y,z=map(int,input().split())
    c.append((x,y,z))
for i in range(n-1):
    ans=0
    for j in range(i,n-1):
        ans=[c[j][1]+((ans-c[j][1]+c[j][2]-1)//c[j][2])*c[j][2],c[j][1]][ans<c[j][1]]
        ans+=c[j][0]
    print(ans)
ans=chk=0
print(ans)

Measured memory_bytes: 43884
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=1;
        
            n = sc.nextInt();
            
            int x[] = new int[n]; 
            for(int i=0;i<n; i++){
                x[i] = sc.nextInt();
            }
            int cnt=0,z;
            for(int i = 0;i<n;i++){
                for(int j = 0;j<n-1;j++){
                if(x[j] > x[j+1]){
                    cnt++;
                    z = x[j];
                    x[j] = x[j+1];
                    x[j+1] = z;
                }
                }    
            }
            for(int i = 0; i<n-1;i++){
                System.out.printf("%d ",x[i]);
            }
            System.out.printf("%d%n%d%n",x[n-1],cnt);
        
        
        sc.close();
    }
}



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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(x), end(x), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(x), rend(x), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T>
constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args>
constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args>
constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class T>
constexpr T ceiling(const T a, const T b) { return (a + b - 1) / b; }
ll plusMod(ll& a, const ll b) { return a = (a + b) % mod; }
template<typename A, size_t N, typename T>
constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, pos[100005];
void solve() {
    cin >> n;

    rep(i, n) {
        int p;
        cin >> p;
        --p;
        pos[p] = i;
    }

    ll ans = 0;
    multiset<int> s;
    s.insert(-1);
    s.insert(-1);
    s.insert(n);
    s.insert(n);
    s.insert(n);
    repd(i, n) {
        auto p = pos[i];
        s.insert(p);

        auto it = s.find(p);
        auto ne = next(it);
        auto ne2 = next(ne);
        auto pre = prev(it);
        auto pre2 = prev(pre);

        ans += ((ll)i + 1) * (((ll)* ne2 - *ne) * ((ll)* it - *pre)
            + ((ll)* pre - *pre2) * ((ll)* ne - *it));

    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

//===
struct UnionFind {
    int n;
    vector<int> parent;

    UnionFind() {}
    UnionFind(int nmemb) { init(nmemb); }

    void init(int nmemb) {
        parent.clear();
        parent.assign(nmemb, -1);
    }

    int root(int x) {
        if (parent[x] < 0) {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -(parent[root(x)]); }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);

        if (x == y) return;

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    }
};
//===

llong n, m;
llong p[100005];
llong x, y;

int main() {
    UnionFind s(100005);
    
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }

    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        s.unite(p[x], p[y]);
    }

    llong ans = 0;
    for (int i = 1; i <= n; i++) {
        if (s.same(p[i], i)) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  long ans, N, K, c;
  scanf("%ld %ld", &N, &K);
  c = N/K;

  if(K % 2 == 0){
    ans = c*c*c;
    if((N - K/2) >= 0){                                                                        
      c = (N - K/2)/K + 1;
      ans += c*c*c;
    } 
  }else {
  ans = c*c*c;
 }

  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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; } //最大公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(0,b+c-a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int n,t[105]={},sum=0;
    cin>>n;
    rep(i,n){
        cin>>t[i];
        sum+=t[i];
    }
    int m,p,x;
    cin>>m;
    rep(i,m){
        cin>>p>>x;
        cout<<sum - t[p-1] + x<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 998244353;

int main(){
  ll n;
  cin >> n;
  vector<ll>a(n);
  for(int i=0; i<n; i++ ){
    cin >> a[i];
    if(a[i]>i || a[i]-a[i-1]>1){
     cout << -1 << endl;
     return 0;
    }
  }
  reverse(a.begin(),a.end());
  ll ans=a[0];
  for(int i=1; i<n ;i++){
    if(a[i]!=a[i-1]-1) ans+=a[i];
  }
  cout << ans << endl;
}
  
  
  
  


Measured memory_bytes: 1920
n=int(input())
Tree_List=list(map(int,input().split()))
ct =0
for i in range(n):
    while Tree_List[i] != 0:
        k = i
        while Tree_List[k] != 0: 
            k+=1
            if k == n:
                break
        Tree_List[i:k]=map(lambda x:x-1,Tree_List[i:k])
        ct += 1
        
print(ct)

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

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

  int n = s.size();

  int ans = 0;
  rep(i, n) {
    int num = s[i] - '0';
    ans = (ans + num) % 9;
  }

  if (ans == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3692
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll k, a, b;
  cin >> k >> a >> b;
  ll ans = 0;
  if (b - a >= 2) {
    k -= (a - 1);
    ans = a + k / 2 * (b - a);
    if (k & 1) {
      ans++;
    }
  } else {
    ans = 1 + k;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
N,K,*as=$<.read.split.map(&:to_i)
as.sort!

if as.max < K
    ret = false
elsif as.include?(K)
    ret = true
else
    gcd = as.each_cons(2).map { |a,b| b-a }.inject(&:gcd)
    ret = as.any? {|a| 0 < a && (a-K) % gcd === 0 }
end

puts (ret ? 'POSSIBLE' : 'IMPOSSIBLE')



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

int main(){
  int n1,n2;
  char op;
  cin >> n1 >> op >> n2;
  if(op == '+'){
    cout << n1 + n2 << endl;
  }else{
    cout << n1 - n2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 200;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

vector<int> g[N];

int col[N], ans;

void bfs(int v){
    queue<int> q;
    q.push(v);
    while (!q.empty() && ans){
        int v = q.front();
        if (col[v] == ans) ans++;
        q.pop();
        for (int to : g[v]){
            if (col[to]){
                if (abs(col[to] - col[v]) != 1){
                    ans = 0;
                    break;
                }
            }
            else{
                col[to] = ans;
                q.push(to);
            }
        }
    }
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int root = -1;
    for (int i = 0; i < n; i++){
        char c;
        for (int j = 0; j < n; j++){
            cin >> c;
            if (c == '1'){
                g[i].pb(j);
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < n; i++){
        memset(col, 0, sizeof(col));
        col[i] = ans = 1;
        bfs(i);
        mx = max(ans, mx);
    }
    cout << mx - 1;
    return 0;
}


Measured memory_bytes: 512
N = int(input())
LR = [[int(i) for i in input().split()] for _ in range(N)]

# 区間を右端の小さい順にソート
LR = sorted([(x-l, x+l) for x,l in LR],key=lambda x: x[1])

ans = 0
# 現在選んでいる区間の内、最も右にある区間の右端
cur_R = -float("inf")

for i in range(N):
    # 区間が被るとき
    if cur_R > LR[i][0]:
        continue
    ans += 1
    cur_R = LR[i][1]

print(ans)

Measured memory_bytes: 37160
n = int(input())
s = input()
red = s.count('R')
green = s.count('G')
blue = s.count('B')
res = red * green * blue
k = n//2
for i in range(n-2):
    for t in range(i+1,((n-1+i)//2)+1):
        if set((s[i],s[t],s[2*t-i])) == set(('R','G','B')):
            res -= 1
print(res)

Measured memory_bytes: 74444