akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

H, N = map(int, input().split())
As = list(map(int, input().split()))
s = sum(As)
if s >= H:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 16868
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

typedef long long ll;
map<ll,ll> res;

void factor(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			res[i]++;
			n /= i;
		}
	}
	if (n != 1) res[n]++;
}

int main() {
	ll n, p;
	cin >> n >> p;
	factor(p);
	ll ans = 1;
	for (auto pr : res) {
		if (pr.second >= n) {
			ans *= pow(pr.first, pr.second / n);
		}
	}
	cout << ans << endl;
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    cout << (min(A, B) <= C && C <= max(A, B) ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

ll dp[405][405];
ll sums[405];
int n;
ll a[405];

ll func(int x, int y){
    if(dp[x][y] != -1) return dp[x][y];
    if(x==y) return 0;
    ll min_val = LLONG_MAX;
    for(int i=x;i<=y-1;i++){
        min_val = min(min_val, func(x, i) + func(i+1,y));
    }
    return dp[x][y] = sums[y+1]-sums[x] + min_val;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, -1, sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sums[i+1] += a[i];
        sums[i+1] += sums[i];
    }
    cout<<func(0, n-1);
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;
int main()
{
    int N;
    cin >> N;
    
    int a, b;
    cin >> a >> b;
    
    if(N==1)
    {
        cout << "Hello World" << endl;
    }
    if(N==2)
    {
        cout << a+b << endl;
    }
}

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

int main(){
  //clock_t start,end;
  //start=clock();

  int n; string s; cin >>n >>s; long long x=0,r=0,g=0,b=0;
  for(int i=0; i<n; i++){
    if(s[i]=='R') r++;
    else if(s[i]=='G') g++;
    else b++;
  }
  for(int i=0; i<n-2; i++) for(int j=1; i+j*2<n; j++){
    if(s[i]!=s[i+j]&&s[i]!=s[i+j*2]&&s[i+j]!=s[i+j*2]) x++;
  }
  cout <<r*g*b-x;

  //end=clock();
  //double time_taken=double(end-start)/double(CLOCKS_PER_SEC); 
  //cout <<"Time taken: "<<fixed<<setprecision(5);
  //cout <<time_taken<<"s/"<<time_taken*1000<<"ms"<<endl;
return 0;}

Measured memory_bytes: 3584
N,Y=map(int,input().split())

res10000=-1
res5000=-1
res1000=-1

for a in range(0,N+1):
    for b in range(0,N-a+1):
        total=a*10000+b*5000+(N-a-b)*1000
        if total == Y:
            res10000=a
            res5000=b
            res1000=N-a-b
            
print(str(res10000) + ' ' + str(res5000) + ' ' + str(res1000))

Measured memory_bytes: 3064
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int t[310][310];
long long g[310][3];
long long dp[310][310];
int main(){
	init_C(1000);
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			scanf("%d",&t[i][j]);
		}
	}
	int R=0;
	for(int i=0;i<a;i++){
		int at=-1;
		for(int j=R;j<a;j++){
			if(t[j][i])at=j;
		}
		if(at!=-1){
			for(int j=0;j<a;j++){
				swap(t[at][j],t[R][j]);
			}
			for(int j=R+1;j<a;j++){
				if(t[j][i]){
					for(int k=0;k<a;k++)t[j][k]^=t[R][k];
				}
			}
			R++;
		}
	}
	for(int i=0;i<=a;i++){
		for(int j=1;j<=i;j+=2){
			g[i][0]=(g[i][0]+Comb(i,j)*pw(3,i-j))%mod;
		}
		g[i][2]=(mod+pw(2,2*a)+(mod+1-pw(2,a-i+1))*pw(2,2*i))%mod;
		g[i][1]=(pw(2,2*a)+mod-(g[i][0]+g[i][2])%mod)%mod;
		//printf("%lld %lld %lld\n",g[i][0],g[i][1],g[i][2]);
	}

	dp[0][R]=1;
	for(int i=0;i<a;i++){
		for(int j=0;j<=a;j++){
			for(int k=0;k<3;k++){
				if(j+k-1>=0&&j+k-1<=a){
					dp[i+1][j+k-1]=(dp[i+1][j+k-1]+dp[i][j]*g[j][k])%mod;
				}
			}
		}
	}
	printf("%lld\n",dp[a][0]);
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

const int MOD = 1e9 + 7;

vector<int> candidates;
vector<int> options = {3, 5, 7};

int solve(int H){
  if(H==1)
    return 1;

  return 1+2*solve(H/2);
}


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

  int H;
  cin >> H;

  cout << solve(H) << endl;  

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a, b, i;
	scanf("%d", &a);
	while (a != 0){
		for (i = 0; i < 9; i++){
			scanf("%d", &b);
			a -= b;
		}
		printf("%d\n", a);
		scanf("%d", &a);
	}
	return 0;
}

Measured memory_bytes: 1028
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val n = BigInt(readInt)
  val as = readLongs

  if (as.contains(0L)) {
    println(0)
  } else {
    var res = BigInt(1)
    val b = new scala.util.control.Breaks
    b.breakable {
      for (a <- as) {
        var temp = res * BigInt(a)
        if (BigInt(pow(10, 18).toLong) < temp) {
          res = BigInt(-1)
          b.break
        } else {
          res = res * a
        }
      }
    }
    println(res)
  }
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


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

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;cin>>s;
  int n=s.length();
  if (s[n-1]=='s')
  {
    cout<<s<<"es"<<endl;
  }else
  {
    cout<<s<<"s"<<endl;
  }
  
  return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	map<int, bool> correct;
	map<int, int> penalty;
	for (int i = 0; i < M; i++) {
		int p;
		string S;
		cin >> p >> S;
		if (correct.count(p)) {
			// 既存キー
			if (S == "AC") {
				correct[p] = true;
			}
			else if (S == "WA" && correct.at(p) == false) {
				penalty[p]++;
			}
		}
		else {
			// 新規キー
			if (S == "AC") {
				correct[p] = true;
				penalty[p] = 0;
			}
			else {
				correct[p] = false;
				penalty[p] = 1;
			}
		}
	}
	int sum_c = 0;
	int sum_p = 0;
	for (auto itr = correct.begin(); itr != correct.end(); ++itr) {
		if (itr->second == true) {
			sum_c += 1;
			sum_p += penalty.at(itr->first);
		}
	}
	cout << sum_c << " " << sum_p << endl;
}


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

int main(void){
    
  int A,B,K,s;
  cin >> A >> B >> K;
  s = B - A + 1;
  
  if(s <= 2*K)  for(int i=A;i<=B;i++){ cout << i << endl; }
  else{
      for(int i=A;i<(A+K);i++) cout << i << endl;
      for(int i=(B-K+1);i<=B;i++) cout << i << endl;
  }
}


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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TC ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ size()
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpl vector< pll >

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // TC
    {
        ll n;
        cin>>n;
        vll v(n);
        ll tot = 0;
        loop(i,0,n){
            cin>>v[i];
            tot ^= v[i];
        }

        vll ans(n);
        loop(i,0,n) {
            ans[i] = tot^v[i];
        }
        loop(i,0,n)
            cout<<ans[i]<<' ';
        cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 6336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int D; cin >> D;
  vector<int> c(26); rep(i,26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(y,D) rep(x,26) cin >> s[y][x];
  vector<int> t(D); rep(i,D) cin >> t[i];
  ll ans = 0;
  vector<int> lst(26,-1);
  rep(i,D){
    ans += s[i][t[i]-1];
    lst[t[i]-1] = i;
    rep(j,26){
      ans -= c[j]*(i-lst[j]);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


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




/* main */
int digitlen(int n){
    int cnt = 0;
    while(n){
        cnt++;
        n /= 10;
    }
    return cnt;
}



signed main(){

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

    std::ostringstream sout;


    int n, m; cin >> n >> m;

    vector<vec<pi>> arr(n + 5);

    rep(i,0,m){
        int p, y; cin >> p >> y;
        arr[p].push_back(make_pair(y, i));
    }

    rep(i,0,n + 5){
        if(not arr[i].empty()) sort(all(arr[i]));
    }

    vec<pi> ans(m + 5, pi(0,0));

    rep(i,0,arr.size()){
        if(not arr[i].empty()){
            rep(j,0,arr[i].size()){
                pi tmp = arr[i][j];
                ans[tmp.second] = make_pair(i, j + 1);
            }
        }
    }
    
    for(auto e : ans){
        if(e != pi(0, 0)){
            printf("%06lld%06lld\n", e.first, e.second);
        }
    }

    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 8576
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent

struct Vacation {
	int Swim, bugs, homework;
};
int n;
vector<Vacation> v;
//int mem[N][4];
int dp[2][4];
/*int solve(int idx = 0, int prev = 0)
{
	if (idx == n)
		return 0;
	int& ret = mem[idx][prev];
	if (~ret)return ret;
	ret = 0;
	if (prev != 1)
		ret = max(ret, solve(idx + 1, 1) + v[idx].Swim);
	if (prev != 2)
		ret = max(ret, solve(idx + 1, 2) + v[idx].bugs);
	if (prev != 3)
		ret = max(ret, solve(idx + 1, 3) + v[idx].homework);

	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n;
	v = vector<Vacation>(n);
	for (int i = 0; i < n; i++)
		cin >> v[i].Swim >> v[i].bugs >> v[i].homework;
	//cout << solve() << endl;

	//baseCase
	dp[n%2][1] = dp[n%2][2] = dp[n%2][3] = 0;


	for (int idx = n-1; idx >=0; idx--) {
		int& ret1 = dp[idx%2][1];
		int& ret2 = dp[idx%2][2];
		int& ret3 = dp[idx%2][3];
		ret1 = ret2 = ret2 = 0;;

		ret1 = max(ret1, dp[(idx + 1)%2][2] + v[idx].Swim);
		ret1 = max(ret1, dp[(idx + 1)%2][3] + v[idx].Swim);
									
		ret2 = max(ret2, dp[(idx + 1)%2][1] + v[idx].bugs);
		ret2 = max(ret2, dp[(idx + 1)%2][3] + v[idx].bugs);
									
		ret3 = max(ret3, dp[(idx + 1)%2][1] + v[idx].homework);
		ret3 = max(ret3, dp[(idx + 1)%2][2] + v[idx].homework);

	}

	cout << max({ dp[0][1],dp[0][2],dp[0][3] }) << endl;
}


Measured memory_bytes: 4464
#include<bits/stdc++.h>
#define N 100000
using namespace std;
int a[N+5],dp[N+5],n,no2,ans;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		dp[a[i]]++;
	}
	for(int i=1;i<=N;i++) {
		//cout<<dp[i]<<" "<<i;getchar();
		if(dp[i]>2) {
			dp[i]=(dp[i]&1?1:2);
		}
		if(dp[i]==2) {
			no2++;
			dp[i]=1;
		}
		ans+=dp[i];
	}
	ans-=no2&1;
	cout<<ans;
	
	
}
// 1 1 2 2 3 3 7


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	string s,t; cin >> s >>t;
	if((int)t.size() - 1 != (int) s.size()) cout << "No" << endl;
	else{
		rep(i, s.size()){
			if(s[i] != t[i]){
				cout << "No" << endl;
				return 0;	
			} 

		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
	int a, b;
	cin >> a >> b;
	if(a < 13) b /= 2;
	if(a <= 5) b = 0;
	cout << b << endl;
}


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

int main() {
  int n,k;
  cin>>k>>n;
  vector<int> a(n);
  rep(i,n) cin>>a.at(i); 
  vector<int> b(n);   //左側の距離
  
  rep(i,n){
    if(i!=0){
      b.at(i)=a.at(i)-a.at(i-1);
    }
    else{
      b.at(0)=a.at(0)+k-a.at(n-1);
    }
  }
  
  int m=0
    rep(i,n){
    m=max(b.at(i),m);
  }
  
  cout<<k-m<<endl;
  
  
}



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

int main(){
  int n,x,b;
  cin >> n >> x;
  vector<int>zhy(n);
  for(int i=0;i<n;i++){
    cin >> b;
    zhy.at(i)=abs(b-x);
  }
  sort(zhy.begin(),zhy.end());
  int l=zhy.at(0),g,m=l,ans=l;
  for(int i=0;i<n;i++){
    g=zhy.at(i);
    l=zhy.at(0);
    while(g%l!=0){
      m=g%l;
      g=l;
      l=m;
    }
    ans=min(ans,m);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  std::unordered_set<string> m;
  string s;
  rep(i, N) {
    cin >> s;
    m.insert(s);
  }

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

  return 0;
}


Measured memory_bytes: 17792
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n = ni()

if n < 1000:
    print("ABC")
else:
    print("ABD")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    string s,t;
    cin>>s>>t;

    ll l=0;
    for(ll i=0; i<s.size(); i++){
        if(s[i]!=t[i]){
            l++;
        }
    }
    cout<<l<<endl;
}


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

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

    int N = s.size();

    long long ans = 0;

    for(int i = 0; i < (1 << N - 1); i++)
    {
        long long  now = s[0] - '0';
        long long sum = 0;
        for(int j = 1; j < N; j++)
        {
            if(i & (1 << j - 1))
            {
                sum += now;
                now = 0;
            }
            now *= 10;
            now += s[j] - '0';
        }
        ans += sum + now;
    }

    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S; cin >> S;
	int N = S.size();
	auto dp = makeVector(N+1, 13, 0ll);
	dp[N][0] = 1;

	ll val = 1;
	for (int i = N; i > 0; i--) {
		for (int j = 0; j < 13; j++) {
			if (dp[i][j] == 0) continue;
			for (int k = 0; k < 10; k++) {
				if (S[i-1] == '?' || S[i-1] == k+'0') {
					(dp[i-1][(j+k*val)%13] += dp[i][j]) %= mod;
				}
			}
		}
		(val *= 10) %= 13;
	}
	cout << dp[0][5] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 16552
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);


ll x=RLL(),ans=0,i=0;
	x = abs(x);
	while(1){
		ll t = i * (i + 1) / 2;
		if (t >= x){
			ans = i;
			break;}
		i++;
	}
	cout << ans << endl;

 }




Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        System.out.println((long) (Math.pow(2, M)*(1900*M+100*(N-M))));
    }
}

Measured memory_bytes: 35680
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
#include<cstdio>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007

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

void dfs(int x,int y){

     //今いるところを-1に置き換える
    mp[x][y] = 'H';
    //移動方向をループ
    for(int i = 0;i <= 4;i++){
        //for(int dy = -1;dy <= 1;dy++){
            //x方向にdx,ｙ方向にdy移動した場所を(nx,ny)とする
            int nx = x + dx[i], ny = y + dy[i];
            //nx,nyが庭の範囲内にあるか、また、現在の場所field[nx][ny]が水たまりかどうかの判定
            if(0 <= nx && nx < 12 && 0 <= ny && ny < 12 && mp[nx][ny] == '1'){
                dfs(nx,ny);
            }
         //}
     }
     return;
}




void solve(){

    int res = 0;
    for(int i = 0;i < 12;i++){
        for(int j = 0;j < 12;j++){
            if(mp[i][j] == '1'){
                //1が残っているならばその場所からdfsを始める
                dfs(i,j);
                //ここで1つの島が見つかったことになるので水たまりの個数を１つ足す
                res++;
            }
        }
    }
    //島の個数を表示
    cout << res << endl;
}


int main(){

    while(cin >> mp[0][0]){

        for(int i = 1;i < 12;i++){
            cin >> mp[0][i];
        }
        for(int i = 1;i < 12;i++){
            for(int j = 0;j < 12;j++){
                cin >> mp[i][j];
            }
        }

        /*REP(i,12){
            REP(j,12){
                cout << mp[i][j];
            }
            cout << endl;
        }
        cout << endl;
        */
        solve();
    }
    
    
    
   






    return 0;
}



Measured memory_bytes: 3032
import sys
N = int(sys.stdin.readline().rstrip())

if N == 1:
    print(1)
    exit()

zahyo = []
for _ in range(N):
    x, y = map(int, sys.stdin.readline().rstrip().split())
    zahyo.append((x, y))
zahyo.sort()

p_q = set()
for i in range(N - 1):
    for j in range(i + 1, N):
        p = zahyo[j][0] - zahyo[i][0]
        q = zahyo[j][1] - zahyo[i][1]
        p_q.add((p, q))

ans = float("inf")
for p, q in p_q:
    used = set()
    ans_tmp = 0
    for i in range(N):
        if i not in used:
            x_base = zahyo[i][0]
            y_base = zahyo[i][1]
            ans_tmp += 1
            for j, (x, y) in enumerate(zahyo[i + 1:], 1):
                if x - x_base == p and y - y_base == q:
                    used.add(i + j)
                    x_base = x
                    y_base = y
    ans = min(ans_tmp, ans)
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}
vector<string> ans;

void solve(void){
    vector <ll> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    ll ans = 0;
    ll sub;

    if(a[2]%2 == (a[0]+a[1]+a[2])%2){
        sub =  a[2];
    }else{
        sub =  a[2]+1;
    }
    
            if(sub == a[2])
            ans=(sub-a[0])/2+(sub-a[1])/2+(sub-a[1])%2;  
            else
            ans=(sub-a[0])/2+(sub-a[1])/2+1;  
            
       
    
    cout << ans << endl;
    

}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
int main()
{
    int i,n;
    string a,b;
    vector<char> str;
    in(n);
    cin >> a >> b;
    rep(i,n)
    {
        str.pb(a[i]);
        str.pb(b[i]);

    }
    rep(i,2*n)
        cout << str[i];
    lin;
}




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

s = list(map(int,input().split()))

ans = 1

m = s[0]

for i in range(1,len(s)):
    if s[i] == 1:
        ans += 1
        break
    elif s[i]>m:
        continue
    else:
        m = s[i]
        ans += 1
        
print(ans)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    LL N,A,B,C,D;
    cin >>N>>A>>B>>C>>D;

    bool isPossible=false;

    REP(i,N-1){
        //N-1回のうちi回下げた
        LL pos=A+ C*(N-1-2*i);
        LL sub =B - pos;
        if(sub>=0&&sub<=(D-C)*(N-1-i)){
            isPossible=true;
        }else if(sub<0&&-1*sub<=(D-C)*i){
            isPossible=true;
        }
    }

    if(isPossible){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
  public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int K = sc.nextInt();
      String S = sc.next();
      if(S.length()<=K) {
        System.out.println(S);
      } else if(S.length()>K) {
        String T = S.substring(0,K);
        System.out.println(T + "...");
      }
    }
  }

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

vector<lli> hBase[400000];
vector<lli> wBase[400000];
map<pair<lli,lli>,lli> cnt;

void func(long long H, long long W, long long M, std::vector<long long> h, std::vector<long long> w){

    lli ansH = 0;
    lli ansW = 0;
    lli nowH,nowW;
    REP(i,0,H){
        if(chmax(ansH,(lli)hBase[i].size()))nowH = i;
    }
    REP(i,0,W){
        if(chmax(ansW,(lli)wBase[i].size()))nowW = i;
    }
    vector<lli> targetH,targetW;
    REP(i,0,H){
        if(hBase[i].size()==ansH)targetH.push_back(i);
    }
    REP(j,0,W){
        if(wBase[j].size()==ansW)targetW.push_back(j);
    }
    REP(i,0,targetH.size()){
        REP(j,0,targetW.size()){
            if(cnt[{targetH[i],targetW[j]}]==0){
                cout<<ansW+ansH<<endl;
                return;
            }
        }
    }
                cout<<ansH+ansW-1<<endl;
                return;
}

int main(){
    // cout << fixed << setprecision(5);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> h(M);
    std::vector<long long> w(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&h[i]);
        scanf("%lld",&w[i]);
        h[i]--,w[i]--;
        hBase[h[i]].push_back(w[i]);
        wBase[w[i]].push_back(h[i]);
        cnt[{h[i],w[i]}]=1;
    }
    func(H, W, M, std::move(h), std::move(w));
    return 0;
}


Measured memory_bytes: 72592
# frozen_string_literal: true

s = gets.chomp.split('')

rainy_days = 0

start = s.find_index('R')

unless start
  puts rainy_days
  exit
end

(start..2).each do |index|
  if s[index] == 'R'
    rainy_days += 1
  else
    break
  end
end

puts rainy_days


Measured memory_bytes: 14364
#include<cstdio>
#include <vector>
#include <algorithm>
#include <functional>

#include <cstdlib>
#include <iostream>
#include <string>
#include <typeinfo>
using namespace std;

int GetDigit(int num);

int main(){
	std::vector<int> r;
	while(true) {
		int nums[2];

		string str;
		int a =0;
		getline(cin, str); 
		string n[2];
		int nn[2];
		for(int i=0; i<str.size(); ++i){
			if(str[i] == ' ') a++;
			n[a] += str[i];
		}
		if(n[1].size() == 0) break;
		nn[0] = std::stoi(n[0]);
		nn[1] = std::stoi(n[1]);


		r.push_back(nn[0]+nn[1]);
	}

	for(int i=0; i<r.size(); ++i) {
		printf("%d\n", GetDigit(r[i]));
	}
	

	return 0;
}

int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        ++digit;
    }
    return digit;
}

Measured memory_bytes: 3240
x = int(input())

ans = []
for i in range(0, x//2+1):
    a = i**5
    diff = x - a

    if diff == 0:
        ans.append(i)
        ans.append(0)
        break

    elif diff < 0:
        j = 0
        while True:
            b = j**5
            if diff*(-1) < b:
                break
            if a-b == x:
                ans.append(i)
                ans.append(j)
                break
            j += 1

    elif diff > 0:
        j = 0
        while True:
            b = j**5
            if diff < b:
                break
            if a+b == x:
                ans.append(i)
                ans.append(j*(-1))
                break
            j += 1

    if len(ans) != 0:
        break

print(ans[0], ans[1])

Measured memory_bytes: 9232
"""
AtCoder :: Beginner Contest 175 :: C - Walking Takahashi 
https://atcoder.jp/contests/abc175/tasks/abc175_c
"""
import sys


def solve(X, K, D):
    """Solve puzzle."""
    # print('solve X', X, 'K', K, 'D', D)
    if D == 0:
        return X

    X = abs(X)
    soln = abs(X - (K * D))
    steps_to_zero = abs(X) // D
    # print('steps to zero', steps_to_zero, K - steps_to_zero)
    # print('to zero', abs(X - (steps_to_zero * D)))
    # Undershoot or get directly on to zero.
    if steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_to_zero * D)))

    # Overshoot by one step
    steps_past_zero = steps_to_zero + 1
    # print('steps past zero', steps_past_zero, K - steps_past_zero)
    # print('past zero', abs(X - (steps_past_zero * D))) 
    if steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_past_zero * D)))

    # Overshoot and return by one
    steps_back_zero = steps_past_zero + 1
    # print('steps back zero', steps_back_zero, K - steps_back_zero)
    # print('back zero', abs(X - (steps_back_zero * D)))
    if steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_back_zero * D)))

    return soln


def main():
    """Main program."""
    X, K, D = (int(i) for i in sys.stdin.readline().split())
    print(solve(X, K, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll X, Y;
  cin >> X >> Y;
  ll ans = 0;
  if (X == 1) ans += 300000;
  if (X == 2) ans += 200000;
  if (X == 3) ans += 100000;
  if (Y == 1) ans += 300000;
  if (Y == 2) ans += 200000;
  if (Y == 3) ans += 100000;
  if (X == 1 and Y == 1) ans += 400000;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
s = list(input())
ans_list=[]
for i in range(len(s)):
    if(s[i] == "0"):
        ans_list.append("0")
    elif(s[i] == "1"):
        ans_list.append("1")
    elif(s[i] == "B"):
        if(len(ans_list) != 0):
            ans_list.pop()
        else:
            continue
for i in range(len(ans_list)):
    print(ans_list[i],end='')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
struct dijkstra{
    const T TINF=numeric_limits<T>::max();
    using P=pair<T,int>;
    int n;
    vector<vector<P>> G;
    vector<T> d;
    vector<int> prev;
    
    dijkstra(int n):n(n),G(vector<vector<P>>(n)),
    d(vector<T>(n,TINF)),prev(vector<int>(n,-1))
    {}
    
    // 始点を変えて何回もダイクストラしたいあなたに
    void reset(){
        rep(i,n) G[i].clear();
        d=vector<T>(n,TINF);
        prev=vector<int>(n,-1);
    }

    //頂点sからtまでのコストcosrの辺を張る
    void add_edge(int s,int t,T cost){
        G[s].push_back(P(cost,t));
    }
    /*頂点sからの各点までの最短経路を計算する
    g.d[i]=(0からiの最短距離)
    */
    vector<T> build(int s){
        // 何回もやるなら毎回初期化する↓
        // init(n);
        d[s]=0;
        priority_queue<P,vector<P>,greater<P>> q;
        q.push(P(d[s],s));
        while(!q.empty()){
            P p=q.top();q.pop();
            int v=p.second;//v:次点
            //自分より最短経路小さいところへは向かう必要がない
            if(d[v]<p.first) continue;
            for(auto e:G[v]){
                int u=e.second;
                T cost=e.first;
                if(d[u]>d[v]+e.first){
                    d[u]=d[v]+cost;
                    prev[u]=v;
                    q.push(P(d[u],u));
                }
            }
        }
        return d;
    }

    vector<int> get_path(int g){
        vector<int> ret;
        if(d[g]==TINF) return ret;
        for(;g!=-1;g=prev[g]){
            ret.push_back(g);
        }
        reverse(ret.begin(),ret.end());
        return ret;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(20);
    
    double sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int n;
    cin>>n;
    double x[n],y[n],r[n];
    rep(i,n){
        cin>>x[i]>>y[i]>>r[i];
    }
    dijkstra<double> g(n+2);
    g.add_edge(0,n+1,sqrt((sx-tx)*(sx-tx)+(sy-ty)*(sy-ty)));
    for(int i=0;i<n;i++){
        double d=sqrt((sx-x[i])*(sx-x[i]) + (sy-y[i])*(sy-y[i]))-r[i];
        g.add_edge(0,i+1,max(0.0,d));
    }
    for(int i=0;i<n;i++){
        double d=sqrt((tx-x[i])*(tx-x[i]) + (ty-y[i])*(ty-y[i]))-r[i];
        g.add_edge(i+1,n+1,max(0.0,d));
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j];
            g.add_edge(i+1,j+1,max(0.0,d));
        }
    }
    // for(int i=0;i<n+2;i++){
    //     cout<<i<<": "<<endl;
    //     for(auto x:g[i]){
    //         cout<<"To: "<<x.first<<" Cost: "<<x.second<<endl;
    //     }
    //     cout<<endl;
    // }
    auto v=g.build(0);
    cout<<v[n+1]<<endl;
    return 0;
}


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

struct tree{
    int parent;
    int left;
    int right;
    int degree;
    int depth;
    int height;
    tree(){
        parent = -1;
        left   = -1;
        right  = -1;
        degree = -1;
        depth  = -1;
        height = -1;
    }
};

int find_root(const vector<tree>& T){
    for (int i = 0; i < T.size(); i++) {
        if (T[i].parent == -1) {
            return i;
        }
    }
}

void calc_depth(int id, int depth, vector<tree>& T){
    T[id].depth = depth;
    if (T[id].left != -1) {
        calc_depth(T[id].left, depth + 1, T);
    }
    if (T[id].right != -1) {
        calc_depth(T[id].right, depth + 1, T);
    }
}

int calc_height(int id, vector<tree>& T){
    int left_height;
    int right_height;
    if (T[id].left  == -1) {
        left_height = -1;
    } else {
        left_height = calc_height(T[id].left, T);
    }
    if (T[id].right  == -1) {
        right_height = -1;
    } else {
        right_height = calc_height(T[id].right, T);
    }
    T[id].height = max(left_height, right_height) + 1;
    return T[id].height;
}

int main(){
    int n;
    cin >> n;
    vector<tree> T(n);

    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        T[id].left      = left;
        T[id].right     = right;
        T[left].parent  = id;
        T[right].parent = id;
    }
    int root = find_root(T);
    calc_depth(root, 0, T);
    calc_height(root, T);

    for (int i = 0; i < n; i++) {
        cout << "node " << i << ": parent = " << T[i].parent;
        cout << ", sibling = ";
        if (T[i].parent == -1) {
            cout << "-1";
        } else {
            if (T[T[i].parent].left == i) {
                cout << T[T[i].parent].right;
            } else {
                cout << T[T[i].parent].left;
            }
        }
        cout << ", degree = ";
        cout << (T[i].left != -1) + (T[i].right != -1);
        cout << ", depth = " << T[i].depth;
        cout << ", height = " << T[i].height;
        cout << ", ";
        if (T[i].parent == -1) {
            cout << "root";
        } else if (T[i].left != -1 || T[i].right != -1){
            cout << "internal node";
        } else {
            cout << "leaf";
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define MAX 0

using namespace std;

#define fst first
#define snd second

#define mp make_pair
#define pb push_back

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

int main() {
  int a, b, c, x, ans = 0;
  scanf("%d %d %d %d", &a, &b, &c, &x);

  for (int i = 0; i <= a; ++i)
    for (int j = 0; j <= b; ++j)
      for (int k = 0; k <= c; ++k)
        if (500 * i + 100*j + 50 * k == x)
          ans++;

  printf("%d\n", ans);
  return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

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

    // 入力
    int n;
    cin >> n;
    int W[n];
    for (int i = 0; i < n; i++) {
        cin >> W[i];
    }

    // 処理
    int s1           = 0;
    int s2           = 0;
    int sumTotal     = 0;
    ll  minimumValue = LLONG_MAX;

    // 総和を求める
    for (int i = 0; i < n; i++) {
        sumTotal += W[i];
    }
    // cout << sumTotal << endl;
    for (int i = 0; i < n; i++) {
        s1 += W[i];
        s2 = sumTotal - s1;
        if (minimumValue > abs(s1 - s2)) {
            minimumValue = abs(s1 - s2);
        }
    }

    // 出力
    cout << minimumValue << endl;

    return 0;
}


Measured memory_bytes: 256