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

typedef long long int lli;
#define pb push_back
#define gcd __gcd
#define MOD 1000000007
#define mod2 998244353
#define forz(i,n) for(long long int i=0;i<n;i++)
set<vector<lli>> s1,s2;
set<pair<lli,lli>>::iterator i1,i2;
vector<lli> A(10001,0);
int ppp=0;

lli mod(lli a){
    if(a<0) return -1*a;
    return a;
}

bool comp(pair<lli,lli> a,pair<lli,lli> b){
    return 0;
}

void solve(int x,int y,int z,int n){
    vector<lli> cur;
    cur.pb(x);cur.pb(y);cur.pb(z);
    sort(cur.begin(),cur.end());
    if(s1.find(cur)!=s1.end()) return;
    s1.insert(cur);
    x=cur[0],y=cur[1],z=cur[2];
    lli m=x*x+y*y+z*z+x*y+y*z+z*x;
    if(m>n) return ;

    if(x==y & y==z) A[m]++;
    else if(x==y || y==z || z==x) A[m]+=3;
    else A[m]+=6;
  
    ppp++;
    solve(x+1,y,z,n);
    solve(x,y+1,z,n);
    solve(x,y,z+1,n);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t=1,u,j;
    //cin>>t;
    for(u=1;u<=t;u++){
        lli z,n,m,i,j,p=0,c,q,k,a,b,ne=0,p1=0,p2=0,p3=0,p4=0,q1=0,k1,k2,a1,a2,x,y;
        cin>>n;
        solve(1,1,1,n);
        for(i=1;i<=n;i++) cout<<A[i]<<endl;
        //cout<<ppp<<endl;
    }
}

Measured memory_bytes: 7860
n,k=map(int,input().split())
A=list(map(int,input().split()))

R=[0]*(n+1)
for i in range(1,n+1):
  R[i]=R[i-1]+A[i-1]

for i in range(1,n-k+1):
  if R[k+i]-R[i]>R[k+i-1]-R[i-1]:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 105740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;

    vector<bool> exist(100000);
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        A--;
        if (exist[A])
            cnt++;
        else
            exist[A] = true;
    }

    cnt += cnt % 2;
    cout << N - cnt << endl;

    return 0;
}


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

int main(){
    long int n;
    cin>>n;
    
    int count=9;
    
    if(n<=9){ cout<<n;return 0;}
    if(n<100){
        cout<<9;return 0;
    }
    if(n==100){
        cout<<10;
        return 0;
    }
    
    if(n>=999){
        count = count+900;
    }
    else if(n>=100 && n<=999){
        
        count = count+n-100+1;
        cout<<count;
        return 0;
    }
    
    if(n==10000){
        count++;
        cout<<count;return 0;
    }
    
    if(n>=99999){
        
        count = count+90000;
       
    }
    else if(n>=10000 && n<99999){
        
        count = count+n-10000+1;
        
        
    }
    
    cout<<count;
    
    
    
    return 0; 
}


Measured memory_bytes: 256
object Main extends scala.App {
    import java.util
    import scala.collection._
    import scala.collection.mutable
    import scala.math._

    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt()
    val S = sc.next()

    val ans = (0 until 1000).foldLeft(0)((e, t) => {
        val t_str = "%03d".format(t)
        var fromIdx = 0
        val is = (0 until 3).map(i => {
            val idx = S.indexOf(t_str(i), fromIdx)
            if (idx >= 0) {
                fromIdx = idx + 1
            } else {
                fromIdx += 1
            }
            idx
        }).forall(_ >= 0)
        if (is) {
            e + 1
        } else {
            e
        }
    })
    println(ans)
}

Measured memory_bytes: 32736
H, W = map(int, input().split())

S = []
for i in range(H) :
    S.append(list(input()))

for i in range(H) :
    for j in range(W) :
        cnt = 0
        if S[i][j] == "." :
            for a in range(-1, 2) :
                for b in range(-1, 2) :
                    if i + a >= 0 and i + a < H and j + b >= 0 and j + b < W :
                        if S[i + a][j + b] == "#" :
                            cnt += 1
            S[i][j] = str(cnt)

for i in range(H) :
    for j in range(W) :
        print(S[i][j], end="")
    print()


Measured memory_bytes: 3572
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

int main() {
	int n;cin>>n;
	vector<int> a(n);
	int mina=2e9;
	long long ans=0;
	int count=0;
	int flag=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0)flag=1;
		if(a[i]<0){
			a[i]=-a[i];
			count++;
		}
		mina=min(mina,a[i]);
		ans+=a[i];
	}
	if(flag==0){
		if(count%2){
			ans-=2*mina;
		}
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef double P;
struct node{
	P x,y,c;
}a[100];
int n,k;
P f(P l,P r)
{
	if(l+0.0000000001>r)
	{
		return (l+r)/2;
	}
	P m=(l+r)/2;
	queue<pair<P,P> > que;
	for(int i=0;i<n;i++)
	{
		que.push(make_pair(a[i].x,a[i].y));
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			P x1=a[i].x,y1=a[i].y,r1=m/a[i].c,x2=a[j].x,y2=a[j].y,r2=m/a[j].c,dx=x2-x1,dy=y2-y1,a=dx*dx+dy*dy,b=((r1*r1-r2*r2)/a+1)/2,d=r1*r1/a-b*b;
			if(d>=0)
			{
				d=sqrt(d);
				P x3=x1+dx*b,y3=y1+dy*b,x4=-dy*d,y4=dx*d;
				que.push(make_pair(x3-x4,y3-y4));
				que.push(make_pair(x3+x4,y3+y4));
			}
		}
	}
	int nu=0;
	while(que.size()!=0)
	{
		pair<P,P> p=que.front();
		que.pop();
		int nq=0;
		for(int i=0;i<n;i++)
		{
			P r=m/a[i].c,dx=p.first-a[i].x,dy=p.second-a[i].y;
			if(dy*dy+dx*dx-r*r<=0.0000001)
			{
				nq++;
			}
		}
		nu=max(nu,nq);
	}
	if(nu>=k)
	{
		return f(l,m);
	}
	else
	{
		return f(m,r);
	}
}
int main(void)
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%lf%lf%lf",&a[i].x,&a[i].y,&a[i].c);
	}
	if(k==1)
	{
		printf("0");
	}
	else
	{
		printf("%.10lf",f(0,1e6*1.0));
	}
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;


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

    long long T[n], A[n];

    for(int i=0;i<n;i++){
        cin >> T[i] >> A[i];
    }
    long long a=1LL, b = 1LL;
    
    for(int i=0;i<n;i++){
        long long k;
        k = max((T[i]+a -1)/ T[i], (A[i]+b-1)/A[i]);
        a = T[i] *k;
        b = A[i] * k;
    }
    cout << a+b << endl;
    return 0;
}

Measured memory_bytes: 256
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-04-30(Thu)
   note   
**********************************************************************/

#include <bits/stdc++.h>
using namespace std;

int main() {
    int k, a, b; 
    cin >> k;
    cin >> a >> b;
    bool isgood = false;
    
    for (int i = 1; i <= 1000; i++){
        if(i * k <= b && a <= i * k){
            //cout << "OK" << endl;
            isgood = true;
            break;
        }
    }

    if(isgood) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3640
n = int(input())
a, b = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p.sort()
one = 0
two = 0
three = 0
for i in range(n):
    if p[i] <= a:
        one += 1
    elif p[i] <= b:
        two += 1
    else:
        three += 1
print(min(one, two, three))
# print("one:{} two:{} three:{}".format(one, two, three))
"""
if one == 0 or two == 0 or three == 0:
    print(0)
else:
    print((one-1)*(two-1)*(three-1))
    """

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i]=sc.nextInt();
		}
		int ans=0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				for (int k = j+1; k < n; k++) {
					if(Math.abs(l[i]-l[j])<l[k]&&l[k]<(l[i]+l[j])){
						if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
						ans++;
						}
					}
				}
			}
		}
		System.out.println(ans+"");
	}
}

Measured memory_bytes: 39208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll a, b, c, k,answer=0;
	cin >> a >> b >> c >> k;
	answer += min(a, k);
	k -= a;
	k -= b;
	if (k>0)
	{
		answer -= k;
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int dp[100000 + 10];
int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];
  REP(j, 10000 + 10) dp[j] = INF;
  dp[0] = 0;
  REP(i, N) {
    REP(j, H + 1) {
      if (j + A[i] >= H) {
        chmin(dp[H], dp[j] + B[i]);
      }
      chmin(dp[j + A[i]], dp[j] + B[i]);
    }
  }
  cout << dp[H] << endl;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

int n,k;
ll Ans;

inline void file() {
	freopen("ARC102C.in","r",stdin);
	freopen("ARC102C.out","w",stdout);
}

inline void solve1() {
	int nn=n/k; Ans+=1ll*nn*nn*nn;
}

inline void solve2() {
	int kk=k/2,nn=n/kk;
	int sum0=nn/2,sum1=(nn+1)/2;
	Ans+=1ll*sum0*sum0*sum0; Ans+=1ll*sum1*sum1*sum1;
}

int main() {
//	file();
	scanf("%d%d",&n,&k);
	if (k&1) solve1();
	else solve2();
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 256
N=list(map(int,input()))
L=len(N)

ans1=9*(L-1)+N[0]-1

for i in range(L-1):
    if N[i]>N[i+1]:
        N[i]=N[i]-1
        for j in range(i+1,L):
            N[j]=9
        break

ans2=sum(N)

print(max(ans1,ans2))

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=2e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)998244353 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";


void work(){
	ll k;
	cin >> k;
	queue<ll> q;
	for(ll i=1;i<=9;i++)
		q.push(i);
	ll x;
	while(k--){
		x=q.front();
		q.pop();
		ll d=x%10;
		if(d!=0)
			q.push(x*10ll+d-1);

		q.push(x*10ll+d);

		if(d!=9)
			q.push(x*10ll+d+1);
	}	

	cout << x ;
	return;
}

int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 	
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	}
return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
	ll a[5];rep(i,0,5)cin>>a[i];
	ll ans=0;
	rep(i,0,5)ans+=(a[i]+10-1)/10;
  	ll b[5];rep(i,0,5)b[i]=a[i]%10;
	sort(b,b+5);
	ll q=10;rep(i,0,5)if(b[i]!=0){q=b[i];break;}
	cout<<ans*10-(10-q)<<ednl;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                count +=1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
long long N;
    cin >> N;
    //pairの書き換えが煩雑であるので、素数リストと指数連想配列に分ける
   map<ll,ll> prime_count;
   vector<ll> prime_list;
   
    //resに素数のペア(素数、その素数の指数）の配列が入る
    const auto  &res = prime_factorize(N);
    
   rep(i,res.size()){
       if(prime_count[res[i].first]==0){
           prime_list.push_back(res[i].first);
       }
       prime_count[res[i].first]+=res[i].second;
   }
   int count=0;
   rep(i,prime_list.size()){
       ll ex=0,p=prime_list[i];
       while(prime_count[p]>=((ex+1)*(ex+2)/2)){
           ex++;
           
           
       }
       count+=ex;

   }
   cout<<count<<endl;



    
return 0;
}



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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		char a;
		cin >> a;
		if(a == 'a' || a == 'o' || a == 'e' || a == 'i' || a == 'u') cout << "vowel" << endl;
		else cout << "consonant" << endl;
}



Measured memory_bytes: 256
def main():
    a, b = input(), input()
    len_a, len_b = len(a), len(b)

    if len_a < len_b:
        print("LESS")
    elif len_a > len_b:
        print("GREATER")
    else:
        if a < b:
            print("LESS")
        elif a > b:
            print("GREATER")
        else:
            print("EQUAL")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61940
#include<iostream>
 using namespace std ;
 int main()
{
short int c=0;
char s[3];

cin>>s;

if(((s[0]=='a')&&(s[1]=='b')&&(s[2])=='c')||
  ((s[0]=='a')&&(s[1]=='c')&&(s[2])=='b')||
  
((s[0]=='b')&&(s[1]=='a')&&(s[2])=='c')||
((s[0]=='b')&&(s[1]=='c')&&(s[2])=='a')||

((s[0]=='c')&&(s[1]=='b')&&(s[2])=='a')||
((s[0]=='c')&&(s[1]=='a')&&(s[2])=='b'))

 cout<<"Yes";
else
cout<<"No";

}

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

int main()
{  
  int l,r;
  cin >> l >> r;
  
  if(r-l>=2018){
    cout << "0";
    return 0;
  }
  
  l=l%2019;
  r=r%2019;
  if(l>=r){
    cout << "0";
    return 0;
  }
  
  int ans=2018;
  for(int i=l;i<r;++i){
    for(int j=i+1;j<=r;++j){
      if(ans>(i*j)%2019){
        ans=(i*j)%2019;
      }
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char a[60];
int n,ans;
int main()
{
//	freopen("in.txt","r",stdin);
	scanf("%d",&n);
	scanf("%s",a+1);
	for(int i=2;i<n;++i)
	{
		if(a[i-1]=='A' && a[i]=='B' && a[i+1]=='C')
		++ans;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>

using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

const double INF = 1e9;
const double EPS = 1e-8;
inline double SQ(double x) { return x * x; }
inline bool EQ(double x, double y) {
    return abs(x - y) < EPS;
}

string to_bit(int n) {
    string s;
    for(int i = 11; i >= 0; i--) {
        if(n & (1 << i)) s.push_back('1');
        else s.push_back('0');
    }
    return s;
}

vector<double> vec;
inline double D(int f, int t) {
    double l = vec[f];
    double r = vec[t];
    return sqrt(SQ(l + r) - SQ(l - r));
}

int N;
map<pair<int, int>, double> memo;

double tsp(int v, int b) {
    if(memo.count(make_pair(v, b))) return memo[make_pair(v, b)];
    if(b == (1 << N) - 1) return memo[make_pair(v, b)] = vec[v];

    double s = 0;
    if(b == 0) s += vec[v];

    double res = INF;
    for(int i = 0; i < N; i++) {
        if(b & (1 << i)) continue;

        if(v == i) res = min(res, s + tsp(i, b | (1 << i)));
        else res = min(res, s + D(v, i) + tsp(i, b | (1 << i)));
    }

    return memo[make_pair(v,b)] = res;
}

int main() {
    for(string line; getline(cin, line); ) {
        istringstream iss(line);
        double len; iss >> len;
        vec.clear();
        for(double r; iss >> r; ) {
            vec.push_back(r);
        }
        N = vec.size();
        memo.clear();
        double res = INF;
        for(int i = 0; i < N; i++) {
            res = min(res, tsp(i, 0));
        }
        // DEBUG(res);
        cout << (res < len + EPS ? "OK" : "NA") << endl;
    }
}

Measured memory_bytes: 2792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    set<ll> s;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        s.insert(x);
    }
    if(ll(s.size())==n)
    cout<<"YES";
    else
    cout<<"NO";
}


Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws IOException {
        try (InputReader reader = new InputReader(System.in)) {
            solve(reader);
        }
    }

    private static void solve(InputReader reader) throws IOException {
        int[] input = reader.readIntsSplitByDelimiter(" ");
        int a = input[0];
        int b = input[1];
        int ba = b - a;
        int h = (ba + 1) * ba / 2;
        System.out.println(h - b);
    }
}

class Util {
    static int gcd(int m, int n) {
        int min = Math.min(m, n);
        int max = Math.max(m, n);
        while (min != 0) {
            int tmp = min;
            min = max % tmp;
            max = tmp;
        }

        return max;
    }

    static int lcm(int m, int n) {
        return m / gcd(m, n) * n;
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        double[] doubles = new double[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


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

int main(){
    int N, X; cin >> N >> X;
    vector<int> L(N);
    int ans=0;
    int dis=0;

    rep(i,N){
        cin >> L[i];
    }

    rep(i,N){
        if(dis > X){
            break;
        }
        dis += L[i];
        ans++;
    
    }

    if(dis > X){
            cout << ans << endl;
    }

    else{
    cout << ans+1 << endl;
    }

}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int cnt[100010];

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    ll sum=0;
    rep(i,N){
        int a; cin>>a;
        sum+=a;
        cnt[a]++;
    }
    int Q; cin>>Q;
    while(Q--){
        int b,c; cin>>b>>c;
        sum += (ll)cnt[b]*(c-b);
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout<<sum<<"\n";
    }
    return 0;
}


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

typedef long long ll;

int main()
{
    ll i,j;
    ll x;
    cin >> x;
    ll tmp1 = x/500*1000;
    ll tmp2 = x%500/5*5;
    cout << tmp1 + tmp2 << endl;

    return 0;
}

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

bool check(std::string a, std::string b)
{
  for(int i=0;i<a.size();i++)
  {
    if(a[i]!=b[i]) return false;
  }
  return true;
}

int main()
{
  std::string s,t;
  std::cin>>s>>t;
  
  if(s.size()+1==t.size() && check(s,t)) std::cout<<"Yes";
  else std::cout<<"No"; 
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int day[300];
int n, d, y = 1;
int a[300], b[300], c[300];
int mem[210][11000];
int rt = 0;
int solve(int i, int bf);
int main(){
  memset(mem, -1, sizeof(mem));
  int ret = -1;
  cin >> d >> n;
  for(int i = 0; i < d; i++){
    cin >> day[i];
  }
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  
  for(int i = 0; i < n; i++){
    if(day[0] >= a[i] && day[0] <= b[i]){
      ret = max(solve(1, c[i]), ret);
    }
  }
  
  cout << ret << endl;
}



int solve(int i, int bf){
  if(i >= d){
    return 0;
  }
  if(mem[i][bf] >= 0) {
    return mem[i][bf];
  }
  int ret = 0;
  for(int j = 0; j < n; j++){
    if(day[i] >= a[j] && day[i] <= b[j]){
      ret = max(solve(i + 1, c[j]) + abs(bf - c[j]), ret);
    }
  }
  return mem[i][bf] = ret;
}

Measured memory_bytes: 10208
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def bit(n, k):
    return (n >> k) & 1


def solve(N: int, a: "List[List[int]]"):
    DP = [0]*(1 << N)
    flag = [False]*(1 << N)

    def rec(S):
        if flag[S]:
            return DP[S]
        flag[S] = True

        ans = 0
        for i in range(N):
            for j in range(i+1, N):
                if bit(S, i) and bit(S, j):
                    ans += a[i][j]
        T = (S-1) & S
        while T > 0:
            ans = max(ans, rec(T)+rec(S ^ T))
            T = (T-1) & S
        DP[S] = ans
        return ans
    print(rec((1 << N)-1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [[int(next(tokens)) for _ in range(N)]
         for _ in range(N)]  # type: "List[List[int]]"
    solve(N, a)


if __name__ == '__main__':
    main()


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

int main() {
  int N, M, L, R;
  cin >> N >> M;
  L = 0;
  R = 100001;
  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    L = max(L, l);
    R = min(R, r);
  }
  int ans = R - L + 1;
  if (ans >= 0) {
    cout << ans << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

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

	int a, b, t;
	cin >> a >> b >> t;
	int ans = (t / a) * b;
	cout << ans << endl;

	return 0;
}



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

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> h(n);
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	
	int ans = 1;
	int maxH = h[0];
	for(int i = 1; i < n; ++i) {
		if( h[0] <= h[i] && maxH <= h[i] ) { 
			ans++;
			maxH = h[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bitset>
#include <functional>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        }

        string init;
        string final;
        cin >> init;
        cin >> final;

        auto encode = [](const string& s) {
            int r = 0b0;
            for (int i = 0; i < s.size(); ++i) {
                if (i != 0) {
                    r <<= 1;
                }
                if (s[i] == 'B') {
                    r |= 0b1;
                }
            }
            return r;
        };

        auto pow = [](int b, int e) {
            int r = 1;
            for (int i = 0; i < e; ++i) {
                r *= b;
            }
            return r;
        };

        auto target = encode(final);
        auto start = encode(init);

        vector<vector<int>> memo(n, vector<int>(pow(2, n), -1));
        // p ??????????????´?????¶?????? s ?????¨??????????°???????????????????
        function<int(int, int)> f = [&f, &memo, n, &pow, start](int p,
                                                                int s) -> int {
            if (memo[p][s] != -1) {
                return memo[p][s];
            }

            // ??????????????´????????????
            if (s == 0) {
                return 0;
            }

            int min_ = numeric_limits<int>::max();
            int pp = -1;
            for (int i = 0; i < n; ++i) {
                // i ??????????????§????????´????????????
                if (((s >> i) & 1) == 0) {
                    continue;
                }
                for (int j = 0; j < n; ++j) {
                    if (i == j) {
                        continue;
                    }
                    // j ??????????????§????????´????????????
                    else if ((s >> j & 1) == 0) {
                        continue;
                    }
                    // ?????????????????\????????????????°???????????????????
                    else if ((((start >> i) & 1) ^ ((start >> j) & 1)) == 0) {
                        continue;
                    }
                    else {
                        // p ?????? i ?????§?????£???, i ?????? j ?????§??????
                        auto cost = abs(i - p) + abs(j - i);
                        auto ss = s;
                        ss ^= 1 << i;
                        ss ^= 1 << j;
                        auto min__ = min_;
                        min_ = min(min_, cost + f(j, ss));
                        if (min__ != min_) {
                            pp = p;
                        }
                    }
                }
            }
            memo[pp][s] = min_;

            return min_;
        };

        int min_ = numeric_limits<int>::max();
        for (int i = 0; i < n; ++i) {
            min_ = min(min_, f(i, start ^ target));
        }
        cout << min_ << endl;
    }
}

Measured memory_bytes: 7280
#include <stdio.h>
int main(void)
{
  int tate[100];
  int yoko[100];
  int a=0;
  int i=0;
  int j,l;

  for (;;) {
	scanf("%d%d",&tate[i],&yoko[i]);
	if (tate[i]==0 && yoko[i]==0) break;
	a++;
	i++;
  }

  for (i=0; i<a; i++) {
	for (j=0; j<tate[i]; j++) {
	  for (l=0; l<yoko[i]; l++) {
		if (j==0 || j==tate[i]-1) {
		  printf("#");
		}
		else if (l==0 || l==yoko[i]-1) {
		  printf("#");
		}
		else printf(".");
	  }
	  printf("\n");
	}
	printf("\n");
  }
  return 0;
}

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


int main(){
    int K, S;
    cin >> K >> S;
    
    int cnt=0;
    for(int x=0; x<=K; x++){
        for(int y=0; y<=K; y++){
            if(x+y+(S-(x+y))==S){
                if(S-(x+y)>=0 && S-(x+y)<=K)
                    cnt++;
            }
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<ll>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

vector<ll> ans ;
vector<bool> seen ;
 void dfs(const Graph & G,ll v){
   seen[v]=true ;
   for(auto u: G[v] ){
   if(seen[u]) continue ;
   ans[u]+=ans[v] ;
   dfs(G,u) ;
 }
}
int main(){
ll n;cin>>n ;
 ll q ; cin>> q ;
 Graph g(n) ;
  rep(i,n-1){
    ll a,b ;
    cin>>a>>b ;
    a-- ;b-- ;
    g[a].pb(b) ;
    g[b].pb(a) ;
  }
  ans.resize(n) ;
  rep(i,q){
    int p,x ;
    cin>>p>> x ;
    p-- ;
    ans[p]+= x ;
  }
  
  seen.assign(n,false) ;
  
  dfs(g,0) ;
  rep(i,n) cout<<ans[i] <<endl ;
 return 0;
  }

Measured memory_bytes: 24320
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PL;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll N, C;
  cin >> N >> C;
  ll x[MAX], v[MAX];
  ll s[MAX]={}, t[MAX]={};
  
  x[0]=0; v[0]=0;
  x[N+1]=C; v[N+1]=0;
  for(i=1; i<=N; i++) cin >> x[i] >> v[i];
  for(i=1; i<=N; i++) s[i]=s[i-1]+v[i];
  for(i=N; i>=1; i--) t[i]=t[i+1]+v[i];
  
  ll p[MAX], pp[MAX];
  ll m=-INF, mm=-INF;
  ll d=0, dd=0;
  for(i=0; i<=N; i++) {
    if(m<s[i]-x[i]) {m=s[i]-x[i]; d=i;}
    if(mm<s[i]-x[i]*2) {mm=s[i]-x[i]*2; dd=i;}
    p[i]=d; pp[i]=dd;
  }
  
  ll ans=0;
  for(i=1; i<=N+1; i++) {
    chmax(ans, s[p[i-1]]-x[p[i-1]]+t[i]-(C-x[i])*2); //OA+OB*2
    chmax(ans, s[pp[i-1]]-x[pp[i-1]]*2+t[i]-(C-x[i])); //OA*2+OB
  }
  
  pt(ans);
}


Measured memory_bytes: 4992
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    k, x = f.read_int_list()

    return " ".join(map(str, range(x-k+1, x+k)))


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 35816
N = int(input())
ans = 0

for i in range(1, N+1):
    count = 0
    if i % 2 != 0:
        for j in range(1, int((i+1)**(1/2))):
            if i % j == 0:
                count += 2
    if count == 8:
        ans += 1

print(ans)



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int n;
  string s;
  cin >> n >> s;
  map<pair<string, string>, int> mp;
  rep(bit, 1<<n) {
    string red, blue;
    rep(i, n) {
      if((bit>>i)&1) red += s[i];
      else blue += s[i];
    }
    reverse(all(red));
    reverse(all(blue));
    mp[make_pair(red, blue)]++;
  }
  int ans = 0;
  rep(bit, 1<<n) {
    string red, blue;
    rep(i, n) {
      if((bit>>i)&1) red += s[i+n];
      else blue += s[i+n];
    }
    ans += mp[make_pair(red, blue)];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 87040
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int k,s;
    cin >> k >> s;
    int i,j,l;
    int ans = 0;
    for(i = 0;i <=k;++i){
        for(j = i;j <= k;++j){
            for(l = j;l <= k;++l){
                if(i+j+l == s){
                    if(i == j && j == l){
                        ++ans;
                    }else if(i == j || j == l){
                        ans += 3;
                    }else{
                        ans += 6;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int ketasuu(int n) { return log10(n) + 1; }

signed main()
{
	int N;
	cin >> N;
	int sum = 0;
	for (int i = 1; i <= N; i++)
	{
		if (ketasuu(i) % 2 == 1)sum++;
	}
	cout << sum;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, P;
	string S;
	cin >>N >> P >> S;
	vector<int>NUM(S.size()+1);
	NUM[0] = 0;
	int num = 0;
	int ten = 1;
	for (int n = 0;n<S.size();++n) {
		int m = S[S.size()-1-n] - '0';
		ten *= 10;
		ten %= P;
		num = (ten * m + num)%P;
		NUM[n+1] = num; 
		//cout << NUM[n + 1] << endl;
	}
	long long nans = 0;
	if (2 == P ||5 == P) {
		for (int n = 0; n < S.size(); ++n) {
			int m = S[n] - '0';
			if (0 == m%P) {
				nans += (n + 1);
			}
		}
	}
	else {
		vector<long long>MOD(P);
		for (int n = 0; n < S.size() + 1; ++n) {
			MOD[NUM[n]]++;
		}
		for (int n = 0; n < P; ++n) {
			nans += (MOD[n] - 1) * MOD[n] / 2;
		}
	}
	cout << nans<< endl;
	return 0;
}

Measured memory_bytes: 4460
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, A = 0;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {cin >> d.at(i);}
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      A += d.at(i) * d.at(j);
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 3616
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

n = SINGLE_INT()
arr = MULTIPLE_INT_LIST()

sum_arr = sum(arr)
current_sum = 0
ans = float('inf')

for x in arr:
    current_sum += x
    
    diff = abs(sum_arr - 2 * current_sum)
    ans = min(ans, diff)
    if ans == 0:
        break
    
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll a = x/d;
    if(a > k){
        cout << x-k*d << "\n";
    }else {
        if((k-a)&1) cout << abs(x-(a+1)*d) << "\n";
        else cout << abs(x-a*d) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextLong();
            var b = cin.nextLong();
            var c = cin.nextLong();
            var d = cin.nextLong();

            var ans = new List<long>();
            ans.Add(a * c);
            ans.Add(a * d);
            ans.Add(b * c);
            ans.Add(b * d);


            Console.WriteLine(ans.Max());
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 28296
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int H,W,K;
vector<vector<char>> v;
set<int> strow,stcol;
int findBlack()
{
	int cnt=0;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if(v[i][j]=='#' && (strow.count(i)!=0 || stcol.count(j)!=0))
			cnt++;
		}
	}
	return cnt;
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 cin>>H>>W>>K;
	 
	 v.resize(H,vector<char>(W));
	 int cnt=0;
	 for(int i=0;i<H;i++)
	 {
		 for(int j=0;j<W;j++)
		 {
			 cin>>v[i][j];
			 if(v[i][j]=='#')
			 cnt++;
		 }
	 }
	 int remove=cnt-K;
	 if(remove<0)
	 {
		 cout<<0<<'\n';
		 return 0; 
	 }
	 //cout<<remove<<'\n';
	 vector<int> row,col;
	 for(int i=0;i<H;i++)
	 {
		 row.push_back(i);
	 }
	 for(int j=0;j<W;j++)
	 {
		 col.push_back(j);
	 }
	 int ans=0;
	 for(int b=0;b<(1<<H);b++)
	 {
		 strow.clear();
		 for(int i=0;i<H;i++)
		 {
			 if((b&(1<<i)))
			 {
				 strow.insert(row[i]);
			 }
		 }
		 
		 for(int bb=0;bb<(1<<W);bb++)
		 {
			 stcol.clear();
			 for(int i=0;i<W;i++)
			 {
				 if((bb&(1<<i)))
				 {
					 stcol.insert(col[i]);
				 }
			 }
			 if(findBlack()==remove)
			 ans++;
		 }
	 }
	 cout<<ans<<'\n';
	 return 0;
}


Measured memory_bytes: 3644
// CPP program to count common prime factors 
// of a and b. 
#include <bits/stdc++.h> 
using namespace std; 
#define int long  long int
// A function to count all prime factors of 
// a given number x 
int countPrimeFactors(int x) 
{ 
	int res = 0; 
	if (x % 2 == 0) { 
		res++; 

		// Print the number of 2s that divide x 
		while (x % 2 == 0) 
			x = x / 2; 
	} 

	// x must be odd at this point. So we 
	// can skip one element (Note i = i +2) 
	for (int i = 3; i <= sqrt(x); i = i + 2) { 
		if (x % i == 0) { 

			// While i divides x, print i and 
			// divide x 
			res++; 
			while (x % i == 0) 
				x = x / i; 
		} 
	} 

	// This condition is to handle the case 
	// when x is a prime number greater than 2 
	if (x > 2) 
		res++; 
	return res; 
} 

// Count of common prime factors 
int countCommonPrimeFactors(int a, int b) 
{ 
	// Get the GCD of the given numbers 
	int gcd = __gcd(a, b); 

	// Count prime factors in GCD 
	return countPrimeFactors(gcd); 
} 

// Driver code 
int32_t main() 
{ 
	int a,b;
	cin>>a>>b;
	int ans= countCommonPrimeFactors(a, b); 
	ans++;
	cout<<ans<<endl;
	return 0; 
} 


Measured memory_bytes: 256