akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int n;
    string s;
    cin >> n >> s;

    vector<int> pref(n), suf(n);
    pref[0] = s[0]=='W';
    for(int i = 1; i < n; ++i) pref[i] = pref[i-1] + (s[i]=='W');
    suf[n-1] = s[n-1]=='R';
    for(int i = n-2; i >= 0; --i) suf[i] = suf[i+1] + (s[i]=='R');

    int ans = 1e9;
    for(int i = -1; i < n; ++i){
        int left = i >= 0 ? pref[i] : 0, right = i+1 < n ? suf[i+1] : 0;
        int need = max(left, right);
        ans = min(ans, need);
    }
    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 5188
S = input()

unko =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for i in unko:
    if S.count(i) == 0:
        print(i)
        exit()

print("None")

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

long long A[200000],B[200000];

int main(){
    
        long long n, m ,ms;
        cin >> n >> m >> ms;
 
        for(int A_i = 0; A_i < n; A_i++){
            cin >> A[A_i];
        }
        for(int B_i = 0; B_i < m; B_i++){
           cin >> B[B_i];
        }

        long long sum = 0;
        long long x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        long long ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }

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

Measured memory_bytes: 6748
s = input()
t = input()

s_alph_index = {}
for i in range(len(s)):
    if s[i] not in s_alph_index:
        s_alph_index[s[i]] = [i,]
    else:
        s_alph_index[s[i]].append(i)
t_alph_index = {}
for i in range(len(t)):
    if t[i] not in t_alph_index:
        t_alph_index[t[i]] = [i,]
    else:
        t_alph_index[t[i]].append(i)

for key, vals in s_alph_index.items():
    cur = t[vals[0]]
    for index in vals:
        if t[index] != cur:
            print('No')
            exit()

for key, vals in t_alph_index.items():
    cur = s[vals[0]]
    for index in vals:
        if s[index] != cur:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 20400
<?php
$string = str_replace(array(" ", "\n"), "", fgets(STDIN));
$splited_string = str_split($string);
if ($splited_string['2'] == $splited_string['3'] && $splited_string['4'] == $splited_string['5']) {
  echo "Yes";
} else {
  echo "No";
}

Measured memory_bytes: 4728
// https://s3.amazonaws.com/codechef_shared/download/Solutions/JAN17/Setter/CHEFCIRC.cpp
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;
#define double long double

const int MaxN = 1e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9;

pair < double, double > p[MaxN];
pair < double, char > all[MaxN];
int n, k;

bool can(double rad) {
  int res = 1;
  for (int i = 1; i <= n && res < k; ++i) {
    int c = 1, sz = 0;
    for (int j = 1; j <= n; ++j) {
      if (i == j) {
        continue;
      }
      double d = hypot(p[i].first - p[j].first, p[i].second - p[j].second);
      if (d / 2 > rad) {
        continue;
      }
      pair < double, double > v = make_pair((p[j].first - p[i].first) / d, (p[j].second - p[i].second) / d);
      double l1 = d / 2;
      double l2 = sqrt(rad * rad - l1 * l1);
      l1 /= rad;
      l2 /= rad;
      pair < double, double > p1 = make_pair(v.first * l1 + v.second * l2, v.second * l1 - v.first * l2);
      pair < double, double > p2 = make_pair(v.first * l1 - v.second * l2, v.second * l1 + v.first * l2);
      double ang1 = atan2(p1.second, p1.first);
      double ang2 = atan2(p2.second, p2.first);
      if (ang1 > ang2) {
        c++;
      }
      all[sz++] = make_pair(ang1, 1);
      all[sz++] = make_pair(ang2 + 1e-10, -1);
    }
    sort(all, all + sz);
    for (int j = 0; j < sz; ++j) {
      c += all[j].second;
      if (res < c) {
        res = c;
      }
    }
  }
  return res >= k;
}

int main() {
//  freopen("input.txt", "r", stdin);
  cin >> n;
  k = n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i].first >> p[i].second;
  }
  random_shuffle(p + 1, p + n + 1);
  double l = 0, r = 1e12;
  for (int it = 0; it < 2000; ++it) {
    double m = (l + r) / 2;
    if (can(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout.precision(20);
  cout << fixed << (l + r) / 2.0 << '\n';
  return 0;
}

Measured memory_bytes: 2432
Coord = Struct.new(:x, :y)
Start = Coord.new(0.0, 0.0)
End = Coord.new(100.0, 0.0)
def koch(n, st, en)
    arr=[]
    return arr << st if n==0
    dx = en.x - st.x
    dy = en.y - st.y
    root3 = 3**(1.0/2)
    s = Coord.new((st.x * 2 + en.x)/3, (st.y * 2 + en.y)/3)
    t = Coord.new(s.x + dx/3, s.y + dy/3)
    u = Coord.new(s.x + (dx - dy * root3)/6, s.y + (dx * root3 + dy)/6)
    arr.concat(koch(n-1, st, s))
    arr.concat(koch(n-1, s, u))
    arr.concat(koch(n-1, u, t))
    arr.concat(koch(n-1, t, en))
end
n = gets.to_i
a = koch(n, Start, End)
a << End
a.each {|e|
    print e.x, ' ', e.y, "\n"
}

Measured memory_bytes: 6228
def main():
    s = input()

    if len(s) ==2:
        if len(set(list(s))) != 2:
            print("1 2")
            exit()



    for i in range(len(s)-2):
        if len(set(list(s[i:i+3]))) != 3:
            print(str(i+1) + " " + str(i+3))
            exit()

    print("-1 -1")


if __name__ == "__main__":
        main()


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
#define MAX_L 2005
pair<long long, long long> a[55]; 
int main() {
	int n, kk;
	long long ans = 9223372036854775807;
	cin >> n >> kk;
	for(int i = 1; i <= n; i++)
		cin >> a[i].first >> a[i].second;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			for(int k = 1; k <= n; k++)
				for(int l = 1; l <= n; l++) {
					long long xi = a[i].first, xj = a[j].first, yi = a[k].second, yj = a[l].second;
					if(xi < xj)
						swap(xi, xj);
					if(yi < yj)
						swap(yi, yj);
					int count = 0;
					for(int p = 1; p <= n; p++)
						if(a[p].first <= xi && a[p].first >= xj && a[p].second <= yi && a[p].second >= yj)
							count ++;
					if(count == kk)
						ans = min((xi - xj) * (yi - yj), ans);
				}	
	cout << ans << endl;
	return 0;
}


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

LL dp[55][2600];

int main(){
	memset(dp,0,sizeof(dp));
	int n,a,tmp;
	cin>>n>>a;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>tmp;
		for(int j=i;j>=1;j--){
			for(int k=0;k<=2500;k++){
				dp[j][k+tmp]+=dp[j-1][k];
			}
		}
	}
	
	LL ans=0;
	for(int i=1;i<=n;i++) ans+=dp[i][i*a];
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B,K;
    cin>>A>>B>>K;
    int C=min(A,B);
    vi v;
    for(int i=1; i<=C; i++) {
        if(A%i==0 && B%i==0) {
            v.push_back(i);
        }
    }
    reverse(all(v));
    cout<<v[K-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if(abs(a-b)%2 == 0)cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] p = new int[n];
		for(int i=0; i<n; i++){
			p[i] = scan.nextInt();
		}
		Arrays.sort(p);
		int sum = 0;
		for(int i=0; i<k; i++){
			sum += p[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 38736
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009
int main(void){
	double x, y, rad;
	double s, l, h;
	scanf("%lf %lf %lf", &x, &y, &rad);
	rad = rad*3.1415926536 / 180;
	s = x*y*(sin(rad)) / 2;
	l = (x*x) + (y*y) - (2 * x*y*cos(rad));
	l = sqrt(l);
	l += x + y;
	h = 2 * s / x;
	printf("%f\n%f\n%f\n", s, l, h);
	return 0;
}

Measured memory_bytes: 2780
#include<stdio.h>

int main()
{
    int n,y,b,r,t,i,j,ans;
    double tem,max;

    while(scanf("%d",&n),n){
        scanf("%d",&y);
        max=0;

        for(i=0;i<n;i++){
            scanf("%d%d%d",&b,&r,&t);

            if(t==1){
                tem=100.0*(1.0+y*r/100.0);
            } else {
                tem=100.0;
                for(j=0;j<y;j++){
                    tem*=(1.0+r/100.0);
                }   
            }   
        //    puts("*");
            if(max<tem){
                ans=b;
                max=tem;
            }   
        }   
        printf("%d\n",ans);
    }   
    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<algorithm>
int main(){
    int n,x,a[100];
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    std::sort(a,a+n);
    for(int i=0;i<n;i++){
        if(x<a[i]){
            printf("%d",i);
            return 0;
        }
        x-=a[i];
    }
    printf("%d",n-(x==0?0:1));
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b;
	cin >> a >> b;
	if(!(a > 8 || b > 8)) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

const long long infinity = 1e18;

long long dp[103][100005]={0};
long long w[100];
long long v[100];

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

    int n,C;
    cin >> n >> C;
    for(int i=0;i<n;i++){
        cin >> w[i] >> v[i];
    }
    dp[0][0] = 0;
    dp[0][w[0]] = v[0];
    for(int id=1;id<n;id++){
        dp[id][0] = 0;
        for(int j=1;j<=C;j++){
            if(j>=w[id])
                dp[id][j] = max(dp[id-1][j], v[id] + dp[id-1][j-w[id]]);
            else
                dp[id][j] = dp[id-1][j];            
        }
    }
    long long ans = -infinity;
    for(int i=0;i<=C;i++){
        ans = max(ans,dp[n-1][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 80908
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  ll sum=0,a[n];
  rep(i,n) {
    R a[i];
    sum+=a[i];
  }
  ll ans=MAXL,x=0;
  rep(i,n-1) {
    x+=a[i];
    sum-=a[i];
    ans=min(ans,abs(sum-x));
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
/**********************************************************/
/**            Bismillahir-rahmanir-rahim                **/
/**  In the name of Allah, the Beneficent, the Merciful. **/
/**********************************************************/
/****@author: Sayed Sohan, CSE 13th batch(2016), MBSTU*****/
/**********************************************************/

#include <bits/stdc++.h>
using namespace std;
//              Typedefs
typedef long long               ll;
typedef unsigned long long      ull;

//              Templates
template<class T>               using min_heap = \
                                priority_queue<T, \
                                std::vector<T>, std::greater<T>>;

//              Basic-Defs
#define PB                      push_back
#define MP                      make_pair
#define SP                      " "
#define NL                      "\n"
#define all(v)                  v.begin(), v.end()

//              DEBUG--SECTION
#define DE                      cout<<"HERE\n";
#define DE1(x)                  cout<<x<<"###\n";
#define DE2(x,y)                cout<<x<<"####"<<y<<"\n";
#define Pause                   system("pause");

//              Functions
#define clr(arr,value)          memset(arr,value,sizeof(arr))
#define __FAST_IO               ios_base::sync_with_stdio(0);\
                                cin.tie(0);cout.tie(0);
#define NUM1(x)                 __builtin_popcount(x)
#define LCM(x,y)                (x*y)/__gcd(x,y)

//              Sizes--Math     0123456789
#define MOD                     1000000007   //1e9+7 
#define MAX                     100050      
#define INF                     1e18
#define PI                      acos(-1)
#define eps                     1e-6

//** your code goes from here


int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    __FAST_IO;
    
    ll i,j,k,n,m,T; //basic variables

    
    string s,s2;
    cin>>s>>s2;
    s+=s2[s.size()];
    if(s==s2){
    	cout<<"Yes"<<NL;
    }
    else{
    	cout<<"No"<<NL;
    }

    /// Don't forget to set array size....
    return 0;
}




Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)

int N, W;
vector<int> w, v;

// [k, ..., N-1]番目の品物で重さp以下に抑えるときの価値の最大値を求める
vector<vector<LLI>> dp(101, vector<LLI>(100001, -1));

LLI f(int k, int p)
{
    if (k == N)
    {
        return 0;
    }

    if (dp[k][p] >= 0)
    {
        return dp[k][p];
    }

    if (w[k] > p)
    {
        dp[k][p] = f(k + 1, p);
    }
    else
    {
        dp[k][p] = max(f(k + 1, p), f(k + 1, p - w[k]) + v[k]);
    }

    return dp[k][p];
};

int main(int argc, char *argv[])
{

    cin >> N >> W;

    for (int i = 0; i < N; i++)
    {
        int ww, vv;
        cin >> ww >> vv;
        w.emplace_back(ww);
        v.emplace_back(vv);
    }

    LLI a = f(0, W);
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 80256
n = int(input())
h = list(map(int,input().split()))
b = ["True"]
 
if n == 1:
  print("Yes")
else:
  for i in range(n-1):
    d = h[i+1] - h[i]
    if d <= -2:
      print("No")
      break
    elif d >= 1:
      b.append("False")
      h[i+1] = h[i+1] - 1
      if i == n-2:
        print("Yes")
    elif d == 0:
      b.append("False")
      if i == n-2:
        print("Yes")
    elif d == -1:
      if b[i] == "True":
        h[i] = h[i] - 1
        b.append("True")
        if i == n-2:
          print("Yes")
      else:
        print("No")
        break

Measured memory_bytes: 14704
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll 
int D[31][31];
int x;
int ct[3][31];
int32_t main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif

	int n,C;
	cin>>n>>C;
	for(int i=1;i<=C;i++)
		for(int j=1;j<=C;j++)cin>>D[i][j];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){cin>>x;ct[(i+j)%3][x]++;}

	int ans=1e18;
	for(int i=1;i<=C;i++)
		for(int j=1;j<=C;j++)
		{
			if(j==i)continue;
			for(int k=1;k<=C;k++)
			{
				if(k==j or k==i)continue;

				int tmp=0;
				for(int l=1;l<=C;l++)
				{
					tmp+=(D[l][i]*ct[0][l]+D[l][j]*ct[1][l]+D[l][k]*ct[2][l]);
				}
				ans=min(ans,tmp);
				//cout<<tmp<<"\n";

			}
		}

	cout<<ans;

}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) {
        cin >> A[i];
        A[i] -= (i + 1);
    }

    sort(ALL(A));
    int b = A[N / 2];

    ll ans = 0;
    REP(i, 0, N) ans += abs(A[i] - b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;

int const MAXN=1100;
int N,M;
i64 a[MAXN][3];
int p[MAXN];

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

  cin>>N>>M;
  rep(i,0,N) rep(j,0,3) cin>>a[i][j];

  i64 res=0;
  rep(mask,0,1<<3) {
    rep(i,0,N) rep(j,0,3) if (mask>>j&1) a[i][j]*=-1;
    rep(i,0,N) p[i]=i;
    sort(p,p+N,[](int x,int y) {
      return a[x][0]+a[x][1]+a[x][2] < a[y][0]+a[y][1]+a[y][2];
    });
    rep(i,0,N) rep(j,0,3) if (mask>>j&1) a[i][j]*=-1;

    i64 s[3] = {0,0,0};
    rep(i,0,M) rep(j,0,3) s[j]+=a[p[i]][j];
    res=max(res,abs(s[0])+abs(s[1])+abs(s[2]));
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll mod_pow(ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    ll ans=0;
    
    //[0] [1] ...... [sz(s)-1]
    // 2   0   .....    9
    
    vector<ll> M(sz(s)+1,0);
    rrep(i,sz(s)){
        M[i]=(M[i+1]+(ll)(s[i]-'0')*mod_pow(10,sz(s)-1-i,2019))%2019;
    }
    
    //[i]~[j]が2019
    // == M[i]-M[j]が2019の倍数
    
    vector<ll> X(2019,0);
    rep(i,sz(M)){
        X[M[i]]++;
    }
    
    rep(i,sz(s)){
        ans+=X[M[i]]-1;
        X[M[i]]--;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 5156
N,K=map(int,input().split())
nodes=[]
for i in range(N):
  x,y=map(int,input().split())
  nodes.append((x,y))
nodes.sort()
import math
ans=math.inf
count=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(N):
      for l in range(i+1,N):
        count=0
        for m in range(N):
          small=min(nodes[k][1],nodes[l][1])
          big=max(nodes[k][1],nodes[l][1])
          if nodes[i][0]<=nodes[m][0]<=nodes[j][0] and small<=nodes[m][1]<=big:
            count+=1
        if count>=K:
          ans=min(ans,(nodes[j][0]-nodes[i][0])*(big-small))
print(ans)

Measured memory_bytes: 75404
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    if (s.back() == 's')
        cout << s << "es" << endl;
    else
        cout << s << 's' << endl;
    return 0;
}

Measured memory_bytes: 3040
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    t=chomp(readline())
    now=s
    while true
        now=join([now[end],now[1:end-1]])
        if now==t
            println("Yes")
            break
        end
        if now==s
            println("No")
            break
        end
    end
end
main()

Measured memory_bytes: 169000
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int n,l; cin>>n>>l;
	string S[n];
	for(int i=0;i<n;i++)cin>>S[i];
	//for(int i=0;i<n;i++)cout<<S[i]<<endl;;

	sort(S, S+n);
	for(int i=0;i<n;i++)cout<<S[i];
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 256
# 長い間考えて分からなかったけど、ようやく方針が分かった。
# 始点を複数にした幅優先探索
# 距離1の点をキューに入れる、
# 距離1の点を出しながら距離2の点をキューに入れる、
# 以下略。でできるじゃん。

h, w = list(map(int, input().split()))

masu = [input() for i in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

distance = [[-1 for _ in range(w)] for _ in range(h)]

from collections import deque

queue = deque([])
for i in range(h):
    for j in range(w):
        if masu[i][j] == '#':
            distance[i][j] = 0
            queue.append((i, j))

ans = 0
while True:
    if len(queue) == 0:
        break
    now = queue.popleft()
    now_h = now[0]
    now_w = now[1]
    now_distance = distance[now_h][now_w]
    # print(now_h, now_w)

    for i in range(4):
        next_h = now_h + dx[i]
        next_w = now_w + dy[i]
        if not (0 <= next_h <= h-1 and 0 <= next_w <= w-1):
            continue
        if distance[next_h][next_w] == -1:
            distance[next_h][next_w] = now_distance + 1
            queue.append((next_h, next_w))
            ans = now_distance + 1
            # print("appended {} {}".format(next_h, next_w))

print(ans)


Measured memory_bytes: 90332
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SimpleKnapsack solver = new SimpleKnapsack();
        solver.solve(1, in, out);
        out.close();
    }

    static class SimpleKnapsack {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long w = in.nextLong();

            long[] weights = new long[n];
            long[] values = new long[n];

            // i番目 | 選んだ個数 | 残 weight
            long[][][] dp = new long[n + 1][n + 1][3 * n + 1];
            for (int i = 0; i < n; i++) {
                weights[i] = Long.parseLong(in.next());
                ;
                values[i] = Long.parseLong(in.next());
                ;
            }

            for (int i = 0; i < n; i++) {
                int diff = (int) (weights[i] - weights[0]);
                for (int j = 0; j <= i; j++) {
                    for (int k = 0; k <= 3 * n; k++) {
                        if (k - diff < 0) {
                            dp[i + 1][j + 1][k] = dp[i][j + 1][k];
                        } else {
                            dp[i + 1][j + 1][k] = Math.max(dp[i][j + 1][k], dp[i][j][k - diff] + values[i]);
                        }
                    }
                }
            }
            long result = 0;
            for (int i = 0; i <= n; i++) {
                long zan = w - i * weights[0];
                if (zan >= 0) {
                    result = Math.max(result, dp[n][i][(int) Math.min(3 * n, zan)]);
                }
            }

            out.println(result);

        }

    }
}



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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    cout<<60*(c-a)+(d-b)-e;
    return 0;
}


Measured memory_bytes: 3636
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h,w] <- getIntList
    n <- getInt
    as <- getIntList
    mapM_ putStrLn $ map (unwords . (map show)) . grid w True $ coloring as

coloring as = concatMap (\(i,a) -> replicate a i) $ zip [1..] as

grid _ _ [] = []
grid w b a = (if b then t else reverse t) : grid w (not b) d
    where (t,d) = splitAt w a

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

int main() {

	bool key = true;
	int ans = 0;
	int N;
	cin >> N;

	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
		if (a.at(i) % 2 == 1)key = false;
	}

	while (key) {
		ans++;
		for (int i = 0; i < N; i++) {
			a.at(i) /= 2;
			if (a.at(i) % 2 == 1) {
				key = false;
				break;
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
pair<int,int>a[N];
priority_queue<int>q;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m,i;
	cin>>n>>m;
	for(i=0;i<n;i++)
		cin>>a[i].first>>a[i].second;
	sort(a,a+n);
	int j=0;
	long long ans=0;
	for(i=1;i<=m;i++)
	{
		while(j<n && a[j].first==i)
			q.push(a[j++].second);
		if(q.size())
		{
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

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

const LL INFL = (LL)1e18;

LL f(LL b, LL n){
    LL sum = 0;
    while(n > 0){
        sum += n % b;
        n /= b;
    }
    return sum;
}

signed main(){
    LL n, s;
    cin >> n >> s;

    LL ans = INFL;
    // s == n の時はn+1しかない
    if(s == n){
        cout << n+1 << endl;
        return 0;
    }

    // s > n の時は作れない
    if(s > n){
        cout << -1 << endl;
        return 0;
    }

    // √n以下の値で全探索
    for(LL i = 2; i*i <= n; i++){
        if(s == f(i, n)){
            ans = min(ans, i);
        }
    }
    
    // 1 <= a < √nで全探索
    for(LL a = 1; a*a < n; a++){
        LL b = (n - s) / a + 1;
        if(b < 2) continue;
        if(s == f(b, n)){
            ans = min(ans, b);
        }
    }
    cout << (ans != INFL ? ans : -1) << endl;
}

Measured memory_bytes: 384
A,B,C = map(int,input().split())
K = int(input())
x = 0
if A >= B:
    x += len(str(bin(A//B)))-2
    B *= 2**x
if B >= C:
    x += len(str(bin(B//C)))-2
#print(x)
if x <= K:
    print('Yes')
if x > K:
    print('No')

Measured memory_bytes: 61660
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi >
const int N=1000010;
vpi v[N];
string ans[N];
int main()
{
	int n,m,p,y;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>p>>y;
		v[p].pb({y,i});
	}
	for(int i=1;i<=n;i++)
	{
		if(!v[i].size()) continue;
		sort(v[i].begin(),v[i].end());
		for(int j=0;j<v[i].size();j++)
		{
			int k=i;
			string x="",y="";
			for(int l=0;l<6;l++)
			{
				x+=char(k%10+'0');
				k/=10;
			}
			k=j+1;
			for(int l=0;l<6;l++)
			{
				y+=char(k%10+'0');
				k/=10;
			}
			reverse(x.begin(),x.end());
			reverse(y.begin(),y.end());
			ans[v[i][j].second]=x+y;
		}
	}
	for(int i=1;i<=m;i++) cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 40576
#include <stdio.h>

#define MAX 100

void push(int);
long pop();

int S[MAX];
int top=0;

int main()
{
  int c;
  long x, a, b;

  while ((c=getchar())!=EOF){
    if (isdigit(c)){
      ungetc(c, stdin);
      scanf("%d", &x);
      push(x);
    }
    else {
      switch(c) {
      case '+':
	b=pop();
	a=pop();
	push(a+b);
	break;
      case '-':
	b=pop();
	a=pop();
	push(a-b);
	break;
      case '*':
	b=pop();
	a=pop();
	push(a*b);
	break;
      case '\n':
	if (top==1){
	  printf("%d\n", pop());
	}
	else {
	  printf("Invalid expression.\n");
	  top=0;
	}
      case ' ':
	break;
      default:
	printf("Invalid input.\n");
	top=0;
	break;
      }
    }
  }
return 0;
}

void push(int x)
{
        if ( top >= MAX){
                fprintf(stderr, "stack overflow\n");
                top=0;
        }
        top++;
        S[top]=x;
}
long pop()
{
	top--;
	return S[top+1];

}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,d,count;cin >> n >> d;
  count=0;
  
  for (int i=0;i<n;i++) {
    long long x,y;cin >> x >> y;
	if (d*d>=x*x+y*y) count++;
  }
  cout << count << endl;
}

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

Sum = sum(a) // 2

cand = 0
for i in range(n):
    temp = cand + a[i]
    if abs(cand - Sum) < abs(temp - Sum):break
    cand = temp
cost = abs(Sum - cand) + abs(Sum - (sum(a) - cand))
print(cost)

Measured memory_bytes: 26396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vi>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define each(x, a) for (auto&& x : (a))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (int i = (a), i##_len = (n); i < i##_len; ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
constexpr int inf = (1LL<<31) - 1;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-10;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};
template<class T> constexpr void print(const T& t) { cout << t << "\n"; }
template<class T, class U> constexpr bool chmax(T& a, const U& b) { if (a < b) a = b; return a < b; }
template<class T, class U> constexpr bool chmin(T& a, const U& b) { if (a > b) a = b; return a > b; }
template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p) { is >> p.fi >> p.se; return is; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.fi << " " << p.se; return os; }
template<class T> istream& operator>>(istream& is, vector<T>& v) { each(e, v) is >> e; return is; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { each(e, v) os << e << " "; return os; }
struct Init { Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); }} init;

template<typename T>
vector<T> smallest_prime_factors(T n) {

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++) spf[i] = i;


    for (T i = 2; i * i <= n; i++) {

        // 素数だったら
        if (spf[i] == i) {

            for (T j = i * i; j <= n; j += i) {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j) {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}

template<typename T>
map<T, T> factolization(T x, vector<T> &spf) {
    map<T, T> ret;
    while (x != 1) {
        ret[spf[x]]++;
        x /= spf[x];
    }
    return ret;
}
int main() {
    int n; cin >> n;
    auto spf = smallest_prime_factors(n);
    int ans = 0;
    rep(i, 1, n) {
        int cnt = 1;
        auto res = factolization(i, spf);
        each(x, res) cnt *= (x.se + 1);
        ans += cnt;
    }
    print(ans);
}

Measured memory_bytes: 7096
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll X;
// vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> X;
  // A.resize(N);
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   A[i] = tmp;
  // }

  ll x = 100;
  ll ans = 0;
  while (x < X) {
    double d = x * 1.01;
    x = d;
    ans++;
  }

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


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

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

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

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

  char c; cin >> c;
  cout << char(c + 1);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    int k=in();
    deque<int> q;
    rep(i,n){
        q.push_back(in());
    }
    ll ans=0;
    for(int x=0;x<=k;x++){
        for(int y=0;x+y<=min((ll)k,(ll)q.size());y++){
            deque<int> p=q;
            vec a(x+y);
            rep(i,x){
                a[i]=p.front();
                p.pop_front();
            }
            rep(i,y){
                a[i+x]=p.back();
                p.pop_back();
            }
            sort(All(a));
            ll tmp=0;
            ll sum=0;
            rep(i,x+y)sum+=a[i];
            tmp=sum;
            for(int i=0;i<k-x-y&i<a.size();i++){
                sum-=a[i];
                tmp=max(tmp,sum);
            }
            ans=max(ans,tmp);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
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; }

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
	ll N,m; cin >> N >> m;
	UnionFind uf(N);
	rep(i,0,m){
		ll a,b; cin >> a >> b;
		a--; b--;
		uf.merge(a,b);
	}
	ll ans = 0;
	rep(i,0,N){
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;
}

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

int main(){
    string s;
    bool flag1, flag2;
    flag1 = flag2 = 0;
    cin >> s;
    int y = stoi(s);
    if(y % 100 <= 12 && y % 100 >= 1) flag2 = 1;
    if(y / 100 <= 12 && y / 100 >= 1) flag1 = 1;
    
    if(flag1 == 1 && flag2 == 1) cout << "AMBIGUOUS" << endl;
    else if(flag1 == 0 && flag2 == 1) cout << "YYMM" << endl;
    else if(flag1 == 1 && flag2 == 0) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 9;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

vector<int> g[N];
int dp[N];

void dfs(int u, int par)
{
    dp[u] = 0;
    for (int v : g[u])
        if (v != par)
        {
            dfs(v, u);
            dp[u] ^= (dp[v] + 1);
        }
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    rep(i, 0, n - 1)
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0, -1);
    cout << (dp[0] > 0 ? "Alice\n" : "Bob\n");
    return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    string s,t;
    cin>>s>>t;
    string res;
    int n=s.size();int m=t.size();
    vii dp(n+1,vi(m+1,0));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int i=n;
    int j=m;
    while(i>0 && j>0)
    {
        
        if(s[i-1]==t[j-1])
        {
            res.push_back(s[i-1]);
            i--;j--;
            continue;
        }
         if(dp[i-1][j]>=dp[i][j-1])
        i--;
        else j--;
            
    }
    reverse(res.begin(),res.end());
    cout<<res;
    
    
    return 0;
}

Measured memory_bytes: 73648
function Main(input) {
	var n  = input.match(/^10+/)
	if(n!==null) console.log(10);
	else console.log(input[0]-0+(arrsum(input.slice(1,input.length).split("").map(Number))-0));
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i];
    }
    return sum;
}

Measured memory_bytes: 7500
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int n = readln().chomp().to!int;
    int m = readln().chomp().to!int;
    int[21][21] map;
    for(int i=0;i<21;i++){
	for(int j=0;j<21;j++){
	    map[i][j] = 100000;
	}
    }
    for(int i=0;i<m;i++){
	auto s = readln().chomp().split(',').to!(int[]);
	map[s[0]][s[1]] = s[2];
	map[s[1]][s[0]] = s[3];
    }
    auto s = readln().chomp().split(',').to!(int[]);
    int pos = s[0];
    int goal = s[1];
    int mon = s[2];
    int pr = s[3];
    bool flg = true;

    while(flg){
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=n;j++){
		flg = false;
		for(int k=1;k<=n;k++){
		    if(map[i][j] > map[i][k] + map[k][j]){
			map[i][j] = map[i][k] + map[k][j];
			flg = true;
		    }
		}
	    }
	}
    }
    writeln( mon - pr - map[pos][goal] - map[goal][pos]);


}

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

using namespace std;

int main() 
{
    
   int n;
   cin>>n;
   int c1=0,c2=0,c3=0,c4=0;
   string s[n];
    
   for( int i=0;i<n;i++)
   {
       cin>>s[i];
       
        if(s[i]=="AC")
           {
               c1++;
           }
              
           else if(s[i]=="WA")
            {
                c2++;
            }
            else if(s[i]=="TLE")
            {
               c3++;
            }
            else if(s[i]=="RE")
            {
                c4++;
            }
   }        
   

    cout<<"AC"<<" "<<"x"<<" "<<c1<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<c2<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<c3<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<c4<<endl;
}

Measured memory_bytes: 6708
#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 <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
//#define len length()
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect 

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) cout << "No";
    else cout << ((c - a - b) * (c - a - b) > 4 * a * b ? "Yes" : "No");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

int main(){
    int n;cin>>n;
    ll ans=0;
    vector<int> d1(10,0);
    vector<int> d2(10,0);
    vector<int> d3(10,0);
    string s;cin>>s;
    for(int i=0;i<n-2;i++){
        int n1=s[i]-'0';
        if(d1[n1]==0){
            d1[n1]++;
            for(int j=i+1;j<n-1;j++){
                int n2=s[j]-'0';
                if(d2[n2]==0){
                    d2[n2]++;
                    for(int k=j+1;k<n;k++){
                        int n3=s[k]-'0';
                        if(d3[n3]==0){
                            ans++;
                            d3[n3]=1;
                        }
                    }
                    for(int ii=0;ii<10;ii++) d3[ii]=0;
                }
            }
            for(int jj=0;jj<10;jj++) d2[jj]=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  while(1){
    long long n,sum=0,a[10101],b[10101]={};
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
      b[i+1]=a[i]+b[i];
      sum+=b[i+1];
    }
    printf("%lld\n",sum);
  }
  return 0;
}

Measured memory_bytes: 3184