akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
   int a,b,c;
   cin>>a>>b;
   if(b==100)a*=1000;
   else if(b<10)a*=10;
   else a*=100;
   c=a+b;
   for(int i=0;i<c;i++){
       if(i*i==c){
           cout<<"Yes"<<endl;
           return 0;
       }
   }
   cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
### constant

MAX_P = 1000000

### subroutines

def gen_primes(max_p)
  primes = Array.new(max_p + 1){true}
  primes[0] = primes[1] = false

  for p in (2..max_p)
    if primes[p]
      for q in (p * p).step(max_p, p)
        primes[q] = false
      end
    end
  end

  return primes
end

### main

primes = gen_primes(MAX_P)

while true
  n = gets.strip.to_i
  break if n == 0

  hn = n / 2
  count = 0

  for i in (3..hn)
    if primes[i] && primes[n - i]
      count += 1
    end
  end

  puts count
end

Measured memory_bytes: 13944
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

vector<ll> factors;
ll n, m;

void solve() {
  for (ll i=1;i*i <= m;i++) {
    if (m % i == 0) {
      factors.push_back(i);
      factors.push_back(m / i);
    }
  }
  sort(factors.begin(), factors.end());
  ll factor = m % n == 0 ? n : *upper_bound(factors.begin(), factors.end(), n);
  cout << (m / factor) << endl;
}

int main() {
  cin >> n >> m;
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

// vector<int> d[60]; // segmentation fault
int d[60][212345]; 

int main() {
  int n; ll k;
  cin >> n >> k;
  rep(i, n) {
    int a;
    cin >> a;
    a--;
    d[0][i] = a;
  }

  rep(i, 59) {
    // if (i==0) continue;
    rep(j, n) {
      // d[i][j] = d[i-1][d[i-1][j]];
      d[i+1][j] = d[i][d[i][j]];
    }
  }

  int v =0;
  for(int i=59; i>=0; i--) {
    ll l = 1ll << i;
    if(l<=k) {
      v = d[i][v];
      k-=l;
    }
  }
  cout << v+1 << endl;

  return 0;
}

Measured memory_bytes: 50748
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
int dp[1100][1100];
signed main(){
    int n;
    cin>>n;
    for(int c=0;c<n;c++){
        string s,t;
        cin>>s>>t;
        int a=s.size(),b=t.size();
        for(int i=0;i<1100;i++){
            for(int j=0;j<1100;j++){
                dp[i][j]=0;
            }
        }
        for(int i=1;i<=a;i++){
            for(int j=1;j<=b;j++){
                if(s[i-1]==t[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
                }
            }
        }
        cout<<dp[a][b]<<endl;
    }
    return 0;
}




Measured memory_bytes: 12592
/*
 *  stay hungry, stay foolish, stay home.
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define ml cout<<"\n"
 
#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define in insert
#define ff first
#define ss second
#define mod 1000000007

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	ios_base::sync_with_stdio(false);
     	cin.tie(NULL);
    	cout.tie(NULL);    
	ll n;cin>>n;
	mi m;
	rep(i,0,n-1){
		ll a;
		cin>>a;
		m[a]++;
	}
	
	rep(i,1,n+1){
		cout<<m[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 16116
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    int n;
    cin >> n;
    pair<ll,ll> p[n];
    rep(i,0,n){
	ll x,l;
	cin >> x >> l;
	p[i] = {x+l,x-l};
    }
    sort(p,p+n);

    
    int ans = 0;
    ll m = -linf;
    rep(i,0,n){
	if(m <= p[i].sd){
	    ans++;
	    m = p[i].ft;
	}
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, a[110];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int min = 10000, max = -100;
    for (int i = 0; i < n; i++) {
        if (a[i] < min) min = a[i];
        if (a[i] > max) max = a[i];
    }
    cout << max - min << endl;
	return 0;
}

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

int main()
{
 string s;
  cin >> s;
  bool f = true;
  if (s.length() < 4)
    f = false;
  if (s[0] != 'Y' || s[1] != 'A' || s[2] != 'K' || s[3] != 'I')
    f= false;
  
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int a, b;
char s[105][105];

int main ()
{
	scanf ("%d %d", &a, &b);
	for (int i = 1; i <= a; i++)
		scanf ("%s", s[i] + 1);
	for (int i = 1; i <= b + 2; i++)	printf ("#");
	printf ("\n");
	for (int i = 1; i <= a; i++){
		printf ("#");
		for (int j = 1; j <= b; j++){
			printf ("%c", s[i][j]);
		}
		printf ("#\n");
	}
	for (int i = 0; i <= b + 1; i++)	printf ("#");
	printf ("\n"); 
}
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}




 
    
void test_case() {

    ll x;
    cin>>x;

    ll ans = 1000*(x/500);

    x= x % 500;

    ans+= 5*(x/5);

    cout<<ans<<endl;

}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

int main()
{
    int n, m;
    vector<int> answer;
    while (cin >> n >> m && n != 0)
    {
        int risk = 0;
        vector<pair<int, int> > p_d(n);
        for (int i = 0; i < n; i++)
        {
            int d, p;
            cin >> d >> p;
            p_d.at(i) = make_pair(p, d);
        }
        sort(p_d.rbegin(), p_d.rend());
        for (int i = 0; i < n; i++)
        {
            if (p_d.at(i).second <= m)
            {
                m -= p_d.at(i).second;
            }
            else if (m != 0)
            {
                risk += p_d.at(i).first * (p_d.at(i).second - m);
                m = 0;
            }
            else
            {
                risk += p_d.at(i).first * p_d.at(i).second;
            }
        }
        answer.push_back(risk);
    }
    for (int i = 0; i < answer.size(); i++)
    {
        cout << answer.at(i) << endl;
    }
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int H, W; cin >> H >> W;
  vector<string> S(H); REP(i, H) cin >> S[i];
  vector<vector<int>> A(H, vector<int>(W, 0));
  vector<vector<int>> B(H, vector<int>(W, 0));
  for(int i = 0; i < H; ++i) {
    int tmp = 0;
    int start = 0;
    for(int k = 0; k < W; ++k) {
      if(S[i][k] == '.') {
        tmp++;
      } else if(S[i][k] == '#') {
        for(int m = start; m < k; ++m) {
          A[i][m] = tmp;
        }
        start = k + 1;
        tmp = 0;
      }
      if(k == W - 1) {
        for(int m = start; m <= k; ++m) {
          A[i][m] = tmp;
        }
      }
    }
  }
  
  for(int k = 0; k < W; ++k) {
    int tmp = 0;
    int start = 0;
    for(int i = 0; i < H; ++i) {
      if(S[i][k] == '.') {
        tmp++;
      } else if(S[i][k] == '#') {
        for(int m = start; m < i; ++m) {
          B[m][k] = tmp;
        }
        start = i + 1;
        tmp = 0;
      }
      if(i == H - 1) {
        for(int m = start; m <= i; ++m) {
          B[m][k] = tmp;
        }
      }
    }
  }

  int ans = 0;
  int tmp = 0;
  REP(i, H) {
    tmp = 0;
    REP(k, W) {
      tmp = A[i][k] + B[i][k] - 1;
      if(ans < tmp) ans = tmp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 42300
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> a(N);
  for(int i=0;i<N;++i) cin>>a[i];
  for(int i=1;i<N;++i) a[i] += a[i-1];
  ll ans = big;
  for(int i=0;i<N-1;++i) {
    ans = min(ans, abs(a[i]-(a[N-1]-a[i])));
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4744
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    a = na()

    if sum(a) >= 22:
        print("bust")
    else:
        print("win")

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long int LL;
const int MAXN = 200010;
int a[MAXN], n;
bool play()
{
    int cnt = 0, x = 0;
    for(int i = 0; i < n; i++) if(a[i]&1) cnt++, x = i;
    if((n - cnt) & 1) return true;
    if(cnt > 1) return false;
    if(a[x] == 1) return false;
    a[x] -= 1;
    int g = a[0];
    for(int i = 1; i < n; i++) g = __gcd(g, a[i]);
    for(int i = 0; i < n; i++) a[i] /= g;
    return !play();
}
int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    int s = 0;
    for(int i = 0; i < n; i++) s ^= (a[i]-1);
    if(n == 1) puts(s&1 ? "First" : "Second");
    else puts(play() ? "First" : "Second");

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int Array[105];
bool dp[100005];

void ConstructDP( int N , int k , int low ){
    int i , j;

    for( i = 0 ; i <= low ; ++i )
        dp[i] = false;
    
    for( i = low + 1 ; i <= k ; ++i ){
        dp[i] = false;

        for( j = 1 ; j <= N ; ++j ){
            if( Array[j] <= i ){
                if( dp[i - Array[j]] == false ){
                    dp[i] = true;
                    break;
                }
            }
        }
    }
}

int main(){
    int N , k , i , Min = 1000000;
    scanf( "%d%d" , &N , &k );

    for( i = 1 ; i <= N ; ++i ){
        scanf( "%d" , Array + i );
        Min = min( Min , Array[i] );
    }    

    ConstructDP( N , k , Min - 1 );
    if( dp[k] == true ) puts( "First" );
    else puts( "Second" );
    return 0;
}

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

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  
  
  bool flag = true;
  int min_number = a[0];
  int ans = 1001001001;
  for(int i = 1; i < n; ++i) {
    int t = gcd(a[0], a[i]);
    if(t == 1) {
      flag = false;
      break;
    }
    ans = min(ans,t);
  }
  if(flag) {
    cout << ans << endl;
    return 0;
  }
  else {
    cout << 1 << endl;
    return 0;
  }
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int a, b;
	string s;
	cin >> a >> b >> s;
	//if (!all_of(s.cbegin(), s.cbegin()+a, isdigit)|| !all_of(s.cbegin()+a+1, s.cend(), isdigit) || (s[a]!='-'))
	//if (!all_of(s.cbegin(), s.cend() + a, isdigit)|| (s[a] != '-'))
	if (!all_of(s.cbegin(),s.cbegin()+a,[](char ch) { return isdigit(ch); })|| !all_of(s.cbegin()+a+1, s.cend(), [](char ch) { return isdigit(ch); })||(s[a]!='-'))
	{
		print("No");
	}
	else print("Yes");
}

Measured memory_bytes: 3588
using System;
					
public class Program
{
	public static void Main()
	{
		int[] all = new int[26];
		for(int i=0; i<26; i++) all[i]=0;
		string w = Console.In.ReadLine();
		
		for(int i=0; i<w.Length; i++)
		{
			all[w[i]-'a']++;
		}
		
		for(int i=0; i<26; i++)
		{
			if(all[i]%2 != 0)
			{
				Console.WriteLine("No");
				return;
			}
		}
		
		Console.WriteLine("Yes");
	}
}

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

int main() {
  int N,t;
  cin >> N;
  t =0;
  for (int i=0; i<N; i++){
	string Si;
    cin >> Si;
    if (Si == "Y")
      t++;
    else
      t+=0;
  }
  if(t == 0)
  cout << "Three" << endl;
  else
  cout << "Four" << endl;
}

Measured memory_bytes: 256
/*
 * yaswanth phani kommineni
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';

const ll mod = 1e9+7,M = 1e6+1;
vector <ll> fact(M);

void precalc(){
	fact[0] = 1;
	for(ll i=1;i<M;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}

ll modpow(ll x,ll n){
	if(n == 0) return 1%mod;
	ll u = modpow(x,n/2);
	u = (u*u)%mod;
	if(n&1) u = (u*x)%mod;
	return u;
}

ll inverse(ll n){
	return modpow(n,mod-2);
}

ll BC(ll n,ll k){
	return (((fact[n]*inverse(fact[n-k]))%mod)*inverse(fact[k]))%mod;
}

void solve(){
	ll n;
	cin >> n;
	ll i = 1;
	ll ans = 0;
	while(true){
		if(3*i>n) break;
		ans+=BC(n-2*i-1,i-1);
		ans%=mod;
		i++;
	}
	cout << ans << endl;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	precalc();
	int z;
	z = 1;
	//cin >> z;
	for(int z1=1;z1<=z;z1++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 11044
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,a[111111];
  cin>>n;
  ll suma=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    suma+=a[i];
  }

  if(suma%((n+1)*n/2)!=0){
    cout<<"NO"<<endl;
    return 0;
  }

  ll k=suma/((n+1)*n/2);
  ll f=1;
  for(int i=0;i<n;i++){
    if(a[i]<k)f=0;
    a[i]-=k;
  }
  
  //  dbg(k);
  
  if(f==0){
    cout<<"NO"<<endl;
    return 0;
  }

  int sumk=0;
  
  for(int i=0;i<n;i++){
    ll dif=abs(k-(a[(i+1)%n]-a[i]));
    //    dbg(dif);
    if(dif%n){
	 cout<<"NO"<<endl;
	 return 0;
    }
    sumk+=dif/n;
  }

  if(sumk==k)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  return 0;
}


Measured memory_bytes: 1024
n = int(input())

xy = [list(map(int, input().split())) for i in range(n)]
s = 0
for i in range(n):
    for j in range(i+1, n):
        s += ((xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2)**0.5
print(s*2/n)

Measured memory_bytes: 3060
import bisect

n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
slst = []
slen = 0
for i in range(2 ** n):
    total = 0
    for j in range(n):
        if i >> j & 1:
            total += A[j]
    slst.append(total)
slst.sort()
slen = 2 ** n
for i in range(q):
    tmp = bisect.bisect_left(slst, m[i])
    if tmp != slen and m[i] == slst[tmp]:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 47012
#include<iostream>
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
 {
	int n;
	cin>>n;

	int a[n];

	for(int i=0;i<n;i++) cin>>a[i];

	int f = 0;
	for(int i=0;i<n && f==0;i++){
		for(int j=i+1;j<n && f==0;j++){
			if(a[i] > a[j]){
				int temp = a[i];
				a[i] = a[j];
				a[j] = temp;
				int fl = 1;
				for(int i=0;i<n-1;i++){
					if(a[i+1] < a[i]) fl = 0;
 				}
				if(fl == 1) f = 1;
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
			else{
				int fl = 1;
				for(int i=0;i<n-1;i++){
					if(a[i+1] < a[i]) fl = 0;
 				}
				if(fl == 1) f = 1;
			}
		}
	}
	if(f == 1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,a,last;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a);
		if(a==last+1)++last;
	}
	if(!last)printf("-1");
	else printf("%d",n-last);
	return 0;
}


Measured memory_bytes: 128
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
String line = in.readLine();
String[] params = line.split(" ");
int a1 = Integer.parseInt(params[0]);
int a2 = Integer.parseInt(params[1]);
int a3 = Integer.parseInt(params[2]);

int sum = a1 + a2 + a3;
if (sum >= 22) {
	System.out.println("bust");
} else {
	System.out.println("win");
}
}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  for(int i=0;i<N;i++){
    cout << S.at(i);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<utility>
using namespace std;
struct unionfind{
  int par[200010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[200010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
int main(){
  int i,n,k,l,p,q;
  pair<int,int> b;
  map<pair<int,int>,int> store;
  scanf("%d %d %d\n",&n,&k,&l);
  unionfind tree(n);
  unionfind tree1(n);
  for(i=0;i<k;i++){
    scanf("%d %d\n",&p,&q);
    tree.unite(p,q);
  }
  for(i=0;i<l;i++){
    scanf("%d %d\n",&p,&q);
    tree1.unite(p,q);
  }
  for(i=1;i<=n;i++){
    b.first=tree.root(i),b.second=tree1.root(i);
    store[b]++;
  }
  for(i=1;i<=n;i++){
    b.first=tree.root(i),b.second=tree1.root(i);
    if(i==1){
      printf("%d",store[b]);
    }
    else{
      printf(" %d",store[b]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 15232
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(a+1):
    total=500*i
    if total>x:
        break
    for j in range(b+1):
        total+=100*j
        if total>x:
            break
        if (x-total)%50==0 and (x-total)/50<=c:
            ans+=1
        total=500*i
    total=0
print(ans)

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

int a[1000000];
long long memo[1000000];

int partial_sum(int array[], int now, int k, int n);
int judge(int x, int y);

int main(void)
{
	int n;
	int i, j, k;
	long long ans;
	
	while (scanf("%d", &n), n){
		ans = -100000000000;
		memset(a, 0, sizeof(a));
		memset(memo, 0, sizeof(memo));
		
		for (i = 0; i < n; i++){
			scanf("%d", &a[i]);
		}
		
		for (i = 0; i < n; i++){
			for (j = n, k = 0; j >= 1; j--, k++){
				ans = judge(ans, partial_sum(a, i, k, n));
			}
		}
		
		printf("%lld\n", ans);
	}
	
	return (0);
}

int partial_sum(int array[], int now, int k, int n)
{
	
	if (now + k < n){
		memo[now] += array[now + k];
	}
	
	return (memo[now]);
}

int judge(int x, int y)
{
	if (x >= y){
		return (x);
	}
	else {
		return (y);
	}
}

Measured memory_bytes: 12324
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int N, T, c[100], t[100];
	cin >> N >> T;
	REP(i, N) cin >> c[i] >> t[i];

	int ans = 2000000;
	REP(i, N){
		if(t[i] <= T){
			if(c[i] < ans) ans = c[i];
		}
	}

	if(ans != 2000000) cout << ans << endl;
	else cout << "TLE" << endl;

	return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable

object Main {

  def main(arg: Array[String]): Unit = {

    val scanner = new java.util.Scanner(System.in)

    var i, j = scanner.nextInt()
    while (i != 0 && j != 0) {
      val map = Array.fill(i)(scanner.next()).map(_.toCharArray)

      val hoge = fordataset(i, j, map)

      println(hoge)

      i = scanner.nextInt()
      j = scanner.nextInt()
    }
  }

  def fordataset(i: Int, j: Int, map: Array[Array[Char]]): Int = {
    val visited = mutable.Set[(Int, Int)]()

    val direction = List((0, 1), (1, 0), (0, -1), (-1, 0))

    var answer = 0

    def checkNext(now: (Int, Int)): Unit = {
      if (visited.contains(now)) return

      visited += now

      val (x, y) = now

      for {
        (dx, dy) <- direction
      } {
        if (((0 until i) contains (x + dx)) && ((0 until j) contains (y + dy)) && map(x + dx)(y + dy) == map(x)(y)) {
          checkNext((x + dx, y + dy))
        }

      }
    }

    def traverse = for (i <- 0 until i; j <- 0 until j) {
      if (!visited.contains((i, j))) {
        checkNext((i, j))
        answer += 1
      }

    }

    traverse

    answer
  }


}

Measured memory_bytes: 76092
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

ll fastPow(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return fastPow(x * x % MOD, n / 2);
    else
        return x * fastPow(x, n - 1) % MOD;
}

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

    ll n, p;

    cin >> n >> p;

    if (n == 1)
    {
        cout << p << endl;
        return 0;
    }

    ll res = 1;

    ll p_ = p;

    for (ll i = 2; i <= sqrt(p_); i++)
    {
        if (p % i)
            continue;

        ll cnt = 0;

        while ((p % i) == 0)
            p /= i, cnt++;

        if (cnt >= n)
            res *= fastPow(i, cnt / n);
    }

    cout << res << endl;

    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);
        String s = sc.next();
        sc.close();

        int cnt = 1;
        String prev = String.valueOf(s.charAt(0));
        StringBuilder sb  = new StringBuilder();
        for(int i = 1; i < s.length();i++) {
            sb.append(String.valueOf(s.charAt(i)));
            if (!prev.equals(sb.toString())) {
                cnt++;
                prev = sb.toString();
                sb.delete(0, sb.length());
            }
        }
        System.out.println(cnt);
    }
}

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

int main() {
  vector<vector<int>> data(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }
  vector<vector<bool>> m_ans(2, vector<bool>(2));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (data.at(i).at(j) + data.at(i+1).at(j+1) == data.at(i).at(j+1) + data.at(i+1).at(j)) {
        m_ans.at(i).at(j) = 1;
      }
    }
  }
  bool r = 1;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      r *= m_ans.at(i).at(j);
    }
  }
  if (r == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int m, k; cin >> m >> k;
	if (m == 0)
	{
		if (k == 0)cout << "0 0" << endl;
		else cout << -1 << endl;
	}
	else if (m == 1)
	{
		if (k == 0)cout << "1 0 0 1" << endl;
		else cout << -1 << endl;
	}
	else
	{
		if (pow(2, m) - 1 < k)cout << -1 << endl;
		else
		{
			vector<int> res;
			rep(i, pow(2, m))
			{
				if (i == k)continue;
				res.push_back(i);
			}
			cout << k << " ";
			for (int a : res)cout << a << " ";
			cout << k << " ";
			reverse(all(res));
			for (int a : res)cout << a << " ";
		}
	}
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int s=S.size();
  int ans;
  for (int i=s/2-1;i>0;i--){
    bool a=true;
    for (int j=0;j<i;j++){
      if (S[j]!=S[j+i]){
        a=false;
      }
    }
    if (a){
      ans=i*2;
      break;
    }
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 384
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
using namespace std;
//#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)&1)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n")
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_arr2(x,n,m) ____; cout<<#x<<":\n"; rep(i,0,n) rep(j,0,m) cout<<#x<<"["<<(i)<<"]["<<(j)<<"]= "<<x[i][j]<<((j==m)?"\n\n":"    ")
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const ll ooo=9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N=200105;
const double PI=acos(-1.0);
const double eps=1e-9;
int o(int x) { return x%_p; }
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; }

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

int n,k,a[N],x,b[N],ans=0;

bool cmp(int x,int y) {
    return a[x]>a[y];
}

int main() {
    //file_put();

    scanf("%d%d",&n,&k);
    rep(i,1,n) {
        scanf("%d",&x);
        a[x]++;
    }
    rep(i,1,n) b[i]=i;
    sort(b+1,b+n+1,cmp);
    rep(i,k+1,n) ans+=a[b[i]];
    printf("%d\n",ans);

    return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n;
    cin>> n;

    ll s[n], a[n], sum= 0;

    cin>> a[0];
    s[0]= a[0];
    for(int i=1; i<n; i++)
    {
        cin>> a[i];
        s[i]= (a[i] % MOD+ s[i-1]% MOD) % MOD;
    }

    for(int i= n-1; i>0; i--)
        sum += (((a[i] % MOD)* (s[i-1] % MOD) )% MOD);

    cout << sum % MOD << '\n';

    return 0;
}




Measured memory_bytes: 6740
# coding: utf-8
# Your code here!
from collections import defaultdict
n=int(input())
a=[0]*100
d=defaultdict(int)
def div(x):
    for i in range(2,int(x**0.5)+2):
        while x%i==0:
            x//=i
            d[i]+=1
    if x!=1:
        d[x]+=1

for i in range(2,n+1):
    div(i)

ans=0
s=set()
for i in d.keys():
    if d[i]>=74:
        ans+=1
        s.add(i**74)
    for j in d.keys():
        if j==i:
            continue
        if all([d[i]>=14,d[j]>=4]):
            ans+=1
            s.add(i**14*j**4)
        if all([d[i]>=24,d[j]>=2]):
            ans+=1
            s.add(i**24*j**2)
        for k in d.keys():
            if k==j or k==i:
                continue
            if all([d[i]>=2,d[j]>=4,d[k]>=4]):
                ans+=1
                s.add(i**2*j**4*k**4)
print(len(s))


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

using namespace std;
int main(){
	int x, y;
	cin >> x >> y;

	if(((4 * x) - y) % 2 == 0 && ((4 * x) - y) / 2 >= 0 && ((4 * x) - y) / 2 <= x)
			cout << "Yes";
		else
			cout << "No";

}


Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] p = new int[n];
            for (int i = 0; i < n; ++i) {
                p[in.nextInt() - 1] = i;
            }
            int max = 1;
            int first = 0;
            for (int i = 1; i < n; ++i) {
                if (p[i] > p[i - 1]) {
                    max = Math.max(max, i - first + 1);
                } else {
                    first = i;
                }
            }
            out.println(n - max);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 46944
#include <bits/stdc++.h>
using namespace std;
 
long long n,k,a[100010],f[100010],m=1;
main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=2;i<=n;i++) f[i]=1e10;
    for(int i=2;i<=n;i++)
	for(int j=i-1;j>=max(i-k,m); j--) f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
    cout<<f[n];
}

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

int main() {
	int n;
	scanf("%d", &n);

	long long bits[62][2];

	for(int i = 0; i < 62; i++) {
		bits[i][0] = bits[i][1] = 0;
	}

	for(int i = 0; i < n; i++) {
		long long v;
		scanf("%lld", &v);
		for(int j = 0; j < 62; j++) {
			if(v&1LL) bits[j][1]++;
			else bits[j][0]++;
			v >>= 1;
		}
	}

	long long resp = 0;
	long long mod = 1000000007;

	for(int i = 0; i < 62; i++) {
		long long qt = bits[i][0] * bits[i][1];
		resp += ((qt%mod)*((1LL << i)%mod))%mod;
	}

	printf("%lld\n",resp%mod );

	return 0;
}


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

#define LL long long


int main()
{
    int N, a, ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i ++){
        cin >> a;
        if (i % 2 == 1 && a % 2 == 1){
            ans ++;
        }
    }
    cout << ans;
    system("pause");
    return 0;
}

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

int main(){
	int n, d, ans;
	cin >> n >> d;
	d *= 2;
	d ++;
	if (n % d == 0)ans =n / d;
	else ans =n / d + 1;
	cout << (n % d ? n / d + 1: n / d) <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e5+5;
int n,k,a[N];
LL sum,ans,s[N];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		if(a[i]>0)
			s[i]=s[i-1]+a[i];
		else s[i]=s[i-1];
	} 
	for(int i=1;i<=k;++i) sum+=a[i];
	ans=max(sum+s[n]-s[k],s[n]-s[k]);
	for(int i=k+1;i<=n;++i){
		sum+=a[i]-a[i-k];
		ans=max(ans,max(sum+s[i-k]+s[n]-s[i],s[i-k]+s[n]-s[i]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    string n;
    cin >> n;
    for(int i=0;i<3;i++){
        if(n[i]=='1') n[i]='9';
        else if(n[i]=='9') n[i]='1';
    }
    cout << n << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long X = sc.nextLong();
        long[] a = new long[N];
        int child = 0;
        long sum = 0;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextLong();
            sum += a[i];
        }
        Arrays.sort(a);
        if(sum >= X){
            for(int i = 0; i < N; i++){
                if(X - a[i] >= 0){
                    X -= a[i];
                    child ++;
                    }
                }
            }else{
                child = N-1;
            }
            
        System.out.println(child);
    }
}


Measured memory_bytes: 21840
#include<stdio.h>
int main(void)
{
	int d;
	scanf("%d",&d);
	if(d==25){
		printf("Christmas\n");
	}
	if(d==24){
		printf("Christmas Eve\n");
	}
	if(d==23){
		printf("Christmas Eve Eve\n");
	}
	if(d==22){
		printf("Christmas Eve Eve Eve\n");
	}
	return 0;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int cnt_dig(int x)
{
	int cntx = 0;
	while(x)
	{
		x/=10;
		++cntx;
	}
	if(cntx%2)
		return 1;
	else
		return 0;
}
int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n,sum=0;
    cin>>n;
    for(int i=1; i<=n; ++i)
    {
    	sum+=cnt_dig(i);
    }
    cout<<sum<<"\n";

}

Measured memory_bytes: 2944
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define N 3050
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n;
ld p[N],dp[N][N];

int main(){

	fastio;
	cin >> n;
	FER(i,1,n+1) cin >> p[i];
	FER(i,0,N) FER(j,0,N) dp[i][j] = 0;

	dp[0][0] = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j <= i; ++j)
			dp[i][j] = p[i]*dp[i-1][j-1] + (1-p[i])*dp[i-1][j];
	
	ld ans = 0;
	for(int i = (n+1)/2; i <= n; ++i) ans += dp[n][i];
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 145664
#include <stdio.h>
int main()
{
  int x,y,i,sum=0;
  scanf("%d%d",&x,&y);
  int ar[y];
  for(int i=0;i<y;i++)
  {
    scanf("%d",&ar[i]);
    sum=sum+ar[i];
    }
    if(x<=sum)
    {
      printf("Yes\n");
    }
    else
    {
      printf("No\n");
    }
   return 0;
   }

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

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

    int A, B, C;

    cin >> A >> B >> C;

    if(A == B) {
        cout << C << endl;
    } else if(A == C) {
        cout << B << endl;
    } else {
        cout << A << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		
		if(a > x ) {
			System.out.println("NO");
		}else if(a + b < x) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}
	
}


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

int main(void){
    int N,A,i,j;
    cin >> N >> A;
    for(i = 0; i <= 10000; i++){
        for(j = 0; j <= A; j++){
            if(N == 500 * i + j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
dinner=[]
for i in range(N):
    a,b=[int(j) for j in input().split(" ")]
    dinner.append([a,b])

dinner=sorted(dinner,key=lambda x:x[1]+x[0])
takahashi=0
aoki=0

while True:
    d=dinner.pop(-1)
    takahashi+=d[0]
    if len(dinner)==0:
        break
    d=dinner.pop(-1)
    aoki+=d[1]
    if len(dinner)==0:
        break

print(takahashi-aoki)


Measured memory_bytes: 25328
#coding: utf-8 
n=gets().chomp().to_i 
a=gets().chomp().split(" ") 
i=1 
ans=0 
while(i<=n) 
    if(i == a[a[i-1].to_i-1].to_i) 
        ans+=1 
    end 
    i+=1 
end 
puts(ans/2)


Measured memory_bytes: 7940
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	string S, P;
	cin >> S >> P;
	S += S;
	for (int i = 0; i < S.size() / 2; i++) {
		if (S.substr(i, P.size()) == P) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3204