akhauriyash/Code-Regression huggingface dataset:
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=sqrt(n);i>0;--i)
	{
		if(n%i==0)
		{
			cout<<i+n/i-2;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

import heapq

def dijkstra():
    #n:辺数,w:スタート一
    n,w = map(int,input().split())

    edge = [[] for i in range(n)]
    dg = 10**7
    # edge[i]:[コスト]
    for i in range(n-1):
        x,y = map(int,input().split())
        z = 1
        x -= 1
        y -= 1
        edge[x].append(dg + y)
        edge[y].append(dg + x)
    
    s = w-1
    d = [-1]*n
    d[s] = 0

    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)

        

    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        v,c = minedge%dg,minedge//dg
        if d[v] >= 0:
            continue
        d[v] = c
        for e in edge[v]:
            vNext = e%dg
            if d[vNext]:
                heapq.heappush(edgelist, (e//dg+d[v])*dg + vNext)

    return d


def warshall_floyd(n,d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d




N,M = m()


d = [[mod for i in range(N*M)] for j in range(N*M)]
for i in range(N*M):
    d[i][i] = 0
a = []
for i in range(N):
    a.append(list(input()))
    for j in range(M):
        if i != 0:
            if a[-1][j] == "." and a[-2][j] == ".":
                d[i*M+j-M][i*M+j] = 1
                d[i*M+j][i*M+j-M] = 1
        if j != 0:
            if a[-1][j] == "." and a[-1][j-1] == ".":
                d[i*M+j][i*M+j-1] = 1
                d[i*M+j-1][i*M+j] = 1

for k in range(N*M):
    for i in range(N*M):
        for j in range(N*M):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])

ma = 0
for i in range(N*M):
    for j in range(N*M):
        if d[i][j] != mod:
            ma = max(ma,d[i][j])

print(ma)






















Measured memory_bytes: 45232
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}

int gcd (int a, int b) {
    while (b > 0) {
        int t = a % b;
        a = b, b = t;
    }
    return a;
}

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

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int arr[maxx << 1], nxt[maxx << 1];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    nxt[n] = n + 1;
    for (int i = n - 1; i >= 1; i--) {
        if (arr[i + 1] != 0) {
            nxt[i] = i + 1;
        } else {
            nxt[i] = nxt[i + 1];
        }
    }
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        int j = i, cur = 0;
        while (j <= n && (arr[j] ^ cur) == arr[j] + cur) cur += arr[j], res += nxt[j] - j, j = nxt[j];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll H,W,N;
  cin >>H;
  cin >>W;
  cin >>N;
  
  ll big;
  if(H>W)big=H;
  else big=W;
  
  int ans;
  ans=(N+big-1)/big;
  
  
   cout << ans<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char o[100],e[100];
int main(){
	cin >> o >> e;

	int i = 0;
	while(true) {
		if(o[i] == '\0') 
			break;
		cout << o[i];
		if(e[i] == '\0')
			break;
		cout << e[i];
		i++;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
s1 = []
s2 = []
 
for i in range(N):
    a = int(input())
    if a % 10 != 0:
        s1.append(a)
    else:
        s2.append(a)

if len(s1) == 0:
    print(0)
else:
    if sum(s1) % 10 == 0:
        print(sum(s1)-min(s1)+sum(s2))
    else:
        print(sum(s1)+sum(s2))

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

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

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

const long long INF = 1LL << 60;

string Sa, Sb, Sc, next1;

int main(){
	next1 = "a";
	cin >> Sa;
	cin >> Sb;
	cin >> Sc;

	while (true) {
		if (next1 == "a") {
			if (Sa.length() == 0) {
				cout << "A" << endl;
				return 0;
			}
			next1 = Sa.substr(0, 1);
			Sa.erase(0,1);
		}
		if (next1 == "b") {
			if (Sb.length() == 0) {
				cout << "B" << endl;
				return 0;
			}
			next1 = Sb.substr(0, 1);
			Sb.erase(0,1);
		}
		if (next1 == "c") {
			if (Sc.length() == 0) {
				cout << "C" << endl;
				return 0;
			}
			next1 = Sc.substr(0, 1);
			Sc.erase(0,1);
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long N;
  cin >> N;
  long long A;
  cin >> A;
  if (N == 1)
  {
    printf("%lld", A);
  }
  else
  {
    long long B;
    long long p, q, r;
    for (int i = 1; i < N; i++)
    {
      cin >> B;
      p = A;
      q = B;
      while (q != 0)
      {
        r = p;
        p = q;
        q = r % q;
      }
      A /= p;
      B /= p;
      A = p * A * B;
    }
    printf("%lld", A);
  }
}

Measured memory_bytes: 256
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
X = int(readline())
def make_divisors(n):
    lower_divisors = []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
        i += 1
    return lower_divisors 

A = make_divisors(X)
for a in A:
    for b in range(10**3,-(10**3),-1):
        Y = X // a
        if ((b+a)**4 + b*(b+a)**3 + b**2*(b+a)**2 + b**3*(b+a) + b**4) == Y:
            print(b+a,b)
            sys.exit()

Measured memory_bytes: 9252
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,a,b,c=0;
  string s1[3],s2[1];
  char str1[11];
  cin >> s1[0] >> n;
 
  for(int i=0;i<n;i++){
    cin >> s1[1] >> a >> b;

    if(s1[1] == "replace"){      // 置き換え
      cin >> s2[0];
      for(int j=a;j<=b;j++){
	s1[0][j]=s2[0][c];
	c++;
      }
      c=0;
    }

    if(s1[1] == "reverse"){      // 逆順
      for(int j=0;j<=(b-a)/2;j++){
	str1[0]=s1[0][a+j];
	s1[0][a+j]=s1[0][b-j];
	s1[0][b-j]=str1[0];
      }
    }

    if(s1[1] == "print"){        // 出力
      for(int j=a;j<=b;j++){
	cout << s1[0][j];
      }
      cout << endl;
    }

  }

  return 0;
}

Measured memory_bytes: 3156
import scala.math

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  def divisors(n: Int): List[Int] =
    for (i <- (1 to n).toList if n % i == 0) yield i
  
  var n = sc.nextInt()
  var d = Array.fill(n)(sc.nextInt()).sorted
  println(d(n/2) - 1 - d(n/2 -1) + 1 )
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
signed main(){
    gearup;
    int n;cin>>n;
    vl a(n-1);
    rep(i,n-1)cin>>a[i];
    map<ll,ll> mp;
    rep(i,n-1)mp[a[i]]++;
    for(int i=1;i<=n;i++)out(mp[i]);
}


Measured memory_bytes: 17192
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

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


	int N;
	N = getint();

	ll dp00 = 0;
	ll dp11 = 0;
	ll dp02 = -1e18;

	int n = N / 2;
	if (N % 2) {
		rep(i, n) {
			int a = getint();
			if (dp11 < dp00) dp11 = dp00;
			//chmax(dp11, dp00);
			dp00 += a;
			dp02 += a;
			if (dp02 < dp11) dp02 = dp11;
			//chmax(dp02, dp11);
			dp11 += getint();
		}
		chmax(dp11, dp00);
		dp02 += getint();
		printf("%lld\n", max(dp02, dp11));
	}
	else {
		rep(i, n) {
			if (dp11 < dp00) dp11 = dp00;
			//chmax(dp11, dp00);
			dp00 += getint();
			dp11 += getint();
		}
		printf("%lld\n", max(dp11, dp00));
	}


	Would you please return 0;
}

Measured memory_bytes: 1732
/*
  KUNAL ANAND
  MNNIT ALLAHABAD
*/  

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<assert.h>
using namespace std;
using namespace __gnu_pbds;
#define debug1(x) cout << # x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define debug3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
const ll INF=1e16;
const ll mod=1e9+7;

ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    ll a=power(x,y/2);
    a=(a*a)%mod;
    if(y%2)
        a=(a*x%mod)%mod;
    return a;
}

ll seg[1000000];

void update(ll node, ll low,ll high, ll l, ll r, ll val)
{
    //debug3(low,high,l);
    if(l>high||r<low||low>high||l>r)
        return;

    if(l<=low&&high<=r)
    {
        seg[node]=val;
        return;
    }

    ll mid=(low+high)/2;

    update((2*node)+1,low,mid,l,r,val);
    update((2*node)+2,mid+1,high,l,r,val);

    seg[node]=max(seg[(2*node)+1],seg[(2*node)+2]);
}

ll query(ll node,ll low,ll high,ll l,ll r)
{
    if(l>high||r<low||l>r)
        return 0;

    if(l<=low&&r>=high)
        return seg[node];

    ll mid=(low+high)/2;

    return max(query((2*node)+1,low,mid,l,r),query((2*node)+2,mid+1,high,l,r));    
}

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

    ll t;
    ll n,q;
    ll i,j,k,a,b,m,c=1,ans1=0,ans2=0,x1,x2,y2,y1,s,mini=LLONG_MAX,idx,ans=0;

    cin >> n;

    ll height[n+1], beauty[n+1];

    for(i=1;i<=n;i++)
    {
        cin >> height[i];
    }

    for(i=1;i<=n;i++)
        cin >> beauty[i];

    ll dp[n+1];

    for(i=1;i<=n;i++)
    {
        ll h=height[i];
        ll x=query(0,1,n,1,h-1);
        dp[i]=beauty[i]+x;

        update(0,1,n,h,h,dp[i]);

        ans=max(ans,dp[i]);
    }

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

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int h,m,s,h2,m2,s2;

int main(){
	while(cin>>h>>m>>s>>h2>>m2>>s2){
		int t=(h2-h)*3600+(m2-m)*60+s2-s;
		cout<<t/3600<<" "<<t%3600/60<<" "<<t%60<<endl;
	}
}

Measured memory_bytes: 0
def gcd(a,b):
    if b > 0:
        c = a % b
        return(gcd(b,c))
    elif b == 0:
        return(a)

N, X = map(int,input().split())
x = list(input().split())
x = [abs(X-int(i)) for i in x]
for i in x:
    if i == x[0]:
        a = i
    else:
        a = gcd(a,i)
print(a)

Measured memory_bytes: 14940
N = int(input())
A = [0]+list(map(int, input().split()))+[0]

A_sum = sum([abs(a1-a2) for a1, a2 in zip(A, A[1:])])

for i in range(1,N+1):
    print(A_sum + abs(A[i-1]-A[i+1]) - (abs(A[i-1]-A[i]) + abs(A[i]-A[i+1])))


Measured memory_bytes: 14048
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	if(d>e)swap(d,e);
	cout<<a+d-50<<endl;
	return 0;
	}



Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,m=MI()
lis=[[]for i in range(n)]
for i in range(m):
    a,b=MI()
    lis[a-1].append(b)
    lis[b-1].append(a)
for i in range(n):
    print(len(lis[i]))


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

using namespace std;

struct node {
  int vl;
  int vr;
  int sum;
  node() {
      vl = -1;
      vr = -1;
      sum = 0;
  }
};

const int maxn = 5e5 + 100;

int n;
int last = 2;
int version[maxn], nxt[maxn], val[maxn], s[maxn];
node t[120 * maxn];

int st, ed, dt;

void init() {
    for (int i = 1; (1 << i) < n; i++) {
        t[last].vl = t[last].vr = i;
        last++;
    }
    version[0] = last - 1;
}

int update(int v, int l, int r) {
    if (l >= ed || r <= st) return v;
    int u = last++;
    t[u].sum = t[v].sum + dt;
    if (l + 1 == r) {
        return u;
    }
    int m = (l + r) / 2;
    t[u].vl = update(t[v].vl, l, m);
    t[u].vr = update(t[v].vr, m, r);
    return u;
}

int build_tree(int v, int l, int r) {
    int u = last++;
    if (l + 1 == r) {
        t[u].sum += val[l];
        return u;
    }
    int m = (l + r) / 2;
    t[u].vl = build_tree(t[v].vl, l, m);
    t[u].vr = build_tree(t[v].vr, m, r);
    t[u].sum = t[t[u].vl].sum + t[t[u].vr].sum;
    return u;
}

int res = 0;

void get_segm(int v, int l, int r) {
    if (l >= ed || r <= st) {
        return;
    }
    if (st <= l && r <= ed) {
        res += t[v].sum;
        return;
    }
    get_segm(t[v].vl, l, (l + r) / 2);
    get_segm(t[v].vr, (l + r) / 2, r);
}

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

    int q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (s[x] == 0) {
            val[i] = 1;
        } else {
            nxt[s[x] - 1] = i;
        }
        s[x] = i + 1;
        nxt[i] = n + 1;
    }
    init();
    version[0] = build_tree(1, 0, n);
    for (int i = 1; i < n; i++) {
        st = i - 1;
        ed = i;
        dt = -1;
        version[i] = update(version[i - 1], 0, n);
        if (nxt[i - 1] < n) {
            st = nxt[i - 1];
            ed = st + 1;
            dt = 1;
            version[i] = update(version[i], 0, n);
        }
    }
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        st = x - 1;
        ed = y;
        res = 0;
        get_segm(version[x - 1], 0, n);
        cout << res << "\n";
    }

    return 0;
}

Measured memory_bytes: 718204
s = list(input())
ans = []
for i in range(len(s)) :
    if s[i] == "0" :
        ans.append("0")
    elif s[i] == "1" :
        ans.append("1")
    elif s[i] == "B" and len(ans) > 0 :
        del ans[-1]
print("".join(ans))


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

int main() {
	int s;
	cin >> s;
  	int s3 = s%10;
  	int s2 = (s%100-s3)/10;	
  	int s1 = s/100;	
  	cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
r, l = [0, 0]
STDIN.each do |s|
  lx = s.split(',').map(&:to_i)
  if (lx[0]**2+lx[1]**2==lx[2]**2)
    r += 1
  elsif (lx[0]==lx[1])
    l += 1
  end
end
puts r, l

Measured memory_bytes: 6096
from collections import Counter
import math

N = input()
PRIMES = [2,3,5,7,11,13,17,19,23,27,29,31] # < sqrt(1000)
factors = []
for n in range(2,N+1):
  tmp = n
  for prime in PRIMES:
    while tmp % prime == 0:
      factors.append(prime)
      tmp /= prime
    if tmp == 1:
      break
  if tmp > math.sqrt(n):
    factors.append(tmp)

count = 1
for v in Counter(factors).values():
  count *= (v+1)
count = count % (10**9+7)
print count 

Measured memory_bytes: 2936
n=int(input())
ls=list(map(int,input().split()))
c=sorted(ls)
mini=c[0]
maxi=c[-1]
lb=0
k=1000
st=0
pmin=c.index(mini)
pmax=c.index(maxi)
for i in range(n):
  if i<n-1:
    if ls[i]>ls[i+1]:
      k+=ls[i]*st
      st=0
    elif ls[i]<ls[i+1]:
      st+=k//ls[i]
      k=k-ls[i]*(k//ls[i])
      lb=ls[i]
  else:     #最終日に売り抜くパターン！
    if lb<ls[i]:
      k+=ls[i]*st
      st=0
k+=lb*st
print(k)


Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;

int main(){
  ll n,ans=0;cin>>n;
  vector<ll> a(n),b(n),c(n);
  REP(i,n) cin>>a.at(i);
  REP(i,n) cin>>b.at(i);
  REP(i,n) cin>>c.at(i);
  sort(ALL(a));
  sort(ALL(c));
  
  REP(i,n){
    auto Iter_a=lower_bound(ALL(a),b.at(i));
    auto Iter_c=upper_bound(ALL(c),b.at(i));
    ans+=(Iter_a-a.begin())*(c.end()-Iter_c);
  }

  cout<<ans;
}


Measured memory_bytes: 2560
s = input()
hurf = len(s) // 2
before = s[:hurf]
after = "".join(list(reversed(s[hurf+len(s)%2:])))

diff_count = 0

for i in range(len(before)):
  if before[i] != after[i]:
    diff_count += 1
    
print(diff_count)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int N, K;
int ans;
int p[1000];

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

    rep0(i, N)
    {
        cin >> p[i];
    }
    sort(p, p + N);
    rep0(i, K) ans += p[i];

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
ll ruijou (ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) {
        return a * ruijou(a, n - 1) % mod;
    }
    else {
        ll k = ruijou(a, n/2);
        return k * k % mod;
    }
}
int main() {
    string l;
    cin >> l;
    ll ret = 0;
    ll bairitu = 1;
    int len = l.length();
    for (int i = 0; i < len; i++) {
        if (l[i] == '1') {
            ret += bairitu * ruijou (3, (len - i - 1));
            ret %= mod;
            bairitu *= 2;
            bairitu %= mod;
        }
        if (i == len - 1) {
            ret += bairitu;
            ret %= mod;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3732
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
    if "##" not in S[A-1:D]:
        print("Yes")
    else:
        print("No")
elif D<C:
    if "##" not in S[A-1:C] and "..." in S[B-2:D+1]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3572
using System;

class AtCoderCS {
    static void Main(string[] args) {
        int K = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();

        if (S.Length <= K)
            Console.WriteLine(S);
        else {
            for (int i = 0; i < K; i++)
                Console.Write(S[i]);
            Console.WriteLine("...");
        }
    }
}

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

using namespace std;

int main(){
  char a, b; cin >> a >> b;
  string res = "";
  if(a-'0' <= b-'0'){
    for(int i = 0; i < (b-'0'); i++) res += a;  
  }
  else{
    for(int i = 0; i < (a-'0'); i++) res += b;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    long long int n, q;
int main() {
    int a, b, c;
    cin >> a >> b >>c;
    if(a < c && c < b){
        cout << "Yes" << endl;
    }else if(b < c && c < a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
	int n;
	cin>>n;
	string s[n];
	int p[n];
	map<string,vector<pair<int,int>>> mp;
	rep(i,n){
		cin>>s[i]>>p[i];
		mp[s[i]].push_back(make_pair(p[i],i));
	}
	
	sort(s,s+n,[](string a,string b){return lexicographical_compare(a.begin(),a.end(),b.begin(),b.end());});
	
	for(auto a:mp){
		sort(mp[a.first].begin(),mp[a.first].end(),[](pair<int,int> x,pair<int,int> y){return x.first>y.first;});
	}
  	rep(i,n-1){
      	if(s[i]==s[i+1])continue;
		vector<pair<int,int>> v = mp[s[i]];
		for(auto a:v){
			puts(a.second+1);
		}
	}
      vector<pair<int,int>> v = mp[s[n-1]];
		for(auto a:v){
			puts(a.second+1);
		}

      
}


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

int main() {
  int N,D;
  cin >> N >> D;
  
  int a = N;
  int b = 1 + 2 * D;
  
  //切り上げ
  int ans = (a + (b - 1)) / b;
  
  cout << ans << endl;
  return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,k; scanf("%d%d",&n,&k);
    vector<P> td(n);
    rep(i,0,n)scanf("%lld%lld",&td[i].second,&td[i].first);
    sort(ALL(td),greater<P>());
    ll sub=0,kind=0; bool used[100010]={};
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    rep(i,0,k){
        sub+=td[i].first;
        if(used[td[i].second])pq.push(td[i].first);
        else used[td[i].second]=1,kind++;
    }
    ll ans=sub+kind*kind;
    rep(i,k,n){
        if(!used[td[i].second]){
            if(pq.empty())break;
            used[td[i].second]=1; kind++;
            sub+=td[i].first-pq.top(); pq.pop();
            chmax(ans,sub+1LL*kind*kind);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main() {
    int N, T, ans = 1001;
    cin >> N >> T;
    for(int i = 0; i < N; ++i) {
        int c, t;
        cin >> c >> t;
        if(t <= T)
            ans = min(ans, c);
    }
    if(ans == 1001)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
    return 0;
}


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

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

while (A%2==0 && B%2==0 && C%2==0)
{
  int a=A/2,b=B/2,c=C/2;
  A=b+c,B=a+c,C=b+a;
  cnt++;
  if(A==B && C==B){
cnt =-1;
break;
  } 
}
cout << cnt << endl;


  return 0;
}

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

struct Point{
	int x; int y; Point(){ x = 0; y = 0; }
};

int main(){
	const int h_max = 101;
	const int w_max = 101;
	int h, w;
	int a[h_max][w_max];

	while (cin >> h >> w , h*w != 0){

	for (int i = 0; i < h_max; ++i){
		for (int j = 0; j < w_max; ++j){
			a[i][j] = 0;
		}
	}

	
		string s;
		for (int i = 0; i < h; ++i){
			cin >> s;
			for (int j = 0; j < s.length(); ++j){
				switch ((int)s[j]){
				case (int)'>':
					a[j][i] = 1;
					break;
				case (int)'<':
					a[j][i] = 2;
					break;
				case (int)'^':
					a[j][i] = 3;
					break;
				case (int)'v':
					a[j][i] = 4;
					break;
				case (int)'.':
					a[j][i] = 5;
					break;
				}
			}
		}


		Point p;
		int count = 0; bool  is_loop = false;
		while (a[p.x][p.y] != 5 && is_loop == false){
			switch (a[p.x][p.y])
			{
			case 1:
				++p.x;
				break;
			case 2:
				--p.x;
				break;
			case 3:
				--p.y;
				break;
			case 4:
				++p.y;
				break;
			}

			++count;
			if (count > 101 * 101){
				is_loop = true;
			}
		}
		if (!is_loop){
			cout << p.x << " " << p.y << endl;
		}
		else{
			cout << "LOOP" << endl;
		}
	}
	
	/*
	for (int i = 0; i < h_max; ++i){
		for (int j = 0; j < w_max; ++j){
			cout << a[i][j];
		}
		cout << endl;
	}
	*/
	


	return 0;
}

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

L = [[0, 0, 0] for _ in range(n)]
for i in range(n):
    x, y, h = map(int, input().split())
    L[i][0] = x
    L[i][1] = y
    L[i][2] = h

L.sort(key=lambda x: x[2], reverse=True)

for i in range(0, 101):
    for j in range(0, 101):
        temp = []
        border = float('inf')
        for k in range(n):
            x = L[k][0]
            y = L[k][1]
            h = L[k][2]
            if h > 0:
                H = abs(i-x)+abs(j-y)+h
                temp.append(H)
            else:
                border = min(border, abs(i-x)+abs(j-y))
        temp = list(set(temp))
        if len(temp) == 1 and temp[0] <= border:
            ans = [i, j, H]
print(*ans)


Measured memory_bytes: 49500
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  vector<ll> count(40, 0);
  REP(i, N) {
    bitset<40> bs(A[i]);
    REP(j, 40) {
      if(bs[j]) {
        count[j]++;
      }
    }
  }
  ll s = 0;
  for(int i = 39; i >= 0; i--) {
    if(count[i] * 2 < N && ((1LL << i) | s) <= K) {
      s = (1LL << i) | s;
    }
  }
  ll ans = 0;
  REP(i, N) {
    ans += s ^ A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
def main(S_: int):
    MOD = int(10**9+7)
    dp = [0] * 2001
    for s in range(3, S_+1):
        dp[s] = 1 #1分割はできる
        for r in range(3, s):
            dp[s] += dp[s-r]
            dp[s] %= MOD

    return dp[S_] % MOD


if __name__ == '__main__':
    S = int(input())
    ans = main(S)
    print(ans)

Measured memory_bytes: 64620
import sys

# sys.stdin = open('b1.in')

n, m = map(int, input().split())

roads = []
for i in range(m):
    a, b = map(int, input().split())
    roads.append((a, b))

res = [0] * n
for a, b in roads:
    res[b - 1] += 1
    res[a - 1] += 1
for r in res:
    print(r)


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

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

	int a = 999;
	int b;
	int n = s.size();
	for (int i = 0; i < n-2; i++) {

		
		b = (s[i]-'0')*100+(s[i+1] - '0')*10+ s[i+2] - '0';
		//cout << b<<"\n";

		a = min(a, abs(753 - b));
	}
	cout << a;
	
}

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

k = int((n * 2) ** 0.5) + 1
if k * (k - 1) != 2 * n:
    print('No')
else:
    print('Yes')
    print(k)
    arr = [list() for _ in range(k)]

    num = 1
    tar1, tar2 = 0, 1
    while True:
        arr[tar1].append(num)
        arr[tar2].append(num)
        if num == n:
            break
        else:
            num += 1
        if len(arr[tar1]) == k - 1:
            tar1 += 1
            tar2 = tar1 + 1
        else:
            tar2 += 1
    for i in range(k):
        print(k - 1, *arr[i])

Measured memory_bytes: 9464
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    p, q, r = map(int, input().split())
    m = max([p, q, r])
    if m == p:
        print(q + r)
    elif m == q:
        print(p + r)
    elif m == r:
        print(p + q)

if __name__ == '__main__':
    main()


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

int main() {

  int a,b,c,d,e;
  cin>>a>>b;
  vector<int> vec(a);
  
  for(int i=0;i<a;i++){
  	cin>>vec.at(i);
      b -= vec.at(i);
  }
  
  
  c = *min_element(vec.begin(),vec.end());
  
  d =b/c;
  
  cout<<d+a<<endl;
}


Measured memory_bytes: 256
import itertools
a,b,c,x,y = map(int, input().split(" "))
ans = 10 ** 11

if x > y:
  dai = a
else:
  dai = b
  
if dai >= 2 * c:
  print(c * max(x, y) * 2)

else:
  for i in range(min(x, y) + 1):
    temp = a * (x - i) + b * (y - i) + c * (i * 2)
    if ans > temp:
      ans = temp
  print(ans)

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

int main(){
    string s;
    int K;cin>>s>>K;
    int n=s.size();
    vector<int> a(n);
    for(int i=0;i<n;i++){
        a.at(i)=s.at(i)-'a';
        if(a.at(i)!=0)a.at(i)=26-a.at(i);
    }
    for(int i=0;i<n-1;i++){
        if(K-a.at(i)>=0){
            K-=a.at(i);
            cout<<'a';
        }
        else{
            cout<<s.at(i);
        }
    }

    if(K==0)cout<<s.at(n-1)<<endl;
    else{
        a.at(n-1)=s.at(n-1)+K-'a';
        a.at(n-1)%=26;
        cout<<char('a'+a.at(n-1))<<endl;
    }
    

    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  vector<string> res = {"AC", "WA", "TLE", "RE"};
  map<string, int> cnt;

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    cnt[s]++;
  }

  for (auto s : res) {
    cout << s << " x " << cnt[s] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll N, D; cin >> N >> D;
	vector<ll> t(N), F(N);
	for (int i = 0; i < N;i++) { cin >> t[i] >> F[i]; F[i]--; }
	ll ans = 0;
	ll pre_t = 0;
	ll pre_f = 0;
	ll cnt = 0;
	for (int i = 0; i < N;i++) {
		if (abs(F[i] - pre_f) > t[i] - pre_t) {
			pre_f = 0,ans = -1; break;
		}
		if (F[i] + pre_f <= t[i] - pre_t) {
			ans += (cnt * pre_f);
			cnt = 1;
		}
		else {
			ans += (cnt * (t[i] - pre_t));
			cnt++;
			if (cnt > D) { pre_f = 0, ans = -1; break; }
		}
		pre_f = F[i]; pre_t = t[i];
	}
	ans += pre_f*cnt;
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define sz(x) ((long long)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const ld eps = 1e-9;
const ld pi = acosl(-1);
const int mod = 998244353;
const int mod1 = 1e9 + 7;

mt19937_64 rnd(time(0));

void faster()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
}

signed main() {
    faster();
    // freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
    //______________________________________
    /*__*/double start = clock();/*__*/
    //_____________________________________
    ll n;
    cin >> n;
    ll a[n];
    ll dp[n][n];
    ll cost[n][n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        cost[i][i] = a[i];
        dp[i][i] = 0;
    }
    for (ll sz = 1; sz < n; sz++)
    {
        for (ll l = 0; l + sz < n; l++)
        {
            ll r = l + sz;
            ll mn = 1e15;
            for (ll l1 = l; l1 < r; l1++)
            {
                ll now = 0;
                now = cost[l][l1] + cost[l1 + 1][r] + dp[l][l1] + dp[l1 + 1][r];
                mn = min(mn, now);
            }
            dp[l][r] = mn;
            cost[l][r] = cost[l][r - 1] + a[r];
            //  cout << l << " " << r << " " << mn << " " << cost[l][r] << endl;
        }
    }
    cout << dp[0][n - 1] << endl;
    //______________________________________
    cerr << "Time " << (clock() - start)  * 1.0 / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 2816
T = list(map(int, input().split()))
T.sort()
T.reverse()

ope = 0

while T[1]!=T[0]:
    ope += 1
    T[1] += 1
    T[2] += 1
    
while T[2]<T[0]:
    ope += 1
    T[2] += 2

if T[0]==T[2]:
    print(ope)
    
else:print(ope+1)

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


int main()
{
  int q;
  cin >> q;
  priority_queue<int> l;
  priority_queue<int, vector<int>, greater<int>> r;
  vector<int> c;
  ll sumda = 0;
  ll sumb = 0;
  rep(i, q)
  {
    int p;
    cin >> p;
    if (p == 1)
    {
      int a, b;
      cin >> a >> b;
      if (c.empty())
      {
        if (l.empty())
          c.push_back(a);
        else if (a < l.top())
        {
          sumda += l.top() - a;
          c.push_back(l.top());
          l.pop();
          l.push(a);
        }
        else if (r.top() < a)
        {
          sumda += a - r.top();
          c.push_back(r.top());
          r.pop();
          r.push(a);
        }
        else
          c.push_back(a);
      }
      else
      {
        if (a < c[0])
        {
          l.push(a);
          sumda += l.top() - a + c[0] - l.top();
          r.push(c[0]);
          c.clear();
        }
        else
        {
          r.push(a);
          sumda += a - c[0];
          l.push(c[0]);
          c.clear();
        }
      }
      sumb += b;
    }
    else
    {
      if (c.empty())
        printf("%d %ld\n", l.top(), sumda + sumb);
      else
        printf("%d %ld\n", c[0], sumda + sumb);
    }
  }
  return 0;
}

Measured memory_bytes: 3452
n,k = map(int,input().split())
p = list(map(int,input().split()))
sum = 0
for i in range(n):
    p[i] = (1+p[i])/2
    if i<k-1:
        sum += p[i]
    elif i==k-1:
        sum += p[i]
        largest = sum
    else:
        sum = sum + p[i] - p[i-k]
        largest = max(largest,sum)
        
print(largest)


Measured memory_bytes: 32060
import sys
po = [1<<i for i in range(10)]
def solve(n,m,p,a,b):
    a -= 1
    b -= 1
    t = [int(x) for x in sys.stdin.readline().split()]
    v = [[] for i in range(m)]
    for i in range(p):
        x,y,z = [int(x) for x in sys.stdin.readline().split()]
        x -= 1
        y -= 1
        v[x].append((y,z))
        v[y].append((x,z))
    dp = [[float("inf")]*m for i in range(po[n])]
    dp[0][a] = 0
    for i in range(po[n]):
        for j in range(n):
            if i&po[j]:continue
            k = i|po[j]
            for x in range(m):
                for y,z in v[x]:
                    d = dp[i][x]+z/t[j]
                    if d < dp[k][y]:
                        dp[k][y] = d
    ans = float("inf")
    for i in range(po[n]):
        if dp[i][b] < ans:
            ans = dp[i][b]
    if ans == float("inf"):
        print("Impossible")
    else:
        print(ans)
while 1:
    n,m,p,a,b = [int(x) for x in sys.stdin.readline().split()]
    if n == 0:
        break
    solve(n,m,p,a,b)



Measured memory_bytes: 5908
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int a = (int)(GetString()[0]);
		int b = (int)(GetString()[0]);
		
		Console.WriteLine(((a^b) == 0)? 'H' : 'D');
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  v2i v(n, v1i(n));
  rep(i, n-1){
    for(int j = i+1; j < n; ++j){
      int d;
      if(i <= x){
        if(j <= x) d = j - i;
        else if(j <= y) d = min(j-i, y-j+x-i+1);
        else d = x-i+j-y+1;
      }
      else if(i <= y){
        if(j <= y) d = min(j-i, y-j+i-x+1);
        else d = min(j-i, i-x+j-y+1);
      }
      else d = j-i;
      ++v[i][d];
    }
  }
  rep(i, n-1){
    int s = 0;
    rep(j, n-1) s += v[j][i+1];
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 16000
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include <iostream>
using namespace std;

int main(){
    string str;

    cin >> str;

    if (str == "Sunny"){
        cout << "Cloudy";
    }
    else if (str == "Cloudy"){
        cout << "Rainy";
    }
    else if (str == "Rainy"){
        cout << "Sunny";
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 2000005;
int sta[MAXN], tmp[MAXN], ans[MAXN], num[MAXN], n, m, K;
char S[MAXN], T[MAXN];

int main() {
	scanf("%d%d%d", &n, &m, &K);
	scanf("%s%s", S, T);
	reverse(S, S + n), reverse(T, T + m);
	for (int i = 0; i < n; i++) num[i] |= (S[i] - '0') << 1;
	for (int i = 0; i < m; i++) num[i] |= T[i] - '0';
	chkmax(n, m);
	int tp = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (num[i] == 3) {
			int x = 3, pos = i, z = K, cnt = 0;
			for (; tp > 0; --tp) {
				if (x == 3) {
					if (pos + z >= sta[tp] >> 2) {
						int t = sta[tp] >> 2;
						z -= t - pos, pos = t;
						tmp[cnt++] = sta[tp] ^ x;
						x &= sta[tp];
					} else break;
				} else if (x) {
					if (sta[tp] >> 2 == pos + 1) {
						if ((sta[tp] & 3) ^ x) x = 3;
						++pos;
					} else break;
				} else break;
			}
			if (x == 1 || x == 2) {
				tmp[cnt++] = (pos + 1) << 2 | x;
			} else if (x) ans[pos + z] = 3;
			for (int j = 0; j < cnt; j++)
				sta[++tp] = tmp[cnt - j - 1];
		} else if (num[i])
			sta[++tp] = i << 2 | num[i];
	}
	for (int i = 1; i <= tp; i++) ans[sta[i] >> 2] = sta[i] & 3;
	m = n + K;
	while (ans[m] < 2) --m;
	for (int i = m; i >= 0; i--) putchar('0' + (ans[i] >> 1));
	putchar('\n');
	m = n + K;
	while (~ans[m] & 1) --m;
	for (int i = m; i >= 0; i--) putchar('0' + (ans[i] & 1));
	return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n)cin >> a[i];
  int cnt=1;
  rep(i,n){
    if(a[i]==cnt)cnt++;
  }
  if(cnt==1)cout << -1 << endl;
  else cout << n-cnt+1 << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int b,c;
    cin>>b>>c;
    for(int j=0;j<c+2;j++){
        cout<<"#";
    }
    cout<<endl;
    for(int i=0;i<b;i++){
        cin>>a;
        cout<<"#"<<a<<"#"<<endl;
    }
    for(int k=0;k<c+2;k++){
        cout<<"#";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,ans;
string s;
int main(){
	cin>>n>>k>>s;
	int i=0,j=0;
	while(j<n){
		while(j<n && s[j]=='1')	++j;
		ans=max(ans,j-i);
		while(j<n && s[j]=='0')	++j;
		--k;
		if(k<0){
			while(i<n && s[i]=='1')	++i;
			while(i<n && s[i]=='0')	++i;
		}
		ans=max(ans,j-i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b,c;
  c3(a,b,c);
  co((a-c)/(b+c));
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

count=0

for b in B:
  count+=b

for i in range(n-1):
  if A[i]+1==A[i+1]:
    count+=C[A[i]-1]
    
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;


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

	if(str[0]==str[1] || str[1]==str[2] || str[2]==str[3])
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;

	return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define _P(...) (void)fprintf(stderr, __VA_ARGS__)

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, m;
	cin >>n >>m;
	
	ll gm = 1LL<<m;
	
	ll ans = m   * gm * 1900;
	ans += (n-m) * gm * 100;

	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	bool an=0;
	cin>>n;
	while(n!=0)
	{
		if(n%10==7)
		{
			an=1;break;
		}
		n/=10;
	}
	cout<<(an?"Yes":"No");
	return 0;
}

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

int N, K;
vector<int> H;

int main() {
  cin >> N >> K;
  H.resize(N + 1, 0);
  rep(i, N) cin >> H[i + 1];

  const ll INF = 1e18;
  vector<vector<ll>> dp(N + 1, vector<ll>(N + 2, INF));

  dp[0][1] = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N + 1; ++j) {
      for (int k = 0; k < i; ++k) {
        dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0, H[i] - H[k]));
      }
    }
  }

  ll ans = INF;
  rep(i, N + 1) ans = min(ans, dp[i][N - K + 1]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input().strip()

white_left = [0 for _ in range(N+1)]
red_right = [0 for _ in range(N+1)]

for i in range(N):
  white_left[i+1] = white_left[i]
  if S[i] == 'W':
    white_left[i+1] += 1
    
for i in range(N):
  red_right[i+1] = red_right[i]
  if S[N-1-i] == 'R':
    red_right[i+1] += 1

ans = N
for i in range(N+1):
  ans = min(ans, max(white_left[i], red_right[N-i]))
print(ans)

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

int main() {
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int a;
        cin >> a;
        n -= a;
    }
    if(n >= 0){
        cout << n << endl;
    }else{
        n = -1;
        cout << n << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<map>
using namespace std;
int a;
int main()
{
    cin>>a;
    if(a>=30) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;
int main()
{
	//int h, w,   q, D, ax[90001], ay[90001], l[100000], r[100000];
	//int  b, c, d, e,ans=0;
	string a, b, c;

	cin >> a>>b>>c;

		cout << a[0]<<b[1]<<c[2] << endl;
		
	

	



	// 出力
	return 0;
}

Measured memory_bytes: 256
#python3
s=input()
a=[int(s[:2]), int(s[2:])]
mmyy=False
yymm=False
if (1 <= a[0] <= 12) & (0 <= a[1] <= 99):
  mmyy = True

if (0 <= a[0] <= 99) & (1<= a[1] <= 12):
  yymm = True

if yymm & mmyy:
  print('AMBIGUOUS')
elif (not yymm) & mmyy:
  print('MMYY') 
elif yymm & (not mmyy):
  print('YYMM')
else:
  print('NA')




Measured memory_bytes: 3064