akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
using namespace std;

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

	for(int n; cin >> n && n;) {
		vector<pair<int, int>> swimmers(n);
		vector<int> t(n), c(n);

		for(auto &e : swimmers) {
			cin >> e.first >> e.second;
		}

		sort(swimmers.begin(), swimmers.end());
		set<pair<int, int>> go, back;
		for(int i = 0; i < n; ++i) {
			go.insert({swimmers[i].first, i});
		}

		while(true) {
			int time = INT_MAX;
			bool go_turn;
			set<int> S;

			if(!go.empty()) {
				time = go.begin()->first;
				go_turn = true;
			}
			if(!back.empty() && time > back.begin()->first) {
				time = back.begin()->first;
				go_turn = false;
			}

			if(go_turn) {
				while(!go.empty() && time == go.begin()->first) {
					S.insert(go.begin()->second);
					go.erase(go.begin());
				}

				const int arrival = (back.empty() ? 0 : back.rbegin()->first);
				for(const auto &e : S) {
					back.insert({max(arrival, time + swimmers[e].first), e});
				}
			}
			else {
				while(!back.empty() && time == back.begin()->first) {
					S.insert(back.begin()->second);
					back.erase(back.begin());
				}

				const int arrival = (go.empty() ? 0 : go.rbegin()->first);
				for(const auto &e : S) {
					if(--swimmers[e].second == 0) continue;
					go.insert({max(arrival, time + swimmers[e].first), e});
				}

				if(go.empty() && back.empty()) {
					cout << time << endl;
					break;
				}
			}
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1208
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
res = 0
for i in range(1,N+1):
    tmp1 = A1[:i]
    tmp2 = A2[i-1:]
    res = max(res,sum(tmp1)+sum(tmp2))
print(res)

Measured memory_bytes: 3060
object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n = s.nextInt
		val a = Array.fill(n)(s.nextLong)
		for(i <- 0 to n - 2) {
			if(a(i) < 0) {
				a(i) *= -1
				a(i + 1) *= -1
			}
		}
		val sum = a.sum
		val f = if(a(n - 1) >= 0) 0
		else a(n - 1) * -2 + a.map(math.abs).min * -2
		println(sum + f)
	}
}


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

int main(){
  int N; string S;
  cin >> N >> S;

  if (N % 2 == 1){
    cout << "No"<< endl;
    return 0;
  }

  string S1 = S.substr(0, N/2);
  string S2 = S.substr(N/2);

  if(S1 == S2){
    cout << "Yes" << endl;
  } else {
    cout << "No"<< endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int zero=0,one=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0')
            zero++;
        if(s[i]=='1')
            one++;
    }
    int mi=min(zero,one);
    cout<<2*mi<<endl;
    return 0;
}


Measured memory_bytes: 512
import math

def lec(a, b):
    # aとbの最小公倍数
    return a * b // math.gcd(a, b)

def cal_num(a, b, x):
    # a ~ bの数値の中にxの倍数が入っている数
    if b >= x:
        x_cum = b // x - (a-1) // x
    else:
        x_cum = 0
    return x_cum

if __name__ == "__main__":
    A, B, C, D = map(int, input().split())

    CD = lec(C, D)
    C_num = cal_num(A, B, C)
    D_num = cal_num(A, B, D)
    CD_num = cal_num(A, B, CD)
    answer = B - A + 1 - C_num - D_num + CD_num

    print(answer)

Measured memory_bytes: 9144
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
int main() {
	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	priority_queue<double> pq;
	for(int i=0;i<n;i++){
		cin>>v[i];
		pq.push(v[i]);
	}
	for(int i=0;i<k;i++){
		int x = pq.top();
		pq.pop();
		pq.push(x/2);
	}
	long ans=0;
	while(!pq.empty()){
		ans+=round(pq.top());
		pq.pop();
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1784
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        print("F")
    else:
        s=m+f
        if s>=80:
            print("A")
        if 65<=s<80:
            print("B")
        if 50<=s<65:
            print("C")
        if 30<=s<50:
            if r>=50:
                print("C")
            else:
                print("D")
        if s<30:
            print("F")


Measured memory_bytes: 5592
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N, A, B;
    cin >> N >> A >> B;
    
    int count = 0;
    FOR(n, 1, N+1)
    {
        int r = 0;
        int n_ = n;
        while(n_ >= 1)
        {
            r += (n_ % 10);
            n_ /= 10;
        }
        if ( A <= r && r <= B) count += n; 
    }
    cout << count << endl;
    return 0;
}



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

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> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    double W=(double)w,H=(double)h;
    cout<<fixed<<setprecision(10)<<W*H/2;
    cout<<" "<<(w==2*x&&h==y*2?"1":"0")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace  std ;
int main ()
  {
  long long int k,a,b,i,c=0;
  cin>>k>>a>>b;
  for(i=a;i<=b;i++){
    if(i%k==0)
      c++;
    }
  if(c>=1)
    cout<<"OK"<<endl;
  else 
    cout<<"NG"<<endl;
  
  return 0;
  }

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,ans;
ll x[52],y[52];
int main()
{
	scanf("%d",&n);
	ans=n;
	for(int i=1;i<=n;i++)scanf("%lld%lld",&x[i],&y[i]);
	for(int i=1;i<n;i++)
	for(int j=i+1;j<=n;j++)
	{
		ll dx=x[i]-x[j],dy=y[i]-y[j];
		int sum=0;
		for(int k=1;k<=n;k++)
		{
			int flag=1;
			for(int l=1;l<=n;l++)if(x[k]-x[l]==dx&&y[k]-y[l]==dy){flag=0;break;}
			sum+=flag;
		}
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#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))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<vector<ll>> a(n,vector<ll>(3));
    rep(i,n){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    vector<vector<ll>> dp(n,vector<ll>(3));
    rep(i,n){
        rep(j,3){
            if(i==0){
                dp[i][j]=a[i][j];
                continue;
            }
            rep(k,3){
                if(j==k) continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    ll ans=0;
    rep(i,3){
        ans=max(ans,dp[n-1][i]);
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 11136
s = list(range(1,14))
h = s[:]
c = s[:]
d = s[:]

n = int(input())

for i in range(n):
    type_k,num = map(str,input().split())
    if type_k == "S":
        s.remove(int(num))
    elif type_k == "H":
        h.remove(int(num))
    elif type_k == "C":
        c.remove(int(num))
    elif type_k == "D":
        d.remove(int(num))

for i in s:
    print("S {}".format(i))
for i in h:
    print("H {}".format(i))
for i in c:
    print("C {}".format(i))
for i in d:
    print("D {}".format(i))
    



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

ll a;
double b;

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

    cin >> a >> b;

    a *= ll(b * 100 + 0.5);
    a /= 100;

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<fstream>

using namespace std;

	ifstream fin;
	ofstream fout;

	//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1160&lang=jp

	int gomi = 0;

	int a[52][52] = {};
	int check(int, int);

	int main(){

		fin.open("input.txt");
		fout.open("output.txt");

		//		int w = 0, h = 0;
		int width = 0, height = 0;
		int count = 0;


		while (1){
			for (int i = 0; i < 50; i++)
				for (int j = 0; j < 50; j++)
					a[i + 1][j + 1] = 0;

			cin >> width >> height;
			if (width == 0 && height == 0)break;

			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
					//初期化
					gomi = a[i + 1][j + 1] = 0;

					cin >> a[i + 1][j + 1];
				}
			}

			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
					if (a[i + 1][j + 1] == 1){
						check(i + 1, j + 1);
						a[i + 1][j + 1] = 1;
						count++;
					}
				}
			}
			cout << count << endl;
			fout << count << endl;

			//初期化
			count = 0;
			for (int i = 0; i < height; i++){
				for (int j = 0; j < width; j++){
					a[i + 1][j + 1] = 0;
				}
			}
		}
	}

	int check(int y, int x){
		for (int i = -1; i <= 1; i++){
			for (int j = -1; j <= 1; j++){
				if (i + j != 0 || i - j != 0){
					if (a[y + i][x + j] == 1){
						a[y + i][x + j] = 0;
						check(y + i, x + j);
					}
				}
			}
		}
		return 0;
	}

/*	int check(int y, int x){
		if (a[y + 1][x] == 1){
			a[y + 1][x] = 0;
			check(y + 1, x);
		}
		//-----------------------------
		if (a[y][x + 1] == 1){
			a[y][x + 1] = 0;
			check(y, x + 1);
		}
		//-----------------------------
		if (a[y - 1][x] == 1){
			a[y - 1][x] = 0;
			check(y - 1, x);
		}
		//-----------------------------
		if (a[y][x - 1] == 1){
			a[y][x - 1] = 0;
			check(y, x - 1);
		}
		//-----------------------------
		if (a[y + 1][x + 1] == 1){
			a[y + 1][x + 1] = 0;
			check(y + 1, x + 1);
		}
		//-----------------------------
		if (a[y + 1][x - 1] == 1){
			a[y + 1][x - 1] = 0;
			check(y + 1, x - 1);
		}
		//-----------------------------
		if (a[y - 1][x + 1] == 1){
			a[y - 1][x + 1] = 0;
			check(y - 1, x + 1);
		}
		//-----------------------------
		if (a[y - 1][x - 1] == 1){
			a[y - 1][x - 1] = 0;
			check(y - 1, x - 1);
		}
		//-----------------------------
		return 0;
	}*/

Measured memory_bytes: 1440
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int t=0;t<T;t++) {
			int[][] hand = new int[2][9];
			for(int i=0;i<2;i++) {
				for(int j=0;j<9;j++) {
					hand[i][j] = sc.nextInt();
				}
			}
			double[][][] dp = new double[2][180][1<<9];
			int now = 0;
			int nex = 1;
			dp[0][0][(1<<9)-1] = 1;
			for(int i=0;i<9;i++) {
				for(int j=0;j<180;j++) {
					for(int h1=0;h1<(1<<9);h1++) {
						if (Integer.bitCount(h1) != 9 - i) {
							continue;
						}
						if (dp[now][j][h1] == 0) {
							continue;
						}
						for(int c1=0;c1<9;c1++) {
							if ((h1&(1<<c1)) == 0) {
								continue;
							}
							int n1 = hand[0][c1];
							int n2 = hand[1][i];
							if (n1 > n2) {
								dp[nex][j+n1+n2][h1&~(1<<c1)] += dp[now][j][h1] * (1D / (9 - i));
							}else{
								dp[nex][j][h1&~(1<<c1)] += dp[now][j][h1] * (1D / (9 - i));
							}
						}
					}
				}
				for(int j=0;j<180;j++) {
					for(int h1=0;h1<(1<<9);h1++) {
						dp[now][j][h1] = 0;
					}
				}
				now = 1 - now;
				nex = 1 - nex;
			}
			double win = 0;
			for(int i=86;i<180;i++) {
				win += dp[now][i][0];
			}
			double lose = limit(1 - win);
			win = limit(win);
			System.out.println(win + " " + lose);
		}
		System.gc();
	}

	public static double limit(double x) {
		if (x > 1) {
			return 1;
		}else if(x < 0) {
			return 0;
		}
		return x;
	}

}

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

int main(){
    ll a,b,count=0;
    cin >> a >> b;
    for (int i=a;i<=b;i++){
        string s = to_string(i);
        string l = s;
        reverse(l.begin(),l.end());
        if(s == l) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
// 	ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
	cin>>n;
	double d = 6.283185307179586232;
	printf("%.6lf\n",d*n);
	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>

int main(void)
{
    int num;
    int a[4][13]={0};
    char c;    
    char check;
    int i,j,k;

    scanf("%d",&num);
    while((check = getchar())!='\n');

    for(k=0;k<num;k++){
        scanf("%c %d",&c,&i);
        while((check = getchar())!='\n');
        switch(c){
            case 'S':
                a[0][i-1]=i;
                break;
            case 'H':
                a[1][i-1]=i;
                break;
            case 'C':
                a[2][i-1]=i;
                break;
            case 'D':
                a[3][i-1]=i;
                break;
        }
    }


    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j]!=j+1){
                if(i==0)
                    printf("S %d\n",j+1);
                else if(i==1)
                    printf("H %d\n",j+1);
                else if(i==2)
                    printf("C %d\n",j+1);
                else if(i==3)
                    printf("D %d\n",j+1);
            }
        }
    }

    return 0;

}   


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll n ,k;
	cin >> n >> k;
	ll ans = 0;
	if(k==0)
	{
		cout<<n*n<<endl;
		return 0;
	}
	for(int i = 1;i<=n;i++)
	{
		int hoge = n - n%i;
		hoge/=i;
		ans += max(0LL,hoge*(i-k));
		
		ans += max(0LL,n%i-k+1);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

const int maxn=3e5+10;
int n,k,a[maxn];

inline void change(){
	int pos=n;
	while(!a[pos])
		--pos;
	if(a[pos]==1){
		--a[pos];
	}
	else{
		--a[pos];
		for(int i=pos+1;i<=n;++i)
			a[i]=k;
	}
}
inline void work(){
	if(k==1){
		for(int i=(n+1)/2;i;--i)
			printf("1 ");
		puts("");
		return;
	}
	if(k%2==0){
		printf("%d ",k/2);
		for(int i=2;i<=n;++i)
			printf("%d ",k);
		puts("");
		return;
	}
	else{
		for(int i=1;i<=n;++i)
			a[i]=(k+1)/2;
		for(int i=n/2;i;--i)
			change();
		for(int i=1;i<=n&&a[i];++i)
			printf("%d ",a[i]);
		puts("");
	}
}

int main(){
	scanf("%d%d",&k,&n);
	work();
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const int INF=1e9;

int main(){
  ll n;
  cin>>n;
  vector<ll> a(n);
  ll s=0;
  rep(i,n){
    cin>>a[i];
    s+=a[i];
  }
  ll minx=s,sum=0;
  rep(i,n){
    sum+=a[i];
    minx=min(minx,abs(sum-(s-sum)));
  }
  cout<<minx <<endl;
  return 0;

}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;


int main(int argc, char *argv[])
{
	int k,x;
	cin >> k>>x;

	cout << ((k*500>=x) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 384
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
P = rl()

A = np.array(list(range(1, N+1)))
B = np.array(list(range(N, 0, -1)))

for i in range(1, N):
    x = P[i]
    A[x-1:] += i
    B[:x] += i

print(*A)
print(*B)
# 37


Measured memory_bytes: 16056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    string s;cin>>s;
    ll n=s.size();
    vi v(n);
    rep(i,n)v[i]=s[n-i-1]-'0';
    ll ans=0;
    bool c=false,d=false;
    rep(i,n){
        ll a=v[i],b=10-v[i];
        if(d){
            if(!c)a++;
            b--;
        }
        if(a<=b)c=true;
        else c=false;
        if(b<=a)d=true;
        else d=false;
        ans+=min(a,b);
    }
    if(d&&!c)ans++;
    out(ans);
}

Measured memory_bytes: 9220
#include <iostream>
#include <climits>
using namespace std;
#define MAX 100
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,d[MAX+10],p[MAX+10],color[MAX+10];
int W[MAX+10][MAX+10];

int prim()
{
  int v,k,mini,flag,u=0;
  for(int i=0;i<n;i++)
  {
      d[i]=INT_MAX;
      p[i]=-1;
  }
  d[0]=0;
  while(1)
  {
      mini=INT_MAX;
      flag=1;
      for(int i=0;i<n;i++)
      {
          if(d[i]<mini&&color[i]!=BLACK)
          {
              u=i;
              mini=d[i];
              flag=0;
          }
      }
      if(flag) break;
      color[u]=BLACK;
      for(v=0;v<n;v++)
      {
          if(W[u][v]!=INT_MAX&&color[v]!=BLACK)
          {
            if(d[v]>W[u][v])
            {
              d[v]=W[u][v];//更新当前点到最小生成树的距离
              p[v]=u;//每一轮都需要跑更新前驱结点
            }
          }
      }
  }
  int sum=0;
  for(int i=0;i<n;i++)
  {
      if(p[i]!=-1) sum+=W[i][p[i]];
  }
  return sum;
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
         int e;
         cin>>e;
         W[i][j]=(e==-1)?INT_MAX:e;
        }
        color[i]=WHITE;
    }
    cout<<prim()<<endl;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n,x,y;

int main(){
    cout << fixed << setprecision(10);
    cin >> n >> x >> y;
    x--; y--;
    map<int,int> mii;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            int now = 0;
            int root1 = j - i;
            int root2 = inf;
            root2 = abs(x-i) + 1 + abs(y-j);
            now = min(root1,root2);
            mii[now]++;
        }
    }
    rep(i,n-1){
        cout << mii[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, s, f, h[N], h2[N];
vi G[N];
int mark[N];

void DFS(int v, int H = 0){
	mark[v] = 1;
	h2[v] = H;
	for (auto u:G[v]){
		if (!mark[u] && u != s) DFS(u, H + 1);
	}	
	
}

void DFS1(int v, int p = 0, int H = 0){
	h[v] = H;
	for (auto u:G[v]){
		if (u == p) continue;
		if (mark[u]) DFS1(u, v, H + 1);
	}
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> f >> s;
	if (f == s) return cout << 0, 0;
	for (int i = 0; i < n - 1; i ++){
		int v, u;
		cin >> v >> u;
		G[v].pb(u);
		G[u].pb(v);
	}
	DFS(f);
	DFS1(s);
	ll Max = 0;
	for (int i = 1; i <= n; i++){
		if (h2[i] <= h[i] && h[Max] < h[i]) Max = i;
	}
	//cout << Max << '\n';
	ll res = h2[Max];
	ll bagh = h[Max] - h2[Max];
	if (bagh % 2 == 1) res += bagh - 1;
	else res += bagh - 1;
	cout << res;








	return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,A[100][100],color[100],d[100],f[100],time;

void visit(int u){
  int i;
  color[u]=GRAY;
  d[u]=++time;
  for(i=0;i<n;i++){
    if(A[u][i]==0)continue;
    if(color[i]==WHITE)visit(i);
  }
  color[i]=BLACK;
  f[u]=++time;
}

void dfs(){
  int i;
  for(i=0;i<n;i++){
    color[i]=WHITE;
  }
  time=0;

  for(i=0;i<n;i++){
    if(color[i]==WHITE)visit(i);
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }

}

int main(){

  int i,j,k,l,h;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&k,&l);
    for(j=0;j<l;j++){
      scanf("%d",&h);
      A[k-1][h-1]=1;
    }
  }

  dfs();
  return 0;
}



Measured memory_bytes: 2112
import java.util.*;

class Main{
	Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		
		
		findans();
	}
	static void findans(){
		Main app=new Main();
		
		while(app.sc.hasNext()){
			String temp[]=app.sc.nextLine().split(",");
			double BMI=(Double.parseDouble(temp[1])/Math.pow(Double.parseDouble(temp[2]),2));
			if(BMI>=25){
				System.out.println(temp[0]);
			}
		}
	}
	
}

Measured memory_bytes: 17168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]);
            int iB = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<int> lstRt = new List<int>();
            lstRt.Add(iA + iB);
            lstRt.Add(iA - iB);
            lstRt.Add(iA * iB);
            lstRt.Sort();                                   // 昇順

            // 出力
            Console.WriteLine("{0}", lstRt[2].ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vi a(n);
    cin >> a;
    int mx = 0;
    rep(i,n) chmax(mx,a[i]);
    if(mx < k) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int g = a[0];
    rep2(i,1,n) g = gcd(g,a[i]);
    cout << (k%g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxk 100111

typedef long long ll;
typedef long double ld;

int k;
int dp[maxk];
queue<int> q;

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

	memset(dp, 0x3f3f, sizeof(dp));
	for(int i = 1; i <= 9; i++){
		q.push(i);
		dp[i] = i;
	}

	while(!q.empty()){
		int val = q.front();
		q.pop();

		for(int i = 0; i <= 9; i++){
			int v = (val * 10 + i) % k;
			if(dp[v] > dp[val] + i){
				dp[v] = dp[val] + i;
					q.push(v);
			}
		}	
	}

	printf("%d\n", dp[0]);
	return 0;
}

Measured memory_bytes: 2176
/*input
1000000000

*/

#include <bits/stdc++.h>


using namespace std;

#define ll long long


vector<ll> prime(10001);
void SieveOfEratosthenes(ll n) 
{ 
    
    
    for(ll i=2;i<10001 && n>0;i++){
        while(n%i==0){
            prime[i]++;
            n = n/i;
        }
    }
    
} 


int main() {
    ll n;cin>>n;
    cout<<(n/500)*1000+((n%500)/5)*5<<endl;
    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<P> p(n);
  rep(i,0,n) {
    int a,b;
    cin >> a >> b;
    p[i] = P(a,b);
  }
  sort(p.begin(), p.end());
  priority_queue<int> q;
  int ans = 0;
  int j = 0;
  rep(i,1,m+1) {
    while(p[j].first == i) {
      q.push(p[j].second);
      j++;
      if (j == n) j = 0;
    }
    if (q.empty()) continue;
    int k = q.top(); q.pop();
    ans += k;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4648
n = open(0)
n = n.read()
l1 = "abcdefghijklmnopqrstuvwxyz"
l2 = [0]*26

for i in n:
   for j in range(len(l1)):
      if i == l1[j] or i == l1[j].upper():
         l2[j] += 1

for i in range(len(l1)):
   print(l1[i], ":", l2[i])




Measured memory_bytes: 5572
h, w, n = map(int, input().split())

if n == 0:
    print((h-2) * (w-2))
    for i in range(9):
        print(0)
    exit()

ab = [tuple(int(x) - 1 for x in input().split()) for _ in range(n)]

p = []

for a, b in ab:
    for x in range(max(0, a-2), min(h-3, a) + 1):
        for y in range(max(0, b-2), min(w-3, b) + 1):
            p.append([x, y])

p.sort()

#print(p)

ans = [0] * 10

c = 1
for i in range(len(p) - 1):
    if p[i] == p[i + 1]:
        c += 1
    else:
        ans[c] += 1
        c = 1
ans[c] += 1

ans[0] = (h - 2) * (w - 2) - sum(ans[1:])

for i in range(10):
    print(ans[i])

Measured memory_bytes: 150644
fun main(args:Array<String>) {
    val point = readLine()!!.toInt()
    val lines = readLine()!!.split(" ").map { it.toInt() }
    val longLine = lines.max()!!
    val otherTotal = lines.sum() - longLine

    if(longLine < otherTotal) {
        println("Yes")
    } else {
        println("No")
    }

}


Measured memory_bytes: 35988
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

ll dp[100010];
const int MOD = 1000000007;

int main(){
    int N,M;cin >> N >> M;
    vector<int> a(100010,0);
    rep(i,M){
        int b;cin >> b;
        //b--;
        a[b]++;
    }

    dp[0]=1;
    for(int i=0;i<N;i++){
        if(!a[i+1])dp[i+1]=(dp[i+1]+dp[i])%MOD;
        if(!a[i+2])dp[i+2]=(dp[i+2]+dp[i])%MOD;
    }
    cout << dp[N] << endl;
    return 0;
}

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

typedef long long ll;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef long double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

bool cmp_x(const P& a,const P& b){ return a.X==b.X?a.Y<b.Y:a.X<b.X; }
bool cmp_y(const P& a,const P& b){ return a.Y==b.Y?a.X<b.X:a.Y<b.Y; }
bool cmp_a(const P& a,const P& b){ return arg(a)==arg(b)?norm(a)<norm(b):arg(a)<arg(b); }
D cross(P a,P b){ return (conj(a)*b).Y; }
D dot(P a,P b){ return (conj(a)*b).X; }
D toRag(D deg){ return deg*PI/180.0; }
P rot(P base,P a,D theta){ return base+polar(abs(a-base),arg(a-base)+theta); }

struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

P crosspoint(L l,L m) {
  D A=cross(l[1]-l[0],m[1]-m[0]);
  D B=cross(l[1]-l[0],l[1]-m[0]);
  if (abs(A)<eps&&abs(B)<eps) return m[0]; // same line
  if (abs(A)<eps) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0]+B/A*(m[1]-m[0]);
}

D x[211],y[211];

int main(){
  int W,H,n;
  while(1){
    cin>>W>>H>>n;
    if(n==0)break;
    rep(i,2*n)cin>>x[i]>>y[i];
    x[2*n]=W; y[2*n]=H;
    x[2*n+1]=W; y[2*n+1]=0;
    vector<D> cand;
    rep(i,2*n+2)rep(j,i){
      L l=L(P(x[i],y[i]),P(x[j],y[j]));
      L yax=L(P(0,0),P(0,1));
      if(abs(cross(l[1]-l[0],yax[1]-yax[0]))<eps)continue;
      P p=crosspoint(l,yax);
      if(p.Y<0||p.Y>H)continue;
      cand.push_back(p.Y);
    }
    cand.push_back(0); cand.push_back(H);
    sort(all(cand));
    D res=0.0;
    rep(i,cand.size()-1){
      if(abs(cand[i]-cand[i+1])<eps)continue;
      vector<D> as;
      D mid=(cand[i]+cand[i+1])/2.0;
      rep(j,2*n+2)as.push_back(atan2(y[j]-mid,x[j]));
      sort(all(as));
      D lb=max((D)0.0,mid+(D)W*tan(as[n]));
      D ub=min((D)H,mid+(D)W*tan(as[n+1]));
      res+=max((D)0.0,ub-lb)*(cand[i+1]-cand[i]);
    }
    printf("%.11Lf\n", res/(D)(H*H));
  }
  return 0;
}



Measured memory_bytes: 3704
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;

  uint16_t max_pair = (N-1)*(N-2)/2;
  
  if (K > max_pair) {
    cout << -1 << endl;
    return 0;
  }

  vector<pair<uint8_t,uint8_t>> ans;

  for (uint8_t n=1; n<N; ++n)
    ans.push_back(make_pair(n,N));

  uint16_t count = 0;
  for (uint8_t ii=1; ii<N; ++ii) {
    for (uint8_t jj=ii+1; jj<N; ++jj) {
      if (max_pair-++count < K)
	break;
      ans.push_back(make_pair(ii,jj));
    }
  }

  cout << ans.size() << endl;
  for (auto& p : ans)
    cout << (uint16_t)p.first << ' ' << (uint16_t)p.second << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,q,j = 0, f = 0,count = 0;
	cin>>n;
	int S[n];
	for(int i = 0;i<n;i++){
		cin>>S[i];
	}
	cin>>q;
	int T[q];
	for(int i = 0;i<q;i++){
		cin>>T[i];
	}
	for(int i = 0;i<q;i++){
		int left = 0;
		int right = n;
		int mid;
		//cout<<"aho"<<endl;
		while(left<right){
			mid = (left +right)/2;
			if(S[mid] == T[i]){
				f = 1;
				//cout<<"iti"<<endl;
				break;
			}
			else if(T[i] <S[mid]){
				right = mid;
				//cout<<"ni"<<endl;
			}
			else{
				left = mid+1;
				//cout<<"san"<<endl;
			}
			//cout<<left<<" "<<right<<endl;
		}
		if(f == 1){
			count++;
		}
		f = 0;
		
	}
	cout<<count<<endl;
}


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

int b[200005], w[200005]; // i番目までの黒, 白の個数
int N;
string S;

int main() {
  
  cin >> N >> S;
  
  b[0] = 0;
  w[0] = 0;
  for(int i=0;i<N;++i) {
    w[i+1] = w[i] + (S[i] == '.' ? 1 : 0);
    b[i+1] = b[i] + (S[i] == '#' ? 1 : 0);
    // cout << b[i+1] << ' ' << w[i+1] << endl;
  }
  
  int ans = N;
  for(int i=0;i<=N;++i) {
    if(b[i]+(w[N]-w[i]) < ans) ans = b[i]+(w[N]-w[i]);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2172
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(i64, a, b, K);
    int cnt = 0;
    vector<int> buf;
    repc(i, 1, min(a, b)) {
        if (a % i == 0 && b % i == 0) {
            buf.push_back(i);
        }
    }

    reverse(all(buf));
    print(buf[K - 1]);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int sx, sy, tx, ty;

	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	tx -= sx;
	ty -= sy;
	for(int i=0; i < 4; i++) {
		if(i == 2) {
			tx++;   ty++;
		}
		if(i >= 2)
			printf((i % 2) ? "U" : "D");
		for(int j=0; j < tx; j++) {
			printf((i % 2) ? "L" : "R");
		}
		for(int j=0; j < ty; j++) {
			printf((i % 2) ? "D" : "U");
		}
		if(i >= 2)
			printf((i % 2) ? "R" : "L");
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s;
    cin>>s;

    ll ans = 0;
    ll n = s.size();
    bool flag = true;
    for(ll i=1;i<n;++i){
        if(s[i]-'0' != 9){
            flag = false;
            break;
        }
    }
    if(n == 1){
        ans += s[0]-'0';
    }else{
        ans += (n - 1) * 9;
        if(flag){
            ans += s[0]-'0';
        }else{
            ans += s[0]-'0' - 1;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int cnt[26] = {0};
    for (int i = 0; i < s.size(); i++) {
        cnt[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (cnt[i] & 1) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {

	int N;
	cin >> N;
	int t = N;
	int count = 0;
	
	
	
	while (t > 0)
	{
		//一桁目から見ていく
		count += t % 10;
		t = t / 10;
	}

	if (N % count == 0) cout << "Yes" << endl;
	else cout << "No" << endl;







}

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

int main(){
int t=0,s=0;;
string S,T;
cin >> S>>T;
for(int i=0; i<S.length()-T.length()+1; i++){
	t=0;
	for(int j=0; j<T.length(); j++){
		if(S.at(i+j)==T.at(j)) t++;
		if(s<t) s=t;
	}
}
cout << T.length()-s << endl;

}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int n;
    cin >> n;
    vector<int> input(n+1);
    vector<int> output(n+1);
    REP(i,1,n+1) cin >> input[i];
    REP(i,n/2+1,n+1) output[i] = input[i]; //後ろ半分は入力と同じ
    RREP(i,1,n/2+1){
        int mul=2;
        int sum=0;
        while(i*mul<=n){
            sum^=output[i*mul];
            mul++; 
        }
        output[i]=sum^input[i];
    }

    vector<int> ans;
    REP(i,1,n+1){
        if(output[i]==1){
            ans.push_back(i);
        }
    }
    P(ans.size());
    if(ans.size()!=0){
        REP(i,0,ans.size()){
            cout << ans[i];
            if(ans.size()-1!=i) cout << " ";
        }
    }
    cout << endl;
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cerr << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;
#define DBG(x) cerr << x << endl;

/*
	https://abc074.contest.atcoder.jp/tasks/abc074_a
*/
int n, a;
int solve()
{
	return n * n - a;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
	//freopen("tmp.out", "w", stderr);
#endif
    cin >> n >> a;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()

ans = True if s[0] == 'A' else False
num = 0
for i in range(1, len(s)):
    if s[i] == 'C' and i != len(s) - 1 and i != 1:
        num += 1
    elif ord(s[i]) <= ord('Z') and ord(s[i]) >= ord('A'):
        ans = False
        break

if num != 1:
    ans = False

print('AC' if ans else 'WA')


Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<pair<pair<ll, ll>, ll>> in;
  vector<ll> p(m), y(m);
  vector<ll> cnt(n + 1, 0), ans(m);

  for (int i = 0; i < m; i++) {
    cin >> p[i] >> y[i];
    in.push_back(make_pair(make_pair(y[i], p[i]), i));
  }
  sort(in.begin(), in.end());

  for (int i = 0; i < in.size(); i++) {
    cnt[in[i].first.second]++;
    ans[in[i].second] = cnt[in[i].first.second];
  }

  for (ll i = 0; i < m; i++) {
    cout << setfill('0') << right << setw(6) << p[i];
    cout << setfill('0') << right << setw(6) << ans[i];
    cout << endl;
  }

  return 0;
}


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

int main(){
    string a;
    cin >> a;
    if(a == "A"){
        cout << "T" <<endl;
    }
    else if(a == "T"){
        cout << "A" <<endl;
    }
    if(a == "G"){
        cout << "C" <<endl;
    }
    else if(a == "C"){
        cout << "G" <<endl;
    }
}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

def main():
    N,M=[int(x) for x in input().split()]

    jobs=defaultdict(list)
    for _ in range(N):
        a,b=[int(x) for x in input().split()]
        jobs[M-a].append(b)
    
    # print(jobs)

    hq=[]
    heapq.heapify(hq)
    ans=0
    for day in reversed(range(M)):
        for job in jobs[day]:
            heapq.heappush(hq, -job)

        if hq:
            ans+=-heapq.heappop(hq)

    print(ans)


main()

Measured memory_bytes: 104280
a,b,k=map(int,input().split())
tmp=[]

if a+k<b+1:
  e = a+k
else:
  e = b+1
for i in range(a,e):
  tmp.append(i)

if a<b-k+1:
  f = b-k+1
else:
  f = a
for i in range(f,b+1):
  tmp.append(i)

ans = sorted(set(tmp))
for i in ans:
  print(i)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  string ans="No";
  if(abs(a-c)<=d)ans="Yes";
  if(abs(a-b)<=d&&abs(b-c)<=d)ans="Yes";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 125568