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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = 100;

int n;

inline void input()
{
	n = read<int>();
}

inline void solve()
{
	static vector<pii> E;

	if(n & 1)
	{
		for(int i = 1; i < n; ++i) E.emplace_back(n, i);
		--n;
	}

	for(int i = 1; i <= n / 2; ++i)
		for(int j = i + 1; j <= n / 2; ++j)
		{
			E.emplace_back(i, j);
			E.emplace_back(i, n + 1 - j);
			E.emplace_back(n + 1 - i, j);
			E.emplace_back(n + 1 - i, n + 1 - j);
		}

	printf("%d\n", SZ(E));
	for(auto i : E) printf("%d %d\n", i.fst, i.snd);
}

int main()
{
#ifndef ONLINE_JUDGE
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

int main(){
    int x, a;
    cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define p second
using namespace std;
typedef pair<int,int> point;

const int maxn = 100009;
vector<point> U, R, D, L;
int r, c, n, X1, X2, Y1, Y2;
int s[maxn], top;

void calc(int x){
	if (top && s[top] == x) top--;
	else s[++top] = x;
}

int main(){
	scanf("%d%d%d", &r, &c, &n);
	for (int i=1; i<=n; i++){
		scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
		if (X1 != 0 && X1 != r && Y1 != 0 && Y1 != c) continue;
		if (X2 != 0 && X2 != r && Y2 != 0 && Y2 != c) continue;
		if (X1 == 0) U.push_back(make_pair(Y1, i));
		else if (Y1 == c) R.push_back(make_pair(X1, i));
		else if (X1 == r) D.push_back(make_pair(Y1, i));
		else L.push_back(make_pair(X1, i));
		if (X2 == 0) U.push_back(make_pair(Y2, i));
		else if (Y2 == c) R.push_back(make_pair(X2, i));
		else if (X2 == r) D.push_back(make_pair(Y2, i));
		else L.push_back(make_pair(X2, i));
	}
	sort(U.begin(), U.end()); sort(R.begin(), R.end());
	sort(D.begin(), D.end()); sort(L.begin(), L.end());
	for (int i=0; i<U.size(); i++) calc(U[i].p);
	for (int i=0; i<R.size(); i++) calc(R[i].p);
	for (int i=D.size()-1; i>=0; i--) calc(D[i].p);
	for (int i=L.size()-1; i>=0; i--) calc(L[i].p);
	puts(top == 0 ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 2584
import sys

k = 0

while k == 0:
    r = raw_input()
    H, W = r.split()
    H = int(H)
    W = int(W)
    
    if H == 0 and W == 0:
        k = 1
    else:
        for i in range(H):
            for j in range(W):
                if (i+j)%2 == 0:
                    sys.stdout.write("#")
                else:
                    sys.stdout.write(".")
            print ("")
        print("")

Measured memory_bytes: 6448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N; cin >> N;
    N+=1;
    vector <ll> X(N);
    vector <ll> rpfxsum(N);
    loop(i,0,N) cin >> X[i];
    rpfxsum[N-1]=X[N-1];
    for (int i=N-2; i>=0; --i) rpfxsum[i]=rpfxsum[i+1]+X[i];
    if (N==1)
    {
        if (X[0]==1) {
            cout << 1 << "\n";
            return 0;
        }
        else {
            cout << -1 << "\n";
            return 0;
        }
    }
    if (X[0]) {
        cout << -1 << "\n";
        return 0;
    }
    ll available=1;
    ll sum=0;
    for (int i=1; i<N; ++i)
    {
        sum+=available;
        ll total=available*2;
        total=min(total, rpfxsum[i]);
        if (X[i]>total) {
            cout << -1 << "\n";
            return 0;
        }
        available=total-X[i];
        // cout << available << "\n";
    }
    // cout << sum << "\n";
    cout << accumulate(X.begin(),  X.end(), sum) << "\n";
    return 0;
}

Measured memory_bytes: 4780
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

tuple<int, int, int> toCol(string s) {
  int x;
  stringstream ss;
  ss << hex << s;
  ss >> x;
  return mt(x / 65536, x / 256 % 256, x % 256);
}

void solve() {
  vector<pair<string, string>> t = {
    {"black", "000000"},
    {"blue", "0000ff"},
    {"lime", "00ff00"},
    {"aqua", "00ffff"},
    {"red", "ff0000"},
    {"fuchsia", "ff00ff"},
    {"yellow", "ffff00"},
    {"white", "ffffff"},
  };
  char gomi;
  string s;
  while (cin >> gomi >> s) {
    int r, g, b;
    tie(r, g, b) = toCol(s);
    vector<pair<int, string>> v;
    for (auto &p : t) {
      int _r, _g, _b;
      tie(_r, _g, _b) = toCol(p.se);
      int d = (r - _r) * (r - _r) + (g - _g) * (g - _g) + (b - _b) * (b - _b);
      v.emplace_back(d, p.fi);
    }
    cout << (*min_element(all(v))).se << endl;
  }
}

Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int main() {
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    //cout << n << " " << q << endl;
    using P = pair<int, ll>;
    set<P> s;
    s.insert(P(-1, TEN(15)));
    s.insert(P(n-1, 0));

    for (int i = 0; i < q; i++) {
        int a; ll b;
        cin >> a >> b; a--;
        while (b) {
            auto it = s.lower_bound(P(a, -1));
            auto pr = *it; it--;
            auto pl = *it;
            int d = a-pl.first;
            if (a == pr.first) s.erase(pr);
            if (pl.second-pr.second <= b/d) {
                s.erase(pl);
                s.insert(P(a, pl.second));
                b -= d*(pl.second-pr.second);
            } else {                
                s.insert(P(a, pr.second + b/d));
                if (b%d) {
                    s.insert(P(pl.first + b%d, pr.second + b/d + 1));
                }
                if (pr.second + (b+d-1)/d == pl.second) {
                    s.erase(pl);
                }
                b = 0;
            }
        }
    }

    ll res[n];
    int b = -1;
    for (auto p: s) {
        for (int i = b+1; i <= p.first; i++) {
            res[i] = p.second;
        }
        b = p.first;
    }

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



Measured memory_bytes: 8576
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<double,P> PP;
struct edge { int to; int cost; };
int a[100006];
int b[100006], c[100006];
signed main() {
	int n, m; cin >> n >> m;
	rep(i, n)cin >> a[i]; rep(i, m)cin >> b[i] >> c[i];
	priority_queue<int,vector<int>,greater<int>>Q;
	vector<P>V;
	rep(i, n) {
		Q.push(a[i]);
	}
	int sum = 0;
	rep(i, m)V.push_back(P(c[i], b[i]));
	sort(V.begin(), V.end());
	reverse(V.begin(), V.end());
	rep(i, V.size()) {
		while (V[i].second) {
			V[i].second--;
			if (!Q.size())goto X;
			int a = Q.top();
			if (a >= V[i].first)goto X;
			Q.pop();
			sum += V[i].first;
		}
	}
X:;
	while (Q.size()) {
		sum += Q.top();
		Q.pop();
	}
	cout << sum << endl;
}

Measured memory_bytes: 5492
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    cin >>n>>k;
    int a[n+1];
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    
    int t[n+1];
    int c[n+1];
    
    for(int i=0;i<n;++i){
        t[i]=0;
        c[i]=0;
        for(int j=i;j<n;++j){
            if(a[i]>a[j]){t[i]++;}
        }
         for(int j=0;j<n;++j){
        if(a[i]>a[j]){c[i]++;}
         }
    }
    long long tmp1=0;
    long long tmp2=0;
    for(int i=0;i<n;++i){
        tmp1+=c[i];
        tmp2+=t[i];
    }
    long long ans=0;
    long long tmp=0;
    ans=k*(((k-1)*tmp1)%(2*1000000007))+2*k*tmp2%(2*1000000007);
    ans=ans%(2*1000000007);
    ans=ans/2;
   cout<<ans<<endl;
    
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class Main {
  public static void main(String[] args){
        
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    
    ArrayList<Long> arr = new ArrayList<>();
    
    for (long i = 1; i <= 9; i++) {
      arr.add(i);
      keisan(i,arr);
    }
    Collections.sort(arr);
    System.out.println(arr.get(K-1));
    sc.close();
  }
  public static void keisan(long K,ArrayList<Long> arr){
    long max = 100000000000L;
    if (K<max) {
      
    
      if(K%10>=1){
        long minus = K*10+(K%10)-1;
        arr.add(minus);
        keisan(minus,arr);

      }
        long same = K*10+K%10;
        arr.add(same);
        keisan(same,arr);

      if(K%10<9){
        long plus = K*10+K%10+1;
        arr.add(plus);
        keisan(plus,arr);
        
      }
    }
  }	

}

Measured memory_bytes: 118420
#include<bits/stdc++.h>
#define ll long long 
#define vt vector<int>

using namespace std;

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

  int s,d,t;
  cin>>d>>t>>s;
  float ct = (float)d/s;
  if(ct<=(float)t) cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 3648
l=list(map(int,input().split()))
l.sort()
a=l[0]
b=l[1]
c=l[2]
if (b-a)%2==0:
    print(c-b+(b-a)//2)
else:
    if c%2==0:
        if b%2==0:
            print((c+1-a)//2+(c-b)//2+1)
        else:
            print((c+1-b)//2+(c-a)//2+1)
    else:
        if b%2==0:
            print((c-a)//2+(c+1-b)//2+1)
        else:
            print((c-b)//2+(c+1-a)//2+1)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    ll r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; ++i) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

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

int main(){
    double pai=3.141592653589;
    char s[100], p[100];
    string scp,s2,chk;
    scanf("%s %s",&s,&p);
    scp=s;
    chk=p;
    s2=scp+scp;
    if(s2.find(p) != string::npos){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3272
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine().trim();
		String[] arr = line.split(" ");
		final int n = Integer.parseInt(arr[0]);
		final int m = Integer.parseInt(arr[1]);

		final int[] c = new int[m];
		line = br.readLine().trim();
		arr = line.split(" ");
		for (int i = 0; i < m; i++) {
			c[i] = Integer.parseInt(arr[i]);
		}
		br.close();

		final int[] dp = new int[n + 1];
		Arrays.fill(dp, 50000);
		dp[0] = 0;

		for (int i = 0; i < m; i++) {
			for (int j = c[i]; j <= n; j++) {
				dp[j] = Math.min(dp[j], dp[j - c[i]] + 1);
			}
		}

		System.out.println(dp[n]);
	}
}

Measured memory_bytes: 25428
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;

struct Que{
	int a;
	int b;
	int c;
	Que(){a=b=c=0;}
	Que(int a, int b, int c){
		this->a=a;
		this->b=b;
		this->c=c;
	}
};

vector<Que> arr;
vi dp[4];

int solve(int pos, int n, int prev){
	if(pos==n){
		return 0;
	}
	if(dp[prev][pos]!=-1){
		return dp[prev][pos];
	}

	if(prev==0){
		int aaa=solve(pos+1,n,1)+arr[pos].a;
		int bbb=solve(pos+1,n,2)+arr[pos].b;
		int ccc=solve(pos+1,n,3)+arr[pos].c;
		return dp[0][pos]=max(aaa,max(bbb,ccc));
	}else if(prev==1){
		int bbb=solve(pos+1,n,2)+arr[pos].b;
		int ccc=solve(pos+1,n,3)+arr[pos].c;
		return dp[1][pos]=max(bbb,ccc);
	}else if(prev==2){
		int aaa=solve(pos+1,n,1)+arr[pos].a;
		int ccc=solve(pos+1,n,3)+arr[pos].c;
		return dp[2][pos]=max(aaa,ccc);
	}else if(prev==3){
		int aaa=solve(pos+1,n,1)+arr[pos].a;
		int bbb=solve(pos+1,n,2)+arr[pos].b;
		return dp[3][pos]=max(aaa,bbb);
	}
}

int main(){
	int n;
	cin>>n;
	arr.resize(n,Que());
	for(int i=0;i<4;i++)dp[i].resize(n,-1);
	for(int i=0;i<n;i++){
		int a,b,c;
		cin>>a>>b>>c;
		Que no(a,b,c);
		arr[i]=no;

	}
	solve(0,n,0);
	cout<<dp[0][0];
	

	return 0;
}

Measured memory_bytes: 9216
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	ll a, b, n;
	cin >> a >> b >> n;
	ll x;
	if(n >= b-1) x = b-1;
	else x = n;
	cout << (ll)(floor((double)a*x / b) - a* floor((double)x/b)) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

struct SegmentTree
{
    int size;
    vector<int> currentChar;
    vector<vector<int> > nodes;

    SegmentTree(int n)
    {
        currentChar.resize(n, 0);

        size = 1;
        while(size < n) size <<= 1;
        nodes.resize(2 * size - 1, vector<int>(26, 0));
    }

    // x: 0-indexed
    void update(int x, char c)
    {
        int k = x + (size - 1);

        nodes[k][currentChar[x]] = max(nodes[k][currentChar[x]] - 1, 0);
        currentChar[x] = c - 'a';
        ++nodes[k][currentChar[x]];

        while(k > 0)
        {
            k = (k - 1) / 2;

            vector<int>& l = nodes[2 * k + 1];
            vector<int>& r = nodes[2 * k + 2];
            vector<int> newNode(26);

            for(int i = 0; i < 26; ++i)
            {
                newNode[i] = l[i] + r[i];
            }

            nodes[k] = newNode;
        }
    }

    // [a, b)
    int query(int a, int b)
    {
        int res = 0;
        vector<int> result = subquery(a, b);

        for(auto val : result)
        {
            res += val ? 1 : 0;
        }

        return res;
    }

    vector<int> subquery(int a, int b, int k = 0, int l = 0, int r = -1)
    {
        if(r == -1)
        {
            r = size;
        }

        if(r <= a || b <= l)
        {
            return vector<int>(26, 0);
        }
        
        if(a <= l && r <= b)
        {
            return nodes[k];
        }

        vector<int> lRes = subquery(a, b, 2 * k + 1, l, (l + r) / 2);
        vector<int> rRes = subquery(a, b, 2 * k + 2, (l + r) / 2, r);
        vector<int> newNode(26);

        for(int i = 0; i < 26; ++i)
        {
            newNode[i] = lRes[i] + rRes[i];
        }

        return newNode;
    }
};

signed main() {
    int n, q;
    string s;

    /*
    SegmentTree st(10);

    st.update(0, 'a');
    st.update(1, 'a');
    st.update(2, 'b');
    st.update(9, 'd');
    st.update(1, 'd');

    cout << st.query(0, 10) << endl;
    */

    cin >> n >> s >> q;

    SegmentTree st(n);

    for(int i = 0; i < s.size(); ++i)
    {
        st.update(i, s[i]);
    }

    for(int i = 0; i < q; ++i)
    {
        int queryType;

        cin >> queryType;

        if(queryType == 1)
        {
            int iq;
            char cq;

            cin >> iq >> cq;

            st.update(iq - 1, cq);
        }
        else if(queryType == 2)
        {
            int lq, rq;

            cin >> lq >> rq;

            cout << st.query(lq - 1, rq) << endl;
        }
    }
}

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

int main() {
  int N;
  string str;
  cin >> N >> str;
  int i=0;
  int j=N-1;
  int count=0;
  while(i<j){
    while(str.at(i)=='R' && i < N-1){
      i++;
    }
    while(str.at(j)=='W' && j > 0){
      j--;
    }
    if(i<j){
      count++;
      i++;
      j--;
    }
  }
  cout << count << endl;
}


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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<int> dp(K + 1);
	for (int i = 1; i <= K; i++) {
		vector<int> vs;
		for (int j = 0; j < N; j++) if (a[j] <= i) {
			vs.push_back(dp[i - a[j]]);
		}
		sort(vs.begin(), vs.end());
		vs.erase(unique(vs.begin(), vs.end()), vs.end());
		while (dp[i] < (int)vs.size() && vs[dp[i]] == dp[i]) ++dp[i];
	}
	cout << (dp[K] ? "First" : "Second") << endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        if(s.length() <= k) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0, k) + "...");
        }
    }
}

Measured memory_bytes: 38552
s=input();S=list(s)
t=input();T=list(t)
l=[chr(ord('a')+j) for j in range(26)]
u=[]
c=0
for i in range(len(s)):
  v=[s[i],t[i]]
  if v not in u:
    u.append(v)
u.sort()
for k in range(len(u)):
  for m in range(len(u)):
    if u[k][0]==u[m][0]:
      if u[k][1]!=u[m][1]:c+=1
for p in range(len(u)):
  for q in range(len(u)):
    if u[p][1]==u[q][1]:
      if u[p][0]!=u[q][0]:c+=1
if c==0:print('Yes')
else:print('No')

Measured memory_bytes: 6704
N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))

DOUB=[[-1]*(N+1) for i in range(62)]

DOUB[0]=[A[i] for i in range(N+1)]

for i in range(61):
    for j in range(N+1):
        DOUB[i+1][j]=DOUB[i][DOUB[i][j]]

NOW=1
while K:
    x=K.bit_length()-1
    NOW=DOUB[x][NOW]
    K-=1<<x
print(NOW)


Measured memory_bytes: 199220
import math
import sys

import numpy as np
from scipy.optimize import minimize


scan = sys.stdin.readline


def main():
    l = int(scan().rstrip())

    v = lambda x: (x[0] ** 2) * x[1] + (x[1] ** 2) * x[0] - l * x[0] * x[1]
    cons = (
        {"type": "ineq", "fun": lambda x: x[0]},
        {"type": "ineq", "fun": lambda x: x[1]},
        {"type": "ineq", "fun": lambda x: l - x[0] - x[1]}
    )

    result = minimize(v, x0=np.array([l/3, l/3]), constraints=cons, method="SLSQP")
    print(-result["fun"])


if __name__ == '__main__':
    main()



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

void harmony(int& A, int& B)
{
    int diff = abs(A - B);

    // If difference is odd...impossible...
    if (diff % 2 != 0) printf("IMPOSSIBLE\n");

    else if (A > B) printf("%d\n", abs(A - (diff/2)));
    else { printf("%d\n", abs(B - (diff/2))); }
}

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

    harmony(A, B);

    return 0;
}

Measured memory_bytes: 128
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N;
  std::cin >> N;
  std::vector<i64> A(N + 1), B(N, 0);
  for (usize i = 0; i < N + 1; i++) std::cin >> A[i];
  for (usize i = 0; i < N; i++) std::cin >> B[i];

  i64 ans = 0;
  for (usize i = 0; i < N; i++) {
    if (B[i] < A[i]) {
      ans += B[i];
      B[i] = 0;
    } else {
      B[i] -= A[i];
      ans += A[i];
    }

    if (B[i] < A[i + 1]) {
      A[i + 1] -= B[i];
      ans += B[i];
      B[i] = 0;
    } else {
      B[i] -= A[i + 1];
      ans += A[i + 1];
      A[i + 1] = 0;
    }
  }

  std::cout << ans << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m,h;
          
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    }
}



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

void solve() {
  string s, t;
  cin >> s;
  cin >> t;
  int n = (int) s.size();
  int ans = 0;;
  for (int i = 0; i < n; i++) {
    if(s[i] != t[i]) {
      ans++;
    }
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
 }


Measured memory_bytes: 3820
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int dy[4] = { 0, -1, 0, 1 };
int dx[4] = { 1, 0, -1, 0 };
bool inside(int y, int x, int H, int W) {
    return 0 <= y && y < H && 0 <= x && x < W;
}
int h,w;
int solve();
char field[2005][2005];
int memo[2005][2005];
int main(){
	cin >>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>field[i][j];
		}
	}
	cout << solve() << endl;
	return 0;
}

int solve(){
	int ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(field[i][j]=='.'){
				int cnt=0;
				int now=j;
				while(now<w&&field[i][now]=='.'){
					++cnt;
					++now;
				}
				for(int k=j;k<now;k++){
					memo[i][k]+=cnt;
				}
				j=now-1;
			}
		}
	}
	for(int i=0;i<w;i++){
		for(int j=0;j<h;j++){
			if(field[j][i]=='.'){
				int cnt=0;
				int now=j;
				while(now<h&&field[now][i]=='.'){
					++cnt;
					++now;
				}
				for(int k=j;k<now;k++){
					memo[k][i]+=cnt;
				}
				j=now-1;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ans=max(ans,memo[i][j]);
		}
	}
	return ans-1;
}

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

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h){
    string s;
    cin >> s;
    c[i] =s;
  }
  ll ans=0;

  for (int biti = 0; biti < (1<<h); ++biti){
    vector<int> row;
    for (int i = 0; i < h; ++i) {
      if (biti & (1<<i)) { // 列挙に i が含まれるか
        row.push_back(i);
      }
    }
    for (int bitj = 0; bitj < (1<<w); ++bitj){
      vector<int> col;
      for (int i = 0; i < w; ++i) {
        if (bitj & (1<<i)) { // 列挙に i が含まれるか
        col.push_back(i);
        }
      }
      int count=0;
      rep(i,h){
        rep(j,w){
          if(find(row.begin(), row.end(), i) != row.end()) continue;
          if(find(col.begin(), col.end(), j) != col.end()) continue;
          if(c[i][j]=='.') continue;
          count +=1;
        } 
      }
      if(count ==k) ans+=1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
#include <string.h>

using namespace std;
static const int INF = 1e9;
static const int SIZE = 10001;
typedef pair<int, int> P;
struct edge
{
	int to;
	int cost;
};

bool isUsed[SIZE];
vector<edge> G[SIZE];

void solve()
{
	int V, E;
	cin >> V >> E;
	for (int i = 0; i < E; ++i)
	{
		int from, to, cost;
		scanf("%d %d %d", &from, &to, &cost);
		//		cin >> from >> to >> cost;
		edge e1, e2;
		e1.to = to;
		e1.cost = cost;
		e2.to = from;
		e2.cost = cost;
		G[from].push_back(e1);
		G[to].push_back(e2);
	}
	memset(isUsed, 0, sizeof(isUsed));
	int ans = 0;
	priority_queue<P, vector<P>, greater<P> > pque;
	pque.push(P(0, 0));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.second;
		if (isUsed[v])
		{
			continue;
		}
		isUsed[v] = true;
		ans += p.first;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			pque.push(P(e.cost, e.to));
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 6112
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int X, Y;
	cin >> X >> Y;
	string ans = "Yes";
	if (Y % 2 == 1)
		ans = "No";
	if (Y < X * 2)
		ans = "No";
	if (Y > X * 4)
		ans = "No";


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

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int sum = m + f;
			if (m == -1 && f == -1 && r == -1)
				break;

			if (m == -1 || f == -1) {
				System.out.println("F");
			} else if (sum >= 80) {
				System.out.println("A");
			} else if (sum >= 65) {
				System.out.println("B");
			} else if (sum >= 50 || r >= 50) {
				System.out.println("C");
			} else if (sum >= 30) {
				System.out.println("D");
			} else {
				System.out.println("F");
			}
		}

	}

}



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

#define ll long long

int main()
{
    
   string str;
   cin>>str;
   
   ll cnt = 0;
   
   for(ll i=0;i<str.length();i++)
   {
       if(str[i] == 'o')
       cnt++;
   }
   
   ll ans = 15-str.length();
   
   if((ans + cnt) >= 8)
   {
       cout<<"YES"<<endl;
   }
   else
   {
       cout<<"NO"<<endl;
   }

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var a,b,c int  
	fmt.Scan(&a,&b,&c)
	if a >b {
		tmp := a
		a = b
		b = tmp
	}
	if b >c {
		tmp := b
		b = c
		c = tmp
	}
	if a >b {
		tmp := a
		a = b
		b = tmp
	}
	fmt.Println(a + b + c * 10)
}

Measured memory_bytes: 512
program ABC100C
    implicit none
    integer(8)::N,i
    integer(8)::result=0
    integer(8),allocatable,dimension(:)::A

    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    do i=1,N
        do
            if(mod(A(i),2)==1)then
                exit
            else
                A(i)=A(i)/2
                result=result+1
            end if
        end do
    end do

    print'(i0)',result
    
end program ABC100C

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, a, b, c, d,ans,count=0;
	while (cin >> n) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					for (int l = 0; l < 10; l++) {
						ans = i + j + k + l;
						if (ans == n) {
							count++;
						}
					}
				}
			}
		}

		cout << count << endl;
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 3112
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
 
//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif
 
 
//改造
typedef long long int ll;
using namespace std;
 
 
//ここから編集する
 
 
int main() {
 
    int N;
    cin >> N;
    vector<ll> A(N + 1, 0);
    vector<ll> B(N + 1, 0);
    REP(i, 1, N + 1) {
        cin >> A[i];
    }
    int flag = 0;
    int ans = 1;
    REP(i, 1, N) {
//        cout << A[i] << " ";
        //flagが0ならA[i]とA[i+1]に応じた値を入れる
        if (flag == 0) {
            if (A[i] == A[i + 1]) flag = 0;
            else if (A[i + 1] - A[i] < 0) flag = -1;
            else flag = 1;
        }
        //flagが0出ないならflagとA[i+1] - A[i]の符号が異なる時
        else{
            if( (A[i+1] - A[i]) * flag < 0 ){
//                i++;
                ans++;
                flag = 0;
//                cout << "|";
            }
        }
    }
//    cout << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
N=int(input())

item={"AC":0,"WA":0,"TLE":0,"RE":0}

for n in range(N):
    S=input()

    if S=="AC":
        item["AC"]+=1
    elif S=="WA":
        item["WA"]+=1
    elif S=="TLE":
        item["TLE"]+=1
    else:
        item["RE"]+=1

print("AC x",end=" ")
print(item["AC"])

print("WA x",end=" ")
print(item["WA"])

print("TLE x",end=" ")
print(item["TLE"])

print("RE x",end=" ")
print(item["RE"])


Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int>a(n);
  for(int i = 0;i<n;i++) cin >> a[i];
  for(int i = 0;i<n-1;i++) cout << a[i]<<' ';
  cout << a[n-1];
  cout << endl;
  for(int i = 1;i<n;i++){
   int temp = a[i];
   int j = i - 1;
   while(j>=0&&a[j]>temp){
     a[j+1] = a[j];
     j --;
   }
   a[j+1] = temp;
    for(int k = 0;k<n-1;k++) cout << a[k]<<' ';
    cout << a[n-1];
    cout <<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3124
#include "stdio.h"

int N;

void sort(int A[]){
  for(int i; i < N; i++){
    int j = i;
    int tmp = 0;
    while(j >= 1 && A[j - 1] < A[j]){//逆
      tmp = A[j];
      A[j] = A[j - 1];
      A[j - 1] = tmp;
      j--;
    }
  }
}

void steps_mochi(int A[]){
  int mochi[N];
  int steps = 0;
  for(int i = 0; i < N; i++){
    mochi[i] = 0;
  }
  for(int j = 0; j < N; j++){
    if(A[j] >= A[j + 1]){
      mochi[j] = A[j];
    }
  }
  for(int k = 0; k < N; k++){
    if(mochi[k] != 0 && mochi[k] != mochi[k + 1]){
      steps++;
    }
  }
  printf("%d\n", steps);
}

int main(void){
  scanf("%d\n", &N);
  int A[N];

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

  sort(A);

  A[N] = 0;

  steps_mochi(A);

  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a)) 
#define pb push_back
#define sz(x) (int)x.size() 
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+10; 

ll arr[N];
ll sums[N];
int main(){
  fast;
  int n;
  cin>>n;
  FOR(i,1,n)
  cin>>arr[i];
  ll ans=INF;
  
  sums[1]=arr[1];
  FOR(i,2,n)
  sums[i]=sums[i-1]+arr[i];

  ll steps=0;
  ll cur=0;
  if(arr[1]==0)
  {
  	steps=1;
  	cur=1;
  }
  else if(arr[1]>0)
  {
  	steps=0;
  	cur=arr[1];
  }
  else if(arr[1]<0)
  {
  	steps=abs(arr[1])+1;
  	cur=1;
  }

  FOR(i,2,n)
  {
  	if(i%2)
  	{
  		cur=cur+arr[i];
  		if(cur==0)
  		{
  			cur++;
  			steps++;
  		}
  		else if(cur<0)
  		{
  			steps+=abs(cur)+1;
  			cur=1;
  		}
  	}

  	else
  	{
  		cur=cur+arr[i];
  		if(cur==0)
  		{
  			cur--;
  			steps++;
  		}
  		else if(cur>0)
  		{
  			steps+=abs(cur)+1;
  			cur=-1;
  		}	
  	}
  }

  ans=min(ans,steps);
  steps=0;
  cur=0;

  if(arr[1]==0)
  {
  	steps=1;
  	cur=-1;
  }
  else if(arr[1]<0)
  {
  	steps=0;
  	cur=arr[1];
  }
  else if(arr[1]>0)
  {
  	steps=abs(arr[1])+1;
  	cur=-1;
  }

  FOR(i,2,n)
  {
  	if(i%2==0)
  	{
  		cur=cur+arr[i];
  		if(cur==0)
  		{
  			cur++;
  			steps++;
  		}
  		else if(cur<0)
  		{
  			steps+=abs(cur)+1;
  			cur=1;
  		}
  	}

  	else
  	{
  		cur=cur+arr[i];
  		if(cur==0)
  		{
  			cur--;
  			steps++;
  		}
  		else if(cur>0)
  		{
  			steps+=abs(cur)+1;
  			cur=-1;
  		}	
  	}
  }

  ans=min(ans,steps);
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int a;
  cin >> a;
  int a1,a2,a3 =0;
  a1 = a/100;
  a2 = (a - (a/100)*100)/10;
  a3 = a - a1*100 - a2*10 ;
  cout << a1 + a2 + a3 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main() {
    int n;
    int ans = 0;
    bool d = true;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 != 0) d = false;
    }

    while (true) {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0) d = false;
            a[i] = a[i] / 2;
        }
        if (d == false) break;
        ans += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef map<ll, pii> mlp;

pli dfs1(vi e[], int x) {
    pli ret = pli(0, 1);
    for (int i : e[x]) {
        pli t = dfs1(e, i);
        ret.first += t.first + t.second;
        ret.second += t.second;
    }
    return ret;
}

void dfs2(vi e[], int x) {
    for (int i : e[x]) {
        cout << x + 1 << " " << i + 1 << endl;
        dfs2(e, i);
    }
}

int main() {
    int n;
    cin >> n;
    mlp dic;
    for (int i = 0; i < n; i++) {
        ll d;
        cin >> d;
        dic[d] = pii(i, 1);
    }

    vi e[n];
    bool f = true;
    for (auto it = dic.rbegin(); it != prev(dic.rend()); it++) {
        ll t = it->first - n + 2 * it->second.second;
        if (t >= it->first || !dic.count(t)) {
            f = false;
            break;
        }
        
        e[dic[t].first].push_back(it->second.first);
        dic[t].second += it->second.second;
    }
    
    f &= dfs1(e, dic.begin()->second.first).first == dic.begin()->first;

    if (!f) {
        cout << -1 << endl;
    } else {
        dfs2(e, dic.begin()->second.first);
    }

    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ; cin >> n ;

    for ( int i=1 ; i*i <= n ; i++ )
    {
        if ( n % i ) C ;

        int a = i ;
        int b = n/i ;

        if ( a < 10 && b < 10 ) { cout << "Yes" ; R ; }
    }
    cout << "No" ;
}

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

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#create date: 2020-07-05 10:48

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    p = na()
    for i in range(n-1):
        for j in range(i, n):
            q = p.copy()
            q[i] = p[j]; q[j] = p[i]
            now = q[0]
            f = True
            for qi in q:
                if now > qi:
                    f = False
                    break
                now = qi
            if f:
                print("YES")
                quit()
    print("NO")



if __name__ == "__main__":
    main()

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

using namespace std;

long long mul(long long x) {
  if (LLONG_MAX / 2 > x) {
    return x * 2;
  } else {
    return LLONG_MAX;
  }
}

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

  int n;
  cin >> n;
  vector<int> a(n + 1);
  long long cur = 1;
  vector<long long> acab(n + 1);
  for (int i = 0; i <= n; ++i) {
    cin >> a[i];
    cur -= a[i];
    acab[i] = cur;
    if (cur < 0) {
      cout << -1;
      return 0;
    }
    cur = mul(cur);
  }
  long long ans = a[n], lst = a[n];
  for (int i = n - 1; i >= 0; --i) {
    long long x = a[i] + min(lst, acab[i]);
    ans += lst = x;
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 4492
import math

def is_prime(x: int):
    if x == 2:
        return True
    elif x == 3:
        return True
    for i in range(2, math.floor(math.sqrt(x)), 1):
        if x % i == 0:
            return False
    return True


X = int(input().strip())
ans = 0
for i in range(X, (10 ** 6 + 1), 1):
    if is_prime(i):
        ans = i
        break
print(ans)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

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

int main()
{
    int n;
    cin>>n;
    vector<int> d;
    for(int i=0;i<n;i++){
        int val;
        cin>>val;
        d.push_back(val);
    }
    sort(d.begin(),d.end());
    cout<<d[n/2]-d[n/2-1]<<'\n';
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    for(char i='a';i<='z';i++){
        if(s.find(i)==-1){
            cout << i<< endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
n=int(input())
s=[int(input()) for i in range(n)]
s.sort()
ans=sum(s)

for i in range(n):
    if ans%10!=0:
        print(ans)
        exit()
    else:
        if s[i]%10!=0:
            ans-=s[i]
        if i==n-1:
            print(0)


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
 
typedef long long ll;
ll MOD = 1e9+7;
double EPS = 1e-10; //誤差
 
ll x[100000];
vector<ll> m; //0未満
vector<ll> p;//o以上
 
 
int main()
{
	int n,k;
	ll ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
		if(x[i]<0)
			m.push_back(abs(x[i]));
		else if(x[i]>0)
			p.push_back(x[i]);
		else{
			k++;
			m.push_back(x[i]);
			p.push_back(x[i]);
		}
	}
	reverse(m.begin(),m.end());
	cerr<<"input"<<endl;
	if(k<=m.size() && k<=p.size())
	{
		ans=min(m[k-1],p[k-1]);
		for(int i=0;i<k-1;i++)
			ans=min(ans,m[i]*2+p[k-i-2]);
		for(int i=0;i<k-1;i++)
			ans=min(ans,p[i]*2+m[k-i-2]);
	}else if(k<=m.size()){
		ans=m[k-1];
		for(int i=0;i<p.size();i++)
		{
			ans=min(ans,p[i]*2+m[k-i-2]);
		}
		for(int i=0;i<k-1;i++)
		{
			if(i+1+p.size()<k)
				continue;
			ans=min(ans,m[i]*2+p[k-i-2]);
		}
	}else if(k<=p.size()){
		//cerr<<"plus"<<endl;
		ans=p[k-1];
		for(int i=0;i<m.size();i++)
		{
			ans=min(ans,m[i]*2+p[k-i-2]);
		}
		for(int i=0;i<k-1;i++)
		{
			if(i+1+m.size()<k)
				continue;
			ans=min(ans,p[i]*2+m[k-i-2]);
		}
	}else{
		ans=min(m[m.size()-1]*2+p[k-m.size()-1],p[p.size()-1]*2+m[k-p.size()-1]);
		for(int i=0;i<p.size();i++)
		{
			if(i+1+m.size()<k)
				continue;
			ans=min(ans,p[i]*2+m[k-i-2]);
		}
		for(int i=0;i<m.size();i++)
		{
			if(i+1+p.size()<k)
				continue;			
			ans=min(ans,m[i]*2+p[k-i-2]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
		final int INF = 300000;
		int[] num = new int[INF];
		for(int i = 1; i < INF; i++) {
			num[i] = i;
		}

		boolean[] isPrime = new boolean[INF];
		for(int a = 0; a < INF; a++)	isPrime[a] = true;
		//	2の倍数は除外
		for(int a = 2; a < INF; a += 2) {
			isPrime[a] = false;
		}
		isPrime[1] = isPrime[0] = false;
		isPrime[2] = true;
		//	3からforで判別を始める
		for(int i = 3; i < INF; i += 2) {
			for(int j = 2; j < INF / i; j++) {
				isPrime[(i*j)] = false;
			}
		}

		int input = -1;
		while(true){
			int count = 0;
			input = src.nextInt();
			if(input == 0)	break;
			for(int a = input + 1; a <= (input * 2); a++) {
				if(isPrime[a])	count++;
			}
			System.out.println(count);
		}
	}
}



Measured memory_bytes: 29088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int n = Integer.parseInt(tmpArray[0]);
			int m = Integer.parseInt(tmpArray[1]);
			if(n == 0 && m == 0){
				break;
			}

			System.out.println(countAvailableCombination(n,m,9));
		}
	}
	
	static int countAvailableCombination(int n, int m, int limit){
		if(m < 0 ){
			return 0;
		}
		
		//System.out.printf("n = %d m = %d limit = %d\n", n, m, limit);


		if(n == 1 && limit >= m){
			//System.out.println("OK");
			return 1;
		}
		else if(n == 1 && limit < m){
			return 0;
		}
		
		int result = 0;
		for(int i = limit; i >= 0; i--){
			result += countAvailableCombination(n - 1, m - i, i - 1);
		}
		return result;
	}

}

Measured memory_bytes: 24172
n,m=map(int,input().split())
p=[];s=[]
if m==0:
    print(0,0)
    exit()
for i in range(m):
    x,y=input().split()
    p.append(int(x))
    s.append(y)
ac=0
wa=0
t=[0]*(n+1)
wf=[0]*(n+1)
for i in range(m):
    if t[p[i]]>=1:
        continue
    elif s[i]=="WA":
        wf[p[i]]+=1
    elif s[i]=="AC":
        t[p[i]]+=1
        ac+=1
        wa+=wf[p[i]]
print(ac,wa)

Measured memory_bytes: 14920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    string s; cin >> s;
    int ans = 0;
    REP(i,s.length()) ans += (s[i]=='2');
    cout << ans << endl;
    return 0;
}

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

bool search(int arr[], int arr_len, int x)
{
  for (int i = 0; i < arr_len; ++i)
  {
    if (x == arr[i]) return true;
  }
  return false;
}

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

  int q;
  cin >> q;
  int T[q];
  int t;
  for (int i = 0; i < q; ++i)
  {
    cin >> t;
    T[i] = t;
  }

  int count = 0;
  for (int i = 0; i < q; ++i)
  {
    if (search(S, n, T[i])) ++count;
  }

  cout << count << endl;

  return 0;
}


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

void solve () {
    int n;
    cin >> n;
    unordered_map<string, long long> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    long long ans = 0;
    for (auto p : mp) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 10312