akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
	int n = 0, m = 0, x = 0, y = 0;
	bool f = 0;

	cin >> n >> m;

	for (x = n; x > -1; x--) {
		for (y = n - x; y > -1; y--) {
			if (10000 * x + 5000 * y + 1000 * (n - x - y) == m) {
				f = 1;
				break;
			}
			if (f == 1)
				break;
		}
		if (f == 1)
			break;
	}
	if (f == 1)
		cout << x << " " << y << " " << n - x - y << endl;
	else
		cout << "-1 -1 -1" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		boolean[] search = new boolean[10000000];
        Arrays.fill(search, true);
        for(int i = 2; i < 10000000; i++){
            // ?´???°????????°?????????????????????
            if(!search[i]){
                continue;
            }

            // ?´???°????????°?????????????????¨???
            for(int j = i * 2; j < 10000000; j += i){
                search[j] = false;
            }
        }

		while(sc.hasNext()) {
			int num = sc.nextInt();
			int count = 0;
			for(int i = 2; i <= num; i++) {
				if(search[i]){
	                count++;
	            }

			}
			System.out.println(count);
		}
	}

}

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

int main(){
	string s; long long k;
	cin >> s;
	cin >> k;
	long long l = s.length();
	string s2 = s+s;
	long long cont = 0;
	long long ig=1;
	for(int i = 0; i < l-1; i++){
		if(s[i] != s[i+1])ig = 0;
	}
	for(int i = 0; i < l-1; i++){
		if(s[i] == s[i+1]){
			s[i+1] = '0';
			cont++;
		}
	}
	long long cont2 = 0;
	for(int i = 0; i < 2*l-1; i++){
		if(s2[i] == s2[i+1]){
			s2[i+1] = '0';
			cont2++;
		}
	}
	if(l == 1 || ig){
		cout << (k*l)/2 << '\n';
	}
	else if(cont2 > 2*cont)cout << cont + (k-1)*(cont2-cont)<<'\n';
	else cout << k*cont << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable : 4996)
int N, L, x[5000], a[5000], dp[5001][5001];
int main() {
	scanf("%d%d", &N, &L);
	for (int i = 0; i < N; i++) scanf("%d", &x[i]);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]), a[i] = a[i] ? a[i] : L;
	dp[N][L] = 1;
	for (int i = N - 1; i >= 0; i--) {
		int sum = dp[i + 1][L];
		for (int j = L - 1; j >= 0; j--) {
			if (j >= x[i] && (j - x[i]) % a[i] == 0) {
				dp[i][j] = sum;
			}
			sum = (sum + dp[i + 1][j]) % 1000000007;
		}
	}
	int ret = 0;
	for (int i = 0; i < L; i++) ret = (ret + dp[0][i]) % 1000000007;
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 69308
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
const int inf = INT_MAX;
const ll INF = 1LL >> 60;
const ll mod = 1e9+7;

int main() {
    int d;
    cin >> d;
    if(d==25) cout << "Christmas" << endl;
    if(d==24) cout << "Christmas Eve" << endl;
    if(d==23) cout << "Christmas Eve Eve" << endl;
    if(d==22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

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

//********************************template END****************************************//

void solve(void){

	int N, M, L;
	cin >> N >> M >> L;

	int as[3] = {abs(N-M), abs(M-L), abs(L-N)};

	sort(as, as+3);

	cout << as[0] + as[1] << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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


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

const int MAXN=301;
double n,dp[MAXN][MAXN][MAXN];
int T=0,D=0,U=0;
double sol(int t,int d,int u)
{
    if(u==1 && d==0 && t==0)
        return n;
    if(dp[t][d][u]!=0)
        return dp[t][d][u];
    int cont=0;
    double aux=0;
    if(t>0)
      {
          aux+=((((double)t/(t+u+d)))*sol(t-1,d+1,u));
          cont++;
      }
    if(d>0)
      {
          aux+=(((double)d/(t+u+d))*sol(t,d-1,u+1));
          cont++;
      }
   if(u>0)
      {
          aux+=(((double)u/(t+u+d))*sol(t,d,u-1));
          cont++;
      }
   dp[t][d][u]=(n*1.0/(u+d+t))+ aux;

   return dp[t][d][u];

}

int main(){
    #ifdef Javier
        freopen(".in", "r", stdin);
    #endif // Javier

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

    cin>>n;
    for(int i=0;i<n;i++)
    {
         int a;
         cin>>a;
         if(a==3)
            T++;
         else
         {
             if(a==2)
                D++;
             else
             {
                 if(a==1)
                    U++;

             }
         }
    }


    cout<<fixed;
    cout<<setprecision(11)<<sol(T,D,U);

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int d[n][2];
  rep(i,n) rep(j,2) cin >> d[i][j];
  bool f = false;
  rep(i,n-2) {
    if(d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]) f = true;
  }
  cout << (f ? "Yes" : "No") << endl;
  return 0;
}


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

public class Main {
	static long INF = Long.MAX_VALUE >> 1;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tokens = br.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		int P = Integer.parseInt(tokens[2]);
		Edge[] edges = new Edge[M];
		for (int i = 0; i < M; i++) {
			tokens = br.readLine().split(" ");
			int src = Integer.parseInt(tokens[0]) - 1;
			int dest = Integer.parseInt(tokens[1]) - 1;
			int weight = Integer.parseInt(tokens[2]) - P;
			edges[i] = new Edge(src, dest, weight);
		}
		long[] dist = new long[N];
		Arrays.fill(dist, -INF);
		dist[0] = 0;
		for (int i = 1; i < N; i++) {
			for (Edge e : edges) {
				if (dist[e.u] != -INF && dist[e.v] < dist[e.u] + e.w) {
					dist[e.v] = dist[e.u] + e.w;
				}
			}
		}
		long max = dist[N - 1];
		for (int i = 0; i < N; i++)
			for (Edge e : edges) {
				if (dist[e.u] != -INF && dist[e.v] < dist[e.u] + e.w) {
					dist[e.v] = INF;
				}
			}
//		System.out.println(Arrays.toString(dist));
		System.out.println(Math.abs(dist[N - 1]) >= (5e10) ? -1 : Math.max(0, max));
	}

	static class Edge {
		int u;
		int v;
		int w;

		Edge(int src, int dest, int w) {
			u = src;
			v = dest;
			this.w = w;
		}

		Edge(Edge e) {
			u = e.u;
			v = e.v;
			w = e.w;
		}

		@Override
		public String toString() {
			return String.format("[%d, %d, %d]", u, v, w);
		}

	}
}

Measured memory_bytes: 27604
#include <iostream>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<algorithm>

typedef long long lli;

#define rep0(i, n) for(int i=0; i < (int)(n); i++)
#define rep1(i, n) for(int i=1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define fill(x,y) memset(x,y,sizeof(x))
#define debug1(i) cout << i << '\n'
#define debug2(i,j) cout << i << j << '\n'

using namespace std;

int n, k;
char s[100001];
int box[100001], num = 0;
int main() {
	cin >> n >> k;
	cin >> s;
	char t = s[0], c = s[0];
	for (int i = 0; i < n; i++) {
		box[num]++;
		if (i == n - 1)break;
		if (c != s[i + 1]) {
			
			c = s[i + 1];
			num++;
		}
	}

	num++;

	vector<int> vec(num, 0);
	if (num - k * 2 >= 0) {
		for (int i = 0; i <= num - k * 2; i++) {
			if (((t == '1') + i) % 2) {
				for (int j = 0; j < 2 * k + 1; j++) vec[i] += box[i + j];
			}
			else {
				for (int j = 0; j < k * 2; j++)vec[i] += box[i + j];
			}
		}

		sort(vec.rbegin(), vec.rend());
		cout << vec[0];
		return 0;
	}
	else {
		int ans = 0;
		for (int i = 0; i < num; i++)ans += box[i];
		cout << ans;
		return 0;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int A,B,C,D;

signed main()
{
	cin>>A>>B>>C>>D;
	while(1){
		C-=B;
		if (C<=0){
			cout<<"Yes\n";
			return 0;
		}
		A-=D;
		if (A<=0){
			cout<<"No\n";
			return 0;
		}
	}
}



Measured memory_bytes: 3592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b);
}

Measured memory_bytes: 256
n, m = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)
total = sum(a)
flg = True
for i in range(m):
    if a[i] * 4 * m < total:
        flg = False
        
print('Yes') if flg else print('No')

Measured memory_bytes: 9096
import itertools
import numpy as np
N,K=map(int,input().split())
count=0
sunuke=[]
sweets=[]
for i in range(1,N+1):
    sunuke.append(i)
while(1):
    d=int(input())
    A=list(map(int,input().split()))
    sunuke=list(set(sunuke)-set(A))
    count+=1
    if count==K:
        break
print(len(sunuke))

Measured memory_bytes: 27152
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[1100][6];
char t[6];
char w[6];
int p[1100];
int q[1100];
int h[11000];
int u[5][5];
int A[5];
int B[5];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%s%d%d",str[i],p+i,q+i);
		}
		int sz=0;
		for(int i=0;i<10000;i++){
			bool ok=true;
			sprintf(t,"%04d",i);
			for(int j=0;j<4;j++)for(int k=j+1;k<4;k++)
				if(t[j]==t[k])ok=false;
			for(int j=0;j<a;j++){
				for(int k=0;k<4;k++)A[k]=B[k]=0;
				int H=0;int L=0;
				for(int k=0;k<4;k++)if(t[k]==str[j][k]){H++;A[k]=B[k]=1;}
				for(int k=0;k<4;k++){
					if(A[k])continue;
					for(int l=0;l<4;l++){
						if(B[l])continue;
						if(t[k]==str[j][l]){L++;A[k]=B[l]=1;break;}
					}
				}
				if(H!=p[j]||L!=q[j]){ok=false;break;}
			}
			if(ok)h[sz++]=i;
		}
	//	printf("%d\n",sz);
		if(sz==1){
			printf("%04d\n",h[0]);
		}else if(sz>25){
			printf("????\n");
		}else{
			bool yet=true;
			for(int i=0;i<10000;i++){
				for(int j=0;j<5;j++)for(int k=0;k<5;k++)u[j][k]=0;
				sprintf(t,"%04d",i);
				bool dame=false;
				for(int j=0;j<4;j++)for(int k=j+1;k<4;k++)
					if(t[j]==t[k])dame=true;
				if(dame)continue;
				for(int j=0;j<sz;j++){
					sprintf(w,"%04d",h[j]);
					for(int k=0;k<4;k++)A[k]=B[k]=0;
					int	H=0;int L=0;
					for(int k=0;k<4;k++)if(t[k]==w[k]){H++;A[k]=B[k]=1;}
					for(int k=0;k<4;k++){
						if(A[k])continue;
						for(int l=0;l<4;l++){
							if(B[l])continue;
							if(t[k]==w[l]){L++;A[k]=B[l]=1;break;}
						}
					}
			//		printf("%d %s: %d %d\n",h[j],str[h[j]],H,L);
					u[H][L]++;
				}
				bool ok=true;
				for(int j=0;j<5;j++)for(int k=0;k<5;k++)
					if(u[j][k]>=2)ok=false;
				if(ok){yet=false;printf("%04d\n",i);break;}
			}
			if(yet)printf("????\n");
		}
	}
}

Measured memory_bytes: 1072
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int a, b;
	cin >> a >> b;
	cout << max(max(a + a - 1,a + b), b + b - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    for (int i = 0; i < m; ++i) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    int st = 0;
    int go = 10;
    if (n == 2) {
        st = 10;
        go = 100;
    }
    if (n == 3) {
        st = 100;
        go = 1000;
    }
    for (int i = st; i <= go; ++i) {
        string k = to_string(i);
        bool ok  = true;
        for (int i = 0; i < m; ++i) {
            if (k[s[i]] != c[i] + '0')
                ok = false;
        }
        if (ok) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = 2 * (a + b);
        System.out.println(area + " " + length);
    }
}


Measured memory_bytes: 26360
class UnionFind():
    def __init__(self, n):
        self._n = n
        self._table = [-1]*n
        self._rank = [0]*n

    def _root(self, x):
        stack = []
        while self._table[x] >= 0:
            stack.append(x)
            x = self._table[x]
        for y in stack:
            self._table[y] = x
        return x
    
    def unite(self, x, y):
        x, y = self._root(x), self._root(y)
        if x == y:
            return
        elif self._rank[x] > self._rank[y]:
            self._table[x] += self._table[y]
            self._table[y] = x
        else:
            self._table[y] += self._table[x]
            self._table[x] = y
            if self._rank[x] == self._rank[y]:
                self._rank[y] += 1
    
    def find(self, x, y):
        return self._root(x) == self._root(y)

    def count(self, x):
        return -self._table[self._root(x)]
    
    def __str__(self):
        return str(list(self))
    def __repr__(self):           
        return repr(list(self))
    def __iter__(self):
        return (self._root(i) for i in range(n))
    def __list__(self):
        return list(iter(self))

from collections import defaultdict
n, m, *X = map(int, open(0).read().split())
P, XY = X[:n], X[n:]

uf = UnionFind(n)
for x, y in zip(XY[::2], XY[1::2]):
    uf.unite(x-1, y-1)
group = list(uf)

d1 = defaultdict(set)
d2 = defaultdict(set)
for i, n in enumerate(group, 1):
    d1[n].add(i)
    d2[n].add(P[i-1])

ans = 0
for i in set(group):
    ans += len(d1[i] & d2[i])
print(ans)

Measured memory_bytes: 137216
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

string s;
int main(void)
{
	cin >> s;
	int a = atoi(s.substr(0, 2).c_str()), b = atoi(s.substr(2, 2).c_str());
	
	bool aflag = (a > 0 && a <= 12), bflag = (b > 0 && b <= 12);
	if(aflag){
		if(bflag) cout << "AMBIGUOUS" << endl;
		else cout << "MMYY" << endl;
	}else{
		if(bflag) cout << "YYMM" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional, std.typecons;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
 
void main()
{
    int Q = readln().strip.to!int;
    foreach(i;0..Q)
    {
        auto aList = readln().strip;
        auto bList = readln().strip;
        writeln(lcs(aList, bList));
    }
}

int lcs(string aList, string bList)
{
    int[][] memo;
    memo.length = aList.length+1;
    memo[0].length = bList.length+1;
    foreach(i; 1..aList.length+1)
    {
        memo[i].length = bList.length+1;
        char a = aList[i-1];
        foreach(j; 1..bList.length+1)
        {
            char b = bList[j-1];
            if(a==b)
            {
                memo[i][j] = memo[i-1][j-1]+1;
            }else{
                memo[i][j] = max(
                    memo[i-1][j],
                    memo[i][j-1],
                );
            }
        }
    }
    return memo[aList.length][bList.length];
}


Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n],i,j;
  for(i=0;i<n;i++) cin>>a[i];
  int s1=0,s2=0;
  i=0;j=n-1;
  while(i<=j)
  {
    if(s1>s2) 
    {
      s2+=a[j];
    //   cout<<"Added "<<a[j]<<" to s2"<<endl;
      j--;
    }
    else
    {
      s1+=a[i];
    //   cout<<"Added "<<a[i]<<" to s1"<<endl;
      i++;
    }
  }
  
  cout<<abs(s1-s2);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		String first = scanner.nextLine();
		String second = scanner.nextLine();

		String[] f = first.split(" ");
		String[] s = second.split(" ");

		if(Integer.parseInt(f[1])- Integer.parseInt(s[1]) < 0) {
			System.out.println("0");
		}else {
			System.out.println("1");
		}


	}

}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  vi bg(9);
  for(ll i=0;i<9;i++){
    cin>>bg[i];
  }
  ll ans=0;
  cin >> n;
  vi a(n);
  REP(i,n){
    cin>>a[i];
    for(ll j=0;j<9;j++){
      if (a[i]==bg[j]){
        bg[j]=-1;
      }
    }
  }


  int flag=0;
  REP(i,3){
    flag=0;
    REP(j,3){
      flag+=(bg[j*3+i]==-1);
    }
    if (flag==3)break;
    
    flag=0;
    REP(j,3){
      flag+=(bg[i*3+j]==-1);
    }
    if (flag==3)break;
  }

  

  if (flag!=3){
    flag=0;
    if (bg[4]==-1){
      if ((bg[0]==-1)&(bg[8]==-1))flag=3;
      if ((bg[2]==-1)&(bg[6]==-1))flag=3;
    }
  }


  if (flag==3){
    cout<<"Yes"<<endl;
    return 0;
  }else{
    cout<<"No"<<endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
right,left=[a[n-1]],[a[0]]
for i in range(1,n):
  left.append(gcd(left[i-1],a[i]))
  right.append(gcd(right[i-1],a[n-i-1]))
ans=max(left[n-2],right[n-2])
for i in range(1,n-1):
  ans=max(ans,gcd(left[i-1],right[n-i-2]))
print(ans)

Measured memory_bytes: 16148
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n;
    string s;
    cin>>n;
    cin>>s;
    int a=0;
    int b=0;
    int c=1000000;
    vector<int> d(n);
    vector<int> e(n);
    for(int i=0;i<n;i++){
        d[i]=a;
    if(s[i]=='W'){
        a++;
    }
    }
    for(int i=n-1;i>=0;i--){
        e[i]=b;
        if(s[i]=='E'){
            b++;
        }
    }
    REP(i,n){
    c=min(c,d[i]+e[i]);
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

bool only_zero(string &S, int x, int y) {
	rep2(i, x, y) if (S.at(i) == '1') return false;
	return true;	
}

bool only_one(string &S, int x, int y) {
	rep2(i, x, y) if (S.at(i) == '0') return false;
	return true;	
}

int main () {
	string S; cin >> S;
	int N = S.size(); // debug(N);
	// int cnt_one = 0;
	// for (char c : S) if (c == '1') cnt_one++;
	for (int K = N; K>=1; K--) {
		// debug(K);
		// debug(only_zero(S, N - K, K));
		// debug(only_one(S, N - K, K));
		if (only_zero(S, N - K, K)) {			
			cout << K << endl;
			break;
		} else if (only_one(S, N - K, K)) {			
			cout << K << endl;
			break;
		}
	}	
}

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

int main(){
	int n,m;cin>>n>>m;
	int L=0,R=n+1;
	rep(i,m){
		int l,r;
		scanf("%d%d",&l,&r);
		L=max(L,l);
		R=min(R,r);
	}
	cout<<max(0,R-L+1)<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    ans=0
    A=[0]*N
    B=[0]*N
    for i in range(N):
        A[i],B[i]=MI()
        
    if A==B:
        print(0)
        
    else:
        ans=sum(A)
        m=10**10
        for i in range(N):
            if A[i]>B[i]:
                m=min(m,B[i])
                
        print(ans-m)
            
        
    

main()


Measured memory_bytes: 74172
#include <stdio.h>

int main(void){
    char s[5];
    int i,ans;
    ans = 0;
    scanf("%s",s);
    for (i=0;i<4;i++){
        if(s[i] == '+'){
            ans +=1;
        }else{
            ans -=1;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
from bisect import bisect_left
INF = 10**4
N = int(input())
nums = list(map(int, input().split()))

nums.sort()
nums.append(INF)
ans = 0
for i in range(N):
  for j in range(i+1, N):
    k = bisect_left(nums, nums[i]+nums[j])
    if k-1 > j:
      ans += k-j-1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    ll c;
    c = b / x - a / x;
    c = (a % x == 0) ? c + 1 : c;
    cout << c << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, m, k = map(int, input().split())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))

    a_sum = b_sum = 0
    a_i = b_i = 0
    while a_i < len(a_list) and a_sum + a_list[a_i] <= k:
        a_sum += a_list[a_i]
        a_i += 1
    ans = a_i

    while a_i > 0:
        # a_sum -= a_list[a_i - 1]  # wrong!
        while b_i < len(b_list) and a_sum + b_sum + b_list[b_i] <= k:
            b_sum += b_list[b_i]
            b_i += 1
            ans = max(ans, a_i + b_i)
        a_sum -= a_list[a_i - 1]  # correct!
        a_i -= 1

    while b_i < len(b_list) and a_sum + b_sum + b_list[b_i] <= k:
        b_sum += b_list[b_i]
        b_i += 1
        ans = max(ans, a_i + b_i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42320
import java.util.Scanner;

/**
 *
 * @author psygn
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int num = scanner.nextInt();
        long[] numbers = new long[num];
        long count = 0;

        for (int i = 0; i < num; i++) {
            numbers[i] = scanner.nextLong();
        }

        while (true) {
            if (!allEven(numbers)) {
                break;
            }
            for (int i = 0; i < num; i++) {
                if (numbers[i] % 2 == 0) {
                    numbers[i] = numbers[i] / 2;
                }
            }
            count++;
        }
        
        System.out.println(count);

    }

    public static boolean allEven(long[] numbers) {
        for (long l : numbers) {
            if (l % 2 != 0) {
                return false;
            }
        }
        return true;
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= 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 all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int n, k;
int x[101];
int ans = 0;

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

    REP(i, n){
        cin >> x[i];
    }

    REP(i, n){
        ans += min(k - x[i], x[i]) * 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;

int main() {
  ll N,M; cin>>N>>M;
  vi A(N,1),B(N);
  B[0]=1;
  REP(i,M) {
    ll x,y; cin>>x>>y; x--; y--;
    if(B[x]==1) B[y]=1;
    if(A[x]==1) B[x]=0;
    A[y]+=1;
    A[x]-=1;
  }
  ll cnt=0; REP(i,N) cnt+=B[i];
  cout<<cnt<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int dy[] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1};

bool solve() {
	string S; cin >> S;
	int N = S.size();
	vector<int> U(N+1);
	if (S == "0") return (false);
	
	int base = 1;

	map<int, int> mp;
	mp[0]++;

	U[N] = 0;
	ll cnt = 0;
	for (int i = N-1; i >= 0; i--) {
		U[i] = (U[i+1] + base * (S[i]-'0')) % 11;
		if (S[i] != '0') cnt += mp[U[i]];
		mp[U[i]]++;
		(base *= 10) %= 11;
	}
	cout << cnt << endl;

	return (true);
}

int main() {
	while (solve());
}



Measured memory_bytes: 3468
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, P;
int a[N];

bool read() {
    if (!(cin >> n >> P))
        return false;

    forn (i, n)
        cin >> a[i + 1];

    return true;
}

void solve(int id = 0) {
    forn (i, n)
        a[i + 1] = (a[i] + a[i + 1]) % P;

    forn (i, n + 1)
        (((a[i] -= i) %= P) += P) %= P;

    int ans = 0;
    map<int, int> cnt;
    cnt[0] = 1;

    for (int r = 1, l = 0; r <= n; ++r) {
        while (r - l >= P)
            --cnt[a[l++]];

        ans += cnt[a[r]]++;
    }

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    //cin >> T;
    T = 1;

    while (read())
        solve(T++);

    return 0;
}



Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
 
ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

ll LCM(ll a, ll b){
    return a/GCD(a,b) * b;
}
 
int main(){
    int N,M; cin>>N>>M;
    int a[N]; 
    int c[N]={0};
    rep(i,N){
        cin>>a[i];
        a[i]/=2;
        int aa=a[i];
        while(aa%2==0){
            aa/=2;
            c[i]++;
        }
    }
    bool flg=0;
    rep(i,N-1){
        if(c[i]!=c[i+1]) flg=1;
    }
    if(flg){
        cout<<0<<endl;
        return 0;
    } 
    sort(a,a+N);
    vector<int> b;
    b.push_back(a[0]);
    for(int i=1;i<N;i++) if(a[i]!=a[i-1]) b.push_back(a[i]);
    ll d=1;
    rep(i,b.size()){
        d=LCM(d,b[i]);
    }
    //cout<<d<<endl;

    cout<<(M/d+1)/2 <<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	long long int x[100000];
	long long int d[100000];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%lld", &x[i]);
		if(i>0){
			d[i-1]=x[i]-x[i-1];
		}
	}
	int m;
	long long int k;
	scanf("%d %lld", &m, &k);
	int ind[100000][60];
	int ind1[100000];
	for(int i=0; i<n-1; i++){
		ind[i][0]=i;
		ind1[i]=i;
	}
	int a;
	for(int i=0; i<m; i++){
		scanf("%d", &a);
		a--;
		int j;
		j=ind[a][0];
		ind[a][0]=ind[a-1][0];
		ind[a-1][0]=j;
	}
	int c[100000];
	for(int i=0; i<n-1; i++){
		c[ind[i][0]]=i;
	}
	for(int i=0; i<n-1; i++){
		ind[i][0]=c[i];
	}
	long long int p2[60];
	p2[0]=1;
	for(int i=1; i<60; i++){
		p2[i]=p2[i-1]*2;
	}
	for(int i=1; i<60; i++){
		for(int j=0; j<n-1; j++){
			ind[j][i]=ind[ind[j][i-1]][i-1];
		}
	}
	
	for(int i=59; i>=0; i--){
		if(k>=p2[i]){
			for(int j=0; j<n-1; j++){
				ind1[j]=ind[ind1[j]][i];
			}
		}
		k=k%p2[i];
	}
	for(int i=0; i<n-1; i++){
		c[ind1[i]]=i;
	}
	printf("%.1lf\n", (double)x[0]);
	for(int i=1; i<n; i++){
		x[i]=x[i-1]+d[c[i-1]];
		double x1=(double)x[i];
		printf("%.1lf\n", x1);
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

string pat[24] =
{
	"123","135","154","142",
	"231","214","246","263",
	"326","365","351","312",
	"421","415","456","462",
	"513","536","564","541",
	"624","645","653","632"
};

string dice[8];
bool used[8];
int sel[8];
int num[8];

bool check(int d1, int pos1, int d2, int pos2) {
	char c1 = dice[sel[d1]][pat[num[d1]][pos1 - 1] - '1'];
	char c2 = dice[sel[d2]][pat[num[d2]][pos2 - 1] - '1'];
	return c1 != c2 && (c1 - 32 == c2 || c2 - 32 == c1);
}

bool dfs(int p) {
	if (p == 8) return true;
	
	REP(i, 8) if (!used[i]) {
		used[i] = true;
		sel[p] = i;
		REP(j, 24) {
			num[p] = j;
			bool flag = false;
			switch (p) {
				case 0: flag = true; break;
				case 1: if (check(0, 3, 1, 4)) flag = true; break;
				case 2: if (check(0, 2, 2, 5)) flag = true; break;
				case 3: if (check(1, 2, 3, 5) && check(2, 3, 3, 4)) flag = true; break;
				case 4: if (check(0, 6, 4, 1)) flag = true; break;
				case 5: if (check(1, 6, 5, 1) && check(4, 3, 5, 4)) flag = true; break;
				case 6: if (check(4, 2, 6, 5) && check(2, 6, 6, 1)) flag = true; break;
				case 7: if (check(6, 3, 7, 4) && check(5, 2, 7, 5) && check(3, 6, 7, 1)) flag = true; break;
			}
			if (flag && dfs(p + 1)) return true;
		}
		used[i] = false;
	}
	return false;
}

int main() {
	REP(i, 24) {
		for (int j = 2; j >= 0; j--) pat[i] += (7 - (pat[i][j] - '0')) + '0';
	}
	
	while (cin >> dice[0]) {
		if (dice[0] == "0") break;
		
		FOR(i, 1, 8) cin >> dice[i];
		
		memset(used, 0, sizeof(used));
		
		if (dfs(0))	puts("YES");
		else puts("NO");
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    int flag = 1;
    if(s.size() >= t.size()){
        flag = 0;
    } else {
        flag = 1;
    }
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) < t.at(i)){
            cout << "Yes";
            break;
        } else if(s.at(i) > t.at(i)){
            cout << "No";
            break;
        } else if(i+1 == min(s.size(), t.size())){
            if(flag == 0){
                cout << "No";
                break;
            } else {
                cout << "Yes";
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

struct edge {
    int to, cost;
    bool flag = false;
};
ll N, M;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];

int main() {
    cin >> N;
    if (N % 11 == 0)PRI((N / 11) * 2)
    else if (N % 11 >= 7)PRI((N / 11) * 2 + 2)
    else PRI((N / 11) * 2 + 1)
    return 0;

}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		scan.close();
		int check=0;
		if(a.length()>b.length())check=1;
		else if(a.length()<b.length())check=2;
		else {
			for(int i=0;i<a.length();i++) {
				int anum=Character.getNumericValue(a.charAt(i));
				int bnum=Character.getNumericValue(b.charAt(i));
				if(anum!=bnum) {
					if(anum>bnum)check=1;
					else check=2;
					break;
				}
			}
		}
		if(check==0)System.out.println("EQUAL");
		else System.out.println((check==1)? "GREATER":"LESS");
	}
}

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

void bubble_sort(vector<int>& vec) {
    for (int i = 0; i <= vec.size() - 2; i++)
        for (int j = vec.size() - 2; j >= i; j--)
            if (vec[j] > vec[j+1])
                swap(vec[j], vec[j+1]);
}

int main() {
    vector<int> vec(3);

    for (int i = 0; i < vec.size(); i++) {
        cin >> vec[i];
    }

    bubble_sort(vec);

    for (int i = 0; i < vec.size(); i++) {
        if (i != 0) cout << ' ';
        cout << vec[i];
    }
    cout << endl;
}

Measured memory_bytes: 1196
'use strict'
function main(input: string) {
    const n: number = Number(input);
    const sqrt = Math.ceil(Math.sqrt(n));
    let result = n-1;
    for (let i = 1; i <= sqrt; i++) {
        if (n % i == 0) {
            result = Math.min(result, (i + n/i -2));
        }
    }
    console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int H[N+1]={0};
	bool bad[N+1]={0};
	for(int i=1;i<=N;i++){
		cin>>H[i];
	}
	for(int i=0;i<M;i++){
		int A,B;
		cin>>A>>B;
		if(H[A]>H[B]){
			bad[B]=1;
		}
		else if(H[B]>H[A])bad[A]=1;
		else bad[A]=bad[B]=1;
	}
	int cnt=0;
	for(int i=1;i<=N;i++){
		if(bad[i]==0)cnt++;
	}
	cout<<cnt<<"\n";
}

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

using namespace std;

using int64 = long long;

vector<int> Solve() {
  int n;
  int64 l;
  cin >> n >> l;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int k = -1;
  for (int i = 0; i + 1 < n; i++) {
    if (xs[i] + xs[i + 1] >= l) {
      k = i;
      break;
    }
  }

  if (k == -1) return vector<int>();

  vector<int> ans;
  for (int i = 0; i < k; i++) {
    ans.push_back(i);
  }
  for (int i = n - 2; i > k; i--) {
    ans.push_back(i);
  }
  ans.push_back(k);

  return ans;
}

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

  auto ans = Solve();
  if (ans.empty()) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    for (int i : ans) cout << i + 1 << endl;
  }
}

Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    vector<int> a;
    inputVector(a, 5);

    int ret = 0;
    rep(i, 5) {
        ret += a[i];
        while (ret % 10) ret++;
    }

    int maxDiff = 0;
    rep(i, 5) {
        if (a[i] % 10 == 0) continue;
        maxDiff = max(maxDiff, 10 - a[i] % 10);
    }

    ret -= maxDiff;

    cout << ret << endl;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }

  ll ans = 0;
  ll sum = 0;
  // 最初が正
  for(int i = 0; i < N; i++){
    if(i %2 == 0){
      sum += A.at(i);
      if(sum > 0){
        //continue;
      } else { 
        ans += 1 - sum;
        sum = 1;
      }
    } else{
      sum += A.at(i);
      if(sum < 0){
        continue;
      } else { 
        ans += sum - (-1);
        sum = -1;
      }
    }
  }


  ll ans2 = 0;
  sum = 0;
  // 最初が負
  for(int i = 0; i < N; i++){
    if(i %2 == 0){
      sum += A.at(i);
      if(sum < 0){
        //continue;
      } else { 
        ans2 += sum - (-1);
        sum = -1;
      }
    } else{
      sum += A.at(i);
      if(sum > 0){
        // continue;
      } else { 
        ans2 += 1 - sum;
        sum = 1;
      }
    }
  }

  cout << min(ans, ans2) << endl;

  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

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

  i64 n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  assert(c <= d);

  const i64 x = (a < b) ? (b - a) : (a - b);

  const bool ok = [&]() -> bool {
    i64 high = (n - 1) * d;
    i64 low = (n - 1) * c;

    // Go up i times, go down (n-1-i) times.
    for (int i = n - 1; i >= 0; --i) {
      if (x > high || high < 0) return false;
      if (low <= x && x <= high) return true;
      high -= c + d;
      low -= c + d;
    }
    return false;
  }();
  cout << (ok ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;


typedef pair<int, int> P;
typedef long long ll;
const int MOD = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
	int N;
	int B[100];
	cin >> N;
	rep(i, N-1){
		cin >> B[i]; 
	}
	int sum = 0;
	sum += B[0] + B[N-2];
 	rep(i, N-2){
		sum += min(B[i], B[i+1]);
	}
	cout << sum;
}


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    v<int> h(n), c(n+5, mod); rep(i,n) cin >> h[i];
    c[0] = 0;
    rep(i,n-1) {
        chmin(c[i+1], abs(h[i+1] - h[i]) + c[i]);
        chmin(c[i+2], abs(h[i+2] - h[i]) + c[i]);
    }

    cout << c[n-1] << endl;

    return 0;
}


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

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  vecint v(4);
  for(auto&& e:v) cin>>e;
  sort(begin(v),end(v));
  int x=v[0]+v[3];
  int y=v[1]+v[2];
  cout<<abs(x-y)<<endl;

  return 0;
}



Measured memory_bytes: 3172
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, l = map(int, input().split())
    S = sorted(list(input() for _ in range(n)))
    print("".join(S))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38384
#include <iostream>
#include <bits/stdc++.h>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#define initrand mt19937 mt_rand(time(0));
#define rand mt_rand()
#define int long long
#define INF 10000000000000
#define mid(l, u) ((l+u)/2)
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
using namespace std;
signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int w = 0, r= 0;
    for(int i =0 ;i<n;i++){
        if(s[i]=='R') r++; else w++;
    }
    int cnt = 0;
    for(int j = n-1;j>=0;j--){
        if(s[j]=='R' && w!=0){
            w--;
            cnt++;
        }
        else if(w && s[j]=='W') w--;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3700
#include<stdio.h>
#include<string.h>
main()
{
	char str[21],rst[21];
	int i,j=0;
	scanf("%s",&str);
	i=strlen(str)-1;
		for(i;i>=0;i--){
		rst[j]=str[i];
		j++;
	}
	rst[j]='\0';
	printf("%s\n",rst);
	return 0;
}

Measured memory_bytes: 524