akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros
#include <bits/stdc++.h>
#define int long long
using ll = long long;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b+a); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#pragma endregion

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  double r; cin >> r;
  cout << r*2*M_PI << endl;

  return 0;
}


Measured memory_bytes: 3796
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int read(){
	int l=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){l=(l<<1)+(l<<3)+(ch^'0');ch=getchar();}
	return f?l:-l;
}
int main(){
	int a,b,c=1;
	a=read();
	for(int i=1;i<=a;++i){
		b=read();
		if(c&&(!(b&1))&&b%3&&b%5)c=0;
	}
	if(c)puts("APPROVED");
	else puts("DENIED");
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
# keyence2020/keyence2020_a
import sys
from math import ceil

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    H = i2n()
    W = i2n()
    N = i2n()
    lgr = max(H, W)
    print(ceil(N / lgr))
    return

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,s,t;
int d[100005];
vector<int> G[100005];
int dist[100005];
priority_queue<P,vector<P>,greater<P> > que;
bool used[100005];

void dfs(int v,int c,int vv){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		if(G[v][i]<vv && dist[G[v][i]]>c){
			dist[G[v][i]]=c;
			que.push(P(c,G[v][i]));
			dfs(G[v][i],c,vv);
		}
	}
}

int main(void){
	scanf("%d%d%d%d",&n,&m,&s,&t);
	s--;
	t--;
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;
		v--;
		G[u].push_back(v);
	}
	if(s>=t){
		printf("0\n");
	}else{
		for(int i=0;i<n;i++){
			dist[i]=1e9;
		}
		dist[s]=0;
		que.push(P(0,s));
		int prev=0;
		while(que.size()){
			P p=que.top();
			que.pop();
			if(dist[p.second]<p.first)continue;
			while(prev<=p.second){
				if(dist[prev]>dist[p.second]){
					dist[prev]=dist[p.second];
					que.push(P(dist[p.second],prev));
				}
				prev++;
			}
			for(int i=0;i<G[p.second].size();i++){
				if(G[p.second][i]>p.second){
					int nec=G[p.second][i];
					if(dist[nec]>dist[p.second]+d[nec]){
						dist[nec]=dist[p.second]+d[nec];
						que.push(P(dist[nec],nec));
					}
				}
			}
		}
		printf("%d\n",dist[t]);
	}
	return 0;
}

Measured memory_bytes: 9404
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    S = list(S) + ['R']
    ans = [0]*len(S)
    b = 'L'
    index = []
    for i, s in enumerate(S):
        if b != s:
            index.append(i)
        b = s
    # print(index)
    for i in range(0, len(index)-2, 2):
        x = index[i]
        y = index[i + 1]
        z = index[i + 2]
        # print(x, y, z)
        a = y - x
        b = z - y
        ans[y-1] = (a+b)//2
        ans[y] = (a+b)//2
        if (a+b)%2 == 1:
            if a%2 == 1:
                ans[y-1] += 1
            if b%2 == 1:
                ans[y] += 1
    print(*ans[:-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 52200
#include <stdio.h>

#define MAX_N 50100

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

int main( void ) {
	int i, j, n, max, min;

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d", &n ) == 1; printf( "%d %d\n", max, min ) ) {
		for ( max = n - 1; !isPrime[ max ]; max-- ) ;
		for ( min = n + 1; !isPrime[ min ]; min++ ) ;
	}

	return 0;
}

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

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

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

int main() {
    int ans = 0;
	int a, b;
	cin >> a >> b;

    cout << max(a+b, max(a+a-1, b+b-1)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

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

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

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int main(){
	string s;
    cin >> s;
    int i = 0;
    ull cnt = 0;
    int size = sz(s);

    while(i < size-1){
        if(s[i] == 'S' && s[i+1] == 'T'){
            s.erase(i,2);
            i--;
            if(i < 0)i = 0;
            cnt++;
        }else{
            i++;
        }
    }

    cout << size -(2*cnt) << endl;
	return  0;
}

Measured memory_bytes: 640
using System;

class Program
{
    static void Main()
    {
        for(int i = 1;i < 10; i++)
        {
            for(int j = 1;j < 10; j++)
            {
                Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            }
        }
    }
}

Measured memory_bytes: 8964
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
 

void solve(){
	int h,w,k; cin >> h >> w >> k;
	int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
	int dx[4] = {-1,1,0,0}, dy[4] = {0,0,-1,1};
	--sx; -- sy; --tx; --ty;
	vector<string> s(h);
	forn(i,0,h) cin >> s[i];
	int dist[h][w];
	memset(dist,inf,sizeof(dist));
	dist[sx][sy] = 0;
	
	//{score to get to cell, cell x coordinte, cell y}
	queue<pair<int,pair<int,int>>> q;
	
	q.push({0,{sx,sy}});
	
	while(q.size() > 0){
		pair<int,pair<int,int>> top = q.front();
		q.pop();
		
		forn(i,0,4){
			forn(j,1,k+1){
				int nx = top.second.first + dx[i]*j, ny = top.second.second + dy[i]*j;
				if(nx < 0 || ny < 0 || nx >= h || ny >= w) break;
				if(s[nx][ny] == '@') break;
				int new_cost = top.first + 1;
				if(dist[nx][ny] < new_cost) break;
				if(dist[nx][ny] > new_cost){
					dist[nx][ny] = new_cost;
					q.push({new_cost,{nx,ny}});
				}
			}
		}
	}
	cout << (dist[tx][ty] == inf ? -1 : dist[tx][ty]);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 9716
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int n;
vector<int> h;
vector<int> ans;

bool dfs(int d, vector<int> r) {
	if (d == n) {
		return true;
	}
	for (int i = 0; i < (int)r.size(); ++i) {
		if ((h[d] & (1 << i)) != 0 && r[i] > 0) {
			--r[i];
			for (int j = 0; j < (int)r.size(); ++j) {
				if (i != j && (h[d] & (1 << j)) != 0) {
					ans[d] = j;
					++r[j];
					if (dfs(d + 1, r)) {
						return true;
					}
					--r[j];
				}
			}
			++r[i];
		}
	}
	return false;
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		n = -1;
		vector<int> r(3);
		cin >> n >> r[0] >> r[1] >> r[2];
		if (n < 0) return 0;
		h = vector<int>(n);
		ans.resize(n);
		for (int i = 0; i < n; ++i) {
			string s;
			cin >> s;
			if (s.find('A') != string::npos) h[i] |= 1;
			if (s.find('B') != string::npos) h[i] |= 2;
			if (s.find('C') != string::npos) h[i] |= 4;
		}
		if (dfs(0, r)) {
			cout << "Yes" << endl;
			for (int j = 0; j < n; ++j) {
				cout << (char('A' + ans[j])) << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


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

/* 配列使用3(ソート) */
int main(){
  int N;
  cin >> N;
  vector<int> mochi(N);
  
  for(int i = 0; i < N; i++)
    cin >> mochi.at(i);

  // ソート
  sort(mochi.begin(), mochi.end());

  // 値が異なるものだけカウント
  int cnt = 1;
  for(int i = 1; i < N; i++)
    if(mochi.at(i) != mochi.at(i - 1))
      cnt++;

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x[n], y[n], a[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> a[i];
    int xl = 0, xr = w, yb = 0, yt = h;
    for (int i = 0; i < n; i++) {
        if (a[i] == 1) xl = max(xl, x[i]);
        else if (a[i] == 2) xr = min(xr, x[i]);
        else if (a[i] == 3) yb = max(yb, y[i]);
        else yt = min(yt, y[i]);
    }
    ll area;
    if (xr <= xl || yt <= yb) area = 0;
    else area = (xr - xl) * (yt - yb);
    cout << area << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

void solve(){
	int x,n;
	cin>>x>>n;
	si s;
	for(int i=0,x;i<n;i++){
		cin>>x;
		s.insert(x);
	}
	int ans=1e6;
	for(int i=0;i<=100;i++){
		if(s.find(x-i)==s.end()){
			ans=min(ans,x-i);
			break;
		}
		else if(s.find(x+i)==s.end()){
			ans=min(ans,x+i);
			break;
		}
	}

	cout<<ans<<endl;

}
 
int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
 int k,a,b;
  cin >> k >> a >> b;
  bool x = false;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      x = true;
      break;
    }
  }
  if(x) cout << "OK" << endl;
  else cout << "NG" << endl;
}


Measured memory_bytes: 3636
def swap(a, i, j):
    # list aのi番目の要素とj番目の要素を交換する関数
    k = a[j]
    a[j] = a[i]
    a[i] = k


def selectionSort(a, n):
    for i in range(n):
        minj = i
        for j in range(i,n):
            if a[j][1] < a[minj][1]: #数字が１桁なのでstrのまま比較可能
                minj = j
        swap(a, i, minj)


def bubbleSort(a, n):
    flag = 1
    while flag:
        flag = 0
        for j in range(n-1,0,-1):
            if a[j][1] < a[j-1][1]:
                swap(a, j-1, j)
                flag = 1


n = int(input())
a = list(input().split())
b = a[:]
bubbleSort(a, n)
print(' '.join(a))
print('Stable')
selectionSort(b, n)
print(' '.join(b))
if a == b:
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5608
from itertools import product
 
n, m = map(int, input().split())
 
xyzs = [[int(x) for x in input().split()] for _ in range(n)]
 
multipliers = product((-1, 1), repeat=3)
 
def max_sum(multiplier):
    sums = (sum(a*mul for a, mul in zip(xyz, multiplier)) for xyz in xyzs)
    top_m = sorted(sums, reverse=True)[:m]
    return sum(top_m)
 
print(max(max_sum(multiplier) for multiplier  in multipliers))

Measured memory_bytes: 42736
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int A,B,C;
	public void solve(){
		A = nextInt();
		B = nextInt();
		C = nextInt();

		if(A == B && B == C){
			if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
				out.println(0);
			}else{
				out.println(-1);
			}
			return;
		}
		int ans = 0;
		while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
			int a = A/2;
			int b = B/2;
			int c = C/2;

			A = b+c;
			B = a+c;
			C = a+b;
			ans++;
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

const int N = 101;
const int W = 10001;

int table[N][W];
int n, w;
int value[N];
int weight[N];

int dp(int ni, int wi)
{
    if (ni < 0) return 0;
    if (wi <= 0) return 0;
    if (table[ni][wi] != -1) return table[ni][wi];
    int t = 0;
    if (wi >= weight[ni]) {
        t = dp(ni-1, wi-weight[ni]) + value[ni];
    }
    return table[ni][wi] = max(t, max(dp(ni-1, wi), dp(ni, wi-1)));
}

int main()
{
    cin >> n >> w;
    fill(&table[0][0], &table[N-1][W], -1);
    for (int i=0; i < n; ++i) {
        cin >> value[i] >> weight[i];
    }
    cout << dp(n-1, w) << endl;
}

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

int cmp(const void*a,const void*b){
	return *(int*)a-*(int*)b;
}

int main(void){
	int n,i;
	long long d,f;
	long long ans=0;
	scanf("%d",&n);
	int a[n],b[n],c[n];
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<n;i++)scanf("%d",&b[i]);
	for(i=0;i<n;i++)scanf("%d",&c[i]);
	qsort(a,n,sizeof(int),cmp);
	qsort(b,n,sizeof(int),cmp);
	qsort(c,n,sizeof(int),cmp);
	int func1(int x){
		int ok = -1;//解が存在する値
		int ng = n;//解が存在しない値
		int mid=0;
		//今回探したい値はx-1以下の値
		while(abs(ok-ng)!=1){
			mid = (ok+ng)/2;
			if(x>a[mid]){
				ok = mid;
			}else{
				ng = mid;
			}
		}
		//printf("ok = %d\n",ok);
		return ok;
	}
	int func2(int x){
		x++;
		int ok = -1;//解が存在する値
		int ng = n;//解が存在しない値
		int mid=0;
		//今回探したい値はx+1以上の値
		while(abs(ok-ng)!=1){
			mid = (ok+ng)/2;
			if(x>c[mid]){
				ok = mid;
			}else{
				ng = mid;
			}
		}
		//printf("ok = %d\n",ok);
		return n-1-ok;
	}
	for(i=0;i<n;i++){
		d = func1(b[i]);
		f = func2(b[i]);
		ans += (d+1)*f;
	}
	printf("%lld",ans);
	return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll x,k,d;cin >>x>>k>>d;
    x=abs(x);
    if(x/d>k)cout <<x-k*d<<endl;
    else {
        if(x/d%2==k%2){
            cout <<x%d<<endl;
        }
        else cout <<abs(d-x%d)<<endl;
    }
}


Measured memory_bytes: 3628
#include <math.h>

#include <algorithm>
#include <bitset>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;

const int INF = 10000000;
typedef pair<int, int> P;

int main() {
  int H, W, N;
  cin >> H >> W;
  vector<vector<char>> field(H, vector<char>(W));
  vector<vector<int>> d(H, vector<int>(W));
  int white_num = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> field[i][j];
      d[i][j] = INF;
      if (field[i][j] == '.') {
        white_num++;
      }
    }
  }
  int dx[4] = {1, -1, 0, 0};
  int dy[4] = {0, 0, 1, -1};

  queue<P> que;
  que.push(P(0, 0));
  d[0][0] = 1;
  int ans = -1;
  while (que.size()) {
    P p = que.front();
    que.pop();
    if (p.first == H - 1 && p.second == W - 1) {
      ans = white_num - d[p.first][p.second];
      break;
    }
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] != '#' &&
          d[nx][ny] == INF) {
        que.push(P(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(){
    int n,a,b,total=0;
    cin >> n >> a >> b;
    for(int i=0; i<=n; i++){
        string s = to_string(i);
        int sum=0;
        for(int j=0; j<s.size(); j++){
            sum += s[j] - '0';
        }
        if((a <= sum) && (sum <= b)){
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
program main
    implicit none
    integer i, n, m, l, c, flag
    character s*99

    read(*,*) s
    n = len_trim(s)

    flag = 0

    do i = 1, (n-1)/2
        if(s(i:i) == s((n+1-i):(n+1-i))) then
            flag = 0
        else 
            flag = 1
            exit
        end if
    end do


    if (flag == 0) then
        m = (n-1)/2

        do i = 1, m/2
            if(s(i:i) == s((m+1-i):(m+1-i))) then
                flag = 0
            else 
                flag = 1
                exit
            end if
        end do
    end if
    
    if (flag == 0) then

        l = (n+3)/2
        c = 1

        do i = l, (n-l+1)/2+l
            if(s(i:i) == s((n+1-c):(n+1-c))) then
                flag = 0
            else 
                flag = 1
                exit
            end if
            c = c + 1
        end do
    end if


    if (flag == 0) then
        write(*,*) "Yes"
    else
        write(*,*) "No"
    end if

end program

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

vector<vector<int>> fr;
vector<vector<int>> bl;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
  ll N,M,K;cin>>N>>M>>K;
  UnionFind tree(N);
  fr.resize(N);bl.resize(N);
  rep(i,M){
    int a,b;cin>>a>>b;a--,b--;
    fr[a].push_back(b);
    fr[b].push_back(a);
    tree.merge(a,b);    
  }
  rep(i,K){
    int a,b;cin>>a>>b;a--,b--;
    bl[a].push_back(b);
    bl[b].push_back(a);    
  }
  rep(i,N){
    int tmp=0;
    rep(j,bl[i].size()){
      if(tree.issame(i,bl[i][j])) tmp++;
    }
    cout << tree.size(i) - tmp - fr[i].size() - 1 << endl;
  }
}

Measured memory_bytes: 12152
/*** Mysterious Gems ***/

#include <bits/stdc++.h>
using namespace std;
#define SIZE 21
#define REP(i, n) for(int i=0; i<n; ++i)

void create_map(int map[][SIZE], int n){
	int x, y;
	REP(j, SIZE){
		REP(i, SIZE){
			map[j][i]=0;
		}
	}
	REP(i, n){
		cin >> x >> y;
		map[y][x]=1;
	}
	return;
}
	
int main(){
	int N, M;
	int l;
	int map[SIZE][SIZE], flag;
	char d;
	
	cin >> N;
	while(N!=0){
		create_map(map, N);
		
		int xx=10, yy=10;
		cin >> M;
		REP(k, M){
			cin >> d >> l;
			while(l>0){
				if(d=='N') ++yy;
				else if(d=='E') ++xx;
				else if(d=='S') --yy;
				else --xx;
				
				if(map[yy][xx]) map[yy][xx]=0;
				--l;
			}
		}
		flag=0;
		REP(j, SIZE){
			REP(i, SIZE){
				if(map[j][i]){
					flag=1;
					break;
				}
			}
		}
		
		if(flag) cout << "No" << endl;
		else cout << "Yes" << endl;
		
		cin >> N;
	}
	return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<limits>

using namespace std;

#define int long long

vector<int> x(3);

/*
numer 0
( 1
) 2
+ 3
- 4
* 5
*/

char temp[] = {'n', '(', ')', '+', '-', '*'};

int solve(vector<pair<int,int>> t, int b, int e){
	vector<pair<int,int>> t2;
	
	for(int i = b, depth = 0, index = -1; i < e; i++){
		switch(t[i].first) {
			case 1: 
				if(depth == 0) {
					index = i;
				}
				depth++;
				break;
			case 2:
				depth--; 
				if(depth == 0) {
					t2.push_back({0, solve(t, index+1, i)});
				}
				break;
			default: if(!depth) t2.push_back(t[i]);
		}
	}
	for(int k = 0; k < 3; k++) {
	
		vector<pair<int,int>> st;
		
		for(int i = 0, depth = 0, index = -1; i < t2.size(); i++){
			st.push_back(t2[i]);
			pair<int,int> a, b, c;
			
			while(st.size() >= 3) {
				a = st.back(); st.pop_back();
				b = st.back(); st.pop_back();
				c = st.back(); st.pop_back();
				
				if(!b.first){
					st.push_back(c);
					st.push_back(b);
					st.push_back(a);
					break;
				}
				
				if(b.first == 3) {
					if(x[0] == k) {
						st.push_back({0,c.second + a.second});
					} else {
						st.push_back(c);
						st.push_back(b);
						st.push_back(a);
						break;
					}
				}
				
				if(b.first == 4) {
					if(x[1] == k) {
						st.push_back({0,c.second - a.second});
					} else {
						st.push_back(c);
						st.push_back(b);
						st.push_back(a);
						break;
					}
				}
				
				if(b.first == 5) {
					if(x[2] == k) {
						st.push_back({0,c.second * a.second});
					} else {
						st.push_back(c);
						st.push_back(b);
						st.push_back(a);
						break;
					}
				} 
			}
		}
		
		if(k == 2) {
			return st.back().second;
		} else {
			t2 = st;
		}
	}
	
	return 0;
}

void hoge(string &s, vector<pair<int,int>> &t){
	
	for(int i = 0, num = 0; i < s.size(); i++){
		switch(s[i]) {
			case '(': t.push_back({1,0}); break;
			case ')': t.push_back({2,0}); break;
			case '+': t.push_back({3,0}); break;
			case '-': t.push_back({4,0}); break;
			case '*': t.push_back({5,0}); break;
			default : 
				num = num * 10 + s[i] - '0';
				if(i + 1 == s.size() || '0' > s[i+1] && s[i+1]){
					t.push_back({0,num});
					num = 0;
				}
		}
	}
}

signed main(){
	
	vector<pair<int,int>> t;
	string s;
	
	int ans =  numeric_limits<long long>::min();
	
	cin>>s;
	
	hoge(s, t);
	
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				x[0] = i;
				x[1] = j;
				x[2] = k;
				ans = max(solve(t, 0, t.size()), ans);
			}
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    string s;
    string a[7]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
    cin>>s;
    for(i64 i=0;i<7;i++){
        if(s==a[i]) cout<<i+1<<endl; 
    }
    return 0;
}


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

namespace ABC123D
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var X = input[0];
            var Y = input[1];
            var Z = input[2];
            var K = input[3];
            var cakeA = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(x => x).ToArray();
            var cakeB = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(x => x).ToArray();
            var cakeC = Console.ReadLine().Split(' ').Select(long.Parse).OrderByDescending(x => x).ToArray();

            var list = new List<long>();
            foreach (var i in Enumerable.Range(0, X))
                foreach (var j in Enumerable.Range(0, Y))
                    foreach (var k in Enumerable.Range(0, Z))
                    {
                        if ((i + 1) * (j + 1) * (k + 1) > K) break;
                        list.Add(cakeA[i] + cakeB[j] + cakeC[k]);
                    }

            foreach (var cake in list.OrderByDescending(x => x).Take(K))
            {
                Console.WriteLine(cake);
            }
        }
    }
}

Measured memory_bytes: 23484
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		long[] a = new long[N];
		for(int i=0;i<N;i++)a[i]=Long.parseLong(sc.next());
		Arrays.sort(a);

		HashMap<Long,Integer> map=new HashMap<>();
		
		for(int i=0;i<N;i++){
			if(map.containsKey(a[i])) {
				map.put(a[i],1+map.get(a[i]));
			}else {
				map.put(a[i],1);
			}
		}

		long res = 0;
		for(int i=N-1;i>=0;i--){
			if(map.get(a[i])==0) continue;
			map.put(a[i],map.get(a[i])-1);
			long diff=2*Long.highestOneBit(a[i])-a[i];
			if(map.containsKey(diff) && map.get(diff)>0){
				res++;
				map.put(diff,map.get(diff)-1);
			}
		}
		System.out.println(res);

	}

}

Measured memory_bytes: 77628
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(n-1):
	s, t = map(int, input().split())
	adj[s-1].append(t-1)
	adj[t-1].append(s-1)
par = [-1 for _ in range(n)]
aff = [0 for _ in range(n)]

def dfs(x, p):
	for v in adj[x]:
		if v == p:
			continue
		aff[x] += 1
		par[v] = x
		dfs(v, x)
	return
dfs(0, -1)
af_lis = [[] for _ in range(n)]
zero = [i for i in range(n) if aff[i] == 0]

def check(x):
	if af_lis[x] == []:
		af_lis[par[x]].append(a[x])
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	s, ma = sum(af_lis[x]), max(af_lis[x])
	if ma*2 > s:
		s_mi = ma
	else:
		s_mi = (s+1)//2
	if s_mi <= a[x] <= s:
		if par[x] == -1:
			if len(af_lis[x]) > 1 and 2*a[x] != s:
				print("NO")
				sys.exit()
			elif len(af_lis[x]) == 1 and a[x] != s:
				print("NO")
				sys.exit()
			return
		af_lis[par[x]].append(2*a[x] - s)
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	else:
		print("NO")
		sys.exit()
		return

while zero:
	check(zero.pop())

print("YES")

Measured memory_bytes: 98976
// Daniel Grzegorzewski15
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 5*(int)1e5 + 3;
const int SQ = 700;

int n, q, wyn, c[N], cnt[N], res[N];
vector<pair<PII, int>> que;

bool cmp(pair<PII, int> x, pair<PII, int> y) {
  if (x.ST.ST/SQ != y.ST.ST/SQ)
    return x.ST.ST < y.ST.ST;
  return x.ST.ND > y.ST.ND;
}

int main() {
  init_ios();
  cin >> n >> q;
  for (int i = 1; i <= n; ++i)
    cin >> c[i];
  for (int i = 1; i <= q; ++i) {
    int l, r;
    cin >> l >> r;
    que.PB({{l, r}, i});
  }
  sort(que.begin(), que.end(), cmp);
  int l = 1, r = 1;
  wyn = cnt[c[l]] = 1;
  for (auto el: que) {
    int le = el.ST.ST;
    int ri = el.ST.ND;
    int id = el.ND;
    while (le < l) {
      --l;
      ++cnt[c[l]];
      if (cnt[c[l]] == 1)
        ++wyn;
    }
    while (r < ri) {
      ++r;
      ++cnt[c[r]];
      if (cnt[c[r]] == 1)
        ++wyn;
    }
    while (l < le) {
      --cnt[c[l]];
      if (cnt[c[l]] == 0)
        --wyn;
      ++l;
    }
    while (ri < r) {
      --cnt[c[r]];
      if (cnt[c[r]] == 0)
        --wyn;
      --r;
    }
    res[id] = wyn;
  }
  for (int i = 1; i <= q; ++i)
    cout<<res[i]<<"\n";
}

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

//Erratic Sleep Habits
public class Main{

	int T, n, INF = 1<<29;
	int[] a, d;
	int[][] dp;
	
	int get(int k, int c){
		if(k==101)return 0;
		if(dp[k][c]!=-1)return dp[k][c];
		int res = get(k+1, 0)+1;
		int f = k+1, nc = (c+1)%T;
		for(;f<=100;f++, nc=(nc+1)%T){
			if(d[f]<a[nc])break;
			res = Math.min(res, get(f+1, 0)+1);
		}
		if(100<f)res = 0;
		return dp[k][c] = res;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			T = sc.nextInt();
			if(T==0)break;
			a = new int[T];
			for(int i=0;i<T;i++)a[i]=sc.nextInt();
			n = sc.nextInt();
			d = new int[101];
			Arrays.fill(d, INF);
			for(int i=0;i<n;i++){
				int x = sc.nextInt();
				d[x] = Math.min(d[x], sc.nextInt());
			}
			dp = new int[101][T];
			for(int[]p:dp)Arrays.fill(p, -1);
			System.out.println(get(1, 0));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

#define EPS 1.0e-6

int main(){
	int a, b, c, d, e, f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double x = 1.0*(e*c-b*f)/(e*a-b*d);
		double y = 1.0*(d*c-a*f)/(d*b-a*e);
		x += EPS;
		y += EPS;
		printf("%.3f %.3f", x, y);
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
"""

https://atcoder.jp/contests/abc173/tasks/abc173_e

クソだけどやろう

正負・0を分割

0がある場合は、最大を0に更新
0がN-K個より多い場合は即終了

残りの場合は、0を取らなくても構成できる場合のみ


"""

import sys
N,K = map(int,input().split())
A = list(map(int,input().split()))

pl = []
mi = []
znum = 0

if K == 1:
    print (max(A))
    sys.exit()

for i in A:
    if i > 0:
        pl.append(i)
    elif i == 0:
        znum += 1
    else:
        mi.append(i)

ans = float("-inf")
if znum > 0:
    ans = 0

#0にならざるを得ない場合を処理
if znum > N-K:
    print (ans)
    sys.exit()

#答えが負になる場合も処理する
#大きいほうからかけていけばいい
#N個の場合 or 正がない場合は負になりえない
mod = 10**9+7
pl.sort()
mi.sort()

if K == N:
    ans = 1
    for i in range(N):
        ans *= A[i]
        ans %= mod
    print (ans)
    sys.exit()

if K % 2 == 1 and len(pl) == 0:
    if znum > 0:
        ans = 0
    else:
        ans = 1
    mi.reverse()
    for i in range(K):
        ans *= mi[i]
        ans %= mod
    print (ans)
    sys.exit()

#まず、2個づつセットにすることを考える
#正負でセットにしていって、あまり同士も合成する

if K % 2 == 1:
    K -= 1
    ans = pl[-1]
    del pl[-1]
else:
    ans = 1

pl2 = []
pl.reverse()
if len(pl) % 2 == 1:
    pl.append(0)
if len(mi) % 2 == 1:
    mi.append(0)
for i in range(0,len(pl),2):
    pl2.append(pl[i] * pl[i+1])
for i in range(0,len(mi),2):
    pl2.append(mi[i] * mi[i+1])


pl2.sort()
pl2.reverse()
for i in range(K//2):
    ans *= pl2[i]
    ans %= mod
print (ans)

Measured memory_bytes: 113040
# include <bits/stdc++.h>
using namespace std;
long long n,k,k1;
string s;
int main()
{
	cin>>s;
	k=int(s[0]-'0')*10;
	k+=int(s[1]-'0');
	k1=int(s[2]-'0')*10;
	k1+=int(s[3]-'0');
	if (k==0 && k1==0) 
	{
		cout<<"NA"<<endl;
		return 0;
	}
	if (k>12 && k1>12)
	{
		cout<<"NA"<<endl;
		return 0;
	}
	if (k==0)
	{
		cout<<"YYMM"<<endl;
		return 0;
	}
	if (k1==0 && k>12)
	{
		cout<<"NA"<<endl;
		return 0;
	}
	if (k1==0)
	{
		cout<<"MMYY"<<endl;
		return 0;
	}
	if (k>12 && k1<=12)
	{
		cout<<"YYMM"<<endl;
		return 0;
	}
	if (k<=12 && k1<=12)
	{
		cout<<"AMBIGUOUS"<<endl;
		return 0;
	}
	if (k<=12 && k1>12)
	{
		cout<<"MMYY"<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    for(ll i = 0; i <= x; ++i){
        for(ll j = 0; j <= x; ++j){
            for(ll k = 0; k <= x; ++k){
                if(i+j+k > x)continue;
                if(a *pow(2, i) < b*pow(2, j) && b*pow(2, j) < c*pow(2, k)){
                    cout << "Yes";
                    return 0;
                }
            }
        }
    }

    cout << "No";
}

Measured memory_bytes: 4096
fun main(args: Array<String>) = abc161d()

fun abc161d() {
    val k = readLine()!!.toInt()

    val list = (1..9L).toMutableList()
    var before = list.toList()

    repeat(9) {
        val next = before.map { curr ->
            val max = Math.min(curr % 10 + 1, 9)
            val min = Math.max(curr % 10 - 1, 0)
            (min..max).map { curr * 10 + it }
        }.flatten()
        list.addAll(next)
        before = next
    }

    val answer = list.sorted()[k - 1]

    println(answer)
}


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

using namespace std;

const int maxn = 1e5 + 20;
int a[maxn];

int main()
{
    int n, c, k, co = 0, jav = 0;
    cin >> n >> c >> k;

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

    sort(a, a + n);

    for (int i = 0; i < n - 1; i ++)
    {
        if (i - co + 2 > c || a[i + 1] > a[co] + k)
        {
            jav += 1;
            co = i + 1;
        }

    }
    cout << jav + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
import math

mod = 1000000007

def solve():
    S = int(input())
    if S <= 2:
        print(0)
        exit()
    n = S // 3
    ans = 0
    for i in range(n):
        if i == 0:
            ans += 1
        else:
            r = i + 1
            h = math.factorial((S - 3 * r) + (r - 1)) // (math.factorial(S - 3 * r) * math.factorial(r - 1))       
            ans += h
    print(ans % mod)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 73416
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a[32]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}

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

int main()
{
	string S;
	cin >> S;
	int n = S.size();
	for (int i = n - 2; i >= 0; i -= 2) {
		if (S.substr(0, i / 2) == S.substr(i / 2, i / 2)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System; 
using System.Text;
using System.Collections.Generic; 
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    //最短ステップ記録用
    static List<int> Num;
    static int N;
    static List<int> A;
    static void Main(string[] args) {
        //入力を受け取る
        var NK = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
        N  = NK[0];
        var K  = NK[1];
        var D = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
        A = new List<int>(){0,1,2,3,4,5,6,7,8,9};
        
        foreach(int num in D){
            A.Remove(num);
        }
        Num = new List<int>();
        CombNum("");
        var ans = Num.Where(num => num >= N);
        
      Console.WriteLine(ans.Min());
     }
     
     static void CombNum(string str){
         if(N.ToString().Length == str.Length){
             
             Num.Add(int.Parse(str));
             foreach(int item in A){
             CombNum(str+item.ToString());
             }
         }else if (N.ToString().Length < str.Length){
             
             Num.Add(int.Parse(str));
         }else{
             foreach(int item in A){
             CombNum(str+item.ToString());
             }
         }
     }
     
     
     }
     
     
                   


Measured memory_bytes: 14428
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int n;
  cin  >> n;
  cout << "ABC" + to_string(n) << endl;
  return 0;
} 

Measured memory_bytes: 3672
input_list = input()
out_list=list()
for i in range(len(input_list)):
    if input_list[i] == "0":
        out_list.append('0')
        i +=1
    elif input_list[i] == "1":
        out_list.append('1')
        i +=1
    else:
        if not len(out_list)==0:
            out_list.pop()
for j in out_list:
    print(j,end="")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;

int gcd(int x, int y){
  return y ? gcd(y, x%y) : x;
}

int print(int x, int y){
  int g = gcd(x, y);
  cout << x/g << "/" << y/g << endl;
}

main(){
  string in; cin >> in;
  int o, p, l, r, d;
  p = -1;
  string all, sub;
  for ( int i = 0; i < in.size(); i++ ){
    if ( in[i] == '.' ){
      o = i;
    } else if ( in[i] == '(' ) {
      p = i;
      sub = all;
    } else if ( in[i] == ')' ) {
    } else {
      all += in[i];
    }
  }
  d = in.size() - o - 1;
  l = p - o - 1;
  if ( p == -1 ){
    print(atoi(all.c_str()), pow(10, d));
  }else {
    d -= 2; // for ()
    print(atoi(all.c_str()) - atoi(sub.c_str()), pow(10, d) - pow(10, l) );
  }
}





Measured memory_bytes: 3396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];
    sort(all(p));
    reverse(all(p));
    sort(all(q));
    reverse(all(q));
    vector<ll> v;
    rep(i,x) v.push_back(p[i]);
    rep(i,y) v.push_back(q[i]);
    rep(i,c) v.push_back(r[i]);
    sort(all(v));
    reverse(all(v));
    ll ans=0;
    rep(i,x+y) ans+=v[i];

    cout<<ans<<endl;

} 


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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x_start = 0;
    int x_end = w;
    int y_start = 0;
    int y_end = h;
    for (int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            if (x - x_start >= 0) x_start = x;
        } else if (a == 2) {
            if (x_end - x >= 0) x_end = x;
        } else if (a == 3) {
            if (y - y_start >= 0) y_start = y;
        } else if (a == 4) {
            if (y_end - y >= 0) y_end = y;
        }
    }
    if (x_end - x_start < 0) {
        x_end = x_start;
    }

    if (y_end - y_start < 0) {
        y_end = y_start;
    }
    cout << (x_end - x_start) * (y_end - y_start) << endl;
    return 0;
}


Measured memory_bytes: 3612
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    sx, sy, tx, ty = map(int, readline().split())

    S = [0] * 4
    S[0] = 'U' * (ty - sy + 1)
    S[1] = 'R' * (tx - sx + 1)
    S[2] = 'D' * (ty - sy + 1)
    S[3] = 'L' * (tx - sx + 1)
    S = ''.join(S)

    ans = ''.join([S[1:], S[:1], S[-1:], S[:-1]])
    print(ans)

    return


if __name__ == '__main__':
    main()


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

int main() {
	int n,h1,h2;
  	cin >> n;
  	
  	h1 = n/500;
  	h2 = (n-h1*500)/5;
  	cout << h1 * 1000 + h2 * 5 << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n,m,k = map(int, input().split())
mod = 998244353
ans = 0
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
#a/b = a*(b`)となるb`を求める
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod
combi = [0 for i in range(n)]
combi[0] = 1
for i in range(1,n):
    combi[i] = (combi[i-1]*(n-i)*mod_inv(i,mod)) % mod
for i in range(k+1):
    plus = m * pow(m-1,n-1-i,mod)
    plus *= combi[n-i-1]
    plus %= mod
    ans += plus
    ans %= mod
print(ans)

Measured memory_bytes: 93252
#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 repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
#define maxn 100020

struct node2{
	int x,y,s;
}dt[maxn];
struct node{
	int next,to,s;
}e[maxn * 2];
int head[maxn],cnt;
int n,m,fa[maxn];
ll mx,ans,mn;
ll f[maxn],g[maxn];

inline void adde(int x,int y,int w){
	e[++cnt].to = y;
	e[cnt].next = head[x];
	e[cnt].s = w;
	head[x] = cnt;
}
int getfa(int x){ return fa[x] == x ? x : fa[x] = getfa(fa[x]); }
void dfs(int x,int fa){
	fore(i,x){
		if ( e[i].to == fa ) continue;
		f[e[i].to] = -f[x] , g[e[i].to] = e[i].s - g[x];
		if ( f[e[i].to] < 0 ){
		   	mx = min(mx,(ll)ceil((double)-g[e[i].to] / f[e[i].to]) - 1);
		}
		if ( g[e[i].to] < 0 ){
			mn = max(mn,(ll)floor((double)-g[e[i].to] / f[e[i].to]) + 1);
		}
		dfs(e[i].to,x);
	}
}
void init(){
	rep(i,1,n) fa[i] = i;
	rep(i,1,m){
		int x = dt[i].x , y = dt[i].y;
		int p = getfa(x) , q = getfa(y);
		if ( p != q ){
			fa[p] = q;
			adde(x,y,dt[i].s) , adde(y,x,dt[i].s);
		}
	}
	f[1] = 1 , g[1] = 0 , dfs(1,0);
}
ll check(){
//	rep(i,1,n) cout<<f[i]<<" "<<g[i]<<endl;
	rep(i,1,m){
		int x = dt[i].x , y = dt[i].y; ll s = dt[i].s;
		if ( f[x] + f[y] == 0 ){
			if ( g[x] + g[y] != s ) return mx = 0;
		}
		else{
			if ( (s - g[x] - g[y]) % (f[x] + f[y]) ) return mx = 0;
			ll cur = (s - g[x] - g[y]) / (f[x] + f[y]);
			if ( (ans != -1 && cur != ans) || cur < 1 ) return mx = 0;
			ans = cur;
		}
	}
	return 1;
}
int main(){
	ans = -1 , mn = 1 , mx = 1e9;
	scanf("%d %d",&n,&m);
	rep(i,1,m) scanf("%d %d %d",&dt[i].x,&dt[i].y,&dt[i].s);
	init();
	check();
	if ( mx < mn ) printf("0\n");
	else if ( ans != -1 ){
		printf("1\n");
	}
	else{
		printf("%lld\n",max(0ll,mx - mn + 1));
	}
}


Measured memory_bytes: 13440
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int n;
	cin>>n;
	double even=n/2;
	double odd=n-even;
	double ans=odd/n;
	cout << fixed << setprecision(6) << ans <<endl; 
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q1();
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            string T = S.Substring(0, S.Length / 2);
            if (T + T == S && (T+T).Length == N)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

ll gcd(ll a, ll b){
	if(b==0)return a;

	return gcd(b, a%b);
}


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

struct edge {
	int to; ll cost;
};

vector<edge> tree[114514];
ll depth[114514];
int q, k, x,y, n;

void dfs(int v, int p, ll d){
	depth[v] = d;
	for(auto &e : tree[v]){
		if(e.to == p) continue;

		dfs(e.to, v, d + e.cost);
	}
}

int main(){
	cin >> n;
	rep(i, n-1) {
		int a,b,c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		tree[a].push_back({b,c});
		tree[b].push_back({a,c});
	}
	cin >> q >> k;
	k--;

	dfs(k, -1,0);

	rep(i, q) {
		scanf("%d %d", &x, &y);
		x--;y--;
		cout << depth[x] + depth[y] << endl;	
	}

}

Measured memory_bytes: 14592
s = input()
a = ['R', 'U', 'D']
b = ['L', 'U', 'D']

def judge():
    for i in range(len(s)):
        if i%2==0 and s[i] not in a:
            return False
        if i%2==1 and s[i] not in b:
            return False
    return True

if judge():
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
char a[10001],x;
int wei=0;
int main() {
	while(cin>>x)
		if(x=='B') {
			if(wei!=0)wei--;
		}
		else {
			wei++;
			a[wei]=x;
		}
	for(int i=1; i<=wei; i++)
		cout<<a[i];
	cout<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long[] a = new long[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextLong());
			long[] sum = new long[n];
			sum[0] = a[0];
			IntStream.range(1, n).forEach(i -> sum[i] = (sum[i - 1] + a[i]) % MOD);
			long answer = 0L;
			for (int i = 0; i < n - 1; i++) {
				answer = (answer + a[i] * (sum[n - 1] - sum[i]) % MOD) % MOD;
			}
			System.out.println((answer + MOD) % MOD);
		}
	}
}


Measured memory_bytes: 61320
#include<cstdio>
#include<cstdlib>
#include<cstring>

using namespace std;

int stack[200];
int pointer;

void init() { pointer = -1; }

void push(int data) {
	pointer++;
	stack[pointer] = data;
}

int pop() {
	int ret = stack[pointer];
	pointer--;
	return ret;
}

int main() {
	init();

	char str[15];
	while (scanf("%s", str) != EOF) {
		if (str[0] == '+') {
			int b = pop();
			int a = pop();
			push(a + b);
		}
		else if (str[0] == '-') {
			int b = pop();
			int a = pop();
			push(a - b);
		}
		else if (str[0] == '*') {
			int b = pop();
			int a = pop();
			push(a * b);
		}
		else {
			int num = atoi(str);
			push(num);
		}
	}

	printf("%d\n", pop());

	return 0;
}


Measured memory_bytes: 2764