akhauriyash/Code-Regression huggingface dataset:
s = list(raw_input())
K = int(raw_input())
for i in xrange(len(s)):
  if s[i] == 'a': continue
  d = ord('z') - ord(s[i]) + 1
  if K >= d:
    s[i] = 'a'
    K -= d
    
K %= 26
s[-1] = chr((ord(s[-1]) - ord('a') + K)%26 + ord('a'))
  
print "".join(s)

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

int main()
{
  ll n,m,l; cin >> n >> m >> l;
  ll A[101][101];
  ll B[101][101];
  ll C = 0;

  rep(i, n){
    rep(j, m){
      cin >> A[i][j];
    }
  }

  rep(j, m){
    rep(k, l){
      cin >> B[j][k];
    }
  }

  rep(i, n) {
    rep (j, l) {
      C = 0;
      rep (k, m) {
        C += A[i][k] * B[k][j];
      }
      cout << C;
      if (j != l-1) cout << " ";
    }
    cout << endl;
  }

  // rep (i, n) {
  //   rep (j, l) {
  //     cout << C[i][j];
  //     if (j != l-1) cout << " ";
  //   }
  //   cout << endl;
  // }

  return 0;
}


Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		int num = r * 100 + g * 10 + b;
		if(num % 4 == 0)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


Measured memory_bytes: 20820
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n, k;
	cin >> n >> k;
	pll* dt = new pll[n];
	rep(i, n) cin >> dt[i].second >> dt[i].first;
	sort(dt, dt + n);

	ll ans = 0, kk;
	map<ll, int> kind;
	deque<ll> stack;
	rep(i, k) {
		ans += dt[n - 1 - i].first;
		if (kind[dt[n - 1 - i].second] != 0) {
			stack.push_front(dt[n-1-i].first);
		}
		kind[dt[n - 1 - i].second] = 1;
	}
	 kk= kind.size()*kind.size();

	int x = n - 1 - k;
	ll sum = ans;
	ll _kk = 0;
	while (!stack.empty()) {
		if (x >= 0) {
			bool flag = false;

			sum -= stack.front();
			stack.pop_front();
			for (x; x >= 0; --x) {
				if (kind[dt[x].second] == 0) {
					kind[dt[x].second] = 1;
					sum += dt[x].first;
					_kk = kind.size()*kind.size();
					
					flag = true;
					break;
				}
			}

			if (flag) {
				if (ans + kk < sum + _kk) {
					ans = sum;
					kk = _kk;
				}
			}
		}
		else {
			break;
		}
	}

	cout << ans+kk << "\n";

	return 0;
}


Measured memory_bytes: 9372
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]


count = 0
for i in A:
  t = C
  for a,b in zip(i, B):
      t += a * b
  if t > 0:
      count += 1
print(count)

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

int main(){
  int n, k;
  int sum = 0;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0; i<n; i++){
  	cin >> p.at(i);
  }
  sort(begin(p),end(p));
  for(int i=0; i<k; i++){
  	sum += p.at(i);
  } 
  cout << sum << endl;
}

Measured memory_bytes: 3612
package main

import (
  "fmt"
  "sort"
)

func main() {
  var n int
  fmt.Scan(&n)
  d := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&d[i])
  }
  sort.Sort(sort.Reverse(sort.IntSlice(d)))

  ans := 1
  prev := d[0]
  for i := 1; i < n; i++ {
    if d[i] < prev {
      ans++
    }
    prev = d[i]
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
n=int(input())
a=[0]*n
b=[0]*(n-1)
b=list(map(int,input().split()))

a[0]=b[0]
for i in range(1,n-1):
  a[i]=min(b[i-1],b[i])
a[n-1]=b[n-2]

print(sum(a))

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

double v[55];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    sort(v, v + n);
    double a = v[0];
    for (int i = 1; i < n; i++)
        a = (a + v[i]) / 2;
    cout << a << endl;
}

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

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

int dp[9][(1<<8)]={};
vector<int> v;
int n,m,s;
int d[201][201];
int r[201]={};


//int calc(int s1,int d1){
//	if(dp[s1][d1]>0)return dp[s1][d1];
//	if(d1==(1<<s1))return 0;
//	int d2=d1-(1<<s1);
//	dp[s1][d1]=200000001;
//	for(int i=0;i<s;++i){
//		int k=(1<<i);
//		if((d2&k)==k)dp[s1][d1]=min(dp[s1][d1],d[r[s1]][r[i]]+calc(i,d2));
//	}
//	return dp[s1][d1];
//}
int main() {
	string s;
	cin>>s;
	char chr[]="abcdefghijklmnopqrstuvwxyz";
	int ls=s.length();
	int a[27]={};
	for(int i=0;i<ls;++i){
		int c=s[i]-97;
		a[c]++;
	}
	for(int i=0;i<26;++i){
		if(a[i]==0){
			cout<<chr[i]<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#define N 101


int main(){

  int M[N][N],n,i,j,a,b,k;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

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

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

 return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

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

    int n;
    cin >> n;

    vector<ld> x(n), y(n);
    vector<char> d(n);
    for (int i = 0; i < n; ++i)
        cin >> x[i] >> y[i] >> d[i];

    auto f = [&](const ld t) {
        pair<ld, ld> dx, dy;
        for (int i = 0; i < n; ++i) {
            ld vx = x[i], vy = y[i];

            if (d[i] == 'R') vx += t;
            else if (d[i] == 'L') vx -= t;
            else if (d[i] == 'U') vy += t;
            else if (d[i] == 'D') vy -= t;

            if (i == 0) {
                dx = make_pair(vx, vx);
                dy = make_pair(vy, vy);
            }
            else {
                dx.first = min(dx.first, vx);
                dx.second = max(dx.second, vx);
                dy.first = min(dy.first, vy);
                dy.second = max(dy.second, vy);
            }
        }
        return (dx.second - dx.first) * (dy.second - dy.first);
    };

    ld min_v = f(0), lb = 0, ub = 1e9;
    for (int i = 0; i < 200; ++i) {
        const ld t1 = (2.0 * lb + ub) / 3.0;
        const ld t2 = (lb + 2.0 * ub) / 3.0;

        min_v = min(min_v, f(t1));
        min_v = min(min_v, f(t2));

        if (f(t1) > f(t2)) lb = t1;
        else ub = t2;
    }

    cout << min_v << endl;

    return 0;
}


Measured memory_bytes: 3456
from math import log10

n = int(input())
m = int(log10(n)) + 1

ans = 0

def dfs(i, s):
    if i == m:
        if not '0' in str(int(s)) and all(a in s for a in '753') and int(s) <= n:
            return 1
        return 0
    res = 0
    for a in '0357':
        res += dfs(i+1, s + a)
    return res

print(dfs(0, ''))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int x[501];
vector<int> v;
signed main(){
	int a,b,sum=0;
	cin>>a>>b;
	f(i,a){
		cin>>x[i];
		sum+=x[i];
	}
	for(int i=1;i*i<=sum;i++){
		if(sum%i==0)v.push_back(i);
	}
	for(int i=v.size()-1;i>=0;i--){
		if((double)v[i]!=sqrt(sum)){
			v.push_back(sum/v[i]);
		}
	}
	for(int k=v.size()-1;k>=0;k--){
		int j=v[k];
		if(sum%j==0){
			vector<int> v1={},v2={};
			int z1=0,z2=0;
			f(i,a){
				if(x[i]%j<j/2){
					v2.push_back(x[i]%j);
					z2+=x[i]%j;
				}
				else{
					v1.push_back(j-(x[i]%j));
					z1+=j-x[i]%j;
				}
			}
			sort(all(v1));
			sort(all(v2));
			int vz=1;
			while(z1!=z2){
				if(z1>z2){
					z2+=j-v1[v1.size()-vz];
					z1-=v1[v1.size()-vz];
				}
				else{
					z1+=j-v2[v2.size()-vz];
					z2-=v2[v2.size()-vz];
				}
				vz++;
			}
			if(z1<=b){
				cout<<j<<endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  int sa[200000],ta[200000],k=0;
  char c[26];
  cin>>s>>t;
  for(int i=0;i<26;i++){
    c[i]='#';
  }
  for(int i=0;i<s.size();i++){
    for(int j=0;j<26;j++){
      if(c[j]==s[i]){
	sa[i]=j;
	break;
      }else if(j==25){
	c[k]=s[i];
	sa[i]=k;
	k++;
      }
    }
  }
  for(int i=0;i<26;i++){
    c[i]='#';
  }
  k=0;
  for(int i=0;i<t.size();i++){
    for(int j=0;j<26;j++){
      if(c[j]==t[i]){
	ta[i]=j;
	break;
      }else if(j==25){
	c[k]=t[i];
	ta[i]=k;
	k++;
      }
    }
  }
  for(int i=0;i<s.size();i++){
    if(s.size()!=t.size()){
      cout<<"No"<<endl;
      break;
    }
    if(sa[i]!=ta[i]){
      cout<<"No"<<endl;
      break;
    }
    else if(i==s.size()-1) cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 2312
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
    	Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 文字列の入力
		// 出力
		int buff = a*100 + b*10 + c;
		if(buff%4==0){
		  System.out.println("YES");  
		}else{
		   System.out.println("NO");  
		}
		
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,o,e) for(int i=o;i<e;i++)

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n,x,t;
	cin>>n>>x>>t;
	int m= n/x;
	if(n==m*x) cout<< m*t<<endl;
	else cout<< t*(m+1)<<endl;

	return 0;
}

Measured memory_bytes: 3548
n,m=map(int,input().split())

t=[-1]*n
for i in range(m):
  s,c=map(int,input().split())
  s-=1
  if t[s] != -1 and t[s] != c:
    print(-1)
    exit()
  t[s]=c

if n != 1:
  if t[0] == 0:
    print(-1)
    exit()
  if t[0] == -1:
    t[0]=1
  for i in range(1,n):
    if t[i] == -1:
      t[i] = 0
else:
  if t[0] == -1:
    t[0] = 0
print(''.join(map(str,t)))


Measured memory_bytes: 3064
#include <stdio.h>

 int main(void)
 {

 int a[10000], min, max, n, i;
 long long sum = 0;
 
scanf("%d", &n);


for(i = 0; i < n; i++)
{
 	scanf("%d", &a[i]);
 	sum = sum +  a[i];
 }
	 max = min = a[0];

for(i = 1; i < n; i++)
{
	if(a[i] > max)max = a[i];
 	if(a[i] < min)min = a[i];
 }
	
	 printf("%d %d %lld\n", min, max, sum);

 	
	return 0;

 }

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	static long N;
	static long ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int z=sc.nextInt();
		int semians=x/(y+z);
		if(x%(y+z)<z)semians-=1;
		System.out.println(semians);
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
const int maxv = 401;
const int inf = 1e9;

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<vector<int>> dp(maxv, vector<int>(maxv, inf));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;

    for (int j = maxv - 1 - a; j >= 0; j--) {
      for (int k = maxv - 1 - b; k >= 0; k--) {
        if (dp[j][k] == inf)
          continue;
        dp[j + a][k + b] = min(dp[j + a][k + b], dp[j][k] + c);
      }
    }
  }
  int ans = inf;
  for (int i = 1; i < maxv; i++) {
    for (int j = 1; j < maxv; j++) {
      if (i * mb == j * ma)
        ans = min(ans, dp[i][j]);
    }
  }
  if (ans == inf)
    ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
using namespace std;




int main() {
	int n,k;
	cin >> n >> k;
	
	unsigned long long int res = 0;
	
	
	while(n!=0){
		n /= k;
		res++;
	}
	cout << res << endl;
	
	
    return 0;
}


Measured memory_bytes: 256
// 復習
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll F(ll a, ll b) {
    return max(log10(a), log10(b)) + 1;
}

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

    ll n; cin >> n;
    ll ans = 1e5;
    for (ll i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) ans = min(ans, F(i, n/i));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int I=1000000007;
void Prime(int N,vector<int>& div){
	for(int i=2;i*i<=N;i++){
		while(N%i==0){
			div[i]++;
			N/=i;
		}
	}
	if(N!=1) div[N]++;
}
int main(){
   int N;
   cin>>N;
   vector<int> div(1001,0);
    for(int i=2;i<=N;i++){
        Prime(i,div);
        }
       
    long long int ans=1;
    for(int i=0;i<div.size();i++){
    	if(div[i]!=0){
    		ans*=(div[i]+1);
    		ans%=I;
    	}
    }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
num = int(input())

monsters_hp = [int(i) for i in input().split()]

attacker = 0

def attack(attacker, monsters_hp):
    for i in range(len(monsters_hp)):
        if i == attacker:
            continue
        else:
            monster_hp = monsters_hp[i]
            if monsters_hp[attacker] == 0:
                continue
            hp_mod = monster_hp % monsters_hp[attacker]
            monsters_hp[i] = hp_mod
    return monsters_hp

def calc_zero(monsters_hp):
    count = 0
    for monster_hp in monsters_hp:
        if monster_hp == 0:
            count += 1
    return count

def change_attacker(monsters_hp):
    minimum = calc_minimum(monsters_hp)
    for i in range(len(monsters_hp)):
        if monsters_hp[i] == minimum:
            return i
def calc_minimum(monsters_hp):
    minimum = monsters_hp[0]
    for i in range(len(monsters_hp)):
        if monsters_hp[i] == 0:
            continue
        elif minimum >= monsters_hp[i]:
            minimum = monsters_hp[i]
    if minimum == 0:
        minimum += 1
    return minimum

while True:
    attack(attacker, monsters_hp)
    attacker = change_attacker(monsters_hp)
    count = calc_zero(monsters_hp)
    if count == (len(monsters_hp) - 1):
        break

print(max(monsters_hp))

Measured memory_bytes: 14480
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int main(){
    int N, tmp, count = 0;
    vector<int> a;

    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> tmp;
        a.push_back(tmp);
    }

    for (int i = 0; i < N; i++){
        if (a[a[i]-1]==i+1) count++;
    }
    cout << count/2 << endl;

    return 0;
}


Measured memory_bytes: 892
#include <iostream>

int main()
{
    std::int64_t x;
    std::cin >> x;

    int count = 0;
    for (std::int64_t n = 100; n < x; ++count)
    {
        n = static_cast<decltype(n)>(n * 1.01);
    }

    std::cout << count << std::endl;
}


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

namespace abc_163c
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] EmpNo = new int[int.Parse(Console.ReadLine())];

            string[] GMNo = Console.ReadLine().Split(' ');
            for(int i=0;i < GMNo.Length; i++)
            {
                
                EmpNo[int.Parse(GMNo[i])-1] += 1;
                
            }

            foreach(int item in EmpNo)
            {
                Console.WriteLine(item);
            }

            Console.Read();
        }
    }
}


Measured memory_bytes: 42008
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

const int MAX_N = 2010;
const int MAX_M = 2010;
ll d[MAX_N][MAX_M + 1];

int main() {
  ll x,y,z;

  cin >> x >> y >> z;
  ll p;
  p = x;
  x = y;
  y = p;
  p = z;
  z = x;
  x = p;

  cout << x << " " << y << " " << z;
}

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

int main(){
  ll n;
  cin>>n;
  map<ll,ll> p;
  rep(i,n){
    ll a;
    cin>>a;
    p[a]++;
  }
  ll ans=0;
  for(auto x:p){
    if(x.second>=x.first){
      ans+=x.second-x.first;
    }
    else{
      ans+=x.second;
    }
  }
  cout<<ans<<endl;
}




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

string s;

int main(void){
	cin >> s;
	int n=s.size();
	int cnt=1;
	int len=1;
	for(int i=1;i<n;i++){
		if(len==1){
			if(s[i-1]==s[i]){
				if((i+1)!=n){
					cnt++;
				}
				len=2;
				i++;
			}else{
				cnt++;
				len=1;
			}
		}else{
			cnt++;
			len=1;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 640
#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 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);

    var(string, s);
    const int N = s.length();

    i64 ans = 0;

    rep(bit, 0, 1 << (N - 1)) {
        vector<int> splits;
        splits.push_back(0);
        rep(k, 0, N-1) if ((bit >> k) & 1) splits.push_back(k + 1);
        splits.push_back(N);

        dump(splits);

        i64 sum = 0;
        rep(i, 1, splits.size()) {
            const int len = splits[i] - splits[i-1];
            sum += stoll(s.substr(splits[i-1], len));
        }
        ans += sum;
    }

    print(ans);

    return 0;
}


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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 1000000007;

using P = pair<int, int>;
struct Sieve {
	int n;
	vector<int> f, primes;
	// n以下の素数を列挙する
	Sieve(int n = 1) :n(n), f(n + 1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i * i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	// xが素数かどうか判定する
	bool isPrime(int x) { return f[x] == x; }
	// 素因数を全列挙
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	// ランレングス圧縮
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res(1, P(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			}
			else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};
signed main() {
	Sieve s(1000010);
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		int now = n - i;
		vector<P>a = s.factor(now);
		int res = 1;
		for (auto x : a) {
			res *= x.second + 1;
		}
		ans += res;
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
char land[20][20];
bool visited[20][20];

int dfs(int y, int x) {
   if (visited[y][x]) return 0;
   if (land[y][x] == '0') return 0;
   visited[y][x] = true;

   int ret = 1;
   for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || ny >= 12 || nx < 0 || nx >= 12) continue;
      if (land[ny][nx] == '0') continue;
      if (visited[ny][nx]) continue;

      ret += dfs(ny, nx);
   }

   return ret;
}

int main() {
   while ( ~scanf("%s", land[0])) {
      memset(visited, false, sizeof(visited));
      for (int i = 1; i < 12; i++) {
         scanf("%s", land[i]);
      }
      
      int cnt = 0;
      for (int i = 0; i < 12; i++) {
         for (int j = 0; j < 12; j++) {
            cnt += (dfs(i, j) ? 1 : 0);
         }
      }

      cout << cnt << endl;
   }

   return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
char a,b;
int main()
{
    cin>>a>>b;
    if(a=='H')
    	cout<<b;
    else
	{
		if(b=='H')
			cout<<'D';
		else
			cout<<'H';	
	} 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

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

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

template <int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}

    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }

    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }

    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1)
                ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

using mint = ModInt<MOD>;

mint dp[100010][2];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    // 各桁において、
    // (a, b) = (0, 0),(0, 1),(1, 0)の選び方がある
    for(int i = 0; i < n; i++) {
        // L未満確定なので3通りどれでも良い
        dp[i + 1][1] += dp[i][1] * 3;
        if(s[i] == '1') {
            // 0 or 1が選べる
            // 1を選ぶとき、2通り
            dp[i + 1][0] += dp[i][0] * 2;
            // 0を選ぶとき、1通り
            dp[i + 1][1] += dp[i][0];
        } else {
            // 0 しか選べない
            dp[i + 1][0] += dp[i][0];
        }
    }
    cout << dp[n][0] + dp[n][1] << endl;
}

Measured memory_bytes: 1280
n,k = map(int,input().split())
su = 0
mod = 10**9+7
for i in range(k,n+2):
  a = i*(i-1)//2
  b = i*(2*n+1-i)//2
  su += b-a+1
 # print(a,b,su)
  su %= mod
print(su)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
long double h[160];
double dp[160][305];

double f(double a, double b, double height) {
    double da = abs(a - height);
    double db = abs(b - height);
    if((a - height) * (b-height) >= 0) {
        return (da + db) / 2.0;
    }
    double xa = da / (da + db);
    double xb = db / (da + db);
    return (xa * da + xb * db) / 2.0;
}

int main() {
    int n;
    cin >> n;
    for(int i = 1;i <= n; i++) {
        cin >> h[i];
    }
    for(int i = 0; i <= 300; i++) {
        dp[0][i] = 1e9;
    }
    dp[0][1] = 0;
    for(int i = 1; i <= n; i++) {
        for(int after = 1; after <= 300; after++) {
            dp[i][after] = 1e9;
        }
        for(int before = 1; before <= 300; before++) {
            for(int after = 1; after <= 300; after++) {
                //cout << before << " " << after << " " << h[i] << " " << f(before, after, h[i]) << endl;
                dp[i][after] = min(dp[i][after], dp[i-1][before] + f(before, after, h[i]));
            }
        }
    }
    double ans = 1e9;
    for(int i = 1; i <= 300; i++) {
        ans = min(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    ll D;
    cin >> D;
    vector<ll> c(27);
    vector<vector<ll>> s(D+1, vector<ll>(27));
    for (int i = 1; i <= 26; ++i) cin >> c[i];
    for (int i = 1; i <= D; ++i)
    {
        for (int j = 1; j <= 26; ++j)
        {
            cin >> s[i][j];
        }
    }
    vector<ll> t(D+1);
    for (int i = 1; i <= D; ++i) cin >> t[i];
    ll M;
    cin >> M;
    vector<P> query(M+1);
    for (int i = 1; i <= M; ++i)
    {
        cin >> query[i].first >> query[i].second;
    }
    vector<ll> res(D+1, 0);
    vector<ll> last(27, 0);
    for (int d = 1; d <= D; ++d)
    {
        res[d] += res[d - 1] + s[d][t[d]];
        last[t[d]] = d;
        for (int k = 1; k <= 26; ++k)
        {
            res[d] -= c[k] * (d - last[k]);
        }
    }

    // スケジュールを変更
    for (int m = 1; m <= M; ++m)
    {
        t[query[m].first] = query[m].second;

        // res, last を初期化して再びres を計算
        res.clear(), last.clear();
        res = vector<ll>(D + 1, 0);
        last = vector<ll>(27, 0);
        for (int d = 1; d <= D; ++d)
        {
            res[d] += res[d - 1] + s[d][t[d]];
            last[t[d]] = d;
            for (int k = 1; k <= 26; ++k)
            {
                res[d] -= c[k] * (d - last[k]);
            }
        }
        cout << res[D] << endl;
    }
    // for (int d = 1; d <= D; ++d)
    // {
    //     cout << res[d] << endl;
    // }
    return 0;
}


Measured memory_bytes: 4684
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <set>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

void print_answer(bool ans);

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

void print_answer(bool ans)
{
  if (ans)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 504
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int c=0;
int maxpair=0;
int k;
int main () {
  IN(n);

  cin>>k;

  maxpair = (n-2+1)*(n-2)/2;
  if(k>maxpair)
    cout<<-1;
  else{
    cout<<n-1+(maxpair-k)<<endl;
    REP(i,n-1){
      cout<<1<<' '<<i+2<<endl;
    }


    foreach_comb(n-1, 2, [](int *indexes){
	c++;
	if(c>maxpair-k){
	  return;
	}
	else
	  cout<<indexes[0]+2<<' '<<indexes[1]+2<<endl;
      });

    
    REP(i, (maxpair-k)){
      
    }
    
      




  }
}


Measured memory_bytes: 256
n = int(input())

if n < 10:
  ans = n
elif 10 <= n < 100:
  ans = 9
elif 100 <= n < 1000:
  ans = n - 99 + 9
elif 1000 <= n < 10000:
  ans = 9 + 900
elif 10000 <= n < 100000:
  ans = n - 9999 + 909
else:
  ans = 99999 - 9999 + 909
  
print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%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 pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！


int main(){
    int n,m; cin >> n >> m;
    vector<int> cant(m+1);
    rep(i,m) cin >> cant[i];
    cant[m]=-1;
    mint dp[n+1];
    dp[0]=1;
    int now=0;
    for(int i=1; i<=n; i++){
      if(cant[now]==i){
        dp[i]=0;
        now++;
      }
      else if(i==1) dp[i]=dp[i-1];
      else dp[i]=dp[i-2]+dp[i-1];
    }
    cout << dp[n].x << endl;
return 0;
}


Measured memory_bytes: 1408
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# n, k = 8, 7
# arr = list(map(int, "1 7 5 6 8 2 6 5".split()))

add = sum(arr)

def check(factor):
	mod_factor = [x%factor for x in arr]
	mod_factor.sort(reverse = True)
	p = sum(mod_factor)//factor
	# print('p: ', p, 'factor:',factor, 'sum: ', sum(mod_factor))
	# print('mod_factor: ', mod_factor)
	# print(mod_factor[:p])
	c = sum(factor - mod_factor[i] for i in range(p))
	return c <= k

ans = i = 1
while i*i <= add:
	if add % i == 0:
		if check(i):
			ans = max(ans, i)
		if check(add//i):
			ans = max(ans, add//i)
	i += 1
print(ans)

Measured memory_bytes: 43740
n = int(input())
l = list(map(int,input().split()))
a = 0

for i in range(n):
    for j in range(n):
        for k in range(n):
            if (l[i]!=l[j])and(l[j]!=l[k])and(l[k]!=l[i])and(abs(l[i]-l[j])<l[k])and(abs(l[j]-l[k])<l[i])and(abs(l[k]-l[i])<l[j]):
                a += 1
print(a//6)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    ll ans = 0;
    int maxnum = 0;
    rep(i, n){
        chmax(maxnum, a.at(i));
        ans += maxnum - a.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  int a[110];
  cin >> N;
  for (int i=0;i<N;++i) cin >> a[i];

  sort(a,a+N,greater<int>());
  int A=0;
  int B=0;
  
  for (int i=0;i<N;++i){
    if (i%2==0) {
      A+=a[i];
    }
    else{
      B+=a[i];
    }
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i <= s.size(); i++) {
    int cnt = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      if (s.rfind(c, i) != -1 && s.find(c, i + 1) != -1)
      cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  string S;
  cin >> S;
  int ans;
  if(S=="SSS") ans=0;
  else if(S=="SSR"||S=="SRS"||S=="RSS"||S=="RSR") ans=1;
  else if(S=="RRR") ans=3;
  else ans=2;
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

struct UnionFind {
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return (-u[root(x)]); }
    int  root(int x)        { return (u[x] < 0)? x : u[x] = root(u[x]); }
    bool same(int x,int y) { return root(x) == root(y); }
    bool unite(int x,int y){return (x=root(x))==(y=root(y))?false:(u[x]+=u[y],u[y]=x,true) ;}
};

int n, m, k;

vector<int> friends[100100], block[100100];

signed main() {

    cin >> n >> m >> k;
    int a, b;
    UnionFind uf(n);
    vector<int> ans(n+5, 0);
    
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        friends[a].bash(b);
        friends[b].bash(a);
        uf.unite(a, b);
    }
    for(int i = 1; i <= n; i++) {
        ans[i] = uf.size(i) - friends[i].size();
    }

    for(int i = 0; i < k; i++) {
        cin >> a >> b;
        block[a].bash(b);
        block[b].bash(a);
        if(uf.same(a,b)) 
            ans[a]--, ans[b]--;
    }
    
    for(int i = 1; i <= n; i++) {
        cout << ans[i]-1 << " \n"[i==n];
    }
  
    return 0;
}



Measured memory_bytes: 13048
N = int(input())
S = list(input())
shiro_sum = [0] * (N+1)
kuro_sum = [0] * (N+1)
for i in range(N):
    if S[i] == '.':
        shiro_sum[i+1] = shiro_sum[i] + 1
    else:
        shiro_sum[i+1] = shiro_sum[i] + 0

    if S[i] == '#':
        kuro_sum[i+1] = kuro_sum[i] + 1
    else:
        kuro_sum[i+1] = kuro_sum[i] + 0

res = 10**9
# i == 0
for i in range(N+1):
    tmp = 0
    # leftを全て白に
    # 左側にある黒の数を数える。
    tmp += kuro_sum[i]

    # rightを全て黒に
    # 右側にある白を数えて、全体の数から白の合計を消す
    tmp += shiro_sum[N] - shiro_sum[i]
    res = min(res, tmp)
print(res)


Measured memory_bytes: 20448
#include <iostream>
#include <algorithm>
using namespace std;
int a[3], x, y, ans;
int main() {
	cin>>a[0]>>a[1]>>a[2];
	sort(a, a+3);
	x = a[2] - a[0];
	y = a[2] - a[1];
	if(x%2 && y%2) ans = (x-1)/2 + (y-1)/2 + 1;
	else if(x%2==0 && y%2==0) ans = x/2 + y/2;
	else if(x%2) ans = (x+1)/2 + y/2 + 1;
	else ans = x/2 + (y+1)/2 + 1;
	cout<<ans;
	return 0;
}

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

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

  if (N > 999){
    cout << "ABD" << endl;
  }
  else
  {
    cout << "ABC" << endl;
  }
  
}


Measured memory_bytes: 3556
s = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))

mx = max(x)
if mx < s[2]:
  mx = s[2]
my = min(y)
if my > s[3]:
  my = s[3]

  
if mx >= my:
  print ("War")
else:
  print ("No War")


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

ll calcsum(string s, int check){
    ll temp = 0;
    ll sum  = 0;
    rep(i, s.size()){
        temp = temp*10 + stoi(s.substr(i, 1));
        if(i != s.size()-1){
            if(check >> i & 1){
                sum += temp;
                temp = 0;
            }
        }
        else{
            sum += temp;
        }
    }

    return sum;
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;

    int n = s.size();

    int nloop = pow(2, n-1);

    ll res = 0;
    rep(i, nloop){
        res += calcsum(s, i);
        // cout << calcsum(s, i) << endl;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>          // printf(), scanf()
const long M = 1000000007;

long
power(long x, long n)
{
	if (n == 0)
		return 1;

	long res = power((x * x) % M, n / 2);
	if (n & 1)
		res = (res * x) % M;

	return res;
}

int
main(int argc, char** argv)
{
	int m, n;

	scanf("%d %d", &m, &n);
	printf("%ld\n", power(m, n));
	return 0;
}

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

using namespace std;

void
chmax(int& aa, int bb)
{
  if (aa < bb) {
    aa = bb;
  }
}

int
main()
{
  int   qq;

  cin >> qq;

  
  for (int qi = 0; qi < qq; qi++) {
    string      xx;
    string      yy;
    vector<vector<int> > dp;

    cin >> xx;
    cin >> yy;

//    cout << xx << endl;
//    cout << xx.length() << endl;

    dp.assign(xx.length() + 1, vector<int>(yy.length() + 1, 0));

    for (int xi = 0; xi < xx.length(); ++xi) {
      for (int yi = 0; yi < yy.length(); ++yi) {
        //cout << yi << endl;
        if (xx[xi] == yy[yi]) {
          dp[xi + 1][yi + 1] = dp[xi][yi] + 1;
        }
        chmax(dp[xi + 1][yi + 1], dp[xi][yi + 1]);
        chmax(dp[xi + 1][yi + 1], dp[xi + 1][yi]);
      }
    }
    cout << dp.back().back() << endl;
  }
}





Measured memory_bytes: 6800
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
     
public class Main{
    static final InputStream in=System.in;
    static final PrintWriter out=new PrintWriter(System.out);

  
    public static void main(String[] args) throws IOException{
	InputReader ir=new InputReader(in);
	int a=ir.nextInt();
	int b=ir.nextInt();
	out.println(a*b+" "+(a+b)*2);
	out.flush();
    }
 
    static class InputReader {
	private InputStream in;
	private byte[] buffer=new byte[1024];
	private int curbuf;
	private int lenbuf;

	public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
   
	public boolean hasNextByte() {
	    if(curbuf>=lenbuf){
		curbuf= 0;
		try{
		    lenbuf=in.read(buffer);
		}catch(IOException e) {
		    throw new InputMismatchException();
		}
		if(lenbuf<=0) return false;
	    }
	    return true;
	}
  
	private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
	private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
  
	private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
	public boolean hasNext(){skip(); return hasNextByte();}
  
	public String next(){
	    if(!hasNext()) throw new NoSuchElementException();
	    StringBuilder sb=new StringBuilder();
	    int b=readByte();
	    while(!isSpaceChar(b)){
		sb.appendCodePoint(b);
		b=readByte();
	    }
	    return sb.toString();
	}
  
	public int nextInt() {
	    if(!hasNext()) throw new NoSuchElementException();
	    int c=readByte();
	    while (isSpaceChar(c)) c=readByte();
	    boolean minus=false;
	    if (c=='-') {
		minus=true;
		c=readByte();
	    }
	    int res=0;
	    do{
		if(c<'0'||c>'9') throw new InputMismatchException();
		res=res*10+c-'0';
		c=readByte();
	    }while(!isSpaceChar(c));
	    return (minus)?-res:res;
	}
  
	public long nextLong() {
	    if(!hasNext()) throw new NoSuchElementException();
	    int c=readByte();
	    while (isSpaceChar(c)) c=readByte();
	    boolean minus=false;
	    if (c=='-') {
		minus=true;
		c=readByte();
	    }
	    long res = 0;
	    do{
		if(c<'0'||c>'9') throw new InputMismatchException();
		res=res*10+c-'0';
		c=readByte();
	    }while(!isSpaceChar(c));
	    return (minus)?-res:res;
	}
  
	public double nextDouble(){return Double.parseDouble(next());}
  
	public int[] nextIntArray(int n){
	    int[] a=new int[n];
	    for(int i=0;i<n;i++)
		a[i]=nextInt();
	    return a;
	}
  
	public char[][] nextCharMap(int n,int m){
	    char[][] map=new char[n][m];
	    for(int i=0;i<n;i++)
		map[i]=next().toCharArray();
	    return map;
	}
    }
}



Measured memory_bytes: 24368
using System;
using System.Collections.Generic;
public class Aprob {
    public static void Main() {
        string[] readSome = new string[3];
        readSome = Console.ReadLine().Split(' ');
        if (readSome[0].Substring(readSome[0].Length - 1,1) == readSome[1].Substring(0,1) && readSome[1].Substring(readSome[1].Length - 1,1) == readSome[2].Substring(0,1)) {
            Console.WriteLine("YES");
        } else {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main()
{
long long int a,b,c,k,s,re;
 cin>>a>>b>>c>>k;

 if(a>=k)
 {
     cout<<k;
 }else if(a+b>=k) 
   cout<<a;
 else
 {
        re=k-a;
        s=a;
        re=re-b;
        s=s-re;
     
  cout<<s;       
 }
}


Measured memory_bytes: 3180
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 heapq import heapify, heappop, heappush
 
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

s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)
if s < t:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 4012
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  if(n>999){
    s = "ABD";
  } else {
    s = "ABC";
  }
  cout << s<< endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
H,W=map(int,input().split())
s=[]
for i in range(H):
    S=input()
    s.append(S)
w_count=0
for i in range(H):
    for j in range(W):
        if s[i][j]==".":
            w_count+=1
count=[[10**9 for i in range(W)]for j in range(H)]
chk=[[0 for i in range(W)]for j in range(H)]
rl=[1,-1]
up=[1,-1]
q=deque([(0,0)])
count[0][0]=1
chk[0][0]=1

while(q):
    #print(q)
    a,b=q.popleft()
    #print(q)
    for i in rl:
        r=b+i
        if r>=0 and r<W:
            if s[a][r]==".":
                count[a][r]=min(count[a][r],count[a][b]+1)
                #print("ON")
                if chk[a][r]==0:
                    q.append((a,r))
                chk[a][r]=1
    for i in up:
        u=a+i
        if u>=0 and u<H:
            if s[u][b]==".":
                count[u][b]=min(count[u][b],count[a][b]+1)
                #print("ON")
                if chk[u][b]==0:
                    q.append((u,b))
                chk[u][b]=1

ans=w_count-count[H-1][W-1]
#print(count)
if count[-1][-1]==10**9:
    print(-1)
    exit()

#print(w_count)
#print(count[-1][-1])
print(ans)

Measured memory_bytes: 42608