akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int B = 64;
const int M = 50010;
const int S = M / B + 1;
const int N = 100100;
int n, m;
int a[N][2];
char ans[N];
bool used[N];
ull b[M][S];

void solveUniform() {
	for (int i = 0; i < n; i++)
		b[i][i / B] ^= (ull)1 << (i % B);
	for (int i = m - 1; i >= 0; i--) {
		int v = a[i][0], u = a[i][1];
		for (int j = 0; j < S; j++) {
			b[v][j] |= b[u][j];
			b[u][j] = b[v][j];
		}
	}
	for (int i = 1; i < n; i++)
		for (int j = 0; j < S; j++)
			b[0][j] &= b[i][j];
	int V = -1;
	for (int i = 0; V == -1 && i < S; i++) {
		if (b[0][i] == 0) continue;
		int j = 0;
		while(((b[0][i] >> j) & 1) == 0) j++;
		V = i * B + j;
	}
	if (V == -1) {
		printf("-1\n");
		return;
	}
	for (int i = 0; i < n; i++)
		used[i] = 0;
	used[V] = 1;
	for (int i = m - 1; i >= 0; i--) {
		int v = a[i][0], u = a[i][1];
		if (used[v]) {
			ans[i] = '^';
			used[u] |= used[v];
		} else {
			ans[i] = 'v';
			used[v] |= used[u];
		}
	}
	ans[m] = '\0';
	printf("%s\n", ans);
}

void solveNonuniform() {
	if (n == 2) {
		printf("-1\n");
		return;
	}
	for (int i = 0; i < n; i++)
		used[i] = 1;
	int x = a[0][0], y = a[0][1];
	used[x] = used[y] = 0;
	int id = 0;
	for (int i = 1; i < m; i++) {
		if (x > y) swap(x, y);
		//eprintf("%d %d %d\n", id, x, y);
		if (x == a[i][0] && y == a[i][1]) {
			ans[id] = '^';
			id = i;
			continue;
		}
		if (a[i][0] == x || a[i][1] == x || a[i][0] == y || a[i][1] == y) {
			if (a[i][0] == y || a[i][1] == y) swap(x, y);
			int z = x ^ a[i][0] ^ a[i][1];
			if (!used[z]) {
				ans[i] = (x < z ? '^' : 'v');
				continue;
			}
			ans[id] = (x < y ? 'v' : '^');
			used[y] = 1;
			used[x] = used[z] = 0;
			y = z;
			id = i;
		} else {
			ans[i] = '^';
			used[a[i][0]] |= used[a[i][1]];
			used[a[i][1]] = 0;
		}
	}
	ans[id] = 'v';
	ans[m] = '\0';
	printf("%s\n", ans);
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int t;
	scanf("%d%d%d", &n, &m, &t);
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < 2; j++) {
			scanf("%d", &a[i][j]);
			a[i][j]--;
		}
	}
	if (t == 1)
		solveUniform();
	else
		solveNonuniform();

	return 0;
}


Measured memory_bytes: 306816
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}

vector<ll> a;
int n;
ll res;


int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
    cin>>n;
    read(a,n);
    ll mx=a[0];
    for(int i=1;i<a.size();i++)
    {
        res+=max(mx-a[i],0LL);
        mx=max(mx,a[i]);
    }
    cout<<res<<endl;
    
  

}


Measured memory_bytes: 4892
#include<iostream>

int main(){
    int room[4][3][10]={0};
    int b,f,r,v,i,j,k,n;

    std::cin>>n;

//格納
    for(i=1;i<=n;i++){
        std::cin>>b>>f>>r>>v;
        room[b-1][f-1][r-1]+=v;
    }

//出力
    for(i=0;i<=3;i++){
        for(j=0;j<=2;j++){
            for(k=0;k<=9;k++){
                std::cout<<" "<<room[i][j][k];
            }
            std::cout<<std::endl;
        }
        if(i==3){break;}
        std::cout<<"####################"<<std::endl;
    }
    
    return 0;
}


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

const int M = 1000000007;

int dp[4096][4096];
char s[1048576];

int main() {
	int n, i, j;
	scanf("%d%s", &n, s);
	for (i=0; i<n; i++)
	{
		dp[n-1][i] = i+1;
	}
	for (i=n-2; i>=0; i--)
	{
		for (j=0; j<=i; j++)
		{
			if (s[n-i-2] == '>')
			{
				dp[i][j] = (dp[i+1][i+1] - dp[i+1][j] + M) % M;
			}
			else
			{
				dp[i][j] = dp[i+1][j];
			}
			if (j)
			{
				dp[i][j] = (dp[i][j] + dp[i][j-1]) % M;
			}
			//printf("%d %d: %d\n", i, j, dp[i][j]);
		}
	}
	printf("%d\n", dp[0][0]);
	return 0;
}

Measured memory_bytes: 47616
#include<stdio.h>

  int Jgraph[1001][1001],Igraph[1001][1001],Ograph[1001][1001];

int main(void){
  char graph[1002][1002];
  int m,n,k,i,j,a,b,c,d,ansJ,ansI,ansO;

  scanf("%d %d %d\n",&m,&n,&k);

  for(i=0;i<m;i++)
    for(j=0;j<n;j++)
      scanf(" %c",&graph[i][j]);

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      Jgraph[i+1][j+1]=graph[i][j]=='J'?1:0;
      Ograph[i+1][j+1]=graph[i][j]=='O'?1:0;
      Igraph[i+1][j+1]=graph[i][j]=='I'?1:0;
    }
  }

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      Jgraph[i+1][j+1]+=Jgraph[i+1][j];
      Ograph[i+1][j+1]+=Ograph[i+1][j];
      Igraph[i+1][j+1]+=Igraph[i+1][j];
    }
  }
  
  for(i=0;i<=m;i++){
    for(j=0;j<=n;j++){
      Jgraph[i+1][j+1]+=Jgraph[i][j+1];
      Ograph[i+1][j+1]+=Ograph[i][j+1];
      Igraph[i+1][j+1]+=Igraph[i][j+1];
    }
  }

  for(i=0;i<k;i++){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    ansJ=Jgraph[c][d]-Jgraph[c][b-1]-Jgraph[a-1][d]+Jgraph[a-1][b-1];
    ansO=Ograph[c][d]-Ograph[c][b-1]-Ograph[a-1][d]+Ograph[a-1][b-1];
    ansI=Igraph[c][d]-Igraph[c][b-1]-Igraph[a-1][d]+Igraph[a-1][b-1];
    printf("%d %d %d\n",ansJ,ansO,ansI);
  }

  return 0;
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
ll dp[10010];

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

    string S,T; cin >> S >> T;
    int A,B; cin >> A >> B;
    string U; cin >> U;

    if(S==U){
        A--;
    }else{
        B--;
    }
    
    cout << A << " " << B << endl;

    return 0;
}


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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int max_chars=0;
  for(int i=0;i<n-1;i++){
    int common_chars=0;
    string x=s.substr(0,i+1);
    vector<char>x_chars(i+1);
    for(int j=0;j<x.size();j++){x_chars.at(j)=x.at(j);}
    sort(x_chars.begin(),x_chars.end());
    x_chars.erase(unique(x_chars.begin(),x_chars.end()),x_chars.end());
    string y=s.substr(i+1,n-(i+1));
    vector<char>y_chars(n-(i+1));
    for(int j=0;j<y.size();j++){y_chars.at(j)=y.at(j);}
    sort(y_chars.begin(),y_chars.end());
    y_chars.erase(unique(y_chars.begin(),y_chars.end()),y_chars.end());
    for(int j=0;j<y_chars.size();j++){
      for(int k=0;k<x_chars.size();k++){
        if(y_chars.at(j)==x_chars.at(k)){
          common_chars++;
        }
      }
    }
    max_chars=max(max_chars,common_chars);
  }
  cout<<max_chars<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(long.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var B = new long [N];
        var A = new int[N];
        for (int i = 0; i < N; i++)
        {
            var l = ReadLine().Split().Select(int.Parse).ToArray();
            A[i] = l[0];
            B[i] = l[1];
        }

       var s= A.Select((x, i) => new { a = x, b = B[i] }).OrderBy(y=>y.a);

        var m = M;
        var ans = 0L;
        foreach (var item in s)
        {
            if (item.b <= m)
            {
                ans += item.a * item.b;
                m -= item.b;
            }
            else
            {
                ans += m * item.a;
                break;
            }
        }

        WriteLine(ans);
    }
}



Measured memory_bytes: 25400
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int a[101010];
int b[101010];
int c[101010];

int main()
{
	int n;
	cin >> n;
	rep(i,0,n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b, b+n);
	int cnt = 0;
	rep(i,0,n) {
		c[i] = abs(i - (lower_bound(b, b+n, a[i])-b));
		if (c[i]%2) cnt++;
	}
	cnt = (cnt+1)/2;
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1408
N,K = map(int,input().split())
S = input()

if S.count('1') == N or S.count('0') == N:
  print(N)
  exit()

S += '2'
s = S[0]
L0 = []
if s == '0':
  L1 = [0]
else:
  L1 = []
c = 1
for i in range(1,N+1):
  if S[i] != s:
    if s == '0':
      L0.append(c)
    else:
      L1.append(c)
    s = S[i]
    c = 1
  else:
    c += 1
L1 += [0]
#print(L0)
#print(L1)

if len(L0) <= K:
  print(N)
  exit()

SL0 = [0 for _ in range(len(L0)+1)]
for i in range(1,len(L0)+1):
  SL0[i] = SL0[i-1] + L0[i-1]
SL1 = [0 for _ in range(len(L1)+1)]
for i in range(1,len(L1)+1):
  SL1[i] = SL1[i-1] + L1[i-1]

ans = 0
for i in range(len(L0)-K+1):
    #ans = max(ans,sum(L0[i:i+K])+sum(L1[i:i+K+1]))
    ans = max(ans,SL0[i+K]-SL0[i] + SL1[i+K+1]-SL1[i])
print(ans)


Measured memory_bytes: 45424
// 26.07.2020
// 00:38:12

#pragma GCC optimize("O3")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(false); cin.tie(0)
#define ll long long
#define ld long double
#define rep(i,a,n) for (int i=(int)(a);i<(int)(n);i++)
#define per(i,a,n) for (int i=(int)(n-1);i>=(int)(a);i--)
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define fi first
#define se second


const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};


template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main() {
    int n, k;
    cin >> n >> k;
    vector<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\n";
        }
        else {
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 3908
#include<bits/stdc++.h>
    using namespace std;
    int main(void){
      int n=0;
      cin>>n;
      map<int,int>field;
      vector<int>data(n);
      vector<int>value(n);
      int type=0;
      for(int i=0;i<n;i++){
      	cin>>data[i];
      	int j=0;
      	bool check=false;
      	if(field[data[i]]==0){
      		value[type]=data[i];
      		field[data[i]]=0;
      		type++;
      	}
      	field[data[i]]++;
      	
      }
      int ans=0;
      for(int i=0;i<type;i++){
      	if(value[i] > field[value[i]]){
      		ans+=field[value[i]];
      	}else{
      		ans+=field[value[i]]-value[i];
      	}
      }
      cout<<ans<<endl;
      return 0;
    }

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for(int i = 0; i < h; i++) {
        cin >> g[i];
    }
    vector<string> ans(h + 2, string(w + 2, '#'));
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            ans[i][j] = g[i - 1][j - 1];
        }
    }
    for(int i = 0; i < h + 2; i++) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k{},ans{};
    cin>>n;
    double d;
    vector<pair<int,int>> p(n);
    ll T[20][20]={};
    fr(i,n){
        cin>>d;
        d*=1000000000;
        d+=0.1;
        ll x=d;
        while(x%2==0) x/=2,p[i].first++;
        while(x%5==0) x/=5,p[i].second++;
        chmin(p[i].first,18);
        chmin(p[i].second,18);
        if(p[i].first>=9 and p[i].second>=9) ++k;
        ++T[p[i].first][p[i].second];
    }
    fr(i,19) fr(j,19) fr(I,19) fr(J,19){
        if(i+I>=18 and j+J>=18) ans+=T[i][j]*T[I][J];
    }
    cout<<(ans-k)/2<<'\n';
}

Measured memory_bytes: 4716
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    vector< vector<string> > map(H, vector<string>(W));

    for (int i = 0; i < H; ++i) {
        string S;
        cin >> S;
        for (int j = 0; j < W; ++j) {
            map[i][j] = S[j];
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int count = 0;

            if (map[i][j] == "#") {
                cout << "#";
                continue;
            }

            // 左上
            // map[i-1][j-1] == "#"
            if (i > 0 && j > 0 && map[i-1][j-1] == "#") {
                ++count;
            }

            // 上
            // map[i-1][j] == "#"
            if (i > 0 && map[i-1][j] == "#") {
                ++count;
            }

            // 右上
            //map[i-1][j+1] == "#"
            if (i > 0 && j < W -1 && map[i-1][j+1] == "#") {
                ++count;
            }

            // 左
            // map[i][j-1] == "#"
            if (j > 0 && map[i][j-1] == "#") {
                ++count;
            }

            // 右
            // map[i][j+1] == "#"
            if (j < W - 1 && map[i][j+1] == "#") {
                ++count;
            }

            // 左下
            // map[i+1][j-1] == "#"
            if (i < H - 1 && j > 0 && map[i+1][j-1] == "#") {
                ++count;
            }

            // 下
            // map[i+1][j] == "#"
            if (i < H - 1 && map[i+1][j] == "#") {
                ++count;
            }

            // 右下
            // map[i+1][j+1] == "#"
            if (i < H - 1 && j < W - 1 && map[i+1][j+1] == "#") {
                ++count;
            }

            cout << count;
        }
        cout << endl;
    }
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memset( x, y, sizeof x )
using namespace std;

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

const int MAXN = 505;

LL n, ret = 1;
int a[MAXN], ha, ta, b[MAXN], hb, tb, cnt, ord[MAXN];

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	cin >> n;
	ha = hb = 100; ta = tb = 99;
	n++;
	while( n > 1 )
	{
		if( n & 1 ) ord[ ++cnt ] = 1, n--;
		else ord[ ++cnt ] = 0, n >>= 1;
	}
	for( int i = cnt ; i ; i-- )
		if( ord[ i ] ) a[ --ha ] = b[ ++tb ] = i;
		else a[ ++ta ] = b[ ++tb ] = i;
	printf( "%d\n", tb - hb + 1 + ta - ha + 1 );
	for( int i = ha ; i <= ta ; i++ ) printf( "%d ", a[ i ] );
	for( int i = hb ; i <= tb ; i++ ) printf( "%d ", b[ i ] );
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		long sum = 0;
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
			if (sum > N) {
				System.out.println(-1);
				sc.close();
				return;
			}
		}
		
		// 結果の出力
		System.out.println(N - sum);

		sc.close();
	}
}


Measured memory_bytes: 37348
n = int(input())
s = sorted([int(input()) for i in range(n)])

ans = sum(s)

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

    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	std::string s, t;

	std::cin >> s >> t;

	if (s.length() + 1 != t.length()) {
		std::cout << "No" << std::endl;
		return 0;
	}

	if (s == t.substr(0, s.length())) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3608
//abc096_c.cpp
//Sat May  5 20:52:43 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int h;
	int w;
	cin >> h;
	cin >> w;

	string a[h][w];
	for (int i=0;i<h;i++){
		string temp;
		cin >> temp;
		for (int j=0;j<w;j++){
			a[i][j] = temp[j];
		}
	}

	int flag = 0;

	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
//			cout << a[i][j] << endl;
			if (a[i][j] == "#"){
				int testnum = 0;
				int posnum = 0;
				if (i>0){
					testnum++;
					if (a[i-1][j] == "#"){
						posnum++;
					}
				}
				if (i<h-1){
					testnum++;
					if (a[i+1][j] == "#"){
						posnum++;
					}
				}
				if (j>0){
					testnum++;
					if (a[i][j-1] == "#"){
						posnum++;
					}
				}
				if (j<w-1){
					testnum++;
					if (a[i][j+1] == "#"){
						posnum++;
					}
				}
//				cout << testnum << posnum << endl;
				if (posnum == 0){
					flag = 1;
				}
			}
		}
	}

	if (flag == 1){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}

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


int main(void) {
    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    //???????????????????????¢???????????\??£????????????
    if(0 < x < W && 0 < y < H) {
        if(0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3100
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	l := make([]int, n)
	for i := range l {
		fmt.Scan(&l[i])
	}

	p := make([]int, n+1)
	p[0] = 0
	for i := 0; i < n; i++ {
		p[i+1] = p[i] + l[i]
	}
	ans := 0
	for _, v := range p {
		if v <= x {
			ans++
		}
	}
	fmt.Println(ans)
}


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

int main(){
    string s; cin >> s; int ans = INT_MAX;
    for (char i = 0; i < 26; i++) {
        char target = i + 'a'; int cnt = 0, tgt_cnt = 0;
//        cout << target << endl;
        // 単一の文字からなる場合
        for (char j : s) if (j == target) tgt_cnt++;
        if(tgt_cnt == (int)s.size()) {
            ans = min(ans, cnt);
            break;
        }
        // その他の場合
        string t1 = s, t2;
        while(true) {
            t2 = ""; tgt_cnt = 0;
            for (auto j = 0; j < (int)t1.size() - 1; j++) {
                if (t1[j] == target or t1[j + 1] == target) t2 += target, tgt_cnt++;
                else t2 += t1[j];
            }
//            cout << cnt << " " << s << " " << t1 << " " << t2 << " " << tgt_cnt << endl;
            t1 = t2; cnt++;
            if(tgt_cnt == (int)t2.size()) break;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

#define INF 1000000001

int count;

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int main(){
  int i,n;
  int S[500000];

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

  mergeSort(S,0,n);

  for(i=0;i<n-1;i++)printf("%d ",S[i]);
  printf("%d\n",S[i]);
  printf("%d\n",count);
  
  return 0;
}

void merge(int *A,int left,int mid,int right){
  int i,j,k,n1,n2;
  int L[250001],R[250001];
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1]=INF;
  R[n2]=INF;
  
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
}

void mergeSort(int *A,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 5668
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=202202;
int n;
int a[N],sm[N];
void put(int x){
	for (int i=x; i<=n; i+=i&(-i))	sm[i]++;
}
int get(int x){
	int sum=0;
	for (int i=x; i; i-=i&(-i))	sum+=sm[i];
	return sum;
}
int main(){
	int ans=0;
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	for (int i=1; i<=n; i++){
		if (get(a[i])==0)	ans++;
		put(a[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<cmath>
#include<string.h>
#include<functional>
#include<algorithm>
int main(void)
{ 
	int  n;
	char s[100+1];
	scanf("%s",s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", s[i]);
	}
		
	
	for (int i = 0; i < n; i++)
	{	
		if (i % 2 == 0)
		{
			if (s[i] == 'L')
			{
				puts("No");
				return 0;
			}
		}else 
		{
			if (s[i] == 'R')
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N,M;
 
int main(){
    cin>>N>>M;
 
    ll b=1;
 
    for(int i=0;i<M;i++)b*=2;
    
    ll ans=(100*N+1800*M)*b;
 
    cout<<ans<<"\n";
    return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
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; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    int n,m;cin>>n>>m;
    cout << n*(n-1)/2+m*(m-1)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int limit=50;
int n,m;
bool a[limit][limit];
bool visited[limit];
void init(){
	for (int i = 0; i < n; i++)
		visited[i] = false;
}
void dfs(int x) {
	if(visited[x]) 
		return;
	visited[x] = true;
	for (int i = 0; i < n; i++)
    	if(a[x][i]) dfs(i);
}
int check() {
	for (int i = 0; i < n; i++)
    	if (!visited[i]) 
			return 1;
	return 0;
}
int main() {
	cin>>n>>m;
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < n; j++) 
	    	a[i][j] = false;
	int num1, num2; 
	for (int i = 0; i < m; i++) {
		cin >> num1 >> num2;
	    a[num1-1][num2-1] = true;
	    a[num2-1][num1-1] = true;
	}
	int ans = 0;
	for (int i = 0; i < n; i++ )
	    for (int j = i+1; j < n; j++) {
	    	if (a[i][j] == false) continue;
	    	init();
	    	a[i][j] = a[j][i] = false;
	    	dfs(0);
	    	ans += check();
	    	a[i][j] = a[j][i] = true;
	    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < (int)n;i++)
#define repb(i, n) for(int i = (int)n;i >= 0;i--)
#define reps(i, m, n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i, m, n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define ll long long
#define INF 999999999999999999
using namespace std;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[]) {
    int d,n;
    cin>>d>>n;
    if(n!=100){
      cout<<pow(100,d)*n<<endl;
      return 0;
    }
    else{
      cout<<(int)pow(100,d)*101<<endl;
      return 0;
    }
}


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

int main() {
	int n, k, d;
	cin >> n >> k;
	int cnt = 0;
	map<int, int> ans;

	for(int i = 1; i <= n; i++) {
			ans[i] = 0;
	}



	for (int i = 1; i <= k; i++) {
		cin >> d;
		for(int j = 0; j < d; j++) {
				int tmp;
				cin >> tmp;
				ans[tmp] = tmp;
		}		
	}

	for (int i = 1; i <= n; i++) {
		if (ans[i] == 0) cnt++;
	}

	cout << cnt << endl;		
}


Measured memory_bytes: 3608
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(); b.sort(); c.sort()
dp = [0]*(n+1)
for i in range(n-1, -1, -1) :
    ins_c = bisect.bisect_right(c, b[i])
    dp[i] = dp[i+1] + (n-ins_c)
ans = 0
for i in range(n) :
    ins_b = bisect.bisect_right(b, a[i])
    ans += dp[ins_b]

print(ans)

Measured memory_bytes: 23360
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;

    int a_cnt = a.size();
    int b_cnt = b.size();
    int c_cnt = c.size();

    int a_itr = 0;
    int b_itr = 0;
    int c_itr = 0;

    int flag = 0;
    while (1) {
        if (flag == 0) {
            if (a_itr == a_cnt) {
                cout << 'A' << endl;
                break;
            }
            if (a[a_itr] == 'b') { flag = 1; }
            if (a[a_itr] == 'c') { flag = 2; }
            a_itr++;
        }
        if (flag == 1) {
            if (b_itr == b_cnt) {
                cout << 'B' << endl;
                break;
            }
            if (b[b_itr] == 'a') { flag = 0; }
            if (b[b_itr] == 'c') { flag = 2; }
            b_itr++;
        }
        if (flag == 2) {
            if (c_itr == c_cnt) {
                cout << 'C' << endl;
                break;
            }
            if (c[c_itr] == 'a') { flag = 0; }
            if (c[c_itr] == 'b') { flag = 1; }
            c_itr++;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.141592653589793238
#define ll long long
#define pii pair<int , int>
#define pll pair<long long , long long>
#define INPUT freopen("travel_restrictions_validation_input.txt", "r", stdin);
using namespace std;
int dx[] = { 0 , 0 , 1 , -1};
int dy[] = { 1 , -1 , 0 , 0};
int getmod(int x, int y , int mod ){return (((x - y)%mod)+mod)%mod;}
int main(){SLAY
	int _=1 , tc=1;
	// cin>>_;
	while(_--){
		ll n,a,b,c;
		string str;
		cin>>a;
		cout<<(ll)a+pow(a,3)+pow(a,2)<<endl;
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define N 2e5
int n,k;
bool sol(int mid,vector<int>&a,vector<int>&f){
	int cnt=0,mul,tmp;
	for(int i=0;i<n;i++){
		mul=a[i]*f[i];
		if(mul>mid){
			tmp=mid/f[i];
			cnt+=a[i]-tmp;
		}
	}
	if(cnt>k)return false;
	else return true;
}
main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	vector<int>a(n);
	vector<int>f(n);

	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>f[i];
	sort(a.begin(),a.end());
	sort(f.rbegin(),f.rend());
	int l=0,r=1e12,mid=(l+r)/2,ans;
	while(l<=r){
		if(sol(mid,a,f)){
			r=mid-1,ans=mid;
		}else{
			l=mid+1;
		}
		mid=(l+r)/2;
	}
		cout<<ans<<"\n";
}

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

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

const long long MOD = 1000000007;

int main(){
  float n,x,t;
  cin >> n >> x >> t;
  int ans = ceil(n/x) * t;
  cout << ans << endl;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll mod=998244353;
const int N=2e5+10;
int n,m,k;
ll f[N],inv[N],fm[N];
void init()
{
    f[0]=1;inv[0]=inv[1]=1;
    for(int i=1;i<N;++i) f[i]=f[i-1]*i%mod;
    ///2的次方逆元
    for(int i=2;i<N;i++)///逆元的预处理
        inv[i]=ll(mod-mod/i)*inv[mod%i]%mod;

    for(int i=1;i<N;i++)///阶乘的逆元预处理
        inv[i]=inv[i-1]*inv[i]%mod;
}
ll C(ll n,ll m)
{
    return f[n]*inv[n-m]%mod*inv[m]%mod;
}
void add(ll &x,ll y)
{
    x=(x+y)%mod;
}
void solve()
{
    cin>>n>>m>>k;
    fm[1]=m;
    for(int j=2;j<=n;++j){
        fm[j]=fm[j-1]*(m-1)%mod;
    }
    ll ans=0;
    for(int i=0;i<=k;++i){
        //if(m<n-i) continue;
        //printf("i:%d fm:%lld\n",i,fm[n-i]);
        add(ans,C(n-1,i)*fm[n-i]%mod);
    }
    cout<<ans<<endl;
}
int main()
{
    init();
	solve();
}


Measured memory_bytes: 8260
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#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 pb push_back
#define EPS (1e-20)
#define INF 2147483647LL
#define MOD 1000000007LL
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int n, m;
llint gc[110][110];
llint gt[110][110];


void warshallFloyd(){
	rep(k, 0, m)
		rep(i, 0, m)
			rep(j, 0, m)
				gc[i][j] = min(gc[i][j], gc[i][k]+gc[k][j]), gt[i][j] = min(gt[i][j], gt[i][k]+gt[k][j]);
}


int main(){
	while(cin >> n >> m, n || m){
		rep(i, 0, m){
			rep(j, 0, m){
				if(i != j) gc[i][j] = gt[i][j] = INF;
			}
		}
		rep(i, 0, n){
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			a--, b--;
			gc[a][b] = gc[b][a] = c;
			gt[a][b] = gt[b][a] = t;
		}
		warshallFloyd();
		int k;
		cin >> k;
		rep(i, 0, k){
			int p, q, r;
			cin >> p >> q >> r;
			p--, q--;
			if(!r) cout << gc[p][q] << endl;
			else cout << gt[p][q] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		string s;
		cin >> s;
		int i = 0, j = n - 1;
		while (j >= 0 && s[j] == 'W') j--;
		if (j < 0) {
			cout << 0;
			return 0;
		}
		while (i < j && s[i] == 'R') i++;
		if (i == j) {
			cout << 0;
			return 0;
		}
		int ans = 0;
		while (i < j) {
			ans++;
			s[i] = 'R';
			s[j] = 'W';
			j--;
			while (i < j && s[i] == 'R') i++;
			while (j > i && s[j] == 'W')j--;

		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] a = new long[n];
        long osum = 0;
        long esum = 0;
        long tmp;

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextLong();
            if (i % 2 == 1) {
                osum += a[i];
            } else {
                esum += a[i];
            }
        }
        tmp = esum - osum;
        System.out.print(tmp + " ");
        for (int i = 1; i < n; i++) {
            tmp = 2 * a[i-1] - tmp;
            System.out.print(tmp + " ");
        }
    }
}



Measured memory_bytes: 64756
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, X, Y = map(int, input().split())
        print(min([max(X, Y) * 2 * C, A * X + B * Y, X * 2 * C + max(0, Y - X) * B, max(0, X - Y) * A + Y * 2 * C]))


# Run main
if __name__ == '__main__':
    AtCoder().main()

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}



int main(){

    double r;
    cin >> r;
    double pi = 3.1415926535;

    cout << fixed;
    cout << setprecision(10) << 2.0*r*pi << endl;
    return 0;
}  



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

using namespace std;

const unsigned long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int arr[200005], dif[200005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;

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

    if(arr[0] != 0){
        cout << "-1\n";
        return 0;
    }

    for(int i = 1; i < n; ++i){
        if(arr[i] - arr[i - 1] > 1){
            cout << "-1\n"; return 0;
        }
    }

    long long tot = 0;

    for(int i = 1; i < n; ++i)
        if(arr[i] != arr[i + 1] - 1)
            tot += arr[i];

    cout << tot << "\n";

    return 0;

}


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

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

	int n,k;
	cin>>n>>k;
	int v[n],ans=0,rem,s,sz;
	vector<int> vv;
	for(int i=0;i<n;i++) cin>>v[i];
	for(int l=0;l<n;l++){
		for(int r=l;r<n;r++){
			rem=k-(n-(r-l+1));
			if(rem>=0){
				s=0;
				vv.clear();
				for(int i=0;i<l;i++){
					s+=v[i];
					vv.push_back(v[i]);
				}
				for(int i=r+1;i<n;i++){
					s+=v[i];
					vv.push_back(v[i]);
				}
				sort(vv.begin(),vv.end());
				sz=vv.size();
				for(int i=0;i<min(rem,sz);i++) s-=min(0,vv[i]);
				ans=max(s,ans);
			}
		}
	}
	rem=k-n;
	if(rem>=0){
		vv.clear();
		s=0;
		for(int i=0;i<n;i++){
			s+=v[i];
			vv.push_back(v[i]);
		}
		sort(vv.begin(),vv.end());
		sz=vv.size();
		for(int i=0;i<min(rem,sz);i++) s-=min(0,vv[i]);
		ans=max(s,ans);
	}
	cout<<ans<<"\n";
	
	return 0;
}

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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int a,b;cin>>a>>b;

    rep(x, 1, 10005){
        int ax = (x*8)/100;
        int bx = (x*10)/100;
        if (ax==a && bx==b){
            cout << x << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python

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

d1 = input_data[0]
d2 = input_data[1]
d3 = input_data[2]

d4 = int(d2 / d1)
if d4 > d3:
    total = d3
else:
    total = d4

print(total)



Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,v[130];
signed main(){
    cin>>n;
    rep(i,n)cin>>v[i];
    sort(v,v+n);
    double ans=1.000000000*v[0];
    for(int i=1;i<n;i++){
        ans=(ans+v[i])/2;
    }
    printf("%.8LF\n",ans);
    return 0;
}


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

const int Nmax=200010;

int main() {
	string s;
	cin >> s;
	char c = s[0];
	int k=s.length();
	for(int i=0;i < s.length()-1;i++){
		if(s[i+1] != c) k=min(k,max(i+1,(int)s.length()-i-1));
		c = s[i+1];
	}
	//i+1かs.length()-i-1のどちらかをガラッと変えれば
	//連続した数字にしていける
	cout << k << endl;
	
	return 0;
}

Measured memory_bytes: 512
import scala.io.StdIn._

object Main extends App {

  solve()
  def solve(): Unit = {
    val n = readInt()
    if (n == 0) return
    val k = readInt()
    val coordinates = Array.tabulate(n){i ⇒
      val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
      Coordinate(x, y)
    }.sortBy(_.y)
    val bottom = coordinates.map{_.y}.distinct.sorted
    val isOut = Array.fill(n){-1}
    val sortBy60 = coordinates.zipWithIndex.sortBy(c ⇒ c._1.y - c._1.x * math.sqrt(3))(Ordering.Double.reverse)
    val sortBy120 = coordinates.zipWithIndex.sortBy(c ⇒ c._1.y + c._1.x * math.sqrt(3))
    var min = Double.MaxValue
    for (lower ← 0 to math.min(k, bottom.length - 1)) {
      coordinates.indices.foreach{i ⇒ isOut(i) = if (coordinates(i).y < bottom(lower)) -1 else 0}
      var right = 0
      var rest = n - k
      while (right < n && (rest > 1 || isOut(sortBy120(right)._2) == -1)) {
        if (isOut(sortBy120(right)._2) == 0) {
          rest -= 1
          isOut(sortBy120(right)._2) = 1
        }
        right += 1
      }
      if (right < n) isOut(sortBy120(right)._2) = 1
      for (left ← 0 until n if isOut(sortBy60(left)._2) != -1 && right < n) {
        if (isOut(sortBy60(left)._2) == 1) {
          val len = calTriangleLength(bottom(lower), sortBy60(left)._1, sortBy120(right)._1)
          if (min > len)
            min = len
          isOut(sortBy60(left)._2) = -1
          right += 1
          while (right < n && isOut(sortBy120(right)._2) != 0) right += 1
          if (right < n) isOut(sortBy120(right)._2) = 1
        }else {
          isOut(sortBy60(left)._2) = -1
        }
      }
    }
    println("%.12f".format(min))
    solve()
  }
  def calTriangleLength(bottom: Int, left: Coordinate, right: Coordinate): Double = {
    val bl = left.x - (left.y - bottom) / math.sqrt(3)
    val br = right.x + (right.y - bottom) / math.sqrt(3)
    (br - bl) * 3
  }
}

case class Coordinate(x: Int, y: Int)



Measured memory_bytes: 582140
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = (int) n/2;
      int y = k*2;
      if(y == n) System.out.println(n);
      else System.out.println(n*2);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
vector <int> g[100001];
long long f[100001][2];
void dfs(int v,int k)
{
	int i;
	f[v][0]=f[v][1]=1;
	for(i=0;i<g[v].size();i++)
	{
		int u=g[v][i];
		if(u==k)
			continue;
		dfs(u,v);
		f[v][0]=f[v][0]*(f[u][0]+f[u][1])%1000000007;
		f[v][1]=f[v][1]*f[u][0]%1000000007;
	}
}
int main()
{
	int i,n,u,v;
	scanf("%d",&n);
	for(i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	printf("%lld",(f[1][0]+f[1][1])%1000000007);
	return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
int arr[5];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	REP(i, 0, 5){
		cin>>arr[i];
	}
	REP(i, 0, 5){
		if (arr[i] == 0){
			cout << i + 1 << endl;
		}
	}
	
}

Measured memory_bytes: 3648
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;
    int N;
    cin >> N;
    vector<int> a(N);
    int s = 0;
    REP(i, N) {
        cin >> a[i];
        s += a[i];
    }
    vector<vector<ll>> dp1(N + 1, vector<ll>(s + 1, 0));
    auto dp2 = dp1;
    dp1[0][0] = 1, dp2[0][0] = 1;
    REP(i, N) {
        REP(j, s + 1) {
            dp1[i + 1][j] += dp1[i][j] * 2;
            dp1[i + 1][j] %= MOD;
            dp2[i + 1][j] += dp2[i][j];
            dp2[i + 1][j] %= MOD;
            if (j - a[i] >= 0) {
                dp1[i + 1][j] += dp1[i][j - a[i]];
                dp1[i + 1][j] %= MOD;
                dp2[i + 1][j] += dp2[i][j - a[i]];
                dp2[i + 1][j] %= MOD;
            }
        }
    }
    ll res = 1;
    REP(i, N) {
        res *= 3;
        res %= MOD;
    }
    FOR(j, (s + 1) / 2, s + 1, 1) {
        res -= (dp1[N][j] * 3) % MOD;
        if (res < 0) {
            res += MOD;
        }
    }
    if (s % 2 == 0) {
        res += dp2[N][s / 2] * 3;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 423104