akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define pb push_back
#define x first
#define y second
#define pii pair<int,int>

const int mod = 1e9+7;

int main()
{
	int A,B;
	cin>>A>>B;
    int lo=0,hi=2000,mid,ans=-1;
  	while(lo<=hi)
    {
      mid=(lo+hi)/2;
      if(mid*8/100 ==A && mid/10==B)
      {
        	ans=mid;
        	hi=mid-1;
      }
      else if(mid*8/100 > A || mid/10 >B)
        hi=mid-1;
      else
        lo=mid+1;
    }
  	cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
  int main(void){
      int W,H,x,y,r;
      scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
      if((x-r)>=0&&(y-r)>=0&&(x+r)<=W&&(y+r)<=H)
        printf("Yes\n");
      else
        printf("No\n");
      return 0;
  }


Measured memory_bytes: 2148
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int solve_testcase() {
    int N; cin >> N;
    if(N == 0) return 1;

    vector< vector< tuple<int, int, int> > > info(31 * 12);
    for(int i=0; i<N; i++) {
        int day = 0, time = 0, inout = 0, id = -1;
        {
            int m, d; scanf("%d/%d", &m, &d); m--, d--;
            day = 31 * m + d;
        }
        {
            int h, m; scanf("%d:%d", &h, &m);
            time = h * 60 + m;
        }
        {
            char c; scanf(" %c", &c);
            inout = (c == 'I' ? 1 : 0);
        }
        {
            scanf(" %d", &id);
        }
        info[day].emplace_back(time, inout, id);
    }

    // id, 時間
    map<int, int> rec;
    const int MAX_TIME = 3600;
    for(int d=0; d<31 * 12; d++) {
        vector<bool> god(MAX_TIME);

        // 誰がいまいるかの集合
        set<int> S;
        
        int ptr = 0;
        for(int t=0; t<MAX_TIME; t++) {
            while(ptr < info[d].size() and get<0>(info[d][ptr]) == t) {
                int inout, id; tie(std::ignore, inout, id) = info[d][ptr];
                if(inout == 1) S.emplace(id);
                if(inout == 0) S.erase(id);
                ptr++;
            }

            god[t] = S.count(0);
            for(auto p : S) {
                if(p == 0) continue;
                if(god[t]) rec[p]++;
            }
        }
    }

    int ans = 0;
    for(auto e : rec) ans = max(ans, e.second);
    printf("%d\n", ans);
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 3260
NM = list(map(int, input().split()))
N = NM[0]
M = NM[1]
A = list(map(int, input().split()))
if N < M:
	print(-1)
sum = 0
for i in A:
	sum += i
if N - sum < 0:
	print(-1)
else:
	print(N - sum)


Measured memory_bytes: 9996
#include<cstdio>
#include<algorithm>
#define int long long
int n,A,B,p[300005];
signed main(){
	scanf("%lld%lld%lld",&n,&A,&B);
	if(n<A+B-1||n>A*B)return puts("-1"),0;
	int cnt=0,now=1;
	for(int i=n-A+1;i<=n;i++){
		p[++cnt]=i;
		int x=std::min(now+B-2,n-A);
		for(int j=1;now<=n-A&&j<B;j++,now++)
			p[++cnt]=x--;
	}
	for(int i=1;i<=n;i++)
		printf("%lld ",p[i]);
}

Measured memory_bytes: 5428
#include<stdio.h>

int main()
{
  int i, j, n, m, x=0, a[100];

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

  for(i=0; i<n; i++)
    {
      for(j=n-1; j>i; j--)
	{
	  if(a[j]< a[j-1])
	    {
	      m = a[j];
	      a[j] = a[j-1];
	      a[j-1] = m;
	      x++;
	    }
	}
    }

  for(i=0; i<n; i++)
    {
      printf("%d", a[i]);
      if(i+1<n) printf(" ");
    }
  printf("\n%d\n", x);
  
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,Z,W;
	cin >> N >> Z >> W;
	vl a(N);
	FOR(i,0,N)cin >> a[i];
	if(N == 1){
		cout << abs(a[0]-W) << endl;
	}
	else{
		cout << max(abs(a[N-1]-W),abs(a[N-1]-a[N-2])) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

void dfs(vector<int>& nodes, vector<int>& c, const vector<vector<int>>& g, const int& v) {
  nodes[v] = c.back(); c.pop_back();
  if (c.empty()) return;
  for (auto& next_v : g[v]) {
    if (nodes[next_v] != 0) continue;
    dfs(nodes, c, g, next_v);
  }
}

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

  int n; cin >> n;
  vector<int> nodes(n, 0);
  vector<pair<int, int>> edges;
  vector<vector<int>> g(n, vector<int>());
  rep(i, n-1) {
    int a, b; cin >> a >> b; a--; b--;
    edges.emplace_back(a, b);
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> c(n);
  rep(i, n) cin >> c[i];
  sort(ALL(c));

  int start = 0;
  int tmp = 0;
  for (int i = 0; i < n; i++) {
    if (g[i].size() > tmp) {
      start = i;
      tmp = g[i].size();
    }
  }

  dfs(nodes, c, g, start);

  ll ans = 0;
  for (auto& edge : edges) {
    ans += min(nodes[edge.first], nodes[edge.second]);
  }

  cout << ans << endl;
  rep(i, n) cout << nodes[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 1280
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    // 5 4, 5 3, 5 2, 5 1
    // 4 5, 4 3, 4 2
    // 3 5, 3 4, 3 1
    // 2 5, 2 4, 2 1
    // 1 5, 1 3, 1 2

    // 4 3, 4 2
    // 3 4, 3 1
    // 2 4, 2 1
    // 1 3, 1 2

    // 7 
    // 6 5, 6 4, 6 3, 6 2
    // 5 6, 5 4, 5 3, 5 1
    // 4 6, 4 5, 4 2, 4 1
    // 3 6, 3 5, 3 2, 3 1
    // 2 6, 2 4, 2 3, 2 1
    // 1 5, 1 4, 1 3, 1 2
    vector<pair<int, int>> ans;
    if(n & 1){
        for(int i = n - 1; i >= 1; i--){
            ans.emplace_back(n, i);
        }
        n--;
    }
    for(int i = n; i >= 1; i--){
        for(int j = i - 1; j >= 1; j--){
            if(i + j == (n | 1) || i == j){ continue; }
            ans.emplace_back(i, j);
        }
    }
    cout << ans.size() << '\n';
    for(auto& a : ans){
        cout << a.first << ' ' << a.second << '\n';
    }
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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 N,M,l,r,ans;

int main(){
    cin>>N>>M;
    int cnt[N+1];
    rep(i,N+1){
        cnt[i]=0;
    }
    rep(i,M){
        cin>>l>>r;
        l--;
        cnt[l]++;
        cnt[r]--;
    }
    rep(i,N){
        cnt[i+1]+=cnt[i];
        if(cnt[i]==M)ans++;
    }
    out(ans);
    
}


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

/* */

int main(){

    int n, m, sum;
    cin >> n >> m ;
    sum = n;
    // **************************************
    int a;
    for(int i=0; i<m; i++) {
        cin >> a;
        sum -= a;
    }
    // **************************************
    
    if(sum >= 0){
        cout << sum << endl;
    }else{
        cout << -1 << endl;
    }


    return 0;
}

Measured memory_bytes: 3640
n, k = map(int, input().split())
mod = 10**9+7
# 最大公約数がx(1 <= x <= k)な数列の数
num_gcd_k = [0]*(k+1)
num_gcd_k[k] = 1
ans = 0
for i in range(k,0,-1):
    # total = ((k // i)**n)%mod
    total = pow(k//i,n,mod)
    m = 2
    while i*m <= k:
        total -= num_gcd_k[i*m]
        m += 1
    num_gcd_k[i] = total
    ans += i*total
    ans %= mod

print(ans)

Measured memory_bytes: 11308
import java.util.Scanner;

public class Main {
    public static void main (String[] args)
    {
        int[] x = new int[10000];
        int i;
        String s;
        Scanner sc = new Scanner(System.in);

        for (i = 0; true; i++)
        {
            s = sc.nextLine();
            if (s.equals("0")) break;
            x[i] = Integer.parseInt(s);
        }
        sc.close();

        int I = i;

        for (i = 0; i < I; i++)
        {
            System.out.println("Case "+(i+1)+": "+x[i]);
        }
    }
}


Measured memory_bytes: 59632
/*
░░░░██████████████████
░░▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ManavJ07▒▀██████▄
░███▀▒▒▒▒BITS▒▒▒▒▒▒▀█████
░▐██▒▒▒.........▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define endl "\n"
#define MOD 998244353
#define nl cout<<"\n"
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i];nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int main()
{
    fastio();
    ll N;
    cin>>N;
    string s,t;
    cin>>s>>t;
    for(ll i=0;i<N;i++)
    {
        cout<<s[i]<<t[i];
    }
}


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

int main(){
  int n,k;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n-1;i++){
    cin >> k;
    a.at(k-1)++;
  }
  for(int i=0;i<n;i++){
    cout << a.at(i) << '\n';
  }
}

Measured memory_bytes: 4020
using System;
using System.Collections.Generic;

namespace AOJ
{
    class Program
    {
        private static int judge(int a, int b)
        {
            if (a == b) { return 0; }
            if (a > b && a - 1 == b) { return -1; }
            if (a < b && b - 1 == a) { return 1; }
            if (a > b) return 1;
            else return -1;
        }

        private static string solve(int l)
        {
            int[][] syusi;
            syusi = new int[12][];
            for (int i = 0; i < 12; i++)
            {
                string[] tmp = Console.ReadLine().Split(new char[]{' '});
                int[]  tmp2 = new int[2];
                tmp2[0] = int.Parse(tmp[0]);
                tmp2[1] = int.Parse(tmp[1]);
                syusi[i] = tmp2;
            }

            int sum = 0;
            for (int i = 0; i < 12; i++)
            {
                sum += syusi[i][0] - syusi[i][1];
                if (sum >= l)
                {
                    return (i + 1).ToString();
                }
            }
            return "NA";

        }
        
        static void Main(string[] args)
        {
            while (true) {
                int l = int.Parse(Console.ReadLine());
                if (l == 0) break;
                Console.WriteLine(solve(l));
            }
        }
    }
}

Measured memory_bytes: 5876
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    vi v;

        ll n, e, w, so;
    void solve() {
        string s;
        cin >> s;
        rep(i, sz(s)) {
            s[i] == 'N' ? n = 1 : 0;
            s[i] == 'E' ? e = 1 : 0;
            s[i] == 'W' ? w = 1 : 0;
            s[i] == 'S' ? so = 1 : 0;
        }
        //cout << n << " " << e << " " << w << " " << so << endl;
        if((n && !so) || (so & !n) || (e & !w) || (!e & w)) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
      #endif
     */
      //te
      solve();
      return 0;
    } 

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

int main() {
  	const vector<int> A = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  
	int X, Y;
	cin >> X >> Y;

  	if( A.at(X) == A.at(Y) ) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets
l = 0
r = n - 1
ans = 0
loop{
	l += 1 while l < n && s[l] != 'W'
	r -= 1 while r >= 0 && s[r] != 'R'
	break if r < l
	ans += 1
	s[l], s[r] = s[r], s[l]
}
puts ans


Measured memory_bytes: 14564
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], m = tmp[1];
        int l = 1, r = n;

        for (int i = 0; i < m; i++)
        {
            tmp = ReadIntArray();
            int li = tmp[0], ri = tmp[1];
            l = Math.Max(l, li);
            r = Math.Min(r, ri);
        }

        int ans = Math.Max(0, r - l + 1);
        WriteLine(ans);
    }
}


Measured memory_bytes: 17484
from fractions import gcd
N=int(input())
a=list(map(int,input().split()))
L=[0]*N
R=[0]*N
L[0]=a[0]
R[-1]=a[-1]
for i in range(1,N):
    L[i]=gcd(L[i-1],a[i])
    R[-i-1]=gcd(R[-i],a[-i-1])
ans=R[1]
for j in range(N-2):
    ans=max(ans,gcd(L[j],R[j+2]))
ans=max(ans,L[-2])
print(ans)

Measured memory_bytes: 16128
import core.stdc.stdio;
import std.algorithm;

void main(){
	int n;
	scanf("%d",&n);
	int[] a = new int[n];
	long sum;
	foreach(ref v;a){
		scanf("%d",&v);
		sum+=v;
	}
	bool Solve(long m){
		int g=114514;
		int c,e,f;
		long cs,es,fs=sum;
		while(c<g){
			bool ok = true;
			while(cs<m){
				cs+=a[e];
				es-=a[e];
				e=(e+1)%n;
				if(e==c)
					ok=false;
			}
			if(!ok)
				goto next;
			while(es<m){
				es+=a[f];
				fs-=a[f];
				f=(f+1)%n;
				if(f==c)
					ok=false;
			}
			if(!ok)
				goto next;
			if(fs>=m)
				return true;
			next:;
			g=min(g,e);
			fs+=a[c];
			cs-=a[c];
			c++;
		}
		return false;
	}
	long l=0;
	long r=sum/3+1;
	while(r-l>1){
		long m=(l+r)/2;
		if(Solve(m))
			l=m;
		else
			r=m;
	}
	printf("%lld\n",l);
}

Measured memory_bytes: 2488
import java.io.*;

class Main {
	public static void main(String args[]) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String t[];
			int w = Integer.parseInt(reader.readLine());
			int n = Integer.parseInt(reader.readLine());
			int a[] = new int[w];
			for(int i = 0;i < w;i++) {
				a[i] = i+1;
			}
			for(int i = 0;i < n;i++) {
				t = reader.readLine().split(",");
				swap(a, Integer.parseInt(t[0])-1, Integer.parseInt(t[1])-1);
			}
			for(int i = 0;i < w;i++) {
				System.out.println(a[i]);
			}
		}
		catch(IOException e) {
			System.out.println(e);
		}
	}
	public static void swap(int a[], int i, int j) {
		int tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}
}

Measured memory_bytes: 16924
L=int(input())
S=str(bin(L))[2:][::-1]
N=len(S)
A=[]
for i in range(N-1):
    A.append((i+1,i+2,0))
    A.append((i+1,i+2,2**i))
for i in range(N-1):
    if S[i]=="1":
        L-=2**i
        A.append((i+1,N,L))
print(N,len(A))
for p in A:
    print(p[0],p[1],p[2])


Measured memory_bytes: 3064
from numba import njit
from math import sqrt
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

@njit
def main(N):
    table = [1] * (N + 1)

    for n in range(2,N):
        for i in range(2*n, N+1, n):
            table[i] += 1
    
    ans = 0
    for i in range(1, N+1):
        ans += i * (table[i] + 1)
    
    print(ans - 1)


if __name__ == "__main__":
    N = int(readline())
    main(N)


Measured memory_bytes: 189044
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




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


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

using namespace std;

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

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); 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) sort(v.end(), v.begin());
#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 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; }

//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(){
	string s;
	cin >> s;
	cout << s[0] << sz(s)-2 << s[sz(s)-1] << endl;
    
	return  0;
}

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

int n;
long long int a[101];
long long int dp[1001][101];

long long int solve(long long int sum, int num) {
  if( sum < 0 || sum > 20 ) return 0;
  if( dp[sum][num] != 0 ) return dp[sum][num];
  if( num == n-1 ) {
    if( sum == a[n-1] ) return 1;
    else return 0;
  }
  long long int ret = solve(sum+a[num], num+1) + solve(sum-a[num], num+1);
  return dp[sum][num] = ret;
}

int main() {
  cin >> n;
  memset(dp, 0, sizeof(dp));
  for(int i=0; i<n; i++) {
    cin >> a[i];
  } 
  cout << solve(a[0], 1) << endl;
}

Measured memory_bytes: 1964
k,a,b=list(map(int,input().split()))
if b-1>a:
    c=a-1
    k-=c
    k-=2
    
    if k%2==0:
        g=(b-a)*(k//2)
        print(g+b)
        
    else:
        g=(b-a)*((k)//2)
        print(b+g+1)
    
    
else:
    print(1+k)

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


using namespace std;

int abs(int a,int b)
{
	int c=a-b;
	return c > 0 ? c : -c;
}

int main()
{
	std:ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k;
	cin>>n>>k;
	
	int height[n],dp[n];
	for(int i=0;i<n;i++)
		cin>>height[i];
	for(int i=0;i<n;i++)
		dp[i]=INT_MAX;
	
	dp[0]=0;
	dp[1]=abs(height[0]-height[1]);
	
	for(int i=2;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j >=0)
				dp[i]=min(dp[i],dp[i-j]+abs(height[i]-height[i-j]));
			else 
				break;
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
using namespace std;
int x[10500],y[10500];
int main()
{
	int w,h,n;
	cin >> w >> h >> n;
	for(int i=0;i<n;i++)
	{
		cin >> x[i] >> y[i];
	}
	int ans=0;
	for(int i=1;i<n;i++)
	{
		int dx=abs(x[i]-x[i-1]),dy=abs(y[i]-y[i-1]);
		if((x[i]>=x[i-1]&&y[i]>=y[i-1])||(x[i]<=x[i-1]&&y[i]<=y[i-1]))
		{
			ans+=max(dx,dy);
		}
		else
		{
			ans+=(dx+dy);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < s.size(); i++)
        if ((i % 2 == 0 && s[i] == '0') || (i % 2 == 1 && s[i] == '1'))
            count++;
    
    cout << min(int(s.size()-count), count) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b){
    return a < b ? a: b;
}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;

    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }

    return 0;
}



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

using namespace std;

#define gc getchar_unlocked
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout << fixed << setprecision(10);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll k;
    cin>>k;
    ll n=7%k;
    for(ll i=1;i<1e7;i++)
    {
        if(n == 0)
        {
            cout<<i<<endl;
            return 0;
        }
        n = (n*10+7)%k;
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3624
import sys
from collections import Counter
N = int(input())
X = list(input())
revX = reversed(X)
count01 = Counter(X)
if count01['1'] == 0:
    for i in range(N):
        print(1)
    sys.exit()
m1 = count01['1']-1
p1 = count01['1']+1
powrem = []
m1rem = 0
p1rem = 0
basem1 = 1
basep1 = 1
if m1 == 0:
    for i, xi in enumerate(revX):
    # print(basep1)
        if xi == '0':
            powrem += [basep1 % p1]
        else:
            powrem += [0]
            p1rem = (p1rem + basep1) % p1
        basep1 = (basep1 * 2) % p1
    revpowrem = reversed(powrem)
    # print(list(revpowrem))
    for xi, rem in zip(X, revpowrem):
        c = 1
        if xi == '0':
            r = (p1rem+rem)%p1
        else:
            print(0)
            continue
        # print(r, xi, rem)
        while r != 0:
            p = bin(r).count('1')
            r = r % p
            c += 1
        print(c)
    sys.exit()

for i, xi in enumerate(revX):
    # print(basep1)
    if xi == '0':
        powrem += [basep1 % p1]
    else:
        powrem += [basem1 % m1]
        m1rem = (m1rem + basem1) % m1
        p1rem = (p1rem + basep1) % p1
    basem1 = (basem1 * 2) % m1
    basep1 = (basep1 * 2) % p1
revpowrem = reversed(powrem)
# print(list(revpowrem))
for xi, rem in zip(X, revpowrem):
    c = 1
    if xi == '0':
        r = (p1rem+rem)%p1
    else:
        r = (m1rem-rem)%m1
    # print(r, xi, rem)
    while r != 0:
        p = bin(r).count('1')
        r = r % p
        c += 1
    print(c)

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

using ll= long long;
#define double long double
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _set(x) __builtin_popcount(x)
#define _setl(x) __builtin_popcountll(x)
#define PI  3.14159265358979323846264338327950L
#define mod 1000000007LL

void debug(){
	cerr<<"]\n";
}
template<class H,class ... T> void debug(H h,T... t){
	cerr<<h;
	if(sizeof... (t)){
		cerr<<", ";
	}
	debug(t...);
}
#ifdef DEBUG
	#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
	#define dpv(...) cerr<< "["#__VA_ARGS__ " : ";for(int i: (__VA_ARGS__)){cerr<<i<<" ";}cerr<<"]\n"
#else
	#define dbg(...) 0
	#define dpv(...) 0
#endif

int n,m;
const int maxN = 1e5+2;
vector<vector<int>> g;
vector<int> vis(maxN);
set<int> s;
void dfs(int node, int from){
	vis[node]=1;
	if(from==-1){
		s.insert(node);
	}
	for(auto el: g[node]){
		if(!vis[el]){
			dfs(el, node);
		}
	}
}
void solve(){
	cin>>n>>m;
	g = vector<vector<int>> (n);
	for(int i=0;i<m;i++){
		int a, b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(int i=0;i<n ;i++){
		if(!vis[i] ){
			dfs(i, -1);
		}
	}
	cout<<(int)s.size()-1<<"\n";
}


int32_t main(){
	IOS
	// freopen("input.txt","r",stdin);
	int _;
	// cin>>_;
	_=1;
	for(int i=1;i<=_;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct mize of array
*/


Measured memory_bytes: 10828
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,h[25],count = 1;
    cin >> n;
    for(int i = 0;i < n;i++){cin >> h[i];}
    for(int i = 1;i < n;i++)
    {
        bool judge = true;
        for(int j = i - 1;0 <= j;j--)
        {
            if(h[i] < h[j]){judge = false; break;}
        }
        if(judge){count++;}
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int N,M,Q;
vector<int> A(55),B(55),C(55),D(55);

int dfs(vector<int> array){
  if(array.size()==N){
    int tmp=0;
    // debug(array)
    REP(q,0,Q){
      if(array[B[q]]-array[A[q]]==C[q]){
        tmp+=D[q];
      }
    }
    return tmp;
  }
  int ans=-1;
  REP(i,array[array.size()-1],M){
    vector<int> array1=array;
    array1.push_back(i);
    ans=max(ans,dfs(array1));
  }
  return ans;

}


signed main(){
  cin>>N>>M>>Q;
  REP(i,0,Q){
    cin>>A[i]>>B[i]>>C[i]>>D[i];
    A[i]--;B[i]--;
  }
  int ans=-1;
  REP(m,0,M){
    vector<int> arg={m};
    ans=max(ans,dfs(arg));
  }
  print(ans);
}


Measured memory_bytes: 3628
using System;
using System.IO;
using System.Collections.Generic;

namespace ARC090
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var A = ss.Next(Int);
            var B = ss.Next(Int);
            var C = ss.Next(Int);
            var X = ss.Next(Int);

            var res = 0;

            for (var i = 0; i <= A; i++)
            {
                for (var j = 0; j <= B; j++)
                {
                    for (var k = 0; k <= C; k++)
                    {
                        if (X == 500 * i + 100 * j + 50 * k)
                        {
                            res++;
                        }
                    }
                }
            }

            sw.WriteLine(res);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;

lli read_term(int &p, string &s);
lli read_expr(int &p, string &s);

lli read_term(int &p, string &s){
    if(s[p] == 'S'){
        p += 2;
        lli ret = read_expr(p, s);
        p++;
        return ret*ret %mod;
    }
    lli res = 0;
    while(p<(int)s.length() and '0'<=s[p] and s[p]<='9'){
        res *= 10;
        res += s[p]-'0';
        res %= mod;
        p++;
    }
    return res;
}

lli read_expr(int &p, string &s){
    lli res = read_term(p, s);
    while(p<(int)s.length() and s[p]!='>'){
        assert(s[p] == '#');
        p++;
        lli ret = read_term(p, s);
        res >>= min(ret, 32LL);
    }
    return res;
}

lli parse(string s){
    string tmp = "";
    for(char c: s){
        if(c != ' '){
            tmp += c;
        }
    }
    s = "";
    bool is_followed_by_num = false;
    for(int i=tmp.length()-1; i>=0; i--){
        if(tmp[i] == '>' and is_followed_by_num){
            s += '#';
            i--;
            is_followed_by_num = false;
        }else{
            s += tmp[i];
            if(('0'<=tmp[i] and tmp[i]<='9') or tmp[i]=='S'){
                is_followed_by_num = true;
            }
        }
    }
    reverse(s.begin(), s.end());
    //cerr << s << endl;
    int p = 0;
    return read_expr(p, s);
}

int main(){
    while(1){
        string s;
        getline(cin, s);
        if(s == "#") break;
        cout << parse(s) << endl;
    }
    return 0;
}


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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int main(){
    int x = read();
    if (x == 0)
        puts("1");
    else
        puts("0");
    return 0;
}

Measured memory_bytes: 3632
num = list(map(int,list(str(input()))))
num_len = len(num)

temp = 0
ans = 0

for i in range(2**(num_len-1)):
  sum = 0
  for j in range(0,num_len):
    temp = temp*10 + num[j]
    
    if j == num_len-1:
      sum = sum + temp
      temp=0
      break
    
    if((i >> j) & 1):
      sum = sum + temp
      temp=0
      
  ans = ans + sum
  
print(ans)

Measured memory_bytes: 3064
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, K, count = 0, ans = 0 ;
  cin >> N >> K ;
  int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  for(int i=K;i<N;i++){
    if(A[i] > A[i-K]){
      cout << "Yes" << endl ;
    }
    else{
      cout << "No" << endl ;
    }
  }
  return 0 ;
}  

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

using namespace std;
int n;
vector<int> x(101);
int main(){
  cin >> n;
  int sum=0;
  for(int i=0; i<n ;i++){
    cin >> x[i];
    sum += x[i];
  }
  sum = sum/n;
  int a = sum;
  int b = sum+1;
  sum=0;
  int sum1=0;
  for(int i=0; i<n;i++){
    sum += (a-x[i])*(a-x[i]);
    sum1 += (b-x[i])*(b-x[i]);
  }
  cout << min(sum, sum1);
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		if(s.equals("AAA") || s.equals("BBB")){
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		in.close();
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int huru(int n, int k){
    ll i = 1LL;
    int cnt = 0;
    double kijun = (double)k/n;
    while(i < kijun){
        i *= 2;
        ++cnt;
    }
    return cnt;
}

int main(){

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

    int n, k;
    cin >> n >> k;


    double ans = 0.0;
    for(int i = 1; i <= n; ++i){
        int h = huru(i, k);
        double p = 1.0/pow(2.0, h);
        ans += p;
    }

    ans /= (double)n;

    cout << setprecision(15) << ans << endl;


    return 0;
}


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

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

    int n;
    string s;
    size_t size;

    cin >> n;
    cin >> s;

    vector<char> alphabet = {
        'A',
        'B',
        'C',
        'D',
        'E',
        'F',
        'G',
        'H',
        'I',
        'J',
        'K',
        'L',
        'M',
        'N',
        'O',
        'P',
        'Q',
        'R',
        'S',
        'T',
        'U',
        'V',
        'W',
        'X',
        'Y',
        'Z'
    };

    int i;

    rep (i, s.size()) {
        char letter;
        letter = s[i];
        auto index = find(alphabet.begin(), alphabet.end(), letter);
        if ((index - alphabet.begin() + n) <= 25) {
             s[i] = alphabet[index - alphabet.begin() + n];
        }
        else {
            s[i] = alphabet[index - alphabet.begin() + n - 26];
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005
 
 
int main()
{
	int t;
	cin >> t;
	string ch;
	cin >> ch;
	string bh = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	for(int i = 0; i < ch.size(); i++)
	{
		int ans = (ch[i] + t ) % 65;
		
		cout <<bh[ans%26] ;
	}
	cout << endl;
	
	
	
	return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();

  // 構築できない場合
  if (s[0] == '0' || s[n-1] == '1') {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n/2; ++i) {
    if (s[i] != s[n-i-2]) {
      cout << -1 << endl;
      return 0;
    }
  }
  int half = n/2;
  cout << "1 2" << endl;
  int from = 2;
  for (int to = 1; to < half; ++to) {
    cout << from << " " << to+2 << endl;
    if (s[to] == '1') {
      from = to+2;
    }
  }
  for (int to = half+1; to < n; ++to) {
    cout << from << " " << to+1 << endl;
  }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W; cin>>N>>W;
    int w[110];
    long long v[110];
    for(int i=1; i<=N; i++) cin>>w[i]>>v[i];
    vector<vector<long long>>cost(110,vector<long long>(W+1,0));

    for(int i=1; i<=N; i++){
        for(int j=0; j<=W; j++){
            if (j-w[i]>=0) cost[i][j]=max(cost[i-1][j],cost[i-1][j-w[i]]+v[i]);
            cost[i][j]=max(cost[i][j],cost[i-1][j]);
        }
    }
    long long ans=0;
    for(int j=0; j<=W; j++) ans=max(ans,cost[N][j]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 90268
s = int(input())

#フラグ
yymm = 0
mmyy = 0

if int(s / 100) <= 12 and int(s / 100) >= 1:
    mmyy = mmyy + 1

if s % 100 <= 12 and s % 100 >= 1:
    yymm = yymm + 1

if yymm == 1 and mmyy == 1:
    print('AMBIGUOUS')
elif yymm == 1:
    print('YYMM')
elif mmyy == 1:
    print('MMYY')
else:
    print('NA')


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

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


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

using namespace std;

int main(){
  int H,W;  cin >> H >> W;

  string a[100];
  for(int i = 0;i < H;i++){
    cin >> a[i];
  }

  string emp = "";

  for(int i = 0;i < W+2;i++){
    emp += "#";
  }

  cout << emp << endl;
  for(int i = 0;i < H;i++){
    cout << "#" << a[i] << "#" << endl;
  }
  cout << emp << endl;
}

Measured memory_bytes: 256
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local z = {}
for i = 1, n do
  local v = t[i]
  if not z[v] then z[v] = 1
  else z[v] = z[v] + 1
  end
end
local tot = 0
for k, val in pairs(z) do
  tot = tot + (val * (val - 1)) // 2
end

for i = 1, n do
  local ret = tot
  local v = t[i]
  ret = ret - (z[v] * (z[v] - 1)) // 2
  ret = ret + ((z[v] - 1) * (z[v] - 2)) // 2
  print(ret)
end


Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    int a = s[0]-'0', b = s[1]-'0', c = s[2]-'0', d = s[3]-'0';
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                int ans = a;
                if (i == 0) ans += b; else ans -= b;
                if (j == 0) ans += c; else ans -= c;
                if (k == 0) ans += d; else ans -= d;
                if (ans == 7) {
                    cout << a << (i == 0 ? "+" : "-")
                         << b << (j == 0 ? "+" : "-")
                         << c << (k == 0 ? "+" : "-")
                         << d << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m,a,b,i;
   cin>>n>>m;
   a=min(n,m);
   b=max(n,m);
   for(i=1;i<=b;i++)
   {
       cout<<a;
   }
   cout<<endl;
}


Measured memory_bytes: 3536