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

#define INF 1000000001
using namespace std;


struct point{
    double x,y;
};

bool kock(int depth,const point &p1,const point &p2){
    static double pi = 3.14159265358979;
    if(depth == 0) return true;
    point s,t,u;
    s.x = (2*p1.x + p2.x)/3;    s.y = (2*p1.y + p2.y)/3;
    t.x = (p1.x + 2*p2.x)/3;    t.y = (p1.y + 2*p2.y)/3;
    u.x = cos(pi/3)*(t.x-s.x) - sin(pi/3)*(t.y-s.y) + s.x;
    u.y = sin(pi/3)*(t.x-s.x) + cos(pi/3)*(t.y-s.y) + s.y;

    kock(depth-1,p1,s);
    printf("%.6lf %.6lf\n",s.x,s.y);
    kock(depth-1,s,u);
    printf("%.6lf %.6lf\n",u.x,u.y);
    kock(depth-1,u,t);
    printf("%.6lf %.6lf\n",t.x,t.y);
    kock(depth-1,t,p2);
    
}


int main(){
    int depth;
    scanf("%d",&depth);
    point p1,p2;
    p1.x = 0;  p1.y = 0;
    p2.x = 100;p2.y = 0;
    printf("%.6lf %.6lf\n",p1.x,p1.y);
    kock(depth,p1,p2);
    printf("%.6lf %.6lf\n",p2.x,p2.y);
    

    return 0;   
}



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

int main(){
  string s ; cin >> s ;
  int cnt_t = 0 ;
  int cnt_s = 0 ;
  int ans = 0 ;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='S') cnt_s++ ;
    else{
      if(cnt_s==0) ans++ ;
      else cnt_s-- ;
    }
  }
  int n = s.size() ;
  for(int i=0;i<s.size();i++){
    if(s.at(n-1-i)=='T') cnt_t++ ;
    else{
      if(cnt_t==0) ans++ ;
      else cnt_t-- ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                Set<Integer> set = new HashSet<>();
                for(; N > 0; N--){
                        int num = sc.nextInt();
                        set.add(num);
                }   
                System.out.print(set.size());
        }   
}

Measured memory_bytes: 22740
def main():
    n = int(input())
    buttons = [int(input()) for i in range(n)]

    histories = [0] * n

    now_button = 0
    histories[now_button] = 1
    count = 0

    while True:
        now_button = buttons[now_button]-1
        count += 1
        if histories[now_button] == 1:
            ans = -1
            break

        histories[now_button] = 1
        if now_button == 1:
            ans = count
            break

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  double w, h, x, y; cin >> w >> h >> x >> y;
  long double ans = h/2.0*w;
  bool frg = false;
  if(w/2.0==x && h/2.0==y) frg = true;
  printf("%.10Lf\n", ans);
  frg ? cout << 1 << endl : cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)

{

int n,ai,i;

long long int x,y,z;

x=1000000;

y=-1000000; z=0;

scanf("%d",&n);

for(i=1;i<=n;i++)

{

scanf("%d",&ai);

if(ai>y)

{

y=ai;

}

if(ai<x)

{

x=ai;

}

z=z+ai;

}

printf("%d %d %ld\n",x,y,z);

return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main(){ 
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll cnt = min(k, x / d);
  x -= cnt * d;
  k -= cnt;
  ll res = abs(x);
  if (k & 1) res = abs(d - res);
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3632
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 1
if a.include?(0)
	ans = 0
else
		a.each do |i|
		ans *= i
	 if ans > 10**18
	 		ans = "-1"
	 		break
	end
	end
end
puts ans

Measured memory_bytes: 21592
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
AB = [LIST() for i in range(N)]
CD = [LIST() for i in range(M)]
ans = []
for a, b in AB:
    i = 0
    num = 0
    mi = 10 ** 9
    for c, d in CD:
        dist = abs(a - c) + abs(b - d)
        if mi > dist:
            num = i
            mi = dist
        i += 1
    ans.append(num + 1)

print(*ans, sep="\n")

Measured memory_bytes: 10532
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

bool cmp(const pair<int , int> &a , const pair<int , int> &b){
    return (a.first < b.first);
}



int main()
{
    weewoo;
    string x;
    cin >> x;
    char c = x[0];
    for(int i=0;i<x.size();i++){
        if(c!=x[i])
            return cout << "Yes" << endl,0;
    }
    cout << "No"<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int a, b; cin >> a >> b&&a;) {
		int n; cin >> n;
		int dp[20][20] = {};
		rep(i, 0, n) {
			int x, y; cin >> x >> y;
			x--; y--;
			dp[x][y] = -1;
		}
		dp[0][0] = 1;
		rep(x, 0, a)rep(y, 0, b) {
			if (dp[x + 1][y] != -1 && dp[x][y] != -1)dp[x + 1][y] += dp[x][y];
			if (dp[x][y + 1] != -1 && dp[x][y] != -1)dp[x][y + 1] += dp[x][y];
		}
		cout << dp[a - 1][b - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int dp[17][17];
  int x,y,n;
  while( cin >> x >> y , x + y ){

    fill(dp[0], dp[17], 0 );
    dp[1][1] = 1;

    int a,b;
    cin >> n;
    for( int i = 0 ; i < n ; i++ ){
      cin >> a >> b;
      dp[b][a] = -1; // 通れないを -1      
    }

    for( int i = 1 ; i <= y ; i++ ){
      for( int j = 1 ; j <= x ; j++ ){
	if( dp[i][j] != -1 ){
	  if( i != 1 && dp[i - 1][j] != -1 )
	    dp[i][j] += dp[i - 1][j];
	  if( j != 1 && dp[i][j - 1] != -1 )
	    dp[i][j] += dp[i][j - 1];
	}
      }
    }
    cout << dp[y][x] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
long long n,i,sum;
long long a[200005],num[200005],res[200005];

int main(){
	cin>>n;
	
    for(i=1;i<=n;i++){
		cin>>a[i];
		num[a[i]]++;
	}
	
	for(i=1;i<=200000;i++)
	   sum=sum+(num[i]*num[i]-num[i])/2;
	
    for(i=1;i<=200000;i++)
	   res[i]=sum-num[i]+1;
	
	for(i=1;i<=n;i++) 
	   cout<<res[a[i]]<<endl;
	
	return 0;
}

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

using namespace std;

int main(void){
    while (1){
        int n;
        cin>>n;

        if(n==0)break;

        int a[1010];
        for(int i=0; i<n;i++){
            cin>>a[i];
        }
        sort(a, a+n);
        int min_a = INT_MAX;
        for(int i=1; i<n; i++){
            min_a = min(min_a, abs(a[i-1]-a[i]));
        }
        cout<<min_a<<endl;
    }


    return 0;


}


Measured memory_bytes: 3152
use std::io;

fn main() {

    let mut input = String::new();

    io::stdin().read_line(&mut input);
    let mut iter = input.split_whitespace();

    let a = iter.next().unwrap().parse::<i32>().unwrap();
    let b = iter.next().unwrap().parse::<i32>().unwrap();
    let c = iter.next().unwrap().parse::<i32>().unwrap();

    if a <= c && c <= b {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int n,a[21],b[21],c[20],sum,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++){
		scanf("%d",&b[i]);
	}
	for(i=1;i<n;i++){
		scanf("%d",&c[i]);
	}
	sum=0;
	for(i=1;i<=n;i++){
		sum+=b[a[i]];
		if(i!=1&&a[i]-a[i-1]==1){
			sum+=c[a[i-1]];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
int n,k,num[100010],mx;
set<int>hu;
int main()
{
    scanf("%d%d",&n,&k);
    ff(i,1,n)
    {
        scanf("%d",&num[i]);
        mx=max(num[i],mx);
    }
    sort(num+1,num+1+n);
    ff(i,1,n)
    {
        hu.insert(num[i]%num[1]);
    }
    if(k>mx)
    printf("IMPOSSIBLE");
    else
    {
        if(hu.count(k%num[1]))
        printf("POSSIBLE");
        else
         printf("IMPOSSIBLE");
    }
    return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    string fp1 = string(abs(y1 - y2), 'U') + string(abs(x1 - x2), 'R');
    string fp2 = string(abs(y1 - y2), 'D') + string(abs(x1 - x2), 'L');

    string fp3 = "L" + string(abs(y1 - y2) + 1, 'U') +
                 string(abs(x1 - x2) + 1, 'R') + "D";

    string fp4 = "R" + string(abs(y1 - y2) + 1, 'D') +
                 string(abs(x1 - x2) + 1, 'L') + "U";

    cout << fp1 + fp2 + fp3 + fp4 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,X,Y,Z = inpl()
x = sorted(inpl(), reverse = True)
y = sorted(inpl(), reverse = True)
z = sorted(inpl(), reverse = True)
x = x[:a]
y = y[:b]
apples = x + y + z
apples.sort(reverse = True)
print(sum(apples[:a+b]))

Measured memory_bytes: 124300
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
const int N = 1e5 + 5;
typedef long long ll; 
using namespace std;

int n, m, a[N], mx[N], ans, cnt; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++) a[i] = read <int> ();
	for(int i = n; i >= 1; i--) mx[i] = max(mx[i + 1], a[i]);
	for(int i = 1; i <= n; i++)
		if(mx[i + 1] - a[i] > 0 && mx[i + 1] - a[i] > ans) ans = mx[i + 1] - a[i], cnt = 1;
		else if(mx[i + 1] - a[i] == ans) cnt++;
	printf("%d\n", cnt); 
	return 0; 
}


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

int main() {
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  else if (b == 'C') cout << 'G' << endl;
  else if (b == 'G') cout << 'C' << endl;
  else if (b == 'T') cout << 'A' << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;

int N, K, C;
bool S[200010];
char str[200010];

int up[200010];
int down[200010];

int down_cnt[200010];
int up_cnt[200010];

signed main()
{
	cin >> N >> K >> C;
	cin >> str;
	REP(i, N)
	{
		S[i] = (str[i] == 'o');
	}

	int cur = -1;
	for (int i = N - 1; i >= 0; i--)
	{
		if (S[i])
			cur = i;
		else
			up[i] = cur;
	}

	cur = -1;
	for (int i = 0; i < N; i++)
	{
		if (S[i])
			cur = i;
		else
			down[i] = cur;
	}

	for (int i = 0; i < N; i++)
	{
		if (S[i])
		{
			int n = i - (C + 1);
			if (n < 0)
			{
				down_cnt[i] = 1;
			}
			else
			{
				int a = n;
				if (!S[n])
				{
					a = down[n];
				}
				if (a >= 0)
				{
					down_cnt[i] = down_cnt[a] + 1;
				}
			}
		}
	}


	for (int i = N - 1; i >= 0; i--)
	{
		if (S[i])
		{
			int n = i + (C + 1);
			if (n >= N)
			{
				up_cnt[i] = 1;
			}
			else
			{
				int a = n;
				if (!S[n])
				{
					a = up[n];
				}
				if (a >= 0)
				{
					up_cnt[i] = up_cnt[a] + 1;
				}
			}
		}
	}


	for (int i = 0; i < N; i++)
	{
		if (S[i])
		{
			int d = 0;
			if (i > 0)
			{
				int a = i - 1;
				if (!S[a])
				{
					a = down[a];
				}
				if (a >= 0)
				{
					d = down_cnt[a];
				}
			}

			int u = 0;
			if (i < N - 1)
			{
				int a = i + 1;
				if (!S[a])
				{
					a = up[a];
				}
				if (a >= 0)
				{
					u = up_cnt[a];
				}
			}

			if (d + u < K)
			{
				int s = down_cnt[i] + up_cnt[i] - 1;
				if (s >= K)
				{
					cout << (i + 1) << endl;
				}
			}
		}
	}

}




Measured memory_bytes: 6912
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) a.begin(),a.end()
using namespace std;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int diff = 1000;
	for (int i = 0;i <= n - 3;i++) {
		int x = abs(((s[i]-'0') * 100 + (s[i + 1]-'0') * 10 + (s[i + 2]-'0'))-753);
		if (x < diff) {
			diff = x;
		}
	}
	cout << diff << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,j,ycnt,xcnt,cnt;
	char s[100001];
	scanf("%d",&n);
	scanf("%s",s);
	ycnt=0;	xcnt=0;
	for(i=0;i<n;i++)	{
		if(s[i]>='A' && s[i]<='M')	ycnt++;
		else if(s[i]>='N' && s[i]<='Z')	ycnt--;
		else if(s[i]>='a' && s[i]<='m')	xcnt++;
		else xcnt--;
	}
	if(ycnt>0)	cnt=ycnt;
	else cnt=-ycnt;
	if(xcnt>0)	cnt+=xcnt;
	else cnt-=xcnt;
	if(cnt==0)	printf("0\n");
	else {
		printf("%d\n",cnt);
		if(ycnt>0)	{
			for(i=0;i<ycnt;i++)	printf("A");
		}
		else {
			for(i=0;i>ycnt;i--)	printf("N");
		}
		if(xcnt>0)	{
			for(i=0;i<xcnt;i++)	printf("a");
		}
		else {
			for(i=0;i>xcnt;i--)	printf("n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using i64 = int64_t;
using u64 = uint64_t;
using f64 = double;
using f80 = __float80;

int main(){
  ll n;
  cin >> n;
  ll ans = 1000000000;
  rep(i, n){
    ll tmp, cnt = 0;
    cin >> tmp;
    while(tmp%2 == 0){
      tmp /= 2;
      cnt++;
    }
    if(ans > cnt)ans = cnt;
  }
  cout << ans << endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

ll g(ll n, ll p) {
    if (n <= 1) return 0;
    return n/p + g(n/p, p);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll n; std::cin >> n;
    if (n & 1) {
        std::cout << 0 << "\n";
    } else {
        std::cout << min(g(n, 2), g(n/2, 5)) << "\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int main(){
  int n, m, x, y, xx, yy, ans;
  std::cin >> n >> m;
  vector<pii> t(n + 1);
  t[n].first = t[n].second = 1e9 + 7;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &t[i].first, &t[i].second);
  }
  sort(t.begin(), t.end());
  for (int i = 0; i < m; i++) {
    ans = 0;
    scanf("%d %d %d %d", &x, &y, &xx, &yy);
    for (int j = 0; j < n; j++) {
      if(x <= t[j].first and t[j].first <= xx){
        if(y <= t[j].second and t[j].second <= yy)ans++;
      }else if(x < t[j].first){
        break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

ll b[200010];
int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,s.size()){
    if(s[i] == '+')ans++;
    else ans --;
  }
  cout << ans << endl;
}
  





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

int main(){
	
    int a,b,c;
	
    cin>> a >> b >> c;
	
	if(a>b){
		
		swap(a,b);
		
	}
	if(a>c){
		
		swap(a,c);
		
	}
	if(b>c){
		
    	swap(b,c);
		
	}


	cout<<a<<" "<<b<<" "<<c<<endl;
	
	return 0;
}







Measured memory_bytes: 3116
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int n, m;
	vector<int> move(3);
	cin >> n >> m >> move[0] >> move[1] >> move[2];
	SORT(move);
	vector<vector<int>> route(n + 1);

	REP(i, m){
		int a, b;
		cin >> a >> b;
		route[a].push_back(b);
	}
	int ans = -1;
	vector<vector<vector<bool>>> step(n + 1, vector<vector<bool>>(n + 1, vector<bool>(3, false)));
	FOR(i, 1, n){
		vector<int> now;
		now.push_back(i);
		REP(j, move[2]){
			int ns = now.size();
			vector<int> now2;
			set<int> si;
			REP(k, ns){
				REP(l, route[now[k]].size()){
					if (si.find(route[now[k]][l]) == si.end()){
						now2.push_back(route[now[k]][l]);
						si.insert(route[now[k]][l]);
					}
				}
			}
			now = now2;
			if (j == move[0] - 1)
				REP(k, now.size())
				step[i][now[k]][0] = true;
			if (j == move[1] - 1)
				REP(k, now.size())
				step[i][now[k]][1] = true;
			if (j == move[2] - 1)
				REP(k, now.size())
				step[i][now[k]][2] = true;
		}
	}
	vector<vector<int>> goalto(n+1,vector<int>(3,10000));
	goalto[n][0] = 0;
	goalto[n][1] = 0;
	goalto[n][2] = 0;
	vector<bool> memo(n+1, false);
	memo[n] = true;
	queue<pair<int,int>> qii;
	qii.push({ 0,n });
	while (!qii.empty()){
		pair<int,int> num = qii.front(); qii.pop();
		REP(i,n){
			REP(j,3){
				if (step[i][num.second][j]){
					if (goalto[i][j] ==10000){
						goalto[i][j] = num.first + 1;
						if (!memo[i]&&goalto[i][0] != 10000 && goalto[i][1] != 10000 && goalto[i][2] != 10000){
							qii.push({ max(goalto[i][0], max(goalto[i][1], goalto[i][2])), i });
							memo[i] = true;
						}
					}
				}
			}
		}
	}

	REP(i,3){
		if (goalto[1][i] == 10000){
			ans = -1;
			break;
		}
		ans = max(ans, goalto[1][i]);
	}
	if (ans != -1)
		cout << ans << endl;
	else
		cout << "IMPOSSIBLE" << endl;
}

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

int n, h, w, a;
vector<int> x, v;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> h >> w;
	x.resize(n);
	for(auto &i:x) cin >> i;
	v.resize(n*w+1);
	for(int i=0; i<n; ++i){
		int f = (i%2 == 0 ? 1 : -1);
		v[w*i+f*x[i]]++;
		v[w*i+f*x[i]+w]--;
	}
	for(int i=1; i<v.size(); ++i)
		v[i] += v[i-1];
	for(int i=0; i<v.size()-1; ++i)
		if(v[i] == 0)
			++a;
//	for(int i=0; i<v.size(); ++i)
//		cout << i << " " << v[i] << "\n";
	cout << a * h << "\n";
}


Measured memory_bytes: 3228
N = int(input())
A = list(map(int, input().split()))
m = {}
targets = []
for a in A:
    m.setdefault(a, 0)
    m[a] += 1
    if m[a] == 2:
        targets.append(a)

if len(targets) < 2:
    print(0)
else:
    targets.sort(reverse=True)
    if m[targets[0]] >= 4:
        print(targets[0]*targets[0])
    else:
        print(targets[0]*targets[1])


Measured memory_bytes: 18060
INF = float("inf")

def interval_scheduling(A):
    A.sort(key=lambda x: x[1])

    res = []
    cur = -INF
    for s, t in A:
        if cur <= s:
            cur = t
            res.append((s, t))

    return res

N, *XL = map(int, open(0).read().split())

A = [(x - l, x + l) for x, l in zip(*[iter(XL)] * 2)]
print(len(interval_scheduling(A)))

Measured memory_bytes: 31472
N = int(input())
a = list(map(int,input().split()))

count = 0
A = 0
B = 0

while count < N+1 and len(a) >0: 
	m = max(a)
	A += m
	a.remove(m)  
	if len(a) > 0:
		m = max(a)
		B += m
		a.remove(m)
	count +=1

print(A - B)

Measured memory_bytes: 3064
function Main(input) {
    input = input.replace(/[^ACGT]/g,"_");
    input = input.split("_");
    var len = 0
    for(var i of input){
      if(len < i.length)len = i.length
    }
    console.log(len)
    return 0
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<stdio.h>
#include<numeric>
#include<ios>
#include<cmath>
#include<string>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<assert.h>
#include<bitset>
#include<tuple>
#include<climits>
#include<deque>
#include<utility>
#include<unordered_map>
#include<unordered_set>
#include<iterator>
#include<sstream>
#include<iomanip>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int>
#define vpii           vector<pair<int,int>>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x:a) cin>>x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
   nitro
   int a,b;cin>>a>>b;
   cout<<(a+b)%24;
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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 int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int main() {

	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;

	if (w > v) {
		cout << "NO" << endl;
		return 0;
	}

	ll c = abs(a - b);
	ll d = (v - w)*t;
	if (d < c) {
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;



}

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

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    map<string, int> dic;
    for(int i=0; i<n; i++) {
        string tmp; cin >> tmp;
        dic[tmp]++;
    }

    cout << dic.size() << endl;

    return 0;
}

Measured memory_bytes: 19152
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int x,a[210000]={0},n,temp,q,b,c,i;
long long int sum=0;
	scanf("%d",&n);
	


printf("%lld\n",n+n*n+n*n*n);
return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
const int INF = 0x3f3f3f3f;

int main(){
	int n;
	scanf("%d",&n);
	if(n >= 400 && n < 600) printf("8\n");
	if(n >= 600 && n < 800) printf("7\n");
	if(n >= 800 && n < 1000) printf("6\n");
	if(n >= 1000 && n < 1200) printf("5\n");
	if(n >= 1200 && n < 1400) printf("4\n");
	if(n >= 1400 && n < 1600) printf("3\n");
	if(n >= 1600 && n < 1800) printf("2\n");
	if(n >= 1800 && n < 2000) printf("1\n");
	return 0;
}

Measured memory_bytes: 3760
import itertools
N, K = map(int, input().split())
d_list = []
A = []
a_set = set()
al_set = {i for i in range(1, N+1)}
for i in range(K):
    d_list.append(int(input()))
    A.append(list(map(int, input().split())))
for i in itertools.chain.from_iterable(A):
    a_set.add(i)
print(len(al_set - a_set))

Measured memory_bytes: 9216
// #define FNAME "template"

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

typedef long long inte;
#define int long long
const int maxn = 55, maxm = 105, maxp = 3005, inf = 0x1f1f1f1f1f1f1f1fll;

#ifndef NDEBUG
#    define dprint(x) (cerr << (#x) << " = "<< (x) << endl)
#else
#    define dprint(x) (NULL)
#endif

template<typename T>
inline void readFig(T& x)
{
#   ifdef FTREAD
        static int c = 0;
        int op = 1;
        x = 0;
        while (!isdigit(c)) {
            if (c == '-')
                op = -1;
            c = getchar();
        }
        while (isdigit(c)) {
            x *= 10;
            x += c - '0';
            c = getchar();
        }
        x *= op;
#   else
        cin >> x;
#   endif
}

int N, M, S;

int C[maxn], D[maxn];

struct Edge {
    int nxt, v, w, x;
} edges[maxm * 2];
int head[maxn] = {0}, newp = 0;
inline void addEdge(int u, int v, int w, int x)
{
    edges[++newp].v = v;
    edges[newp].w = w;
    edges[newp].nxt = head[u];
    edges[newp].x = x;
    head[u] = newp;
}

int dis[maxn][maxp + 1];
bool vis[maxn][maxp + 1] = {0};
typedef pair<int, pair<int, int> > DPoint;
int cnt = 0;
void diji()
{
    priority_queue<DPoint, vector<DPoint>, greater<DPoint> > q;
    q.push(make_pair(0, make_pair(1, min(S, maxp - 1))));
    while (!q.empty()) {
        int u = q.top().second.first, s = q.top().second.second, d = q.top().first;
        q.pop();
        if (vis[u][s])
            continue;
        // cout << u << ' ' << s << endl;
        dis[u][s] = d;
        vis[u][s] = true;
        q.push(make_pair(d + D[u], make_pair(u, min(maxp - 1, C[u] + s))));
        for (int i = head[u]; i; i = edges[i].nxt) {
            if (s - edges[i].x >= 0 && d + edges[i].w < dis[edges[i].v][s - edges[i].x])
                ++cnt, q.push(make_pair(d + edges[i].w, make_pair(edges[i].v, s - edges[i].x)));
        }
        //cout << cnt / 100 << endl;
    }
}

inline void solve()
{
    memset(dis, 0x1f, sizeof(dis));
    readFig(N); readFig(M); readFig(S);
    for (int i = 1; i <= M; ++i) {
        int u, v, w, x;
        readFig(u); readFig(v); readFig(x); readFig(w);
        addEdge(u, v, w, x);
        addEdge(v, u, w, x);
    }
    for (int i = 1; i <= N; ++i) {
        readFig(C[i]); readFig(D[i]);
        C[i] = min(C[i], maxp - 1);
    }
    diji();
    for (int i = 2; i <= N; ++i) {
        int t = inf;
        for (int j = 0; j < maxp; ++j) {
            t = min(t, dis[i][j]);
        }
        cout << t << endl;
    }
}

signed main()
{
#   ifdef FNAME
        freopen(FNAME".in", "r", stdin);
        freopen(FNAME".out", "w", stdout);
#   endif
#   ifndef FTREAD
    	ios::sync_with_stdio(false);
    	cin.tie(0);
#   endif

#   ifdef MULTEST
        int T;
        readFig(T);
        while (T--)
            solve();
#   else
        solve();
#   endif

#   ifdef FNAME
        fclose(stdin);
        fclose(stdout);
#   endif
    	return 0;
}



Measured memory_bytes: 10924
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
$v = explode(" ", $stdin[0]);


if($v[0] % 2 == 0 && $v[1] % 2 == 0){
  $hidari = $v[0] / 2;
  $migi = $v[1] / 2;
  $ans = $hidari + $migi;
}elseif($v[0] % 2 == 1 && $v[1] % 2 == 1){
  $hidari = $v[0] / 2;
  $migi = $v[1] / 2;
  $ans = $hidari + $migi;
}else{
  $ans = "IMPOSSIBLE";
}






echo $ans . PHP_EOL;






Measured memory_bytes: 3828
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
def main():
    N,M = map(int,input().split())
    A = [0 for i in range(M)]
    B = [0 for i in range(M)]
    for i in range(M):
        A[i],B[i] = map(int,input().split())
        
    uf = UnionFind(max(N,M))
    for i in range(M):
        a = A[i]-1
        b = B[i]-1
        uf.union(a, b)
        
    ans = 1
    for i in range(M):
        ans = max(ans,uf.size(i))
        
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 30024
// include all standard library.
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(int argc, char const *argv[]) {
  int x, n;
  vector<int> p;
  cin >> x >> n;
  if( n == 0) { cout << x << endl; return 0;}

  for(int i=0; i < n;i++){
      int k;
      cin >> k;
      p.push_back(k);
  }

  // 数列pに含まれない整数でxに最も近いものをプリント
  // 複数ある時は小さいものを答える．
  sort(p.begin(), p.end());
  for( int i=0 ; i< p[n-1]+1; i++) {
      int zantei_1 = x + i;
      int zantei_2 = x - i;
      // cout << zantei_1 << ", " << zantei_2 << endl;

      if(!binary_search(p.begin(), p.end(), zantei_2)) {
          cout << zantei_2 << endl;
          return 0;
      }
      if(!binary_search(p.begin(), p.end(), zantei_1)) {
          cout << zantei_1 << endl;
          return 0;
      }      
  }

  return 0;
}


Measured memory_bytes: 3636
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int n;
    public static int MAX = 500000;
    public static long a[] = new long[MAX + 1];

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

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] v = new int[N + 1];
        int[] w = new int[N + 1];
        int[][] dp = new int[N + 1][W + 1];
        for(int i = 1; i <= N; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }
        for(int i = 1; i <= N; i++) {
            for(int j = 1; j <= W; j++) {
                if(j < w[i]) dp[i][j] = dp[i - 1][j];
                else dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
            }
        }
        System.out.println(dp[N][W]);

        //??????
    }

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 32840
sa = list(input())
sb = list(input())
sc = list(input())

s = {'a':sa, 'b':sb, 'c':sc}
nxt = 'a'

while 1:
  if len(s[nxt]) == 0:
    break
  nxt = s[nxt].pop(0)
print(chr(ord(nxt)-32))

Measured memory_bytes: 3060
n=int(input())
b=list(map(int,input().split()))
ba=[]#右からの距離を足したやつ
for i in range(n):
    if len(ba)<b[i]-1:
        print(-1)
        break
    else:
        ba.insert(b[i]-1,b[i])
else:
    for i in range(n):
        print(ba[i])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  int N,M; cin >> N >> M;
  int P[N+1][N+1] = {};
  int a, b;
  rep(i,M){
    cin >> a >> b;
    P[a][b] = 1;
    P[b][a] = 1;
  }
  vector<int> A(N);
  rep(i,N) A[i] = i + 1;

  int cnt = 0;
  do{
    if (A[0]!=1) continue;

    bool possible = true;
    for (int i=0;i<N-1;i++) {
      if (P[A[i]][A[i+1]]==0) possible = false; 
    }
    
    if (possible) cnt++;
  }while(next_permutation(all(A)));

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long prm[78498]={2,3},n,m,cnt=2;
	int judge;
	for(n=5;n<=999999;n+=2) {
		judge=1;
		for(m=0;prm[m]*prm[m]<=n;m++) {
			if(n%prm[m]==0) {
				judge=0;
				break;
			}
		}
		if(judge) {
			prm[cnt++]=n;
		}
	}
	while(scanf("%ld",&n)!=EOF) {
		for(cnt=0;prm[cnt]<=n;cnt++){}
		printf("%ld\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1216
import kotlin.math.ceil

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (a, b, c, d) = readIntList()
    println(if (ceil(c.toDouble() / b) <= ceil(a.toDouble() / d)) "Yes" else "No")
}


Measured memory_bytes: 36396
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
// #define INF 100000000
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
string stin() {string s;cin>>s;return s;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}

const ll MOD=1e9+7;
const int N=1100000;
 
vecll p;
ll solve(ll x,int d,int t){
    if(d==1){
        if(x==0)return 10;
        else return 0;
    }
    if(d==0)return x==0;
    ll res=0;
    ll T = (p[d-1]-1);
    rep2(j,-9,9){
        if((x-T*j)%10==0){
            res+=(9-abs(j)+t)*(solve((x-T*j)/10,d-2,1));
        }
    }
    return res;
}


int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
    ll d=lin();
    p=vecll{1};
    rep(i,18)p.pb(p.back()*10);
    ll ans=0;
    rep2(i,2,18){
        ans+=solve(d,i,0);
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
import numpy as np

n = int(input())
a = np.array(list(map(int,input().split())))

mod = 10**9 + 7
ans = 0

for j in range(60):
    li = (a >> j) & 1
    i = np.count_nonzero(li)
    o = n - i
    ans += i*o*2**j
    ans %= mod

print(ans % mod)

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

int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int main()
{
    long n,a[100000],b[100000],i,j,suma = 0,sumb = 0,oridiff[100000],diff[100000],ans = 0;
    scanf("%ld",&n);
    for (i = 0; i < n; i++)scanf("%ld",&a[i]);
    for (i = 0; i < n; i++)scanf("%ld",&b[i]);

    for (i = 0; i < n; i++)
    {
        suma += a[i];
        sumb += b[i];
        diff[i] = a[i] - b[i];
    }

    if(suma < sumb)printf("-1\n");
    else
    {
      int mi = 0,pi = n - 1;
      qsort(diff,n,sizeof(long),asc);

      for (j = 0; j < n; j++)
      {
        oridiff[j] = diff[j];
      }
      for (i = 0; i < n; i++)
      {
        if(diff[mi] >= 0)break;
        if(-diff[mi] >= diff[pi])
        {
          diff[mi] += diff[pi];
          diff[pi] -= diff[pi];
          pi--;
        }
        else
        {
          diff[pi] += diff[mi];
          diff[mi] -= diff[mi];
          mi++;
        }
      }
      for (i = 0; i < n; i++)
      {
        if(diff[i] != oridiff[i])ans ++;
      }
      printf("%ld\n",ans);
    }
}


Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
int ans[3002][3002];
/*int functions(string s,string t,int len1,int len2)
{
    if(len1==-1||len2==-1)
    {
        ans[len1+1][len2+1]=0;
        return 0;
    }
    if(ans[len1+1][len2+1]!=-1)
    return ans[len1+1][len2+1];
    if(s[len1]==t[len2])
    {
        //cout<<ans<<endl;
        //return (1+functions(s,t,len1-1,len2-1));
        ans[len1+1][len2+1]=1+functions(s,t,len1-1,len2-1);
    }
    else
    ans[len1+1][len2+1]=max(functions(s,t,len1,len2-1),functions(s,t,len1-1,len2));
    return ans[len1+1][len2+1];
}*/
int main(void)
{
    string s,t;
    cin>>s>>t;
    int len1=s.size();
    int len2=t.size();
    for(int i=0;i<=len1;i++)
    for(int j=0;j<=len2;j++)
    ans[i][j]=0;
    for(int i=0;i<len1;i++){
        for(int j=0;j<len2;j++){
            if(s[i]==t[j])
            {
                ans[i+1][j+1]=ans[i][j]+1;
            }
            else{
                ans[i+1][j+1]=max(ans[i][j+1],ans[i+1][j]);
            }
        }
    }
    /*int maximum=functions(s,t,len1-1,len2-1);
    //cout<<maximum<<endl;
    int i=len1;
    int j=len2;
    string first;*/
    /*for(int i=0;i<=len1;i++){
        for(int j=0;j<=len2;j++)
        cout<<ans[i][j]<<" ";
        cout<<endl;
    }*/
    int i=len1;
    int j=len2;
    string first;
    while(ans[i][j]!=0)
	{
		//printf("Hello world\n");
	   //printf("%d %d\n",i,j);
		if(t[j-1]==s[i-1])
		{
			first+=s[i-1];
			i--;
			j--;
		}
		else{
			int f=max(ans[i][j-1],ans[i-1][j]);
			if(f==ans[i][j-1]&&f!=ans[i-1][j])
			{
				j--;
			}
			else
			{
				i--;
			}
        }
    }
    reverse(first.begin(),first.end());
    cout<<first<<endl;
}

Measured memory_bytes: 35584
/**Bismillahir Rahmanir Rahim**/


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

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag,l,x,k,dif;

string s,str;


ll a[200007],b[200007];
int main()
{

   io;
cin>>n>>m; a[0]=n+m;
 a[1]=n-m;
 a[2]=n*m;
 sort(a,a+3);
 cout<<a[2];
return 0;
}





Measured memory_bytes: 3660