akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

ll x,y;

int main(){
	cin >> x >> y;
	int ans = 1;
	while(1){
		x <<= 1;
		if(x > y) break;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

if s == "SUN":
    print(7)
elif s == 'MON':
    print(6)

elif s == "TUE":
    print(5)

elif s == 'WED':
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)













Measured memory_bytes: 38384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                        ' '
#define EPS                        1e-9
#define P_INF                      2e9+17
#define N_INF                     -2e9-17
#define MOD                        1000000007
#define PI                         2*acos(0.0)
#define All(x)                     x.begin(),x.end()
#define Mem(Name, type)            memset(Name, type, sizeof(Name))

template<typename T>
T GCD(T a, T b) { return a ? GCD(b % a, a) : b; }

template<typename T>
T LCM(T a, T b) { return (a * b) / GCD(a, b); }

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto ob : v) os << ob << " ";
    return os;
}

template<typename T, typename S>
std::ostream &operator<<(std::ostream &os, const std::map<T, S> &v) {
    for (auto ob : v) os << ob.first << " : " << ob.second << std::endl;
    return os;
}

using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;

class ANot {
public:
    void solve(std::istream &in, std::ostream &out) {
        int x;
        in >> x;
        out << (x == 0 ? 1 : 0) << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ANot solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
    char n[4];
    scanf("%s", n);
    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
    {
        printf("Yes\n");
    }
        else
        {
            printf("No\n");
        }

    return 0;
}

Measured memory_bytes: 1628
#include <iostream>
#include <deque> 
#include <algorithm>
 
using namespace std;
 
int main(void){
	int n;
 
	int t;
	deque<int> x;
 
	cin >> n;
 
 
	while(cin >> t){
		x.push_back(t);
	}

	deque<int> v;
	v = x;
	sort(v.begin(), v.end());
 
 
	for(int i=0; i < n; i++){

		if(v[n/2 - 1] >= x[i])
			cout << v[n/2] << endl;
		else
			cout << v[n/2-1] << endl;
 
		
	}
 
 
	return 0;
}

Measured memory_bytes: 3840
n = int(input())
S = [input() for _ in range(n)]

num_ac, num_wa, num_tle, num_re = 0, 0, 0, 0

for s in S:
    if s == 'AC':
        num_ac += 1
    elif s == 'WA':
        num_wa += 1
    elif s == 'TLE':
        num_tle += 1
    else:
        num_re += 1

print(f'AC x {num_ac}')
print(f'WA x {num_wa}')
print(f'TLE x {num_tle}')
print(f'RE x {num_re}')


Measured memory_bytes: 15928
#include<bits/stdc++.h>
using namespace std;
const int N=5e5;
int a[N],fa[N],l[N],b[N],r[N],jo[N];
vector<int> si[N];
bool vis[N];
const int oo=2e8;
void dfs(int x){
	int xl=-oo,xr=oo,now=-1;
	if (vis[x])
		xl=b[x],xr=b[x],now=b[x]&1;
	for (int i=0;i<si[x].size();i++)
	{
		int p=si[x][i];
		if (fa[p]==0)
		{
			fa[p]=x;
			dfs(p);
			if (jo[p]==-1) continue;
			if (now==-1)
			{
				xr=min(xr,r[p]+1);
				xl=max(xl,l[p]-1);
				now=max(now,1^jo[p]);
				continue;
			}
			int xianr=r[p]+1;
			int xianl=l[p]-1;
			int xianjo=jo[p]^1;
			if (xianjo+now==1)
			{printf("No");exit(0);}
			xr=min(xianr,xr);
			xl=max(xl,xianl);					
		}
	}
	if (xr<xl) {printf("No");exit(0);}
	l[x]=xl;
	r[x]=xr;
	jo[x]=now;
}
void ddfs(int x){
	 for (int i=0;i<si[x].size();i++)
	 {
		int p=si[x][i];
		if (fa[p]==x)
		{
			for (int j=-1;j<=1;j+=2)
			if (a[x]+j<=r[p] && a[x]+j>=l[p])
			{
				a[p]=a[x]+j;
				ddfs(p);
				break;
			}
		}
	}
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		si[x].push_back(y);
		si[y].push_back(x);
	}
	int t;
	scanf("%d",&t);
	for (int i=1;i<=t;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		b[x]=y;
		vis[x]=1;
	}
	fa[1]=1;
	dfs(1);
	printf("Yes\n");
	a[1]=l[1];
	ddfs(1);/*
	for (int i=1;i<=n;i++)
		printf("%d %d %d %d\n",i,l[i],r[i],jo[i]);*/
	for (int i=1;i<=n;i++)
		printf("%d\n",a[i]);
}
	

Measured memory_bytes: 28704
#include <bits/stdc++.h>
#include <regex>
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
#define EPR(msg) cerr << msg << endl;
#define AST(exp, msg) EPR(msg) assert(exp);
#define TAST(exp, msg) EPR(msg) while(!exp){}
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N,M; cin>>N>>M;

  // 奇数、奇数
  int odd = N*(N-1)/2;
  // 偶数、偶数
  int even = M*(M-1)/2;

  int  ans = odd + even;
  cout << ans << endl;


  return 0;
}


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

int main(){
  int N;  cin >> N;
  bool flag = false;
  for(int i = 0;i <= (N / 4);i++){
    for(int j = 0;j <= (N / 7);j++){
      if((4 * i + 7 * j) == N)flag = true;
    }
  }

  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long LL;

int X;
LL money;

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

	if (X <5) {
		cout << 0 << endl;
	}
	else {
		money += ((X / 500) * 1000);
		X %= 500;
		money += ((X / 5) * 5);
		X %= 5;
		cout << money << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
    int n, k; std::cin >> n >> k;
    int c = 0;
    std::vector<std::pair<int, int>> a;
    for (int i = 0; i < n; i++) {
        int h; std::cin >> h;
        if (h >= k) {
            c++;
        }
    }
    std::cout << c << std::endl;
    return 0;
}

Measured memory_bytes: 3152
#include<stdio.h> 
#include<stdlib.h> 
int main() 
{ 
long int a,b,ave,n1,n2; 
scanf("%ld %ld",&a,&b); 
ave=((a+b)/2); 
n1=abs(a-ave); 
n2=abs(b-ave); 
if(n1==n2) 
printf("%ld\n",ave); 
else 
printf("IMPOSSIBLE\n"); 
return 0; 
} 


Measured memory_bytes: 128
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int k[100010][2];
int a[3];
char ans[100010];

int main(){
    int n;
    cin >> n >> a[0] >> a[1] >> a[2];

    rep(i, n) {
        string s;
        cin >> s;
        k[i][0] = s[0] - 'A';
        k[i][1] = s[1] - 'A';
    }

    rep(i, n){
        if (a[k[i][0]] > a[k[i][1]]) swap(k[i][0], k[i][1]);
        else if (a[k[i][0]] == a[k[i][1]]){
            if (i < n-1 && k[i][1] == k[i+1][0] || k[i][1] == k[i+1][1]){
                swap(k[i][0], k[i][1]);
            }
        }

        if (a[k[i][1]] == 0) {
            cout << "No" << endl;
            return 0;
        }

        a[k[i][0]]++;
        a[k[i][1]]--;
        ans[i] = k[i][0] + 'A';
    }

    cout << "Yes" << endl;
    rep(i, n) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 4436
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

roundUpOn5 :: (RealFrac a, Integral b) => a -> b
roundUpOn5 x
  | n <= -0.5 = m - 1
  | n >= 0.5 = m + 1
  | otherwise = m
  where (m, n) = properFraction x

main :: IO ()
main = do
    -- 整数の入力
    _ <- getLine
    -- スペース区切り整数の入力
    as <- map strToInt . words <$> getLine
    let ave = roundUpOn5 $ (fromIntegral $ sum as) / (fromIntegral $ length as)
    -- 出力
    putStrLn . show $ foldl (\acc x -> acc + (x - ave) ^ 2) 0 as


Measured memory_bytes: 1020
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n, tmp;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(n){
        cin >> tmp;
        mp[tmp]++;
        a[i] = tmp;
    }
    int dim = *max_element(all(a));
    int  flag = 1;
    if(dim % 2 == 0){
        for(int i=dim;i>dim/2;i--){
            if(mp[i] >= 2){
                mp[i] -= 2;
            }else{
                flag = 0;
                break;
            }
        }
        if(flag){
            if(mp[dim/2] == 1){
                mp[dim/2]--;
            }else{
                flag = 0;
            }
        }
        if(flag){
            for(auto iter=mp.begin(); iter!=mp.end(); iter++){
                if(iter->second == 0) continue;
                if(dim/2+1 > iter->first){
                    flag = 0;
                    break;
                }
            }
        }
    }else{
        for(int i=dim;i>=(dim+1)/2;i--){
            if(mp[i] >= 2){
                mp[i] -= 2;
            }else{
                flag = 0;
                break;
            }
        }
        if(flag){
            for(auto iter=mp.begin(); iter!=mp.end(); iter++){
                if(iter->second == 0) continue;
                if((dim+1)/2 >= iter->first){
                    flag = 0;
                    break;
                }
            }
        }
    }

    if(flag) cout << "Possible";
    else cout << "Impossible";
}


Measured memory_bytes: 896
using System;
class Program
{
    static void Main(string[] args)
    {
        string a = Console.ReadLine(); //標準入力


        int N = int.Parse(a);
        string s = "";
        for (int i= 0; i < N; i++)
        {
            s = s + "ACL";
        }
        Console.WriteLine("{0}", s);
    }
    
}

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

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

int vector_finder(vector<vector<int>> vec, vector<int> number){
  auto itr = find(all(vec),number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()){
    return 1;
  }
  else{
    return 0;
  }
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> paths;
  rep(i,M){
    int A,B;
    cin >> A >> B;
    vector<int> C = {A,B}, D = {B,A};
    paths.push_back(C);
    paths.push_back(D);
  }
  vector<int> points(N-1);
  rep(i,N-1){
    points.at(i) = i+2;
  }
  int ans = 0;
  sort(all(points));
  do {
    vector<int> v = points;
    v.push_back(1);
    int S = 1;
    rep(i,N-1){
      vector<int> path = {v.at(i), v.at(i+1)};
      if (!vector_finder(paths,path)){
        S = 0;
        break;
      }
    }
    if (S==1){
      ans++;
    }
  } while(next_permutation(all(points)));
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		String t = br.readLine();
		
		if(t.substring(0, t.length() - 1).equals(s))
			System.out.println("Yes\n");
		else
			System.out.println("No\n");
	}

}

Measured memory_bytes: 32424
def gcd(a,b):
	return a if b==0 else gcd(b,a%b)
def lcm(a,b):
	return a*b//gcd(a,b)
def f(n,c,d):
	return n-n//c-n//d+n//lcm(c,d)
A, B, C, D = map(int,input().split())
print(f(B,C,D)-f(A-1,C,D))

Measured memory_bytes: 61848
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int n,m;
  cin >> n >> m;
  
  queue<int> q[n];
  REP(i,n){
    REP(j,m){
      int a;
      cin >> a;
      q[i].push(a-1);
    }
  }
  
  int ans = n;
  int sum[m];
  bool f[m];
  REP(i,m) f[i] = true;

  REP(_,m-1){
    REP(i,m) sum[i] = 0;
    REP(i,n){
      while(!f[q[i].front()]) q[i].pop(); 
      sum[q[i].front()]++;				
    }
    int maxi = 0,index = -1;
    //REP(i,m) cout << sum[i] << " ";
    //cout << endl;
    REP(i,m){
      if(sum[i] > maxi){
        maxi = sum[i];
        index = i;
      }
    }
    f[index] = false;
    ans = min(ans,maxi);
  }
   
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1152
void main() {
	auto N = ri;
	auto S = rs;
	auto warr = new int[](N);
	warr[0] = (S[0] == 'W' ? 1 : 0);
	foreach(i; 0..N-1) warr[i+1] = (S[i+1] == 'W' ? 1 : 0) + warr[i];

	auto f(int n) {
		return n+1 - warr[n];
	}

	int res = int.max;
	foreach(i; 0..N) {
		int tmp;
		tmp += f(N-1) - f(i);
		tmp += i < 1 ? 0 : warr[i-1];
		res = min(res, tmp);
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; i++)
    {
        cin >> T[i];
    }
    cout << count_if(T.begin(), T.end(), [S](int x) {
        return find(S.begin(), S.end(), x) != S.end();
    }) << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <set>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	auto s = set<int>();
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 101
#define Whi 0
#define Gra 1
#define Bra 2


int M[N][N],color[N],d[N],f[N];
int n,tt;
void visit(int x){
  int v;
  color[x] = Gra;
  d[x] = ++tt;
  for(v=0;v<n;v++){
    if(M[x][v] == 0) continue;
    if(color[v] == Whi){
      visit(v);
    }
  }
  color[x] = Bra;
  f[x] = ++tt;
}


void dfs(){
  int u;

  for(u = 0; u < n; u++) color[u] = Whi;
  tt = 0;

  for(u = 0; u < n; u++){
    if(color[u] == Whi) visit(u);
  }
  for(u = 0; u < n; u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}


int main(){
  int u,v,k,i,j;

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

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

  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

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


Measured memory_bytes: 256
while True:
  try:
    data = list(map(int,input().split(",")))
  except EOFError:
    break
  dist = 0.0
  for i in range(10):
    dist += data[i]
  time = dist / float(data[10]+data[11])
  pos = data[10] * time
  tmp = 0.0
  for i in range(10):
    tmp += data[i]
    if tmp >= pos:
      print(i+1)
      break


Measured memory_bytes: 5608
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c;
	cin >> a >> b >> c;
	cout << max(c-a+b,0ll);
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int cnt = 0,cnt2 = 0;
    for(char i='a'; i<='z'; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i==s[j])
            {
                cnt++;
            }
            else
            {
                if(cnt>=1)
                    cnt2++;
                cnt = 0;
            }
        }
        if(cnt>=1)
            cnt2++;
        cnt = 0;
    }
    cout<<cnt2<<endl;
    return 0;
}

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

int n,t;

main()
{
    int ans=0,mx=0;
    int nwmin=1e9;
    bool use=false;
    scanf("%d %d",&n,&t);
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        if(a<=nwmin)
        {
            nwmin=a;
            use=false;
            continue;
        }
        int get=a-nwmin;
        if(get>mx)
        {
            mx=get;
            ans=1;
            use=true;
        }
        else if(get==mx&&!use)
        {
            use=true;
            ans++;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010];

int main(){
    int n, k;
    cin >> n >> k;
    rep(i, n) cin >> a[i+1];

    vector<string> ans;

    for(int i = k+1; i <= n; i++){
        if (a[i] > a[i-k]) ans.push_back("Yes");
        else ans.push_back("No");
    }

    for(auto e : ans) cout << e << endl;

    return 0;
}


Measured memory_bytes: 13208
x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort_by{|e| -e}
b = gets.split.map(&:to_i).sort_by{|e| -e}
c = gets.split.map(&:to_i).sort_by{|e| -e}

M = 1 << 35
@h = Array.new(k+1, M)
@l = 0

def enque(v)
    i = @l += 1
    @h[i] = v

    while i > 1 && @h[i] < @h[i/2]
        @h[i], @h[i/2] = @h[i/2], @h[i]
        i /= 2
    end
end

def deque
    x = @h[1]
    @h[1] = @h[@l]
    @h[@l] = M
    @l -= 1
    i = 1

    while i * 2 <= @l
        j = @h[i*2] < @h[i*2+1] ? i*2 : i*2+1
        break if @h[i] <= @h[j]
        @h[i], @h[j] = @h[j], @h[i]
        i = j
    end

    x
end

x.times do |xx|
    fy = y.times do |yy|
        fz = z.times do |zz|
            break zz if @l == k && a[xx] + b[yy] + c[zz] <= @h[1]
            deque if @l == k
            enque(a[xx] + b[yy] + c[zz])
        end

        break yy if fz == 0
    end

    break if fy == 0 
end

ans = []
k.times {ans << deque}
puts ans.reverse


Measured memory_bytes: 2040
#include<iostream>
#include<algorithm>
using namespace std;
main(){
  int ans=0;
  int be[10002];
  int x=-1,n,m;
  while(1){
    x=-1;
    ans=0;
    cin>>n>>m;
    if(m==0&&n==0)break;
    for(int i=0;i<n;i++){
      cin>>be[i];
      ans+=be[i];
    }
    sort(be,be+n,greater<int>());
    while(n>=m){
      x+=m;
      ans-=be[x];
      n-=m;
    }
    cout<<ans<<endl;
  }
}

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

int main() {
  string s;
  while (cin >> s) {
    if (s == "0")
      break;
    int t = 0;
    for (int i = 0; i < s.length(); i++)
      t += s[i] - '0';
    cout << t << endl;
  }
  return 0;
}


Measured memory_bytes: 3236
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
ll dp[100010];
ll h[100010];
int main(void) {
	ll n;
	cin >> n;
	for (ll i = 0;i < n;i++)cin >> h[i + 1];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = (ll)abs(h[2] - h[1]);
	for (ll i = 3;i <= n;i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException{
    int sub = 0;
    int i = 1;
    String s;
    int a = 0;
    int b = 0;
        while(i>0){
            BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
            s = x.readLine();
            StringTokenizer st = new StringTokenizer(s," ");
            a = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());

            if(a >= -1000 && a <= 1000 )
                i = -1;
            else if(b >= -1000 && b <= 1000)
                i = -1;
            else
                i = 1;
         }
        sub = a-b;
            if(sub<0)
                System.out.println("a < b");
            else if(sub>0)
                System.out.println("a > b");
            else if(sub==0)
                System.out.println("a == b");
    }
}

Measured memory_bytes: 24212
#include <stdio.h>

#define LENGE 10000

int main(void) {
    char input[LENGE];
    int n,r;

    scanf("%d",&n);

    if(n%1000 == 0){
        r = 0;
    }else{
    r = 1000-(n%1000);
    }
    printf("%d\n",r);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = 0x3f3f3f3f;

int a[11][11];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    int n, r, ans=0;
    cin >> n >> r;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=r; j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int x=1; i+x<=n; x++)
        {
            double d=0;
            for(int j=1; j<=r; j++)
            {
                d+=(a[i+x][j]-a[i][j])*(a[i+x][j]-a[i][j]);
            }
            if(sqrt(d)==floor(sqrt(d))) ans++;
        }
    }
    cout << ans;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);

    int n;

    cin >> n;

    if (n%2) {
        cout << 0;
        return 0;
    }

    int nn = n;

    int ans1 = 0;

    while (nn) {
        ans1 += nn/2;
        nn /= 2;
    }

    nn = n/2;
    int ans2 = 0;

    while (nn) {
        ans2 += nn/5;
        nn /= 5;
    }

    cout << min(ans1, ans2);



    return 0;
}


Measured memory_bytes: 256
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}


void func(void)
{
	char s[202];
	scanf("%s", s);

	int len = strlen(s);
	s[len-1] = '\0';
	len = strlen(s);
	if(len%2 == 1){
		s[len-1] = '\0';
		len--;
	}
	int startLen = len;
	while(len > 0){
		if(len%2 == 1){
			s[len-1] = '\0';
			len = strlen(s);
			continue;
		}
		bool isSameStr = true;
		for(int i=0; i<len/2; i++){
			if(s[i] != s[len/2 + i]){
				isSameStr = false;
				break;
			}
		}
		if(isSameStr){
			break;
		} else {
			s[len-1] = '\0';
			len = strlen(s);
		}
	}

	cout << len << endl;

	return;
}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;

int main() {
    int n, q, c, t, x, v_size;
    cin >> n >> q;
    vector<stack<int>> v(n);
    for(int i = 0; i < q; ++i) {
        cin >> c;
        if(c == 0) {
            cin >> t >> x;
            v[t].push(x);
        } else if(c == 1) {
            cin >> t;
            if(v[t].size() != 0) {
                cout << v[t].top() << '\n';
            }
        } else {
            cin >> t;
            if(v[t].size() != 0) {
                v[t].pop();
            }
        }
    }
}



Measured memory_bytes: 4256
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  char last = '$';
  int cnt = 0;
  long long ans = 0;
  for (auto const& c : s) {
    if (c == 'A') {
      int mv = (last == 'B' ? cnt / 2 : 0);
      ans += mv;
      cnt = 2 * mv;
    } else {
      if (c != last) cnt++;
      else cnt = 1;
      last = c;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		double n; cin >> n;
		double d; cin >> d;
		vector<vector<double>> vec(n, vector<double>(d));
		rep (i, n) {
			rep (j, d) {
				cin >> vec[i][j];
			}
		}
		double ans;
		int cnt = 0;
		rep (i, n) {
			for (int j = i + 1; j < n; ++j) {
				ans = 0.0;
				rep (k, d) {
					double tmp = abs(vec[i][k] - vec[j][k]);
					ans += tmp * tmp;
				}
					ans = sqrt(ans);
					if (ans - (int)(ans) == 0) cnt++;
			}
		}
		cout << cnt << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;

int main() {
    ll x;
    cin >> x;
    double a = 100;
    int ans = 0;
    rep(i,4000) {
        a *= 1.01;
        a = floor(a);
        ans++;
        if(a >= x) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    int Q[N];
    rep(i,N){
        int p;
        cin >> p;
        Q[p-1]=i;
    }
    int ms=0;
    int ts=1;
    rep(i,N){
      cerr << Q[i] << ' ';
        if(i!=0){
            if(Q[i]>Q[i-1])ts++;
            else{
                chmax(ms,ts);
                ts=1;
            }
          	if(i==N-1)chmax(ms,ts);
        }
      	cerr << ts << ' ' << ms << endl;
    }
  	if(N==1)ms++;
    cout << N-ms;
    


}

/*



 */




Measured memory_bytes: 1024
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int mod = 100000;
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] map = new int[n];
		int sum = 0;
		for (int i = 1; i < n; i++) {
			sum += scanner.nextInt();
			map[i] = sum;
		}
		int ans = 0;
		int index = 0;
		int now = 0;
		while (m-- > 0) {
			index += scanner.nextInt();
			ans += Math.abs(map[index] - now);
			ans %= mod;
			now = map[index];
		}
		System.out.println(ans);

	}
}

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

int main(){
 int ans,n,i,flag,a;
  cin>>n;
  flag=0;
  for(i=0;i<n;i++){
  	cin >> a;
    if(a%2==1){flag=1;}
  }
  if(flag==1){
  cout << "first" <<endl;
  }else{
  cout << "second" <<endl;
  }
 return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = readLine()!!
    var T : String = ""

    var i = 0
    while (i < S.length)
    {
        if(S.startsWith("dreameraser", i, false)) {
            i += 11
        } else if(S.startsWith("dreamerase", i, false)) {
            i += 10
        } else if(S.startsWith("dreamer", i, false)) {
            i += 7
        } else if(S.startsWith("eraser", i, false)) {
            i += 6
        } else if(S.startsWith("dream", i, false)) {
            i += 5
        } else if(S.startsWith("erase", i, false)) {
            i += 5
        } else {
            break
        }
    }

    if(i == S.length)
        println("YES")
    else
        println("NO")

}

Measured memory_bytes: 34400
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<lint>S(N);
	S[0] = A[0];
	for (int i = 1; i < N; i++) {
		S[i] = S[i - 1] + A[i];
	}
	lint ans = 100000000000;
	rep(i, N-1) {
		ans = min(ans,abs(S[N - 1] - 2*S[i]));
	}
	
	cout << ans << endl;
}




Measured memory_bytes: 3328
process.stdin.resume()
process.stdin.setEncoding("utf8")

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
})

const lines = []

reader.on("line", (line) => {
  lines.push(line)
})

reader.on("close", () => {
  const [n, k] = lines[0].split(" ").map(Number)

  const boxes = Array(n)
  for (let i = 0; i < n; i++) {
    boxes[i] = lines[i + 1] - 0
  }

  // 最大積載量 P の k 台のトラックで何個の荷物を積めるか
  const check = (P) => {
    let i = 0
    for (let j = 0; j < k; j++) {
      let s = 0
      while (true) {
        s += boxes[i]
        if (s > P) break
        i++
        if (i === n) return n
      }
    }
    return i
  }

  const solve = () => {
    let left = 0
    let right = 100000 * 10000
    let mid
    while (right - left > 1) {
      mid = Math.floor((left + right) / 2)
      let v = check(mid)
      if (v >= n) right = mid
      else left = mid
    }
    return right
  }

  console.log(solve())
})



Measured memory_bytes: 29248
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Mod = 2019

func main() {
	S := ReadString()
	T := make([]int, len(S)+1)
	base := 1
	for i := len(S) - 1; i >= 0; i-- {
		T[i] = T[i+1] + base*int(S[i]-'0')
		T[i] %= Mod
		base = base * 10 % Mod
	}
	m := make(map[int]int)
	for _, v := range T {
		m[v]++
	}
	ans := 0
	for _, c := range m {
		ans += c * (c - 1) / 2
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define rep(i,a,b) for(i=a;i<b;i++)
#define hell 1000000007
#define mod 998244353
#define fs first
#define sc second
#define all(v) v.begin(),v.end()

int main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int a,b;
  cin>>a>>b;
  if(2*b>=a)
    cout<<"0";
  else
    cout<<a-2*b;
  return 0;
}

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

int main(){
    int h, w, n, x=0;
    cin >> h >> w >> n;
    vector<int> A(n);
    vector<int> C(h*w);
    for(int i=0 ; i<n ; i++){
        cin >> A[i];
    }
    for(int j=0 ; j<n ; j++){
        for(int k=x ; k<x+A[j]; k++){
            C[k]=j+1;
        }
        x+=A[j];
    }
    for(int l=w ; l < h * w ; l+=2*w){
        reverse(C.begin()+l, C.begin()+l+w);
    }
    for(int m=0 ; m<h*w ; m++){
        cout << C[m];
        if((m+1)%w==0){
            cout << endl;
        }else{
            cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a;
    cin>>b;
    if((a==1&&b==2)||(b==1&&a==2))
        cout<<3<<endl;
    else if((a==1&&b==3)||(b==1&&a==3))
        cout<<2<<endl;
    else
        cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

ll modbeki(ll x, ll n){
  ll res = 1LL;
  while(n > 0){
    if(n & 1){
      res *= x % MOD;
      res %= MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res % MOD;
}

struct COM{
  ll modpow(ll x, ll nn){
    ll res = 1;
    while(nn > 0){
      if(nn & 1) res = res * x % MOD;
      x = x * x % MOD;
      nn >>= 1;
    }
    return res;
  }
  vll fact, ifact;
  COM(ll n): fact(n+1), ifact(n+1){
    assert(n < MOD);
    fact[0] = 1LL;
    for(ll i = 1; i <= n; i++) fact[i] = fact[i-1]*i%MOD;
    ifact[n] = modpow(fact[n], MOD-2);
    for(ll i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i%MOD;
  }
  ll operator()(int n, int k){
    if(k < 0 || k > n) return 0;
    return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  COM c(2000010);
  ll K;
  cin >> K;
  string S;
  cin >> S;
  ll N = S.size();
  ll ans = 0LL;
  for(int i = N; i <= N+K; i++){
    ans += c(i-1, N-1) * modbeki(25, i-N) % MOD * modbeki(26, N+K-i) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 35508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int h[N], m[N];
    for (int i = 0; i < N; i++) {
        cin >> h[i] >> m[i];
    }
    int M;
    cin >> M;
    int k[M], g[M];
    for (int i = 0; i < M; i++) {
        cin >> k[i] >> g[i];
    }
    set<int> s;
    for (int i = 0; i < N; i++) {
        int t = h[i] * 60 + m[i];
        s.insert(t);
    }
    for (int i = 0; i < M; i++) {
        int t = k[i] * 60 + g[i];
        s.insert(t);
    }
    for (auto it = s.begin(); it != s.end(); it++) {
        int t = *it;
        if (it != s.begin()) cout << " ";
        printf("%d:%02d", t / 60, t - (t / 60) * 60);
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int S,K,ans;
int main(){
    cin>>K>>S;

    REP(i,K+1)REP(j,K+1){
      if(S-(i+j)<=K)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>

using namespace std;

int N;
string X;

const long MOD = 998244353;

int loop(int n){
    int m = 1<<(N-1);
    int tmp = n;
    int cnt = 0;
    while(tmp != n || cnt == 0){
        cnt++;
        //cout << tmp << ' ';
        if(tmp%2 == 0){
            tmp/=2;
            tmp += m;
        }else{
            tmp -= 1;
            tmp /= 2;
        }
    }
    return cnt;
}

template <typename T>
vector<T> prime_facs(T N){
    vector<T> ans;
    for(int i = 2; i*i <= N; i++){
        if(N%i == 0){
            ans.push_back(i);
            while(N%i == 0){
                N /= i;
            }
        }
    }
    if(N != 1) ans.push_back(N);
    return ans;
}

long pow[200011];

void init(){
    pow[0] = 1;
    for(int i = 1; i <= 200010; i++){
        pow[i] = pow[i-1]*2;
        pow[i] %= MOD;
    }
}

long count(int n){
    long ans = 1;
    int m = N/n;
    string pref;
    string pref1;
    for(int i = 0; i < n; i++){
        if(X[i] == '0'){
            pref += '0';
            pref1 += '1';
        }else{
            pref += '1';
            pref1 += '0';
            ans += pow[n-1-i];
            ans %= MOD;
        }
    }
    string cmp;
    for(int i = 0; i < m; i++){
        if(i%2 == 0) cmp += pref;
        else cmp += pref1;
    }
    if(cmp > X) ans--;
    ans += MOD;
    ans %= MOD;
    return ans;
}

int main(){
    init();
    cin >> N >> X;
    int M = N;
    long ans = 0;
    while(M%2 == 0){
        M /= 2;
    }
    vector<int> v;
    for(int i = 1; i*i <= M; i++){
        if(M%i == 0) {
            v.push_back(i);
            if(i*i != M)v.push_back(M/i);
        }
    }
    for(int i = 0; i < v.size(); i++){
        int K = N/v[i];
        vector<int> p = prime_facs(M/v[i]);
        int cnt = p.size();
        long tmp = 0;
        for(int j = 0; j < (1<<cnt); j++){
            long prod = 1;
            int c = 0;
            for(int k = 0; k < cnt; k++){
                if(j&(1<<k)){
                    c++;
                    prod *= p[k];
                }
            }
            if(c%2 == 0){
                tmp += count(N/(v[i]*prod));
            }else{
                tmp -= count(N/(v[i]*prod));
            }
            tmp %= MOD;
            tmp += MOD;
            tmp %= MOD;
        }
        tmp *= K*2;
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    //cout << count(1) << endl;
    //cout << count(3) << endl;
    cout << ans << endl;
}

Measured memory_bytes: 2748
S = str(input())

N1 = int(S[:2])
N2 = int(S[2:])

if 0<N1<=12 :
    if 0<N2<=12:
        print( "AMBIGUOUS")
    elif 0 <= N2:
        print("MMYY")
    else:
        print("NA")


elif 0<=N1:
    if 0<N2<=12:
        print("YYMM")
    else:
        print("NA")
else:
    print("NA")



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

int main(){
  int n, k; cin>>n >>k;
  vector<int> h(n), dp(n, INT_MAX);
  for(int i=0;i<n;i++)cin>>h[i];
  
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      if(i+j<n){
        dp[i+j]=min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
      }
    }
  }
  
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024