akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll dp[100];

ll func(int depth){
    //cout << dp[depth] << endl;
    if(dp[depth]!=NULL){
        return dp[depth];
    }
    
    return dp[depth] = func(depth-1)+func(depth-2);
}

int main(){
    int N;
    cin >> N;
    dp[0]=2; dp[1]=1;
    ll ans;
   
    ans = func(N);
    
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
//vector.assign (n,value)... for global vectors
class abc
{
public:
    ll x, y;
};
ll val = 0;
ll N1;
bool isvalid (ve <ll> ans)
{
    ll mx=0;
    rep (i,0,N1)
    {
        if (ans[i]!=0&&(ans[i]-mx)>1)
        {
            return false;
        }
        mx=max(ans[i],mx);
    }
    return true;
}
void solve(ll k, ve<ll> ans)
{
    if (k == N1)
    {
        rep(i, 0, k)
        {
            ans[k - 1] = i;
            if (isvalid(ans))
            {
                rep(j, 0, N1)
                {
                    cout << char(ans[j] + 'a');
                }
                cout << "\n";
            }
        }
        return;
    }
    rep(i, 0, k)
    {
        ans[k - 1] = i;
        solve(k + 1, ans);
    }
}
int main()
{
    FAST
            // freopen("input1.txt", "r", stdin);
            // freopen("output.txt", "w", stdout);
            /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
            cin >>
        N1;
    ve<ll> ans(N1);
    rep(i, 0, N1)
    {
        ans[i] = 0;
    }
    solve(1, ans);
}


Measured memory_bytes: 1536
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	for(int i=0;i<10000;i++)printf("-1\n");
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    ll N, C;
    cin >> N >> C;
    ll D[C][C];
    REP(i, 0, C) {
        REP(j, 0, C) {
            cin >> D[i][j];
        }
    }
    ll c[N][N];
    REP(i, 0, N) {
        REP(j, 0, N) {
            cin >> c[i][j];
        }
    }
    ll dis[3][C];
    REP(i, 0, 3) {
        fill(dis[i], dis[i] + C, 0);
    }
    REP(i, 0, N) {
        REP(j, 0, N) {
            REP(k, 0, C) {
                dis[(i + j) % 3][k] += D[c[i][j] - 1][k];
            }
        }
    }
    ll ans = inf;
    REP(i, 0, C) {
        REP(j, 0, C) {
            if (i == j) {
                continue;
            }
            REP(k, 0, C) {
                if (i == k || j == k) {
                    continue;
                }
                ans = min(ans, dis[0][i] + dis[1][j] + dis[2][k]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
#define USE_MATH_DEFINES 1
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 998244353ll
#define INF 1000000000000000000ll
#define EPS 1e-9

#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll N, M, H[300005], C;
vector <ll> adj[300005];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> M;
	
	for (ll i = 1; i <= N; i++) cin >> H[i];
	
	for (ll i = 1; i <= M; i++) {
		ll a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	C = 0;
	for (ll i = 1; i <= N; i++) {
		bool good = true;
		for (ll j : adj[i]) {
			if (H[i] <= H[j]) good = false;
		}
		if (good) C++;
	}
	
	cout << C;
	
    return 0;
}














Measured memory_bytes: 14964
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<double,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
signed main(){
    int n;
    cin>>n;
    double t,a;
    cin>>t>>a;
    P x[n];
    r(i,n){
        double h;
        cin>>h;
        x[i]=P(abs(a-(t-h*0.006)),i);
    }
    sort(x,x+n);
    cout<<x[0].S+1<<endl;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

bool is_parindrome(string s){
	rep(i,s.size()){
		if(s[i]!=s[s.size()-i-1])return false;
	}
	return true;
}
int main(){
	string s;cin>>s;
	int n=s.size();
	if(is_parindrome(s)&&is_parindrome(s.substr(0,(n-1)/2))&&is_parindrome(s.substr((n+3)/2-1))){
		puts("Yes");
	}
	else puts("No");
}

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

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

for i in range(len(a_list)):
    if i+k > len(a_list)-1:
        break
    if a_list[i] < a_list[i+k]:
        print("Yes")
    else:
        print("No")

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

int main()
{	
	int n;
	double x, s = 0;
	string c;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x >> c;

		if (c == "BTC")
			s += x * 380000;
		else
			s += x;
	}

	cout << s << endl;

	return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
      cin>>a.at(i);  
    }
    sort(a.begin(),a.end());
    int ans;
    int sen=n/2;
    if(n%2==1)ans=0;
    else ans=a.at(sen)-a.at(sen-1);
    cout<<ans<<endl;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second

using namespace std;

int main(){

    int a,b;
    cin >> a >> b;

    if(a <= b)cout << a;
    else cout << a-1;


    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);

        int counter = 0;
        String w = sc.next();
        String t = "";
        while (!(t = sc.next()).equals("END_OF_TEXT")) {
            if (w.equals(t.toLowerCase())) {
                counter += 1;
            }
        }

        System.out.println(counter);

        sc.close();
    }
}


Measured memory_bytes: 26196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		scan.useDelimiter("[^0-9.]+");

		while(scan.hasNext()){
			double v = scan.nextDouble();
			double t = v/9.8;
			double y = 4.9*t*t;
			
			for(int n=1;n<1000;n++){
				if(5*n-5 > y){
					System.out.println(n);
					break;
				}
			}
		}
		
		scan.close();
	}
}

Measured memory_bytes: 27604
x, y = map(int, input().split())

diff = abs(abs(x)-abs(y))
bs = abs(y) - abs(x)
if x == 0 or y == 0:
    reverse = 0
else:
    reverse = 1


if x >= 0 and y >= 0:
    if bs >= 0:
        ans = diff
    else:
        ans = reverse + diff + 1
elif x >= 0 and y <= 0:
    if bs >= 0:
        ans = diff + 1
    else:
        ans = reverse + diff
elif x <= 0 and y >= 0:
    if bs >= 0:
        ans = reverse + diff
    else:
        ans = diff + reverse
elif x <=0 and y <=0:
    if bs >= 0:
        ans = reverse + diff + 1
    else:
        ans = diff
print(ans)

Measured memory_bytes: 3064
// ABC 147-A
// 2019.12.8 bal4u

#include <stdio.h>

int main()
{
	int A1, A2, A3;
	
	scanf("%d%d%d", &A1, &A2, &A3);
	puts(A1+A2+A3 >= 22? "bust": "win");
	return 0;
}


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

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n,m;
    cin>>n>>m;

    int a[n][m];
    rep(i,0,n)
    {
        rep(j,0,m)
        {
            cin>>a[i][j];
        }
    }
    int cnt = 0;
    rep(i,0,n)
    {
        rep(j,i+1,n)
        {
            double ans = 0;
            rep(k,0,m)
            {
                ans += (a[j][k]-a[i][k])*(a[j][k]-a[i][k]);
            }
            ans = sqrt(ans);
            if ( ans - (int)ans == 0 )
            {
                cnt++;
            }
        }
    }

    cout<<cnt<<endl;

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
int a,b,c,x,ans;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			for(int k=0;k<=c;k++)
				if(500*i+100*j+50*k==x)
					ans++;
				else if(500*i+100*j+50*k>x)
					break;
			if(500*i+100*j>x)
				break;
		}
		if(500*i>x)
				break;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;
typedef long double ld;
typedef vector<ld> vd;

const ld EPS = 10e-10;

ld solve();
bool search(const ld t, const ld r, vd& s);

int main(void) {
	
	while(true){
		ld ans = solve();
		if( ans < 0.0 ) { break; }
		cout << fixed << setprecision(5) << ans << endl;
	}

	return 0;
}


bool search( const ld t, const ld r, vd& s ) {

	for( int i = -20; i < 20; i++ ) {

		ld d = (ld)i, e = (ld)(i+1);
		bool b[2] = {false,false};

		
		if(d>=-r+EPS&&d+EPS<=r)
			b[0] = sqrt(r*r-d*d)+t>r+s[i+20]+EPS;
		if(e>=-r+EPS&&e+EPS<=r)
			b[1] = sqrt(r*r-e*e)+t>r+s[i+20]+EPS;

		if( b[0]|b[1] ) {
				return false;
		}

	}

	return true;

}

ld solve() {

	//????????¢?´¢
	ld r, low, high, mid;
	int n, m;
	cin >> m >> n;
	if( m == 0 && n == 0 ) { return -1.0; }
	r = (ld)m;

	vd v(40,0.0);

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

		int xl, xr;
		ld h;
		cin >> xl >> xr >> h;

		for( int j = xl+20; j < xr+20; j++ ) {
			if( v[j] < h ) {
				v[j] = h;
			}
		}

	}
	low = 0.0;
	high = 21.0;

	//low???????????????????????????
	for( int i = 0; (i < 1000); i++ ) {
		mid = (high+low)/2.0;
		if( search(mid,r,v) ) {
			low = mid;
		} else {
			high = mid;
		}
	}

	return mid;

}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(true){
        int a,b;
        string op;
        cin>>a>>op>>b;
        if(op=="+"){
            cout<<a+b<<endl;
        }
        else if(op=="-"){
            cout<<a-b<<endl;
        }
        else if(op=="*"){
            cout<<a*b<<endl;
        }
        else if(op=="/"){
            cout<<a/b<<endl;
        }
        else{
            break;
        }
    }
}


Measured memory_bytes: 3148
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = n // 2
print(n - t - 1)

Measured memory_bytes: 6548
#include <stdio.h>

int main(void){
	while(1){
		int k, t, i, sum=0;
		
		scanf("%d", &k);
		if(k==0) break;
		
		for(i=0; i<k*(k-1)/2; i++){
			scanf(" %d", &t);
			sum+=t;
		}
		sum/=k-1;
	
		printf("%d\n", sum);
	}

	return 0;
}

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

using namespace std;

int dp[100001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, i, j, k;
    memset(dp, 0, sizeof(dp));
    cin >> n;
    int a[n];
    for (i = 0; i < n; i++)
        cin >> a[i];

    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);

    for (i = 2; i < n; i++)
    {
        j = (dp[i - 1] + abs(a[i] - a[i - 1]));
        k = (dp[i - 2] + abs(a[i] - a[i - 2]));
        dp[i] = min(j, k);
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int h[100005];
int PD[100005];

int pd(int i){
	if(i == 0){
		return 0;
	}
	int &ans = PD[i];
	if(ans != -1){
		return ans;
	}
	ans = INF;
	if(i-2 >= 0){
		ans = min(ans, abs(h[i]-h[i-2]) + pd(i-2));
	}
	ans = min(ans, abs(h[i]-h[i-1]) + pd(i-1));
	return ans;
}

int main(){
	int n;
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%d", h+i);
	}
	memset(PD, -1, sizeof PD);
	printf("%d\n", pd(n-1));
	return 0;
}

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const ll MOD = 998244353;

int main() {
  int n, s; read(n, s);
  vector <ll> dp(s + 1, 0);
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    int x; read(x);
    for(int j = s; j >= 0; j--) {
      if(j - x < 0) continue;
      dp[j] = (dp[j] + dp[j - x]) % MOD;
    }
    if(x <= s) dp[x] = (dp[x] + i + 1) % MOD;
    sum = (sum + dp[s]) % MOD;
  }
  print(sum);
}

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

typedef long long ll;

const int N = 2e3 + 1;
int n;
int v[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    sort(v, v + n);
    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int *p = lower_bound(v + j + 1, v + n, v[i] + v[j]);
            res += p - v - j - 1;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
//AOJ0002

#include <stdio.h>

int main(){
    int a,b;
    while(1){
        if(scanf("%d %d",&a,&b)==EOF){
            break;
        }
        a+=b;
        b=0;
        while(a!=0){
            b++;
            a/=10;
        }
        printf("%d\n",b);
    }
    return 0;
}

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

ll C(int n, int r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

int dp[101][4][2];

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

    string n;
    int k;
    cin >> n >> k;
    int d =  n.size();
    for(int i=0; i<k+1; i++){
        if (i==0){
            dp[0][i][1] = 1;
            dp[0][i][0] = 0;
        }
        else if(i==1){
            dp[0][i][0] = 1;
            dp[0][i][1] = (int)(n[0]-'0')-1;
        }
        else {
            dp[0][i][0] = 0;
            dp[0][i][1] = 0;
        }


    }
    for(int i=1; i<d; i++){
        int x = int(n[i] - '0')-1;
        for(int j=0; j<k+1; j++){
            if(j>=1){
                dp[i][j][1] = dp[i-1][j][1] + 9*(dp[i-1][j-1][1]) + fmax(x, 0)*dp[i-1][j-1][0];
                if(x==-1) {
                    dp[i][j][0] = dp[i-1][j][0];
                }
                else {
                    dp[i][j][0] = dp[i-1][j-1][0];
                    dp[i][j][1] += dp[i-1][j][0];
                }

            }
            else {
                dp[i][j][0] = 0;
                dp[i][j][1] = 1;
            }
        }
    }
    cout << dp[d-1][k][0] + dp[d-1][k][1] << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

string S;

bool isPalindrome(int s, int t) {
    REP (i, t-s) {
        if (S[s+i] != S[t-i-1]) return false;
    }
    return true;
}

bool solve() {
    int n = S.size();
    return isPalindrome(0, n/2) && isPalindrome(n/2+1, n) && isPalindrome(0, n);
}

int main() {
    cin >> S;
    cout << (solve() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long t,i,j,k,a,b,c=0,d=0,n;
  scanf("%lld",&n);
  for(i=1;i<n;i++)
  c+=(n-1)/i;
printf("%lld\n",c);
  return 0;
}


Measured memory_bytes: 3804
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto A = new long[](N);
    auto B = new long[](N);
    auto C = new long[](M);
    auto D = new long[](M);
    foreach (i; 0 .. N)
    {
        scan(A[i], B[i]);
    }
    foreach (i; 0 .. M)
        scan(C[i], D[i]);
    foreach (i; 0 .. N)
    {
        auto I = iota(M);
        auto E = iota(M).map!(j => abs(A[i] - C[j]) + abs(B[i] - D[j])).array;
        (1 + zip(E, I).reduce!(min)[1]).writeln();
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int array[N];
    for(int i=0;i<N;i++){
        cin >> array[i];
    }

    for(int i=1;i<N;i++){
        if(array[i-1]>array[i]){
            cout << "No" << endl;
            return 0;
        } else if(array[i-1]<array[i]){
            array[i]--;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b,c,d;
  string str,strr;
  cin>>str;
  bool flag[3]={};
  for(int i=0;i<3;i++){
  if(str[i]=='a')flag[0]=true;
  if(str[i]=='b')flag[1]=true;
  if(str[i]=='c')flag[2]=true;
  }if(flag[0]&&flag[1]&&flag[2])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{ 
  int n, m;
  cin >> n >> m;
  vector<vector<int>> light(m, vector<int>());
  for(int i = 0; i < m; i++)
  {
    int k;
    cin >> k;
    for(int j = 0; j < k; j++)
    {
      int s;
      cin >> s;
      light[i].push_back(s - 1);
    } 
  }
  vector<int> p(m);
  for(int i = 0; i < m; i++)
  {
    cin >> p[i];
  }
  int result = 0;
  for(unsigned int i = 0; i < pow(2, n); i++){
    vector<int> sw(n, 0);
    for(unsigned int j = 0; j < n; j++)
    {
      unsigned int temp = pow(2, j);
      if(i & temp){
        sw[j] = 1;
      }
    }
    bool correct = true;
    for(int j = 0; j < m; j++)
    {
      int sum = 0;
      for(int k = 0; k < light[j].size(); k++)
      {
        sum += sw[light[j][k]];
      }
      if(sum % 2 != p[j]){
        correct = false;
      }
    }
    if(correct) result++;
  }
  cout << result << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    map<int,int> seen;
    int n;
    cin>>n;
    bool ok=true;
    rep(i,n){
        int a;
        cin>>a;
        a--;
        seen[a]++;
        if(seen[a]!=1) ok=false;
    }
    if(ok) puts("YES");
    else puts("NO");
    return 0;
}

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

long long n,W;
long long v[100],w[100];
long long dp[100 + 1][100010] = {0};

int main(){
    cin >> n >> W;
    for(int i = 0;i < n;i++){
        cin >> w[i] >> v[i];
    }
    /**/
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= W;j++){
            if(j >= w[i]){
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
                //cout << j << " " << w[i] << endl;
            }
            else{
                dp[i + 1][j] = dp[i][j];
            }   
        }
    }

    /*
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= W;j++){
            printf("%2d ",dp[i][j]);
        }
        cout << endl;
    }

    */
    cout << dp[n][W] << endl;
    
    return 0;
}

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

void solve(){
    int n, m;
    cin >> n >> m;
    vector <pair <int, int>> req(m);
    for(int i = 0; i < m; i++) cin >> req[i].first >> req[i].second;
    //cout << "hello1" << endl;
    int i = pow(10, n-1);
    if(i == 1) i = 0;
    for(; i < pow(10, n); i++){
        string num = to_string(i);
        bool found = true;
        for(auto x : req){
            if(num[x.first-1]-'0' != x.second){
                found = false;
                break;
            }
        }
        if(found){
            cout << i << endl;
            return;
        }
    }
    //cout << "hello2" << endl;
    cout << -1 << endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    solve();
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String argsp[]){
		Scanner sc = new Scanner(System.in);
		int a = 0;
		String s = sc.next(), t = sc.next();
		for(int i = 0; i< 3; i++){
			if(s.charAt(i) == t.charAt(i)){
				a++;
			}
		}
		System.out.print(a);
	}
}

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

int n;
string s,t,ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>s>>t;
    for(int i=0;i<n;i++){//从前往后跑s和t的字符
        ans+=s[i];
        ans+=t[i];//向ans的末尾添加字符
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A = collections.Counter(prime_factorize(N))
ans = 0
for i in A.values():
  for j in range(40):
    if ((j + 1) * (j + 2) / 2 <= i) and ((j + 2) * (j + 3) / 2 > i):
      ans = ans + j + 1
print(ans)

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

int main() {
  int N,K;
  cin >> N >> K;
  int sum=1;
  for(int i=0;i<N;i++){
    if(sum<K){
      sum*=2;
    }else{
      sum+=K;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
var
    n,a,b:longint; {定义QwQ}
begin
  read(n,a,b);
  if a>b then                    //特判
    writeln(0)
  else
    if n=1 then writeln(ord(a=b))
    else writeln((b-a)*(n-2)+1); //套公式
end.
//Hello, world!

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N];

char s[N];

map<int,int> sub;

int main(){
	scanf("%d%d",&n,&m);
	int cnt=0;
	while(m--){
		scanf("%d %s",&x,s);
		if (s[0]=='A'){
			if (sub.count(x) && sub[x]!=-1){
				ans+=sub[x];
				cnt++;
				sub[x]=-1;
			}
			else if (!sub.count(x))
				cnt++,sub[x]=-1;
		}
		else{
			if (sub[x]!=-1)
				sub[x]++;
		}
	}
	printf("%d %d\n",cnt,ans);
}


Measured memory_bytes: 7040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int Q = scan.nextInt();
        int[] candidates = new int[N];
        for (int i = 0; i < Q; i++) {
            int winner = scan.nextInt() - 1;
            candidates[winner] += 1;
        }
        for (int i = 0; i < N; i++) {
            if (0 < K - Q + candidates[i]) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 54076
-- Structured Program I - Print a Chessboard

import Control.Applicative

main :: IO ()
main = do
  xs <- map words . takeWhile (/= "0 0") . lines <$> getContents
  mapM_ putStrLn $ map (chessbord . map read) xs

chessbord :: [Int] -> String
chessbord [h, w] = concat $ take h $ cycle [a, b]
  where
    a = (take w $ cycle "#.") ++ "\n"
    b = (take w $ cycle ".#") ++ "\n"



Measured memory_bytes: 4612
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        k: usize,
    }
    let mut v = vec![];
    for i in 1..std::cmp::min(a, b) + 1 {
        if a % i == 0 && b % i == 0 {
            v.push(i);
        }
    }
    v.reverse();
    println!("{}", v[k - 1]);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

#define LEN 4

void alphabet(char *str,int *);
void count(int *box);

int main (void){
  int i,j;
  char str[LEN]= {'\0'};
  int box[26] = {0};
  if ( scanf("%s",str) == 1){
    alphabet(str,box);
    count(box);   
  }
  return 0;
}

void alphabet(char *str,int *box){
  int i=0,j=0;
  char *alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for(i=0; i<LEN; i++){
    for(j=0; j<26; j++){
      if ( alp[j] == str[i]) box[j] +=1;
    }}
  return;
}


void count(int *box){
  int i;
  int count=0;
  for(i=0; i<26; i++){
    if (box[i] == 2) count++;
  }
  if (count == 2) printf("Yes\n");
  else printf("No\n");
  return;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
//      freopen("q.in","r",stdin);
//      freopen("q.out","w",stdout);
      int n,k,s;
      cin>>n>>k>>s;
      vector<int>ans;
      for(int i=0;i<k;i++)ans.pb(s);
      int rid=s+1;
      if(rid+1>1e9)rid=1;
      for(int i=0;i<n-k;i++)ans.pb(rid);
      for(int i=0;i<n;i++)cout<<ans[i]<<" ";
}


Measured memory_bytes: 2292
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i<b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(int i = a;i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

class BIT{
    vl bit;
public:
    void BIT_init(ll n){
        bit.assign(n + 1, 0);
        return;
    }
    ll get_sum(int i){
        ll res = 0;
        while(i > 0){
            res += bit[i];
            i -= i&(-i);
        }
        return res;
    }
    void add(int i, ll x){
        while(i <= bit.size() - 1){
            bit[i] += x;
            i += i&(-i);
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,Q;
    cin >> N >> Q;
    BIT bit;
    bit.BIT_init(N);
    vl A(N);
    rep(i,N){
        cin >> A[i];
        bit.add(i+1,A[i]);
    }
    rep(i,Q){
        int t,l,r;
        cin >> t >> l >> r;
        if(t==0){
            bit.add(l+1,r);
        }
        else{
            cout << bit.get_sum(r)-bit.get_sum(l) << '\n';
        }
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 12168
#include<bits/stdc++.h>
using namespace std;
int h[11];
int main()
{
	int n;
	cin>>n;
	int a[n+1],cnt=0,cnt1=0;
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			cnt1++;
			if(a[i]%3==0 || a[i]%5==0)
			cnt++;
		}
		
	}
	if(cnt==cnt1)
	cout<<"APPROVED\n";
	else cout<<"DENIED\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int N, K;
std::vector<ll> V;
std::vector<std::vector<std::vector<ll>>> dp;

ll sol(int k, int i, int j){
  if ( k == 0 ) return 0;
  if ( k <  0 ) return 0;
  if ( i == j ) return 0;
  if ( dp[k][i][j] != std::numeric_limits<ll>::min() ) return dp[k][i][j];

  if ( i+1 != j ) {
    ll f = V[i];
    ll l = V[j-1];

    ll ans1 = std::max( { f+sol(k-1, i+1, j),    sol(k-2, i+1, j)   } );
    ll ans2 = std::max( { l+sol(k-1, i,   j-1),  sol(k-2, i,   j-1) } );
    ll ans3 = sol(k-1, i, j);
    return dp[k][i][j] = std::max ( { ans1, ans2, ans3 } );
  }
  else {
    ll f = V[i];
    ll ans1 = std::max( { f+sol(k-1, i+1, j), sol(k-2, i+1, j) } );
    ll ans3 = sol(k-1, i, j);
    return dp[k][i][j] = std::max ( {ans1, ans3} );
  }
}

int main (void) {
  std::cin >> N >> K;

  V.resize(N);
  for(int i=0; i<N; i++) std::cin >> V[i];

  dp.resize(K+1);
  for(int i=0; i<K+1; i++) dp[i].resize(N+1);
  for(int i=0; i<K+1; i++) for(int j=0; j<N+1; j++) dp[i][j].assign(N+1, std::numeric_limits<ll>::min());

  std::cout << sol(K, 0, N) << std::endl;

  return 0;
}

Measured memory_bytes: 2432
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> A,B;
  REP(i,N){
    ll a,b;
    cin>>a>>b;
    A.PB(a);
    B.PB(b);
  }
  SORT(A);
  SORT(B);
  
  if(N%2==1) ans=B[N/2]-A[N/2]+1;
  else ans=(B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1])+1;
  co(ans);
  return 0;
}

Measured memory_bytes: 6624
n,C[124][101],*p,a,b,c;D(i){int f[101]={0},T;memset(p=C,9,404);for(p[a]=0;T=a;)for(f[T]=1,a=i=0;i++<n;a=f[i]|p[i]>p[a]?a:i)p[i]=fmin(p[i],p[T]+C[T][i]);printf("%d\n",p[b]>1e8?-1:p[b]);}main(k){for(;scanf("%d%d",&n,&k)*n;)for(memset(C,9,5e4);k--;a?scanf("%d%d%d",&a,&b,&c),C[a][b]=fmin(C[a][b],c),C[b][a]=fmin(C[b][a],c):D(scanf("%d%d",&a,&b)))scanf("%d",&a);}

Measured memory_bytes: 472
from operator import itemgetter

def main():
	n, t = map(int, input().split())

	costs = []
	for i in range(n):
		costs.append(list(map(int, input().split())))

	costs = sorted(costs, key=itemgetter(0))
	for i in range(n):
		if costs[i][1] <= t:
			print(costs[i][0])
			return
	print("TLE")
	return

main()

Measured memory_bytes: 3060
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//236
	ll sum = 0;
	int n;
	cin>>n;
	vi arr(n);
	for(int &i:arr)cin>>i;
	REP(i,0,n-1)
	REP(j,i+1,n-1)
		sum+=arr[i]*arr[j];
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3648
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
for i in range(101):
    if x - i not in p:
        print(x - i)
        break
    elif x + i not in p:
        print(x + i)
        break



Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int c[3][3];
int a[3], b[3];

bool check(){
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			if(a[i] + b[j] != c[i][j]) return false;
		}
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}

	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			for(int k = 0; k <= 100; k++){
				a[0] = i, b[0] = c[0][0] - i;
				a[1] = j, b[1] = c[1][1] - j;
				a[2] = k, b[2] = c[2][2] - k;
				if(check()){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back
#define MP make_pair

using namespace std;

int main(){
	lint n,a,ans=0;
	cin>>n;
	rep(i,0,n){
		cin>>a;
		if(a%2==1)ans++;
	}
	if(ans%2==1)cout<<"NO";
	else cout<<"YES";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long int n,a[110],cost[300]={},ans=100000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=-100;i<101;i++){
        for(int j=0;j<n;j++){
            cost[i+100]+=(a[j]-i)*(a[j]-i);
        }
        if(cost[i+100]<ans)ans=cost[i+100];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
int n,A,B,a[N],b[N];
int main(){
	scanf("%d%d%d",&n,&A,&B);
	int kk=n;
	a[1]=A;n-=A;
	for (int i=2;i<=B;i++){
		a[i]=n/(B-i+1);
		n-=n/(B-i+1);
	}
	if (n){
		puts("-1");
		return 0;
	}
	for (int i=2;i<=B;i++)
		if (!a[i]||a[i]>A){
			puts("-1");
			return 0;
		}
	n=kk;	
	for (int i=1,j=1,now=n;i<=B;i++){
		for (int k=a[i];k;k--)b[j++]=now-k+1;
		now-=a[i];
	}
	for (int i=1;i<=n;i++)printf("%d ",b[i]);
	return 0;	
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#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
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;

#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,m; cin >> n >> m;
    queue<int> q[n];
    rep(i,n){
        rep(j,m){
            int a; cin >> a;
            a--;
            q[i].push(a);
        }
    }
    int ans=n;
    vector<bool> ok(m,1);
    vector<int> cnt(m,0);
    rep(j,n){
        cnt[q[j].front()]++;
    }
    int ma=-1,x=0;
    rep(j,m){
        if(ma<cnt[j]){
            ma=cnt[j];
            x=j;
        }
    }
    chmin(ans,ma);
    rep(i,m-1){
        vector<int> cnt(m,0);
        rep(j,n){
            cnt[q[j].front()]++;
        }
        int ma=-1,x=0;
        rep(j,m){
            if(ma<cnt[j]){
                ma=cnt[j];
                x=j;
            }
        }
        chmin(ans,ma);
        ok[x]=0;
        rep(j,n){
            while(ok[q[j].front()]==0){
                q[j].pop();
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4060