akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

/*[DSU TEMPLATE] int dsu[501], ranks[501];

void resetDSU(){
    for(int i = 0; i < 501; ++i){
        dsu[i] = i; ranks[i] = 0;
    }
}
int find(int node){
    if(dsu[node] == node) return node;
    return dsu[node] = find(dsu[node]);
}
void combine(int a, int b){
    a = find(a); b = find(b);
    if(ranks[a] < ranks[b]){ dsu[a] = b; }
    else if(ranks[a] > ranks[b]){ dsu[b] = a; }
    else { dsu[a] = b; ranks[b]++; }
}*/

long long x[51], y[51];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    map<string, int> cnt;

    for(int i = 0; i < n; ++i){

        cin >> x[i] >> y[i];

    }

    for(int i = 0; i < n; ++i){

        for(int j = 0; j < n; ++j){

            if(i == j) continue;

            string label = to_string(x[i] - x[j]) + " " + to_string(y[i] - y[j]);

            if(cnt.find(label) != cnt.end()){
                ++cnt[label];
            } else {
                cnt.insert({label, 1});
            }

        }

    }

    int m = 0;

    for(auto i : cnt){
        m = max(m, i.second);
    }

    cout << n - m;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e6;

ll a[MAXN * 2];

int main()
{
	faster();
	ll q , ans = 0;
	cin >> q;
	string s[q];
	map <string, ll> m;
	for (int i = 0; i < q; i++)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		m[s[i]]++;
	}
	for (auto itr = m.begin(); itr != m.end(); itr++)
	{
		ll k = (*itr).second;
		ans += k * (k - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 16640
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

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

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

const int M = 350;

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int N;
    cin >> N;
    vector<int> x(N);
    cin >> x;
    int L;
    cin >> L;

    vector<int> nxt1(N), nxtM(N), prv1(N), prvM(N);
    for (int i = 0; i < N; ++i) nxtM[i] = i;
    for (int i = 0; i < N; ++i) prvM[i] = i;
    for (int i = 0; i < N; ++i) {
        nxt1[i] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
        prv1[i] = lower_bound(x.begin(), x.end(), x[i] - L) - x.begin();
    }
    nxt1[N - 1] = N;
    prv1[0] = -1;

    for (int l = 0; l < M; ++l) {
        for (int i = 0; i < N; ++i) {
            if (nxtM[i] != N) {
                nxtM[i] = nxt1[nxtM[i]];
            }
        }
        for (int i = N - 1; i >= 0; --i) {
            if (prvM[i] != -1) {
                prvM[i] = prv1[prvM[i]];
            }
        }
    }

    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (a < b) {
            int ans = 0;
            while (nxtM[a] <= b) {
                ans += M;
                a = nxtM[a];
            }
            while (nxt1[a] <= b) {
                ++ans;
                a = nxt1[a];
            }
            if (a != b) ++ans;
            cout << ans << "\n";
        } else {
            int ans = 0;
            while (prvM[a] >= b) {
                ans += M;
                a = prvM[a];
            }
            while (prv1[a] >= b) {
                ++ans;
                a = prv1[a];
            }
            if (a != b) ++ans;
            cout << ans << "\n";
        }
    }
}


Measured memory_bytes: 5272
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};




int main(){
    int N;cin >> N;
    vector<int> vec;
    for(int i = 0;i < N;i++){
        int b;cin >> b;
        vec.push_back(b);
    }
    vector<int> ans(N+1);
    for(int i = N;i >= 1;i--){
        int cnt = 0;
        for(int j = i;j <= N;j+=i){
            cnt += ans.at(j);
        }
        if(cnt%2 != vec.at(i-1)){
            ans.at(i) = 1;
        }else{
            ans.at(i) = 0;
        }
    }

    int M = 0;
    vector<int> q;
    for(int i = 1;i <= N;i++){
        if(ans.at(i) == 1){
            q.push_back(i);
        }
    }
    cout<<q.size()<<endl;
    for(auto a : q){
        cout<<a<<endl;
    }
}


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

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H+2);
    for (int i = 0; i < W+2; ++i) S[0]+='.';
    for (int i = 0; i < H; ++i){
        string s;
        cin >> s;
        S[i+1] = '.' + s + '.';
    }
    for (int i = 0; i < W+2; ++i) S[H+1]+='.';

    vector<string> ans(H);
    for (int i = 1; i < H+1; ++i) {
        for (int j = 1; j < W+1; ++j) {
            if(S[i][j] == '#') {
                ans[i-1] += '#';
            }else {
                int cnt = 0;
                for (int dx = -1; dx <= 1; ++dx) {
                    for (int dy = -1; dy <= 1; ++dy) {
                        if(S[i+dx][j+dy] == '#') cnt++;
                    }
                }
                ans[i-1] += to_string(cnt);
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


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

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = (int) x; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = (int) n; i > (int)x; i--)
#define rrep(i,n) RREP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
#define SZ(x) ((int)(x).size())

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main (){
  char a,b;
  cin >>a;
  cin >>b;
  
  if((a=='H' && b=='H') || (a=='D' && b=='D')){
    P('H');
  } else 
    P('D');
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *AF = map(int, read().split())
    A = AF[:N]
    F = AF[N:]

    A.sort()
    F.sort(reverse=True)

    def is_ok(cost):
        k = 0
        for a, f in zip(A, F):
            if a * f > cost:
                k += (a * f - cost + f - 1) // f
        return k <= K

    ok = max(a * f for a, f in zip(A, F))
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid

    print(ok)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 125132
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int x;
	cin >> x;
	string s;
	if(x < 1200)
		s = "ABC";
	else
	if(x < 2800)
		s = "ARC";
	else
		s = "AGC";
	cout << s;
		





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
using System;
using System.Text.RegularExpressions;

namespace arc058_a
{
    class Program
    {
        static void Main()
        {
            var tmpNk = Console.ReadLine().Split();
            var n = int.Parse(tmpNk[0]);
            var d = Console.ReadLine().Split();
            var pattern = $"[{string.Join(",", d)}]";
            for (var i = n; ; i++)
            {
                var matchCollection = Regex.Matches(i.ToString(), pattern);
                if (matchCollection.Count != 0)
                {
                    continue;
                }

                Console.WriteLine(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 20044
# include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b)
    printf("a < b\n");
    if(a > b)
    printf("a > b\n");
    if(a == b)
    printf("a == b\n");



















    return 0;
}

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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (u == s) cout << --a << " " << b << endl;
    else cout << a << " " << --b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1);
}   

Measured memory_bytes: 256
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod 998244353

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2) 
		if(n % i == 0) return false;
	return true;
}

int main(){ 
    do_not_disturb
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //freopen("milkvisits.in", "r", stdin);
    //freopen("milkvisits.out", "w", stdout);
	int n, i, k, j;
	cin >> n >> k;
	vector <int> v(n), dp(n);
	for(i = 0; i < n; i++){
		cin >> v[i];
	}
	dp[0] = 0;
	for(i = 1; i < n; i++){
		dp[i] = mod;
		for(j = i-1; j >= max(i-k, 0); j--){
			dp[i] = min(dp[i], abs(v[i]-v[j])+dp[j]);
		}
	}
	cout << dp[n-1];
    
    return 0;
} // What is to be written here?


Measured memory_bytes: 1024
n = gets.to_i

m = (10**9) * 2 + 1

z_max = -m
z_min = m
w_max = -m
w_min = m

n.times do
  x, y = gets.chomp.split.map(&:to_i)
  z = x + y
  w = x - y
  z_max = z if z_max < z
  z_min = z if z_min > z
  w_max = w if w_max < w
  w_min = w if w_min > w
end

puts [z_max - z_min, w_max - w_min].max


Measured memory_bytes: 14392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 200010;
int uni[N];
int getfa(int pos) {
  return pos == uni[pos] ? pos : uni[pos] = getfa(uni[pos]);
}
struct data {
  int v0, v1, id;
  bool operator < (const data& a) const {
    return 1ll * v1 * a.v0 > 1ll * v0 * a.v1;
  }
};
priority_queue<data> pq;
int vis[N], n, fa[N], cur0[N], cur1[N], res;
ll ans;
int main() {
  int x;
  read(n);
  rep (i, 2, n) read(fa[i]);
  rep (i, 1, n) {
    read(x);
    if (x == 0) ++ cur0[i];
    else ++ cur1[i];
    res += x ^ 1;
  }
  rep (i, 1, n) uni[i] = i;
  rep (i, 1, n) pq.push((data) {cur0[i], cur1[i], i});
  while (!pq.empty()) {
    int p = pq.top().id;
    if (pq.top().v0 != cur0[p] || pq.top().v1 != cur1[p]) {
      pq.pop();
      continue;
    }
    pq.pop();
    if (p == 1 || vis[getfa(fa[p])]) {
      vis[p] = 1;
      res -= cur0[p];
      ans += 1ll * cur1[p] * res;
    } else {
      int t = getfa(fa[p]);
      ans += 1ll * cur1[t] * cur0[p];
      cur1[t] += cur1[p], cur0[t] += cur0[p];
      pq.push((data) {cur0[t], cur1[t], t});
      uni[p] = t;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7924
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i,max,min;
		for(i = 0; i <=6; i++){
			max = sc.nextInt();
			min = sc.nextInt();
			System.out.println(max-min);
		}

	}

}

Measured memory_bytes: 17324
#include<iostream>
#include<cstdio>

using namespace std;



int main()
{
	long long a,b,c,ans=0;
	scanf("%lld %lld",&a,&b);
	for(long long i=0;i<=a;i++)
	{
		c=b-i;
		if(c>=0 && c<=a)ans+=c+1;
		if(c>a && c<=2*a)ans+=2*a-c+1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
def getInputListF():
    outputData = []
    inputData = input().split()
    outputData = [float(n) for n in inputData]

    return outputData

while True:
    n = int(input())
    if n == 0:
        break
    d = getInputListF()
    print(statistics.pstdev(d))


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,s.size()){
      if(s[i] == 'o') cnt++;
    }
    
    if((15-s.size() + cnt) >= 8){
      cout << "YES" << "\n";
      return 0;
    }else{
      cout << "NO" << "\n";
    }
    return 0;
}


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

int	main()
{
	int	N;
	cin >> N;
	vector<int>	d(N);
	for (int i = 0; i < N; ++i)
		cin >> d.at(i);
	int	sum = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			sum += d.at(i) * d.at(j);
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

m=0
a=100
while a<n:
    a=a*1.01//1
    m+=1
print(m)


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

int main(){
    long long int n;
    cin >> n;
    long long int x;
    long long int y,z=0;
    int i;

    for(i=0; i<n; i++){
        x=n/(i+1);
        y=x*(x+1)/2;
        z+=y*(i+1);
    }

        cout << z << endl;

    return 0;
}

Measured memory_bytes: 3524
S = list(input())
T = list(input())

char_dict = {}
target_chars = []

is_valid = True
for i in range(len(S)):
    if S[i] in char_dict:
        if char_dict[S[i]] != T[i]:
            is_valid = False
            break
    else:
        if T[i] in target_chars:
            is_valid = False
            break
        char_dict[S[i]] = T[i]
        target_chars.append(T[i])

if is_valid:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 6704
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a,n,dig = 0, msd = 0,m;
int64_t pow10(int a)
{
    if (a < 0) return 0;
    int ret = 1;
    for (int i = 0; i < a;i ++) ret *= 10;
    return ret;
}
int64_t count(int x, int y)
{
    if (x < msd) return (pow10(dig - 1) - 1) / 9 + (x == y ? 1 : 0);

    if (x > msd) return (pow10(dig - 2) - 1) / 9 + (x == y ? 1 : 0);

    return (pow10(dig - 2) - 1) / 9 + n / 10 - msd * pow10(dig - 2) + (y <= n % 10 ? 1 : 0) + (x == y ? 1 : 0);
}
int main()
{
	cin >> n;
	if (n <= 9) cout << n;
	else
    {
        m = n;
        while (m != 0)
        {
            dig ++;
            msd = m;
            m /= 10;
        }
        int ans = 0;
        for (int i = 1; i <= 9; ++i)
        {
            for (int j = 1; j <= 9; ++j)
                ans += count(i, j) * count(j, i);
        }
        cout << ans;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int N;
	cin >> N;
	cout << (N+1)/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int dp[302][302];
int main() {
    int n;
    while(cin >> n, n){
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= n; ++j) {
                dp[i][j] = -INF<int>;
            }
            dp[i][i] = 0;
        }
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        for (int len = 2; len <= n; len += 2) {
            for (int i = 0; i+len <= n; ++i) {
                int j = i+len;
                if(abs(v[j-1]-v[i]) <= 1){
                    dp[i][j] = max(dp[i][j], dp[i+1][j-1]+2);
                }
                for (int k = i; k <= j; ++k) {
                    dp[i][j] = max(dp[i][j], dp[i][k]+dp[k][j]);
                }
            }
        }
        for (int i = 0; i <= n; ++i) {
            dp[i][i+1] = 0;
        }
        for (int len = 1; len <= n; ++len) {
            for (int i = 0; i+len <= n; ++i) {
                int j = i+len;
                for (int k = i; k <= j; ++k) {
                    dp[i][j] = max(dp[i][j], dp[i][k]+dp[k][j]);
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j <= n; ++j) {
                ans = max(ans, dp[i][j]);
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3480
#include <iostream>
#include <string>
#include <cctype>
#include <cassert>
#include <algorithm>
using namespace std;
size_t cur;
string s;

int expression();

int digit(){
  assert(cur < s.size());
  return s[cur++] - '0';
}
int number(){
  int n = 0.0;
  assert(cur < s.size());
  while(cur < s.size() && isdigit(s[cur])){
    n = n * 10 + digit();
  }
  return n;
}

int factor(){
  assert(cur < s.size());
  if(isdigit(s[cur])){
    return number();
  }else{
    cur++;
    int a = expression();
    assert(s[cur] == ')');
    cur++;
    return a;
  }
}

int term(){
  assert(cur < s.size());
  int a = factor();
    while(cur < s.size() && (s[cur] == '*' || s[cur] == '/')){
    char op = s[cur++];
    int b = factor();
    if(op == '*') a *= b; else a /= b;
  }
  return a;
}

int expression(){
  assert(cur < s.size());
  int a = term();
  while(cur < s.size() && (s[cur] == '-' || s[cur] == '+')){
    char op = s[cur++];
    int b = term();
    if(op == '-') a -= b; else a += b;
  }
  return a;
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cur = 0;
    cin >> s;
    cout << expression() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; ++i) // マクロ
using namespace std; // stdの省略
using pii = pair<int, int>; // pairの略記
using ll = long long; // long longの略記


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

   int n = s.size();
   cout << s;
   
   if (s.at(n-1)=='s') cout << 'e';
   
   cout << 's' << endl;
   
   return 0;
}

Measured memory_bytes: 3624
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h>
using namespace std;
int main(void){
    
   int N,K;
   cin >> N >> K;
   vector<int> vec(N);
   for(int i = 0; i < N; i++)  cin >> vec.at(i);
   
   sort(vec.begin(),vec.end());
   reverse(vec.begin(),vec.end());
   
   int count = 0;
   for(int i  = 0; i < K; i++) count += vec.at(i);
   cout << count << endl;
   
   
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc162/tasks/abc162_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string s;
    cin >> s;
    int tr = 0, tg = 0, tb = 0;
    for (auto &x : s) {
        if (x == 'R') {
            tr++;
        } else if (x == 'G') {
            tg++;
        } else {
            tb++;
        }
    }
    int ans = tr * tg * tb;
    REP(i, N - 2) {
        for (int d = 1; i + 2 * d < N; ++d) {
            // if (s[i] != s[i + d] && s[i] != s[i + 2 * d] &&
            //     s[i + d] != s[i + 2 * d]) {
            //     ans--;
            // }
            if ((s[i] ^ s[i + d] ^ s[i + 2 * d]) == ('R' ^ 'G' ^ 'B'))
                ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
// #pragma warning(disable : 4996)
#include<bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using ull = unsigned long long;
 
#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define len(s) (int)(s).size()
// #define endl '\n'
 
 
inline void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
 
template<class T> ostream& operator<< (ostream& out, const pair<int, int>&X) {
    out << X.first << ' ' << X.second << endl;
    return out;
}
 
template<class T> ostream& operator<< (ostream& out, const vector<T> &X) {
    for (const auto& it : X)
        out << it << ' ';
    return out;
}
template<class T> ostream& operator<< (ostream& out, const set<T> &X) {
    for (const auto& it : X)
        out << it << ' ';
    return out;
}
template<class T> void dbg(const T &X) {
    cerr << "DEBUG: " << ": ";
    cerr << X << endl;
}
 
const int MOD1 = 1e9 + 7;
const int N = 3e5;
const int MOD2 = 998244353;
const int inf = 1e13;
const int mx = (1 << 19) - 1;
const int mod = 1e9 + 7;
vector<int>g[N];

class SegTree {
public:
	SegTree(int n) {
		sz = n;
		t.resize(4 * n);
		add.resize(4 * n);
	}
	void Add(int l, int r, int x) {
		AddOnRange(1, 0, sz - 1, l, r, x);
	}
	int getsum() {
		return t[1];
	}
	void out() {
		dfs(1, 0, sz - 1);
		cout << endl;
	}
	~SegTree() {
		t.clear();
		add.clear();
	}
private:
	int sz;
	vector<int>add;
	vector<int>t;
	int getlen(int l, int r) {
		return r - l + 1;
	}
	void addition(int v, int x, int ln) {
		t[v] += ln * x;
		add[v] += x;
	}
	void push(int v, int ln1, int ln2) {
		add[2 * v] += add[v];
		add[2 * v + 1] += add[v];
		t[2 * v] += add[v] * ln1;
		t[2 * v + 1] += add[v] * ln2;
		add[v] = 0;
	}
	int foo(int x, int y) {
		return x + y;
	}
	void AddOnRange(int v, int tl, int tr, int l, int r, int x) {
		if (tl > r || tr < l) {
			return;
		}
		if (l <= tl && tr <= r) {
			addition(v, x, getlen(tl, tr));
			return;
		}
		int tm = (tl + tr) / 2;
		push(v, getlen(tl, tm), getlen(tm + 1, tr));
		AddOnRange(2 * v, tl, tm, l, r, x);
		AddOnRange(2 * v + 1, tm + 1, tr, l, r, x);
		t[v] = foo(t[2 * v], t[2 * v + 1]);
	}
	void dfs(int v, int tl, int tr) {
		if (tl == tr) {
			cout << t[v] << ' ';
			return;
		}
		int tm = (tl + tr) / 2;
		push(v, getlen(tl, tm), getlen(tm + 1, tr));
		dfs(2 * v, tl, tm);
		dfs(2 * v + 1, tm + 1, tr);
	}
};



 
signed main() {
    accell();
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		if (a > b)
			swap(a, b);
		g[b].push_back(a);
	}
	SegTree t(n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		t.Add(0, i, 1);
		for (int p : g[i]) {
			t.Add(0, p, -1);
		}
		ans += t.getsum();
	}
	cout << ans << endl;
    return 0;	
}


Measured memory_bytes: 29004
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

s = sorted(input())
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5076
x = int(input())
dp = [0]*(x + 106)
dp[0] = 1
for i in range(x):
  if dp[i] == 1:
    dp[i + 100] =1
    dp[i + 101] =1
    dp[i + 102] =1
    dp[i + 103] =1
    dp[i + 104] =1
    dp[i + 105] =1
if dp[x] ==1:
  print(1)
else :
  print(0)

  
      
  
      


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

struct Problem {
    UL N;
    int A[200000];

    void Solve() {
        scanf("%d", &N);
        rep(i, N) scanf("%d", A + i);
        map<int, UL> G;
        ULL ans = 0;
        for (int i = 0; i < N; i++) {
            ans += G[i - A[i]];
            G[A[i] + i]++;
        }
        cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 21232
from itertools import accumulate
import sys
read = sys.stdin.buffer.read

def main():
  N, K, *p = map(int, read().split())
  p = [0] + list(accumulate(p))
  print((max(b - a for a, b in zip(p, p[K:])) + K) / 2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=998244353;
int add(int x,int y){x+=y;return x>=mod?x-mod:x;}
int sub(int x,int y){x-=y;return x<0?x+mod:x;}
int mul(int x,int y){return (ll)x*y%mod;}
void ckadd(int&x,int y){x=add(x,y);}
void cksub(int&x,int y){x=sub(x,y);}
void ckmul(int&x,int y){x=mul(x,y);}
const int N=305;
bool ok[N][N][N];
int dp[N][N][N];
char s[N];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	ok[0][0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=n;~j;j--){
			for(int k=n;~k;k--){
				if(!ok[i][j][k])continue;
				if(j+k>=2&&j)ok[i][j-1][k]=1;
				if(j+k>=2&&k)ok[i][j][k-1]=1;
				if(s[i+1]=='1'||s[i+2]=='1')ok[i+2][j][k+1]=1;
				if(s[i+1]!='1'||s[i+2]!='1')ok[i+2][j+1][k]=1;
				if(s[i+1]=='1'&&k)ok[i+1][j][k]=1;
				if(s[i+1]=='1'&&j)ok[i+1][j-1][k+1]=1;
				if(s[i+1]!='1'&&k)ok[i+1][j+1][k-1]=1;
				if(s[i+1]!='1'&&j)ok[i+1][j][k]=1;
			}
		}
	}
	int ans=0;
	dp[n+1][0][0]=1;
	for(int i=n+1;i>=1;i--){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				if(ok[i-1][j][k]||ok[i][j+(s[i]!='1')][k+(s[i]=='1')])ckadd(ans,dp[i][j][k]);
				ckadd(dp[i-1][j][k],dp[i][j][k]);
				if(s[i-1]=='1')ckadd(dp[i][j+1][k],dp[i][j][k]);
				else ckadd(dp[i][j][k+1],dp[i][j][k]);
			}
		}
	}
	printf("%i\n",sub(ans,1));
	return 0;
}

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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll n,m;
	cin>>n>>m;
	
	ll sum=0;
	ll x;
	for(int i=0;i<m;i++)
	{
		cin>>x;
		sum+=x;
	}
	
	if(sum>n)
		cout<<-1<<"\n";
	else cout<<n-sum<<"\n";
	
	return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

typedef pair<int, int> P;

vector<int> graph[100000];
int memo[100000] = {};

int dfs(int p, int s){
    if(memo[s] != -1) return memo[s];
    int res = 0;
    rep(i, graph[s].size()){
        int to = graph[s][i];
        if(to == p) continue;
        res = max(res, dfs(s, to)+1);
    }
    memo[s] = res;
    if(res == 0) return 0;
    else return memo[s];
}

void init(){
    rep(i, 100000) memo[i] = -1;
}

int main(void){
    init();
    int N, M; cin >> N >> M;
    rep(i, M){
        int x, y; cin >> x >> y; x--; y--;
        graph[x].push_back(y);
    }
    int ans = 0;
    rep(i, N){
        ans = max(ans, dfs(-1, i));
    }
    cout << ans << endl;
    return 0;
}

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

int func(int);

int main(){
	int A,B,C,D,E,sum=0;
	cin >> A >> B >> C >> D >> E;
	sum-=10-min(min(min(min(func(A),func(B)),func(C)),func(D)),func(E));
	A=(A+9)/10;
	B=(B+9)/10;
	C=(C+9)/10;
	D=(D+9)/10;
	E=(E+9)/10;
	sum+=A*10+B*10+C*10+D*10+E*10;
	cout << sum << endl;
	return 0;
}
int func(int i){
	while(i>10){
		i-=10;
	}
	return i;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll m;
int n;
ll dp[5050][5050];
ll powmod(ll a, ll k, ll MOD){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a, ll MOD){
    return powmod(a, MOD-2, MOD);
}
int main()
{
	cin>>n>>m;
	dp[0][0]=1;
	for(int i=0; i<n-1; i++){
		for(int j=0; j<=n-1; j++){
			(dp[i+1][j]+=dp[i][j])%=m;
		}
		int d;
		if(n&1){
			if(i+1<=(n-1)/2) d=i+1;
			else d=n-i;
		}else{
			if(i+1<=n/2) d=i+1;
			else d=n-i;
		}
		for(int j=0; j<=n-1-d; j++){
			(dp[i+1][j+d]+=dp[i+1][j])%=m;
		}
	}
	ll ans=0;
	for(int i=0; i<n; i++){
		(ans+=(n-i)*dp[n-1][i])%=m;
	}
	/*ll c=1;
	for(int i=0; i<n-1; i++){
		(c*=(2*n-1-i))%=m;
		(c*=inv(i+1, m))%=m;
	}
	ans=(c-ans+m)%m;*/
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 198912
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    cin>>n;
    ll a=0,b=0,c=0,d=0;
    while(n--)
    {
     string s;
     cin>>s;
     if(s=="AC")
     a++;
     else if(s=="WA")
     b++;
     else if(s=="TLE")
     c++;
     else
     d++;
    }
    cout<<"AC x"<<" "<<a<<"\n";
    cout<<"WA x"<<" "<<b<<"\n";
    cout<<"TLE x"<<" "<<c<<"\n";
    cout<<"RE x"<<" "<<d<<"\n";}
    
    
    
    

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
  ll d;cin >> d;
  vl c(26);rep(i,26)cin >> c[i];
  vvl s(d,vl(26));rep(i,d)rep(j,26)cin >> s[i][j];
  vector<set<ll>> ch(26);rep(i,26)ch[i].ins(-1),ch[i].ins(d);
  vl days(d);
  ll pre=0;
  vl last(26,-1);
  rep(i,d){
    ll t=0;
    ll maxi=-INF;
    rep(j,26){
        ll p=s[i][j];
        rep(k,26){
            if(k==j)continue;
            p-=c[k]*(i-last[k]);
        }
        if(chmax(maxi,p))t=j;
      }
      days[i]=t;
      last[t]=i;
  }
  rep(i,d){
    ll t=days[i];
    pre+=s[i][t];
    ch[t].ins(i);
    days[i]=t;
  }
  ll score=pre; 
  rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      score-=c[i]*mini;
  }
  //rep(i,d)cout << days[i] <<endl;

  ll q=300000;
  while(q--){
    ll x=rand()%d,y=rand()%26;
    //cout << x <<" " << y <<endl;
    ll old=days[x];
    pre-=s[x][days[x]];
    ch[days[x]].erase(x);
    days[x]=y;
    pre+=s[x][y];
    ch[y].ins(x);
    ll p=0;
    rep(i,26){
      ll mini=0;
      ll pp=-1;
      for(auto a:ch[i]){
        mini+=(a-pp)*(a-pp-1)/2;
        pp=a;
      }
      p+=c[i]*mini;
    }
    //if(q>299990)cout << score <<endl;
    if(pre-p>=score){
      score=pre-p;
    }
    else{
      ch[y].erase(x);
      pre-=s[x][y];
      days[x]=old;
      ch[days[x]].ins(x);
      pre+=s[x][old];
    }
  }
  rep(i,d)cout << days[i]+1 <<endl;
}   

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
ll XOR(ll n){
    if(n < 0) return 0;
    if(n % 4 == 0) return n;
    else if(n % 4 == 1) return 1;
    else if(n % 4 == 2) return n + 1;
    else if(n % 4 == 3) return 0;
}
int main(){
    Hello
    ll a, b;
    cin >> a >> b;
    ll x1 = XOR(a - 1), x2 = XOR(b);
    cout << (x1 ^ x2);
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int mod=1e9+7;

ll solve(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d <= k){
        k-=x/d;
        x%=d;
        if(k%2) return d-x;
        return x;
    }
    return x-k*d;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 3636
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>a>>b;
     cout<<a*b<<endl;
     return EXIT_SUCCESS;
}




Measured memory_bytes: 3612
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  ll int a,b; cin>>a>>b;
  if(a%b==0) cout<<-1;
  else cout<<a*(b-1);
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	int s;
	cin >> s;
	int a, b;
	b = s%100;
	a = s/100;
//	cout << a << " " << b << endl;

	if(a==0 || a>12){
		if(b==0 || b>12){
			cout << "NA" << endl;
		}else{
			cout << "YYMM" << endl;
		}
	}else{
		if(b==0 || b>12){
			cout << "MMYY" << endl;
		}else{
			cout << "AMBIGUOUS" << endl;
		}
	}

	return 0;
}

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

ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }
  do {
    ll c = a;
    a = b;
    b = c % b;
  } while (b != 0);
  
  return a;
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  ll result = A[0];
  for (int i = 1; i < N; ++i) {
    ll b = A[i];
    result = gcd(result, b);
  }
  cout << result << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N];
bool dp[N][2];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    dp[1][0]=dp[1][1]=true;
    for(int i=2;i<=n;i++)
    {
        if(a[i]>=a[i-1]) dp[i][0]|=dp[i-1][0];
        if(a[i]+1>=a[i-1]) dp[i][1]|=dp[i-1][0];
        if(a[i]>=a[i-1]+1) dp[i][0]|=dp[i-1][1];
        if(a[i]+1>=a[i-1]+1) dp[i][1]|=dp[i-1][1];
    }
    if(dp[n][0]||dp[n][1]) printf("Yes\n");
    else printf("No\n");
}


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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

vector<int> z_algorithm(string s){
	// z[i] : s[i]から始まるtの部分列でsのprefixと一致するもののうち最長のものの長さ
	int n = s.length();
	vector<int> z(n,0);

	int l=0,r=0;
	z[0] = n;
	for (int i = 1; i < n; i++){
		if(i>r){
			l=i,r=i;
			while(r<n && s[r]==s[r-l]) r++;
			z[i]=r-l;
			r--;
		}else{
			int k = i-l;
			if(z[k]<r-i+1){
				z[i]=z[k];
			}else{
				l=i;
				while(r<n && s[r]==s[r-l]) r++;
				z[i]=r-l;
				r--;
			}
		}
	}
	return z;
}

P toporogical_sort(const vector<vector<int> > g){
	int n = g.size();
	vector<int> in_degree(n,0);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < g[i].size(); j++){
			in_degree[g[i][j]]++;
		}
	}

	vector<int> res,length(n);
	stack<int> S;
	for(int i = 0; i < n; i++){
		if(in_degree[i]==0) S.push(i),length[i]=0;
	}

	while(!S.empty()){
		int p = S.top();
		S.pop();
		res.push_back(p);
		for(int i = 0; i < g[p].size(); i++){
			in_degree[g[p][i]]--;
			if(in_degree[g[p][i]]==0) S.push(g[p][i]),length[g[p][i]]=length[p]+1;
		}
	}

	return P(res.size(),*max_element(all(length)));
}

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

	int n = s.size(), m = t.size();
	string res=s;
	for (int cnt = 0; cnt < m/n; cnt++){
		res += s;
	}
	s=res;
	s += s;

	s = t + '0' + s;

	vector<int> z = z_algorithm(s);
	vector<vector<int>> g(n,vector<int>());
	set<P> edge;
	for (int i = m+1; i < s.size(); i++){
		if(z[i]==t.size()) edge.insert(P((i-(m+1))%n, (i-(m+1)+z[i])%n));
	}

	for(auto x: edge){
		g[x.first].push_back(x.second);
	}


	P ans = toporogical_sort(g);
	cout<<(ans.first==n?ans.second:-1)<<endl;


	return 0;
}

Measured memory_bytes: 96016
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const dataStrings = input.split(' ');
const a = Number(dataStrings[0])
const b = Number(dataStrings[1])
const d = Math.floor(a/b);
const r = a % b;
const f = (a/b).toFixed(5);

console.log(d + ' ' + r + ' ' + f);


Measured memory_bytes: 19212
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N;
  cin >> N;
  vector<P> tasks;
  rep(i, N){
    ll a, b;
    cin >> a >> b;
    tasks.push_back(P(b, a));
  }
  sort(tasks.begin(), tasks.end());
  string ans = "Yes";
  ll cost = 0;
  rep(i, N){
    cost += tasks[i].second;
    if(tasks[i].first < cost) ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        _n: usize, m: usize, x: usize,
        a: [usize; m]
    }
    let mut left = 0;
    let mut right = 0;
    for ai in a {
        if ai < x {
            left += 1;
        } else {
            right += 1;
        }
    }
    println!("{}", std::cmp::min(left, right));
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{

	int n, x;
	int ii;

	scanf("%d", &n);
	for (ii = 1; ii <= n; ii++) {
		if (ii % 3 == 0) {
			printf(" %d", ii);
			continue;
		}
		x = ii;
		do {
			if (x % 10 == 3) {
				printf(" %d", ii);
				break;
			}
			x /= 10;
		} while (x);
	}

	printf("\n");

	return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

const int MAX = 1e6 + 10;

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 print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

void print(Pll &p){
    print(p.first, p.second);
}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    vector<ll> max_(n), min_(n);
    COMinit();
    rep(i,n){
        max_[i] = COM(i, k-1);
        min_[i] = COM(n-1-i, k-1);
    }
    // print(max_);
    // print(min_);
    // print(a);
    ll ans = 0;
    // debug(ans);
    for(int i = n-1; 0 <= i; i--){
        ans += (max_[i] * a[i]) % MOD;
        ans %= MOD;
        ans -= (min_[i] * a[i]) % MOD;
        while(ans < 0)ans += MOD;
        ans %= MOD;
        // debug(ans);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 25984