akhauriyash/Code-Regression huggingface dataset:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()
A = inlist()
pos = [0]*(n+1)

for i in range(n):
    pos[A[i]] = i+1
A = sorted(A)
res = []
for i in A:
    res.append(pos[i])
print(*res)


Measured memory_bytes: 14060
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector


int n;
int arr[N];

signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    cin>>n;
    forn(i,1,n)cin>>arr[i];
    sort(arr+1,arr+1+n);
    
    if(arr[n]-arr[1]>1){
        cout<<"No";
        return 0;
    }
    
    if(arr[1] == arr[n])
    {
        if(arr[1] == n-1 or 2*arr[1]<=n)cout<<"Yes";
        else cout<<"No";
        return 0;
    }
    
    int x = 0, y = 0;
    forn(i,1,n)x += (arr[i]==arr[1]);
    y = n - x;
    int gr = arr[1] - x + 1;
    
    if(gr*2 <= y and gr>0)cout<<"Yes";
    else cout<<"No";
    



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

// デバッグ用
#define _DEBUG
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
// ここまで
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    string str;
    cin >> str;
    char pre = 0;
    int s = 0;
    int cnt = 0;
    REP(i, str.length()) {
        if(str[i] == (i % 2 ? '0' : '1'))
            cnt++;
    }
    cout << min(cnt, (int)str.length() - cnt);
    return 0;
}

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

#define MAX_N 100000+10

struct ST
{
	int size = 0;

	bool left_cal;
	bool right_cal;
};

int light[MAX_N];
int grp_size[MAX_N];

int main(void)
{
	int n;

	int grp_n = 1;

	int max_sum=0;

	int i;

	cin >> n;

	cin >> light[0];
	grp_size[1]++;

	for (i = 1; i < n; i++)
	{
		cin >> light[i];

		if (light[i] != light[i - 1])
		{
			grp_size[grp_n]++;
		}
		else
		{
			grp_n++;
			grp_size[grp_n]++;
		}
	}

	max_sum = max(grp_size[1]+ grp_size[2], grp_size[grp_n]+ grp_size[grp_n-1]);

	for (i = 1; i < grp_n; i++)
	{
		max_sum = max(max_sum, grp_size[i - 1] + grp_size[i] + grp_size[i + 1]);
	}

	cout << max_sum << endl;

	return 0;
}


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

int main(){
  int m=-1;
  int n,nn;
  cin>>n>>nn;
  vector<int> a(n);
  a[0]=nn;
  int ans=0;
  for(int i=1;i<n;i++){
    cin>>a[i];
    if(a[i-1]==a[i]){
      ans++;
      a[i]=m;
      m--;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

map<int, int> ma;

void returnOriginalValues(int p, int x)
{
	if(p <= ma.size())
	   	ma[p] = x;
}

int sumMap(int n)
{
	int sum = 0;
	for(int i = 1; i <= n; i++)
		sum += ma[i];
	return sum;
}

int main()
{
	int n, m, k, p, x;
	scanf("%d", &n);
	
	ma[0] = 0;
	
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &m);
		ma[i] = m;
	}
	
	scanf("%d", &k);
	
	for(int i = 0; i < k; i++)
	{
		scanf("%d %d", &p, &x);
		
		int temp = ma[p];
		ma[p] = x;
		
		printf("%d\n", sumMap(n));
		
		returnOriginalValues(p, temp);
	}
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func bi(m []int, l, r int) int {
	var ml, mr, mm int
	ml, mr = 0, len(m)-1
	mm = (ml + mr) / 2
	for {
		if m[mm] > l && r > m[mm] {
			return 1
		}
		if ml == mr {
			return 0
		} else if l >= m[mm] {
			ml = mm + 1
			mm = (ml + mr) / 2
		} else if m[mm] >= r {
			mr = mm
			mm = (ml + mr) / 2
		}
	}
}

func main() {
	var S string
	fmt.Scan(&S)
	fmt.Scan(&S)
	M := make(map[int][]int)
	for i, s := range S {
		ns, _ := strconv.Atoi(string(s))
		M[ns] = append(M[ns], i)
	}
	var ans, l, r int
	for i := 0; i < 10; i++ {
		if m, ok := M[i]; ok {
			l = m[0]
			for j := 0; j < 10; j++ {
				if m, ok := M[j]; ok {
					r = m[len(m)-1]
					for k := 0; k < 10; k++ {
						if m, ok := M[k]; ok && r > l {
							ans += bi(m, l, r)
						}
					}
				}
			}
		}
	}
	fmt.Println(ans)
}


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

int main()
{
	int64_t l, r, mod = 2019;
	cin >> l >> r;

	if (r - l < 2019)
	{
		int64_t ans = 2019;
		for (int64_t i = l; i <= r; i++)
		{
			for (int64_t j = i + 1; j <= r; j++)
			{
				ans = min(ans, i * j % mod);
			}
		}
		cout << ans << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int l=a+b;
	int r=c+d;
	if(l>r)cout<<"Left"<<endl;
	else if(r>l)cout<<"Right"<<endl;
	else cout<<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int n;
vector<int> et[100000];
map<P, int> mp;
int ans[100000];

void dfs(int p, int v, int pColor) {
	int i;
	
	int color = -1;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		
		color++;
		if (color == pColor) color++;
		
		//v --> nvを塗る. 辺{v, nv}が何番目か？
		int a = v; int b = nv;
		if (a > b) swap(a, b);
		int edge_id = mp[P(a, b)];
		ans[edge_id] = color;
		
		dfs(v, nv, color);
	}
}

signed main() {
	int i;
	
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		mp[P(a, b)] = i;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	dfs(-1, 0, -1);
	
	int K = 0;
	rep(i, n) K = max(K, ans[i]);
	K++;
	cout << K << endl;
	
	rep(i, n - 1) cout << ans[i] + 1 << endl;
	return 0;
}

Measured memory_bytes: 15744
def num(a,m)
	t = a
	n = 1
	while t != 1
		t = t*a%m
		n+=1
	end
	n
end

while gets
	a1,m1,a2,m2,a3,m3 = $_.split.map(&:to_i)
	break if [a1,m1,a2,m2,a3,m3] == [0,0,0,0,0,0]
	x,y,z = [num(a1,m1),num(a2,m2),num(a3,m3)]
	p x.lcm(y).lcm(z)
end

Measured memory_bytes: 6128
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   ll N, A, B;
   cin >> N >> A >> B;
   if (A > B) cout << 0 << endl;
   else if (A == B) cout << 1 << endl;
   else if (N == 1) cout << 0 << endl;
   else {
      B -= A;
      ll ans = 0;
      ans = (N - 2) * B + 1;
      cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 256
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define PCC pair<char,char>
#define PIC pair<int,char>
#define Pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PI 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE() freopen("out0.txt","w",stdout)
#define IN scanf
#define OUT(x) cout<<x<<endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second

#include<iostream>
#include <limits.h>
#include<algorithm> 

using namespace std;
int main()
{
  ll result = INF;
  // 入力
  int size = 3;
  ll ary[size];
  scanf("%lld %lld %lld", &ary[0], &ary[1], &ary[2]);
  sort(ary, ary + size);
  
  if(ary[0] % 2 == 0 || ary[1] % 2 == 0 || ary[2] % 2 == 0) {
    result = 0;
  } else {
    result = ary[0] * ary[1];
  }
  OUT(result);
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    ll a[200005];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<ll>());
    int k = 1;
    ll ans = a[0];
    for(int i = 1; i < n; i++){
        if(k < n - 2){
            ans += a[i] * 2;
            k += 2;
        }
        else if(k == n - 2){
            ans += a[i];
            k++;
        }
    }
    cout << ans << endl;
}


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

int main(void)
{
	int i,t,lon,count=0;
	char s[27];
	scanf("%s",s);
	
	lon=strlen(s);
	
	for(i=0;i<lon;i++){
		for(t=i+1;t<lon;t++){
			if(s[i]==s[t]){
				count++;
			}
		}
	}
	
	if(count!=0){
		printf("no\n");
	} else{
		printf("yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
def solve(bit):
    ret = 0
    score = 0
    done = set()
    for i in range(D):
        if bit[i]:
            done.add(i)
            ret += L[i][0]
            score += ((i + 1) * 100) * L[i][0] + L[i][1]
    j = D - 1
    cnt = 0
    while score < G:
        while j in done:
            j -= 1
        ret += 1
        cnt += 1
        score += (j + 1) * 100
        if cnt == L[j][0]:
            done.add(j)
            score += L[j][1]
            cnt = 0
    return ret

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = float('inf')
for i in range(1 << D):
    bit = [0] * D
    for j in range(D):
        if i >> j & 1:
            bit[j] = 1
    ans = min(ans, solve(bit))
print(ans)


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

int main(void){
  char s[16], t[16];
  scanf("%s%s", s, t);
  int sn = strlen(s);
  int tn = strlen(t);
  // printf("s: %s, len(%d)\nt: %s, len(%d)\n", s, sn, t, tn);
  if(memcmp(s, t, sn)  == 0){
    if(tn == sn+1){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300010;
int n, t[N];
ll sum[N], fl[N], fr[N];
int X[N]; ll Y[N];
int stk[N], top;
inline void Clear() {top = 0;}
inline double slope(int x, int y) {return 1.0 * (Y[y] - Y[x]) / (X[y] - X[x]);}
inline void Push(int x) {
	while (top >= 2 && slope(stk[top - 1], stk[top]) <= slope(stk[top], x)) -- top;
	stk[++ top] = x;
}
inline void Pop(int i) {while (top >= 2 && slope(stk[top - 1], stk[top]) <= i) -- top;}
inline void dp(ll *f) {
	for (int i = 1; i <= n; ++ i) sum[i] = sum[i - 1] + t[i];
	f[0] = X[0] = Y[0] = 0; Clear(); Push(0);
	for (int i = 1; i <= n; ++ i) {
		Pop(i);
		f[i] = f[stk[top]] + 1ll * (i - stk[top]) * (i - stk[top] + 1) / 2 - (sum[i] - sum[stk[top]]);
		f[i] = max(f[i], f[i - 1]);
		X[i] = i; Y[i] = f[i] + sum[i] + 1ll * (i - 1) * i / 2;
		Push(i);
	}
}
ll F[N], tmp[N];
void solve(ll *f1, ll *f2, int l, int r) {
	if (l == r) {F[l] = max(F[l], f1[l - 1] + f2[l + 1] - t[l] + 1); return ;}
	int mid = (l + r) >> 1;
	Clear();
	for (int i = l - 1; i < mid; ++ i) {
		Y[i] = 1ll * i * i - i + 2ll * f1[i] + 2ll * sum[i];
		Push(i);
	}
	for (int i = mid; i <= r; ++ i) {
		Pop(2 * i);
		tmp[i] = f2[i + 1] + f1[stk[top]] - sum[i] + sum[stk[top]] + 1ll * (i - stk[top]) * (i - stk[top] + 1) / 2;
	}
	for (int i = r - 1; i >= mid; -- i) tmp[i] = max(tmp[i], tmp[i + 1]);
	for (int i = mid; i <= r; ++ i) F[i] = max(F[i], tmp[i]);
	solve(f1, f2, l, mid); solve(f1, f2, mid + 1, r);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) scanf("%d", &t[i]);
	dp(fl); reverse(t + 1, t + n + 1); dp(fr); reverse(fr + 1, fr + n + 1); reverse(t + 1, t + n + 1);
	for (int i = 1; i <= n; ++ i) F[i] = -t[i], sum[i] = sum[i - 1] + t[i];
	solve(fl, fr, 1, n);
	reverse(t + 1, t + n + 1); reverse(F + 1, F + n + 1); reverse(fl + 1, fl + n + 1); reverse(fr + 1, fr + n + 1);
	for (int i = 1; i <+ n; ++ i) sum[i] = sum[i - 1] + t[i];
	solve(fr, fl, 1, n); reverse(t + 1, t + n + 1); reverse(F + 1, F + n + 1); reverse(fl + 1, fl + n + 1); reverse(fr + 1, fr + n + 1);
	int m; scanf("%d", &m);
	for (int i = 1; i <= m; ++ i) {
		int x, y; scanf("%d%d", &x, &y);
		printf("%lld\n", max(fl[x - 1] + fr[x + 1], F[x] - y + t[x]));
	}
	return 0;
}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i = 0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int c = 0;
  bool ans = false;
  
  while(true){
    for(int i = 0; i<N; i++){
      if(vec.at(i) % 2 > 0) {
        ans = true;
        break;
      }
      vec.at(i) = vec.at(i) / 2;
    }
    if(ans) break;
    c++;
  }
  cout << c << endl;
}
   

Measured memory_bytes: 256
ans = [0 for i in range(10050)]
for i in range(1, 105):
  for j in range(1, 105):
    for k in range(1, 105):
      v = i**2 + j**2 + k**2 + i*j + j*k + i*k
      if v < 10050:
        ans[v]+=1
       
n = int(input())
for i in range(n):
  print(ans[i+1])




Measured memory_bytes: 9068
#include<stdio.h>

#define nMAX 20
#define qMAX 200

int solve(int,int);
int n,A[nMAX];
int main()
{
  int q,m[qMAX],i;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i = 0 ; i < q ; i++)
    {
      scanf("%d",&m[i]);
    }

  for(i = 0 ; i < q ; i++)
    {
      if(solve(0,m[i])) printf("yes\n");
      else printf("no\n");
    }

  return 0;
}

int solve(int i,int m)
{
  int res;

  if(m == 0) return 1;

  if(i >= n ) return 0;

  res = solve(i+1,m) || solve(i+1,m-A[i]);

  return res;
}



Measured memory_bytes: 2108
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,k,q) = get!(usize, usize, usize);
    let a = get!(usize; q);

    let mut scores = vec![0; n+1];
    for e in a {
        scores[e] += 1;
    }
    for i in 1..n+1 {
        if scores[i] + k > q {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


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

int main() {
 long long n;
 cin>>n;
 long long count=0;
 vector<long long> K(n+1);
 vector<long long> L(n+1);
 for(long long i=1;i<=n;i++){
 	long long a=0;
 	cin>>a;
   if(a+i<=n){
 	K.at(a+i)++;}
   if(0<=i-a){
 	L.at(i-a)++;}
	}
	for(long long i=0; i<=n;i++){
      count+=K.at(i)*L.at(i);
		}
	
	cout<<count<<endl;
}

Measured memory_bytes: 6428
#include <iostream>

int main(){

  int i, j, n=0, all=0, alice=0, temp;
  int card[110] = {};
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &card[i]);
    all += card[i];
  }

  for (i=0; i<n-1; i++) {
    for (j=n-1; j>i; j--) {
      if (card[j-1] < card[j]) {
        temp = card[j-1];
        card[j-1] = card[j];
        card[j] = temp;
      }
    }
  }
  for(i=0; i<n; i+=2)alice += card[i];
  printf("%d", 2*alice-all);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

const int MAXN = 200010;
ll A[MAXN];
int n;

void solve () {
  if (A[0]) {
    cout << -1 << endl;
    return;
  }

  for (int i=1;i<n;i++) {
    if (A[i] != 1 && A[i-1] + 1 < A[i]) {
      cout << -1 << endl;
      return;
    }
  }

  ll cnt = 0;
  ll ans = 0;
  ll prev = 0;
  for (int i=0;i<n;i++) {
    if (A[i] <= prev) {
      ans += prev;
    }
    prev = A[i];
  }
  ans += prev;
  cout << ans << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> A[i];
  }
  solve();
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
const int MaxN = 1e5;
typedef long long LL;


int x,y;



int main()
{
	cin >> x >> y;
	if(x % y != 0)
	{
		cout << x << endl;
		return 0;
	}
	else cout << "-1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;
typedef long long ll;

int d[300][300];
int used[300][300];

bool warshall_floyd(int n) {
  memcpy(used, d, sizeof(d));

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

      for (int j = 0; j < n; j++) {
        if (i == j || k == j) continue;

        int cost = d[i][k] + d[k][j];

        if (d[i][j] > cost) return false;

        if (d[i][j] == cost) {
          used[i][j] = 0;
        }
      }
    }
  }

  return true;
}

int main() {
  int n, v;

  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> v;
      d[i][j] = v;
    }
  }

  if (warshall_floyd(n)) {
    ll ans = 0;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        ans += used[i][j];
      }
    }

    cout << ans / 2 << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define spl set<pll>
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll mod=1e9+7;
const ll maxs=1e6+6;
ll max2d=1e3+3;
ll INF = 9e18;

int main(){
    rapido;
    ll n;
    cin>>n;
    ll ans = 0;
    for(ll i=1; i<=n; i++) if(i%3!=0 and i%5!=0) ans += i;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(){
  int c=0, t, j, f, n, a[100];
  scanf("%d", &n);
  for(j = 0; j < n; j++) scanf("%d", &a[j]);
  do{
    f = 0;
    for(j = n-1; j > 0; j--){
      if(a[j] < a[j-1]){
        t = a[j];
        a[j] = a[j-1];
        a[j-1] = t;
        f++;
        c++;
      }
    }
  } while(f);
  for(; j < n-1; j++) printf("%d ", a[j]);
  printf("%d\n%d\n", a[j], c);
return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S, T, U;
    int A, B;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S) {
        A -= 1;
    } else {
        B -= 1;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
w,h,n = STDIN.gets.split.map{|s| s.to_i}
x = [0, w]
y = [0, h]
n.times do
        w,h,a = STDIN.gets.split.map{|s| s.to_i}
        case a
        when 1
                x[0] = [x[0], w].max
        when 2
                x[1] = [x[1], w].min
        when 3
                y[0] = [y[0], h].max
        when 4
                y[1] = [y[1], h].min
        end
        if x[0] >= x[1] or y[0] >= y[1]
                puts 0
                exit
        end
end
puts (x[1] - x[0])*(y[1] - y[0])


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

int main()
{
  int64_t n, i, sum, kazu;
  cin >> n;
  kazu = 3*n;
  vector<int> a(kazu);
  for(i=0; i<(kazu); i++)
  {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  sum = 0;
  for(i=1; i<2*n; i+=2)
  {
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((abs(a - b) <= d and abs(b -c) <= d)
  or
  abs(a - c) <= d){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define R register
#define int long long
inline char getalpha(){R char c;for (;(c=getchar())<'A'||c>'Z';);return c;}
inline bool query(int x){
	printf("? %lld\n",x);
	fflush(stdout);
	return getalpha()=='Y';
}
#define MN 10
int len,b10[MN]={1},ans;
main(){
	for (R int i=1; i<=9; ++i) b10[i]=b10[i-1]*10;	
	for (len=1; len<=9; ++len)
		if (query(b10[len]-1)&&!query(b10[len])) break;
	if (len==10){
		for (len=0; len<9; ++len)
			if (query(b10[len+1]-1)) break;
		printf("! %lld\n",b10[len]);
		fflush(stdout);return 0;
	}
	for (R int i=1; i<=len; ++i){
		R int l=i==1,r=9,m;
		while(l<r){
			m=l+r>>1;if (query((ans+m*b10[len-i])*10+b10[len-i+1]-1)) r=m;
			else l=m+1;
		}ans+=l*b10[len-i];
	}printf("! %lld\n",ans);fflush(stdout);return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli a[200000] = {};

int main(void) {


	lli n;
	cin >> n;

	for (int i = 0; i < n - 1; i++) {
		int A;
		cin >> A;

		a[A - 1]++;
	}

	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>//D
namespace my_std{
	using namespace std;
	#define reg register
	#define Rint register int
	#define FOR(i,a,b) for(register int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
	#define FORit(templ,arr,i,a,b) for(register templ *i=(arr)+(a);i!=(arr)+(b)+1;++i)
	#define ROFit(templ,arr,i,a,b) for(register templ *i=(arr)+(b);i!=(arr)+(a)-1;--i)
	#define GO(x,p,e,i,v) for(register int i=p[x].head,v;i;i=e[i].link)
	#define MEM(x,v) memset(x,v,sizeof(x))
	#define fir first
	#define sec second
	#define pq priority_queue
	#define PII pair<int,int>
	#define MP make_pair
	typedef long long LL;
	typedef double DB;
	inline int read(){
		int ans=0,f=1;char c=getchar();
		while(!isdigit(c)){ f^=(c=='-'); c=getchar(); }
		for(;isdigit(c);c=getchar()) ans=ans*10+c-'0'; return f?ans:-ans;
	}
	const int mod = 1e9+7 , N = 10010;
	inline void inc(int &x,const int &y){ x+=y; if(x>=mod) x-=mod; }
	inline int ksm(int x,LL y){ int res=1; for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod; return res;}
	inline int gcd(int x,int y){ if(x<y) swap(x,y); return y?gcd(y,x%y):x; }
	#define FILE(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
}
using namespace my_std;

struct EdgeD{
	int frm,to,link;
	LL wgh;
}e[N << 1];
struct VerticeD{
	int head;
	LL dgr = 0,id;
	inline bool operator <(const VerticeD &A)const{
		return dgr < A.dgr;
	}
}p[N];
int n,ecnt,cnt,vis[N];
LL c[N],w[N];
LL ans;
queue<int>Q;

inline void add_edgeD(int u,int v){
	e[++ecnt] = (EdgeD){ u , v , p[u].head , 0 };
	p[u].head = ecnt;
	e[++ecnt] = (EdgeD){ v , u , p[v].head , 0 };
	p[v].head = ecnt;
	++p[u].dgr,++p[v].dgr;
	return;
}

int main(){
	n = read();
	FOR(i,1,n-1) add_edgeD(read(),read());
	FOR(i,1,n) c[i] = read();/*
	FOR(i,1,n){
		pp[i] = p[i] , pp[i].id = i;
		GO(i,p,e,o,v) pp[i].dgr += p[e[o].to].dgr - 1;
	}
	sort(pp + 1,pp + n + 1);
	FOR(i,1,n) p[pp[i].id].wgh = c[i];
	FOR(i,1,n - 1) ans += min(p[e[i * 2 - 1].to].wgh,p[e[i * 2 - 1].frm].wgh);*/
	sort(c + 1,c + n + 1);
	FOR(i,1,n) if(p[i].dgr == 1) w[i] = c[++cnt] , Q.push(i) , vis[i] = 1;
	while(!Q.empty()){
		Rint t = Q.front();
		Q.pop();
		GO(t,p,e,i,v){
			v = e[i].to;
			if(!vis[v] && 1 == (--p[v].dgr)) w[v] = c[++cnt],Q.push(v);
		}
	}
	FOR(i,1,n-1) ans += min(w[e[i * 2 - 1].to],w[e[i * 2 - 1].frm]);
	printf("%lld\n",ans);
	FOR(i,1,n) printf("%lld ",w[i]);
	return 0;
}

Measured memory_bytes: 1280
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
string a,b,c;int n,m;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	cin>>a>>b>>n>>m>>c;
	if(c==a)printf("%d %d\n",n-1,m);
	else printf("%d %d\n",n,m-1);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int rank[100];
	int ch[100];
	int kak[100];
	int a, b, c, d, e, f;
	int ans, x, y;
	
	a = 0;
	while (1) {
		scanf("%d,%d", &b, &rank[a]);
		ch[a] = rank[a];
		if (b == 0 && rank[a] == 0) {
			break;
		}
		a++;
	}
	
	for (c = 0; c <= a; c++) {
		d = c;
		for (e = c + 1; e <= a; e++) {
			if (rank[d] < rank[e]) {
				d = e;
			}
		}
		f = rank[c];
		rank[c] = rank[d];
		rank[d] = f;
	}
	while (scanf("%d", &b) != EOF) {
		ans = 0;
		for (c = 0; c <= a; c++) {
			kak[c] = rank[c];
		}
		for (c = 0; c <= a; c++) {
			if (c != 0) {
				if (kak[c - 1] == kak[c]) {
					kak[c - 1] = -1;
				}
			}
		}
		for (c = 0; c <= a; c++) {
			if (kak[c] == ch[b - 1]) {
				ans++;
				break;
			}
			if (kak[c] != -1) {
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define MAX 101
#define INF (int)1e5

int path[MAX][MAX];

void solve(void){
    int n, m;
    cin >> n >> m;
    rep(n, i) rep(n, j) if(i != j) path[i][j] = INF; else path[i][j] = 0;
    int as[m], bs[m], cs[m];
    rep(m, i) {
        scanf("%d%d%d\n", &as[i], &bs[i], &cs[i]);
        as[i]--; bs[i]--;
        path[as[i]][bs[i]] = min(path[as[i]][bs[i]], cs[i]);
        path[bs[i]][as[i]] = min(path[bs[i]][as[i]], cs[i]);
    }
    //WF
    rep(n, k) rep(n, i) rep(n, j) path[i][j] = min(path[i][j], path[i][k]+path[k][j]);
    int ans = m;
    rep(m, k){
        bool flag = false;
        /*
        rep(n, i) if (path[i][as[k]] == path[i][bs[k]] + cs[k]) {
            flag = true; break;
        }
        */
        rep(n, i) rep(n, j) if (path[i][j] == path[i][as[k]] + path[bs[k]][j] + cs[k]) {
            flag = true; break;
        }
        if (flag) ans--;
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
        int x,a,b;
        cin>>x>>a>>b;
        int z=abs(x-a);
        int zz=abs(x-b);
        if(z>zz)
        cout<<"B\n";
        else
        cout<<"A\n";
    }
    
}
// 🍪 🍪 🍪


Measured memory_bytes: 3648
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=998244353;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

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

char s[15][15];
void Solve(){
  int n,m,k;
  cin>>n>>m>>k;
  rep(i,1,n){
    cin>>s[i]+1;
  }
  int ans=0;
  rep(i,0,o(n)-1){
    rep(j,0,o(m)-1){
      int tmp=0;
      rep(x,1,n){
        rep(y,1,m){
          if(!getplc(i,x-1)&&!getplc(j,y-1)){
            tmp+=(s[x][y]=='#');
          }
        }
      }
      if(tmp==k){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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

int n;
int a[100];

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



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>
using namespace std;
int par[10010],sz[10010];
void init(int N){
	rep(i,N){
		par[i]=i;
		sz[i]=1;
	}
}
int find(int x){
	if(par[x]==x)return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);y=find(y);
	if(sz[x]<sz[y]){
		par[x]=y;
		sz[y]+=sz[x];
	}
	else{
		par[y]=x;
		sz[x]+=sz[y];
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
int getsize(int x){
	return sz[find(x)];
}
int n,q,com,x,y;
signed main(){
	cin>>n>>q;
	init(n);
	rep(i,q){
		cin>>com;
		if(com==0){
			cin>>x>>y;
			unite(x,y);
		}
		else{
			cin>>x>>y;
			cout<<same(x,y)<<endl;
		}
	}
	return 0;
}



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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 5;
int a[N];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    scanf("%d",&n);
    for ( int i = 1; i <= n; i++ ){
        scanf("%d",&a[i]);
    }
    if ( n % 2 == 0 ){
        for ( int i = n; i > 0; i -= 2 ){
            printf("%d ",a[i]);
        }
        for ( int i = 1; i <= n - 1; i += 2 ){
            printf("%d ",a[i]);
        }
    }
    else{
        for ( int i = n; i >= 1; i -= 2 ){
            printf("%d ",a[i]);
        }
        for ( int i = 2; i <= n - 1; i += 2 ){
            printf("%d ",a[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 2944
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	string str;
	int a, b;
	cin >> a >> str >> b;
	if (str == "+")cout << a + b << endl;
	else cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define x3 dflgkg
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define y3 dfhgdh
#define SQ 320
#define PI 3.14159265359
typedef long long ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,r,timer,mx,l,sum, ans;
ll a[200500],  b[200500];
vector<ll> g[100500];
int main() {
    //freopen("input.txt","r",stdin);
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K%2 == 0)
        cout << A-B << endl;
    else
        cout << B-A << endl;
    return 0;
}


Measured memory_bytes: 4352
n = int(input())
from numpy import sqrt
cnt = 2
rt = int(sqrt(n))
for i in range(2,rt+1):
    if n % i == 0:
        m = n
        while m%i ==0:
            m = m//i
        if m%i == 1:
            cnt += 1
    elif (n-1) % i ==0:
        cnt += 2
if n == rt ** 2 + 1:
    cnt -= 1
print(cnt)

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

using namespace std;

int main(){
	string x; cin >> x;
	int op = 0;
	for (int i = 0; i < x.length(); i++){
		if (x[i] == 'C' && !op) op = 1;
		if (x[i] == 'F' && op == 1) op = 2;
	}

	if (op == 2) puts("Yes"); else puts("No");
}	


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

long long K, S;

int main(){
	cin >> K >> S;

	long long ans = 0;
	for(long long x = 0; x <= K; x++){
		for(long long y = 0; y <= K; y++){
			if(S - x - y >= 0 && S - x - y <= K){
				ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string t;
  cin >> t;
  int n = t.length();
  string ans = "";
  for (int i = 0; i < n; ++i) {
    if (t[i] == '?') ans += 'D';
    else ans += t[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3888
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void solve(int a, int b, vector<string>& s)
{
    const int n = 100;

    if(a > b){
        solve(b, a, s);
        for(int y=0; y<n; ++y){
            for(int x=0; x<n; ++x){
                s[y][x] ^= '.' ^ '#';
            }
        }
        return;
    }

    s.assign(n, string(n, '.'));
    for(int i=0; i<b; ++i){
        int y = i / (n / 4) * 4;
        int x = i % (n / 4) * 4;
        for(int j=0; j<9; ++j){
            int y2 = y + j / 3;
            int x2 = x + j % 3;
            s[y2][x2] = '#';
        }
        if(a > 1){
            -- a;
            s[y+1][x+1] = '.';
        }
    }
}

int main()
{
    int a, b;
    cin >> a >> b;
    vector<string> s;
    solve(a, b, s);

    int h = s.size();
    int w = s[0].size();
    cout << h << ' ' << w << endl;
    for(int y=0; y<h; ++y)
        cout << s[y] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
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 EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1
 
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
 
    int A,B,C;
    int N,M,K,X,Y,W,H;
    int ans;
    string S;
    int temp[100]={0};
    bool f=true;
    bool fir=true;
 
int main(){
    cin>>A>>B>>C;
    A<=C&&C<=B?cout<<"Yes":cout<<"No";
    return 0;
 
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long K = scanner.nextLong();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt()-1;
        }
        int count = 0;
        int current = 0;
        int[] visited = new int[N];
        for (int i = 0; i < visited.length; i++) {
            visited[i] = -1;
        }
        visited[0] = 0;
        while(true){
            count ++;
            current = A[current];
            if(count == K) break;
            if(visited[current] != -1) break;
            visited[current] = count;
        }
        if(visited[current] == -1){
            System.out.println(current+1);
            return;
        }
        // for (int i = 0; i < N; i++) {
        //     System.out.print(visited[i]);
        // }
        int roopsize = count - visited[current];
        if(roopsize == 0){
            System.out.println(current+1);
            return;
        }
        // System.out.println(roopsize);
        int beforeroop = visited[current];
        // System.out.println(beforeroop);
        long res = (K-(long)beforeroop) % (long)roopsize;
        // System.out.println(res);
        for (long i = 0; i < res; i++) {
            current = A[current];
        }
        System.out.println(current +1);
    }
}

Measured memory_bytes: 59880
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define semicolon ;
#define ryan bear
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int dp[262262][55];
int bk[262262];
int a[20],b[20];
vector<int>ls[20];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<n;i++)
        bk[1<<i]=i;
    for(int i=0;i<1<<n;i++)
    {
        ls[__builtin_popcount(i)].eb(i);
        for(int j=1;j<51;j++)
            dp[i][j]=inf;
    }
    dp[0][1]=0;
    for(int l=1;l<=n;l++)
    {
        for(int&i:ls[l])
        {
            for(int j=i;j>0;j=j&j-1)
            {
                int la=bk[j&-j];
                int mv=abs(l-1-la);
                int col=mv&1?b[la]:a[la];
                int ni=__builtin_popcount(j)-1;
                for(int k=1;k<=col;k++)
                    dp[i][col]=min(dp[i][col],dp[i^1<<la][k]+ni);
            }
        }
    }
    int li=(1<<n)-1;
    int m=inf;
    for(int i=1;i<51;i++)
        m=min(m,dp[li][i]);
    if(m>inf/2)
        m=-1;
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 57972
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 100005
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 9223372036854775807
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

signed main() 
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    int n;
    cin>>n;
    int A[n+1];
    fn(i,n) cin>>A[i+1];
    int dp[n+1];
    dp[1]=0;
    if(n==1) 
    {
        cout<<0<<endl;
        return 0;
    }
    dp[2]=abs(A[2]-A[1]);
    for(int i=3;i<=n;i++) dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
    cout<<dp[n]<<endl;
}   

Measured memory_bytes: 5124
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	int d;
	cin >> n >> d >> x;
	int a[105];
	rep(i, n) cin >> a[i];

	f = 0;
	
	rep(i, n){
		m = 1;
		j = 0;
		while(m <= d){
			++f;
			++j;
			m = j*a[i] + 1;
		}
	}
	cout << f+x;
}

Measured memory_bytes: 256