akhauriyash/Code-Regression huggingface dataset:
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#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 SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    int al = a.length();
    int bl = b.length();
    if(al == bl){
        REP(i, al){
            if(a[i] - '0' > b[i] - '0'){
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a[i] - '0' < b[i] - '0'){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    else {
        cout << ((al > bl) ? "GREATER" : "LESS") << endl;
    }
    return 0;
}

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

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

string S;
int idx;
int N, M;
string alphas;
int curr;

void consume(char c) {
  if(idx >= N) throw std::logic_error("failed consuming");
  if(S[idx] != c) throw std::logic_error("failed consuming");
  idx ++;
}

bool try_consume(char c) {
  try {
    consume(c);
  } catch(std::logic_error const& e) {
    return false;
  }
  return true;
}

int E();

int convert(string const& b) {
  int n = b.size();
  int ret = 0;
  for(int i=0; i<n; i++) {
    ret *= 2;
    assert(isdigit(b[i]));
    ret += b[i] - '0';
  }
  return ret;
}

string B() {
  string ret;
  while(1) {
    if(S[idx] == '0') ret += '0';
    else if(S[idx] == '1') ret += '1';
    else break;
    idx++;
  }
  return ret;
}

int Nu() {
  if(try_consume('0')) return 0;
  consume('1');
  return convert("1" + B());
}

int F() {
  if(try_consume('-')) {
    return -F();
  }
  else if(try_consume('(')) {
    int r = E();
    consume(')');
    return r;
  }
  else {
    return Nu();
  }
}

int T() {
  int num1 = F();
  while(try_consume('*')) {
    int num2 = F();
    num1 *= num2;
  }
  return num1;
}

int E() {
  int term1 = T();
  while(1) {
    bool cont = 0;
    while(try_consume('+')) {
      cont = 1;
      int term2 = T();
      term1 += term2;
    }
    while(try_consume('-')) {
      cont = 1;
      int term2 = T();
      term1 -= term2;
    }
    if(!cont) break;
  }
  return term1;
}

bool Q() {
  int expr1 = E();
  consume('=');
  int expr2 = E();
  return expr1 == expr2 && idx == N;
}

int main() {

  string T = "01+-*()=";
  sort(T.begin(), T.end());
  string RS; cin >> RS;
  N = RS.size();
  for(auto c: RS) if(isalpha(c)) alphas.push_back(c);
  sort(alphas.begin(), alphas.end());
  alphas.erase(unique(alphas.begin(), alphas.end()), alphas.end());
  M = alphas.size();

  if(M > T.size()) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  set<string> st;
  do {
    S = RS;
    rep(i, N) {
      if(isalpha(S[i])) S[i] = T[alphas.find(S[i])];
    }
    if(!st.count(S)) {
      st.insert(S);
      idx = curr = 0;
      try { ans += Q(); } catch (std::logic_error const& e) {}
    }
  } while(next_permutation(T.begin(), T.end()));
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7560
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll ma1=-1,ma2=-1;
    cin >> n;
    vector<ll> a(n);

    for(int i=0 ; i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    for (int i=0;i<n-1;i++){
        if (a[i]==a[i+1]){
            if (ma1==-1){
                ma1=a[i];
                i++;
            }
        
            else {
                cout << a[i]*ma1<<endl;
                return 0;
            }
        }
        
    }

    cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 1024
m,d = gets.chomp.split(" ").map(&:to_i)

count = 0
(1..m).each do |mi|
  (1..d).each do |di|
    d1 = di % 10
    d10 = (di - d1) / 10
    count += 1 if d1 >= 2 && d10 >= 2 && d1 * d10 == mi
  end
end

puts count


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

int main(){
    string s;
    cin>>s;
    int a_point=1e9,b_point=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A' && a_point>i) a_point = i;
        if(s.at(i)=='Z' && b_point<i) b_point = i;
    }
    cout<< b_point - a_point +1<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N,INF),B(N-1);
    for(int i=0;i<N-1;i++){
        cin>>B[i];
    }
    for(int i=0;i<N-1;i++){
        A[i]=min(A[i],B[i]);
        A[i+1]=min(A[i+1],B[i]);
    }
    
    int ans=0;
    
    for(int i=0;i<N;i++){
        ans+=A[i];
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int N,M,R,z[1000],L[200][200],S[200][200],dp[1000][200];

int main(){
	while(cin>>N>>M&&N){
		rep(i,N){
			fill(L[i],L[i]+N,INF);
			fill(S[i],S[i]+N,INF);
		}
		rep(i,N){
			L[i][i]=0;
			S[i][i]=0;
		}
		int x,y,t;
		char c;
		rep(i,M){
			cin>>x>>y>>t>>c;
			x--;y--;
			if(c=='L')L[x][y]=(L[y][x]=min(L[x][y],t));
			else S[x][y]=(S[y][x]=min(S[x][y],t));
		}
		cin>>R;
		rep(i,R)fill(dp[i],dp[i]+N,INF);
		rep(i,R){
			cin>>z[i];z[i]--;
			if(!i)dp[i][z[i]]=0;
		}
		rep(i,N)rep(j,N)rep(k,N){
			L[j][k]=min(L[j][k],L[j][i]+L[i][k]);
			S[j][k]=min(S[j][k],S[j][i]+S[i][k]);
		}
		for(int i=1;i<R;i++)rep(j,N){
			dp[i][j]=min(dp[i][j],dp[i-1][j]+L[z[i-1]][z[i]]);
			rep(k,N)dp[i][k]=min(dp[i][k],dp[i-1][j]+L[z[i-1]][j]+S[j][k]+L[k][z[i]]);
		}
		int ans=INF;
		rep(i,N)ans=min(ans,dp[R-1][i]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1960
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

int A[N];
int dp[N];
int INF = 1e9+7;
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,m;
    int k;
    cin>>n>>k;
    dp[1]=0;
    rep(i,1,n)cin>>A[i];
    dp[2]= abs(A[2]-A[1]);
   
    rep(i,3,n)dp[i]=INF;
    rep(i,3,n)
    {
        rep(j,1,k){
        if(j>=i)continue;
        dp[i]=min(dp[i-j]+abs(A[i]-A[i-j]),dp[i]);
        }
    }
    cout<<dp[n]<<"\n";

    
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    int t=x;
    x=y;
    y=t;
    t=z;
    z=x;
    x=t;
    
    printf("%d %d %d",x,y,z);
}

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

def f(xs):
    res = 0
    for i in xs:
        res = 10 * res + i
    return res

def dfs(xs):
    ans = 1 if f(xs) <= n and 3 in xs and 5 in xs and 7 in xs else 0
    if len(xs) == 9:
        return ans
    for i in [3,5,7]:
        xs.append(i)
        ans += dfs(xs)
        xs.pop(-1)
    return ans

print(dfs([]))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

string s;
char c;
long long q, t, f;

bool ltr = false;

int main(){

    cin >> s >> q;

    deque<char> d;

    for(long long i = 0; i < s.length(); i++){
        d.push_back(s[i]);
    }


    for(long long i = 0; i < q; i++){
        cin >> t;
        if(t == 1){
            if(ltr){
                ltr = false;
            } else if (!ltr){
                ltr = true;
            }
        } else if(t == 2){
            cin >> f >> c; //1, begin - 2, end
            if(ltr){
                if(f == 1){
                    f = 2;
                } else if(f == 2){
                    f = 1;
                }
            }
            if(f == 1){
                d.push_front(c);
            } else {
                d.push_back(c);
            }
        }
    }

    if(ltr){
        reverse(d.begin(), d.end());
    }

    for(long long i = 0; i < d.size(); i++){
        cout << d[i];
    }




}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out


//Surely this is going to AC

Measured memory_bytes: 896
#include <iostream>
#include <string.h>
#include <cstdint>
using namespace std;
 
int main() {
	int d, n;
	int nn;

	cin >> d >> n;

	nn = 1;
	for( int i = 0; i < d; i++ ) {
		nn *= 100;
	}
	nn *= n;
	if( d == 0 && nn >= 100 ) {
		nn++;
	}
	if( d == 1 && nn >= 100*100 ) {
		nn += 100;
	}
	if( d == 2 && nn >= 100*100*100 ) {
		nn += 100*100;
	}
	cout << nn << "\n";
 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX_H 250

int parent(int i) {return i / 2;}
int left(int i) {return 2 * i;}
int right(int i) {return 2 * i + 1;}

int main(void) {
	int H, i, A[MAX_H+1] = {0};
	
	scanf("%d", &H);
	for (i = 1; i <= H; ++i) {
		scanf(" %d", &A[i]);
	}

	for (i = 1 ; i <= H; i++) {
		printf("node %d: key = %d, ", i, A[i]);
		if (parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
		if (left(i) <= H) printf("left key = %d, ", A[left(i)]);
		if (right(i) <= H) printf("right key = %d, ", A[right(i)]);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
int d[115][3];
int main() {
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=2;j++) 
			cin>>d[i][j];
	int ss=0;
	for(int i=1;i<=n;++i) {
		if(d[i][1]==d[i][2]) ss++;
		else ss=0;
		if(ss==3) {
			printf("Yes\n");
			exit(0);
		}
	} 
	printf("No");
	return 0;
}


Measured memory_bytes: 3688
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 998244353
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	int n;cin >> n;
	vector<int> v(2*n);
	cu(i,0,2*n)cin >> v[i];
	sort(all(v));
	int ans = 0;
	cu(i,0,n){
		ans += v[2*i];	
	}
	cout << ans << '\n';
}


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

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;
const ll MOD = 1e9 + 7;

int N;
int arr[MAXN];
ll fac[MAXN];
ll finv[MAXN];

ll cpow (ll b, int e)
{
    if (e == 0) return 1;
    ll v = cpow (b, e / 2);
    v = (v * v) % MOD;
    if (e % 2) v = (v * b) % MOD;
    return v;
}

ll ch (int n, int k)
{
    if (n < k) return 0;
    if (n < 0) return 0;
    if (k < 0) return 0;
    ll v = (fac[n] * finv[k]) % MOD;
    v = (v * finv[n-k]) % MOD;
    return v;
}

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

    fac[0] = 1;
    finv[0] = 1;
    for (int i = 1; i < MAXN; i++)
    {
        fac[i] = (fac[i-1] * i) % MOD;
        finv[i] = cpow (fac[i], MOD - 2);
    }


    cin >> N;
    ll ctot = 0;
    for (int i = 0; i <= N; i++)
    {
        cin >> arr[i];
        ctot += arr[i];
    }

    ctot -= (N * ((ll) N + 1)) / 2;
    int llo = 0, lhi = N;
    while (arr[llo] != ctot) llo++;
    while (arr[lhi] != ctot) lhi--;

    int nd = lhi - llo - 1;
    for (int i = 1; i <= N; i++)
    {
        ll cc = ch (N, i) + ch (N-1, i-1) - ch (N-nd-1, i-1) + ch (N - 1, i - 2);
        cc = (cc + MOD) % MOD;
        cout << cc << "\n";
    }
    cout << "1\n";
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;cin>>n>>m;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  int count=0;
  int sum=0;
  rep(i,n)sum+=a[i];
  rep(i,n)
  {
    if(a[i]*m*4>=sum)
    {
      count++;
    }
  }
  if(count>=m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
import heapq as hp

INF = 1000000

def diikstraMethd(G, s):
    # ?????????
    n = len(G)
    d = [INF for _ in range(n)]
    d[s] = 0
    PQ = [(d[s], s)]

    while PQ:
        u = hp.heappop(PQ)[1]
        for v, c in G[u]:
            alt = d[u] + c
            if d[v] > alt:
                d[v] = alt
                hp.heappush(PQ, (alt, v))

    return d


if __name__ == '__main__':
    n = int(input())
    G = [ [] for _ in range(n)]
    for _ in range(n):
        tmp = list(map(int, input().split()))
        u = tmp.pop(0)
        k = tmp.pop(0)
        for i in range(k):
            v = tmp.pop(0)
            c = tmp.pop(0)
            G[u].append((v, c))

    d = diikstraMethd(G, 0)

    for i in range(n):
        print('{0} {1}'.format(i, d[i]))

Measured memory_bytes: 70372
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string S;
  std::cin >> S;

  ll x = std::atoi(S.substr(0, 2).c_str());
  ll y = std::atoi(S.substr(2, 2).c_str());

  if (y >= 1 && y <= 12 && (x >= 13 || x <= 0)) {
    print("YYMM");
  } else if (x >= 1 && x <= 12 && (y >= 13 || y <= 0)) {
    print("MMYY");
  } else if (x >= 1 && x <= 12 && y >= 1 && y <= 12) {
    print("AMBIGUOUS");
  } else {
    print("NA");
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d;
int main()
{
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if (a<b) puts("No");
		else if (a%b>c) puts("No");
		else if (d<b) puts("No");
		else if (b<=c) puts("Yes");
		else{
			ll Gcd=__gcd(b,d);
			if ((a-c-1)/Gcd-(a-b)/Gcd>0) puts("No");else puts("Yes");
		}
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	defer stdout.Flush()
	x := readInt()
	t := readInt()

	if x < t {
		x = t
	}
	println(x - t)
}

var (
	stdin  *bufio.Reader
	stdout *bufio.Writer
)

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func scanf(f string, args ...interface{}) (int, error) {
	n, err := fmt.Fscanf(stdin, f, args...)
	for {
		r, _, err := stdin.ReadRune()
		if err != nil || !unicode.IsSpace(r) {
			stdin.UnreadRune()
			break
		}
	}
	return n, err
}

func readInt() int {
	var n int
	scanf("%d", &n)
	return n
}

func readIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	return a
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func readString() string {
	var s string
	scanf("%s", &s)
	return s
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, W: "List[str]"):
    s = set([W[0]])
    for i in range(1, len(W)):
        if (W[i] in s) or (W[i-1][-1] != W[i][0]):
            return NO
        s.add(W[i])
    return YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    result = solve(N, W)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5508
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
const int K = 20;
int n;
int v[K];
int k;
int arr[N];
int nxt[K][N];
int prv[K][N];
int dp1[1 << K];
int dp2[1 << K];
int pre(int mask){
	if(dp1[mask] != -1){
		return dp1[mask];
	}
	int res = 0;
	for(int i = 1 ; i < k ; ++i){
		if((mask >> i) & 1){
			int tmp = pre(mask ^ (1 << i));
			res = max(res , nxt[i][tmp + 1] - 1);
		}
	}
	return dp1[mask] = res;
}
int suf(int mask){
	if(dp2[mask] != -1){
		return dp2[mask];
	}
	int res = n + 1;
	for(int i = 1 ; i < k ; ++i){
		if((mask >> i) & 1){
			int tmp = suf(mask ^ (1 << i));
			res = min(res , prv[i][tmp - 1] + 1);
		}
	}
	return dp2[mask] = res;
}
bool solve(int lft , int rgt){
	int mask = (1 << k) - 2;
	for(int i = mask ; i ; i = (i - 1) & mask){
		if(pre(i) >= lft && suf(mask ^ i) <= rgt){
			return 1;
		}
	}
	return pre(0) >= lft && suf(mask) <= rgt;
}
int main(){
	scanf("%d" , &n);
	scanf("%d" , &v[0]);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
	}
	k = 1;
	for(int i = 1 ; i < K ; ++i){
		v[i] = v[i - 1] >> 1;
		if(v[i]){
			k = i + 1;
		}
	}
	v[k++] = 0;
	for(int i = 0 ; i < k ; ++i){
		nxt[i][n] = n + 1;
		nxt[i][n + 1] = n + 1;
		for(int j = n - 1 ; j >= 1 ; --j){
			if(arr[j + 1] - arr[j] <= v[i]){
				nxt[i][j] = nxt[i][j + 1];
			}
			else{
				nxt[i][j] = j + 1;
			}
		}
		prv[i][1] = 0;
		prv[i][0] = 0;
		int steps = 1;
		for(int j = 2 ; j <= n ; ++j){
			if(arr[j] - arr[j - 1] <= v[i]){
				prv[i][j] = prv[i][j - 1];
			}
			else{
				++steps;
				prv[i][j] = j - 1;
			}
		}
		if(!i && steps > k + 5){
			for(int i = 1 ; i <= n ; ++i){
				puts("Impossible");
			}
			return 0;
		}
	}
	memset(dp1 , -1 , sizeof(dp1));
	memset(dp2 , -1 , sizeof(dp1));
	for(int i = 1 ; i <= n ; i = nxt[0][i]){
		bool ans = solve(prv[0][i] , nxt[0][i]);
		for(int j = i ; j < nxt[0][i] ; ++j){
			puts(ans ? "Possible" : "Impossible");
		}
	}
}

Measured memory_bytes: 42112
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
#define MAX 3005

struct Rectangle {int height; int pos;};

int getLargestRectangle(int size, int buffer[]){
    stack<Rectangle> S;
    int maxv = 0;
    buffer[size] = 0;

    for(int i = 0; i <= size; i++){
        Rectangle rect;
        rect.height = buffer[i];
        rect.pos = i;
        if(S.empty()){
            S.push(rect);
        }else{
            if(S.top().height < rect.height){
                S.push(rect);
            }else if(S.top().height > rect.height){
                int target = i;
                while(!S.empty() && S.top().height >= rect.height){
                    Rectangle pre = S.top(); S.pop();
                    int area = (pre.height + 1) * (i - pre.pos + 1);
                    maxv = max(maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                S.push(rect);
            }
        }
    }
    return maxv;
}

int H, W;
int buffer[MAX][MAX]; // 1 is wall.
int T[MAX][MAX];

int getLargestRectangle(){
    for(int j = 0; j < W; j++){
        for(int i = 0; i < H; i++){
            if(buffer[i][j]){
                T[i][j] = 0;
            }else{
                T[i][j] = (i > 0) ? T[i-1][j] + 1 : 1;
            }
        }
    }

    int maxv = 0;
    for(int i = 0; i < H; i++){
        maxv = max(maxv, getLargestRectangle(W, T[i]));
    }

    return maxv;
}


int main() {
    /*
    cin >> H >> W;
    string s[H];
    rep(i,H){
        cin >> s[i];
        rep(j,W) if(s[i][j] == '#')buffer[i][j] = 1;
    }

    

    cout << ans << endl;
    */

    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i,h)cin >> s[i];

    H = h - 1;
    W = w - 1;

    rep(i,H){
        rep(j,W){
            int cnt = 0;
            if(s[i][j] == '#')cnt++;
            if(s[i][j+1] == '#')cnt++;
            if(s[i+1][j] == '#')cnt++;
            if(s[i+1][j+1] == '#')cnt++;
            if(cnt == 1 || cnt == 3)buffer[i][j] = 1;
        }
    }

    int ans = max(getLargestRectangle(), max(h,w));
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 53504
# -*- coding: utf-8 -*-

from itertools import product

N = int(input())

cnt = 0
# 候補となりうる9桁までの数字を列挙
for prod in product(['0', '3', '5', '7'], repeat=9):
    # チェック用に変形
    num = int(''.join(prod))
    s = str(num)
    # 753数ではない
    if (s.find('3') == -1 or s.find('5') == -1
            or s.find('7') == -1 or s.find('0') != -1):
        continue
    # N以下ではない
    if num > N:
        continue
    cnt += 1
print(cnt)


Measured memory_bytes: 3060
import numpy as np

a,b,h,m = map(int,input().split())

h_y = a*np.cos((2*np.pi)*(h*60+m)/(12*60))
h_x = a*np.sin((2*np.pi)*(h*60+m)/(12*60))

m_y = b*np.cos((2*np.pi)*m/60)
m_x = b*np.sin((2*np.pi)*m/60)

ans = np.sqrt((h_y - m_y)**2 + (h_x - m_x)**2)
print(ans)

Measured memory_bytes: 27192
#include <cstdio>
#include <algorithm>

using namespace std;

int a[100001];
int b[100001];
int c[100001];
int INF = 0x3f3f3f3f;
int dp[100001][4];

int main()
{
    int n, aa, bb, cc;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d%d%d", &aa, &bb, &cc);
        a[i] = aa; b[i] = bb; c[i] = cc;
    }
    for(int i=1; i<=n; i++)
    {
        dp[i][1] = max(dp[i-1][2] + a[i], dp[i-1][3] + a[i]);
        dp[i][2] = max(dp[i-1][1] + b[i], dp[i-1][3] + b[i]);
        dp[i][3] = max(dp[i-1][1] + c[i], dp[i-1][2] + c[i]);
    }
    printf("%d", max(dp[n][1], max(dp[n][2], dp[n][3])));
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define getl(s) getline(cin,s);

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin>>s;
  int ans =0;
  for(int i=0;i<s.length();){
    if(s[i]!='R'){
      i++;
    }else{
      int f =0;
      while(s[i]=='R'){
        f++;
        i++;
      }
      ans = max(f,ans);
    }
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int occur[26] = {0};
    string w;
    cin >> w;
    for(int i = 0; i < w.length(); i++){
        occur[w[i]-97]++;
    }
    bool good = true;
    for(int i = 0; i < 26; i++){
        if(occur[i]%2!=0){
            good = false;
            break;
        }
    }
    if(good){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    return 0;
}

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

string s;
int n,k;

int main(){
	cin>>n>>s>>k;
	k--;
	int x=s[k];
	for(int i=0;i<s.size();i++)
		if(s[i]!=x) s[i]='*';
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = ReadLine();
            if(s[2] == s[3] && s[4] == s[5]){
                WriteLine("Yes");
            }
            else{
                WriteLine("No");
            }
        }



    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int n, m;
  int d[210000], t[210000];
  int res=0;
  cin >> n;
  rep(i,n) cin >> d[i];
  cin >> m;
  rep(i,m) cin >> t[i];

  sort(d,d+n);
  sort(t,t+m);

  int j = 0;
  rep(i,m){
    while(j<n) {
      if(t[i] < d[j]) {
        cout << "NO" <<endl;
        return 0;
      }
      if(t[i]== d[j]) {
        j++;
        break;
      }
      j++;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

long long max(long long x, long long y){return (x > y ? x : y);}
long long min(long long x, long long y){return (x < y ? x : y);}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

#define ll int
#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=6e5+500;
const ll inf=1e9+800;
const ll mod=1e9+7;

vector<char> de;
deque<ll>  fargh;

void makee(){
	fargh.clear();
	for(ll i=1;i<de.size();i++){
		if(de[i]!=de[i-1]){
			fargh.pb(de[i-1]);
		}
	}
}
void pel(){
	ll tol=0;
	for(ll i=0;i<de.size();i++){
		tol=i;
		if(i+1!=de.size() && de[i]!=de[i+1]){
			fargh.pop_front();
		}
		if(de[i]=='9'){
			de[i]='0';
		}else{
			de[i]++;
			break;
		}
	}	
	for(ll i=tol;i>=0;i--){
		if(i+1!=de.size()){
			if(de[i]!=de[i+1]){
				fargh.push_front(de[i]);
			}
		}
	}
}
bool good(){
	if(de.size()==0)return 0;
	if(fargh.size()==0)return 1;
	if(fargh.back()<de.back())return 0;
	else  return 1;
}
void pri(){
	for(ll i=(ll)de.size()-1;i>=0;i--){
		cout<<de[i];
	}
	cout<<"***"<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	

	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	for(ll i=0;i<s.size();i++){
		de.pb(s[i]);
	}
	makee();
	ll ans=0;
	while(de.size()){
	//	pri();
		ans++;
		while(good()){
			char c=de.back();
			de.pop_back();
			if(de.size()!=0){
				if(de.back()!=c){
					fargh.pop_back();
				}
			}
		}
		if(de.size()){
			char c=de.back();
			de.pop_back();
			if(de.size()){
				if(de.back()!=c){
					fargh.pop_back();
				}
			}
			pel();
		}
	}
	cout<<ans;
}



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

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

const int N = 55;

int a[N];
long long f[N][N][N * N];

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n, A;
  scanf("%d %d", &n, &A);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  f[0][0][0] = 1;
  f[0][1][a[0]] = 1;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j <= i + 1; ++j) {
      for (int k = 0; k < N * N; ++k) {
        f[i][j][k] += f[i - 1][j][k];
        if (j > 0 && k >= a[i]) {
          f[i][j][k] += f[i - 1][j - 1][k - a[i]];
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += f[n - 1][i][A * i];
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 63872
// header {{{
// header {{{
#include <bits/stdc++.h>
using namespace std;
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
 
#define ASSERT(expr...) assert((expr))
 
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

 
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <int>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
 
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
 
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
bool isOK(int mid, double key){
 
    if((double)mid*mid > key) {
             return true;
     } else {
              return false;
     }
}

 int binary_search(double key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


bool isKaibun(string st){
    bool ans = true;
    int n = st.length();
    REP(i,n/2){
        if(st[i] != st[n-i-1]){
            return false;
        }
    }
    return true;
}


void solve() {
string S;
cin >> S;
int N = S.length();
//cout <<S.substr(0,(N-1)/2) << endl;
//cout << S.substr((N+3)/2-1,(N-1)/2);
if(isKaibun(S) && isKaibun(S.substr(0,(N-1)/2)) && isKaibun(S.substr((N+3)/2-1,(N-1)/2))){
    cout << "Yes";
} else {
    cout << "No";
}


//cout << isKaibun(S);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(x) scanf("%d", &x)
using namespace std;

int t[100010], x[100010], y[100010];

int main() {
	int n;
	fr(n);
	for(int i=1; i<=n; ++i) {
		fr(t[i]);
		fr(x[i]);
		fr(y[i]);
		int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
		if(dist > t[i] - t[i-1]) {
			puts("No");
			return 0;
		}
		int val = dist - (t[i] - t[i-1]);
		if(val&1) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main() {
    
    int n;cin>>n;
    vector<int> arr(n+1),dp(n+1);
    for(int i=1;i<=n;i++) cin>>arr[i];
    dp[0] = dp[1] = 0; dp[2] = abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++) 
        dp[i] = min( dp[i-1] + abs(arr[i]-arr[i-1]) , dp[i-2] + abs(arr[i]-arr[i-2]) );
    cout<<dp[n];
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
  ArrayList<Integer>po=new ArrayList<>();
  for(int i=0;i<n;i++)po.add(sc.nextInt());
  Collections.sort(po,new Comparator<Integer>(){
  public int compare(Integer a,Integer b){
  return -a.compareTo(b);
  }
  });
    int x=0;
  while(po.size()>1){
  	if(po.get(0).equals(po.get(1))){
      x=po.get(0);
      po.remove(0);po.remove(0);break;
    }
    else po.remove(0);
  }
  int y=0;
  while(po.size()>1){
  	if(po.get(0).equals(po.get(1))){
      y=po.get(0);
      po.remove(0);po.remove(0);
      break;
    }
    else po.remove(0);
  }
  System.out.println((long)x*y);
}
}

Measured memory_bytes: 59520
n, k  =map(int, input().split())

ans = 0
#ｋで割り切れるn以下の数のリスト
odd = [i for i in range(k, n+1, k)] #kから始まり、nまで、ｋ刻み
ans += len(odd) ** 3 #abcの選び方のため3乗

if k % 2 == 0:
  #k/2から始まり、nまでで、kで割ると余りがk/2になる
  even = [i for i in range(k//2, n+1, k)]
  ans += len(even) ** 3
  
print(ans)


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define inf 9000000000000000000
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto& a : x)


class UnionFind{ // findSet(a), isSameSet(a,b), unionSet(a,b), sizeOfSet(a)
private:
  vi parent, rank, size, val, sm;
public:
  UnionFind(ll n, vi &_val) {
    rank.assign(n, 0); parent.assign(n,0); size.assign(n, 1);
    val = _val; sm.assign(n,0);
    rep(i,0,n) sm[i] = val[i];
    rep(i,0,n) parent[i] = i;
  }
  ll findSet(ll i) {
    if (parent[i] == i) return i;
    else return parent[i] = findSet(parent[i]);
  }
  bool isSameSet(ll i, ll j) { return findSet(i) == findSet(j); }
  void unionSet(ll i, ll j) {
    if (!isSameSet(i, j)){
      ll x = findSet(i); ll y = findSet(j);
      if (rank[x] < rank[y]){
        parent[x] = y; size[y] += size[x];
        sm[y] += sm[x];
      }
      else {
        parent[y] = x;
        size[x] += size[y];
        sm[x] += sm[y];
        if (rank[x] == rank[y]) rank[x]++;
      }
    }
  }
  ll sizeOfSet(ll i) { return size[findSet(i)]; }
  ll smSet(ll i) { return sm[findSet(i)]; }
};

vi x,ok,_,vis;
vector< pair<ll,ii> > e;
vector<vii> edges;
vii __;
ll cur = 0;

ll dfs(ll v){
  trav(u,edges[v]){
    if (u.second >= cur && vis[u.second] == 0){
      vis[u.second] = 1;
      ok[u.second] = 2;
      dfs(u.first);
    }
  }
}

int main(){
  ios::sync_with_stdio(0);
  ll m,n; cin >> n >> m;
  x.assign(n,0); rep(i,0,n) cin >> x[i];
  e.assign(m,{0,{0,0}});
  rep(i,0,m) {
    cin >> e[i].second.first >> e[i].second.second >> e[i].first;
    e[i].second.first--; e[i].second.second--;
  }
  sort(all(e)); reverse(all(e));

  UnionFind uf(n,x);
  ok.assign(m,0);

  per(i,m-1,0){
    uf.unionSet(e[i].second.first,e[i].second.second);
    if (uf.smSet(e[i].second.first) >= e[i].first) ok[i] = 1;
  }

  edges.assign(n,__);
  rep(i,0,m){
    edges[e[i].second.first].push_back({e[i].second.second,i});
    edges[e[i].second.second].push_back({e[i].second.first,i});
  }

  ll res = 0;
  vis.assign(m,0);
  rep(i,0,m){
    if (ok[i] == 0) res++;
    if (ok[i] == 1){
      vis[i] = 1;
      dfs(e[i].second.first);
      dfs(e[i].second.second);
    }
    cur++;
  }
  cout << res << endl;

}


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

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    // {
        
    // }

    int arr[5];
    for(int i=0;i<5;i++)cin>>arr[i];
    int ans =0;
    for(int i = 0;i<5;i++)
    {
        if(arr[i] == 0)
        
        {
            ans = i+1;
        break;
        }
    }
    cout<<ans<<endl;
    //system("pause");
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


void Main(){
  int N, S;
  cin >> N >> S;
  VI A(N);
  rep(i, N) cin >> A[i];

  vector<mint> dp(S+1, 0);

  dp[0] = 1;

  rep(i, N){
    vector<mint> p(S+1, 0);
    rep(j, S+1){
      p[j] += dp[j] * 2;
      if(j >= A[i]) p[j] += dp[j-A[i]];
    }
    swap(p, dp);
  }

  cout << dp[S] << endl;



}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 998244353;

bool cmp(pair<int, int> l, pair<int, int> r){
  if(l.first != r.first){
    return l.first < r.first;
  }
  return l.second > r.second;
}
int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  REP(i, N){
    cin >> S[i];
  }
  vector<pair<int, int>> p, m;
  bool ans = true;
  int SSum = 0;
  REP(i, N){
    int mins = 0, sum = 0;
    REP(j, (int)S[i].size()){
      if(S[i][j] == '('){
        sum++;
      }
      else{
        sum--;
      }
      mins = min(mins, sum);
    }
    if(sum < 0){
      m.push_back({mins-sum, -sum});
    }
    else{
      p.push_back({mins, sum});
    }
    SSum+=sum;
  }
  sort(m.rbegin(), m.rend());
  sort(p.rbegin(), p.rend());
  int sum = 0;
  REP(i, (int)p.size()){
    if(sum + p[i].first < 0){
      ans = false;
      break;
    }
    sum += p[i].second;
  }
  sum = 0;
  REP(i, (int)m.size()){
    if(sum + m[i].first < 0){
      ans = false;
      break;
    }
    sum += m[i].second;
  }
  cout << (ans && SSum == 0? "Yes" : "No") << endl;
  return 0;
}


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

int main() {
  string a;
  string b;
  int num;
  cin >> a >> b;
  num = stoi(a + b);
  for (int i = 1; i++; i < 101) {
    if (num == i * i) {
      cout << "Yes" << endl;
      break;
    } else if (i * i > 100100) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int max = 0;

    for (int i = 0; i < n; i++) {
      String first = s.substring(0,i+1);
      String last = s.substring(i+1,n);
      char[] data1 = first.toCharArray();
      char[] data2 = last.toCharArray();
      int[] table1 = new int[26];
      int[] table2 = new int[26];

      for (int j = 0; j < first.length(); j++) {
        table1[data1[j]-'a']++;
      }
      for (int j = 0; j < last.length(); j++) {
        table2[data2[j]-'a']++;
      }

      int count = 0;
      for (int j = 0; j < 26; j++) {
        if (table1[j] > 0 && table2[j] > 0) {
          count++;
        }
      }
      max = Math.max(max,count);
    }

    System.out.println(max);

  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, d, x;
	cin >> n >> d >> x;
	int ans = 0;
	for(int i = 0; i < n; i ++){
		int temp; cin >> temp;
		for(int j = 0; j*temp + 1 <= d; ++j ) ++ans;
	}
	cout << ans + x << endl;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int S;
    cin >> S;
    int h = S / 3600;
    int m = S % 3600 / 60;
    int s = S % 3600 % 60;
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<=(b);++i)
#define DEC(i,a,b) for(int i=(a);i>=(b);--i)
#define DEBUG(x) cerr<<#x" == "<<x<<endl
using namespace std;
typedef long long ll;
inline int read(){
	int w=0,p=0;char c;
	while(!isdigit(c=getchar()))if(c=='-')p=1;
	while(isdigit(c))w=(w<<1)+(w<<3)+(c^'0'),c=getchar();
	return p?-w:w;
}
const int N=1e5+7;
int n,a[N],p[N];
long double sum[N];
typedef pair<int,int> pii;
inline bool cmp(pii a,pii b){
	return a.first>b.first&&a.second>=b.second-1;
}
pii ss[N];
int main(){
	n=read();
	REP(i,1,n)a[i]=read();
	sort(a+1,a+1+n);
	DEC(i,n,2){
		int s=upper_bound(a+1,a+i,a[i]/2)-a;
		if(s<i)p[i]=a[i]-a[s];
		p[i]=max(p[i],a[s-1]);
		ss[i]={a[i],p[i]};
	}
	sort(ss+1,ss+1+n,cmp);
	if(*lower_bound(a+1,a+1+n,ss[1].second)!=ss[1].second)ss[1].second=ss[1].first-ss[1].second;
	printf("%d %d\n",ss[1].first,ss[1].second);
	return 0;
}


Measured memory_bytes: 1792
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var age = int.Parse(Console.ReadLine());

            if (age == 1)
            {
                Console.WriteLine("Hello World");
            } else
            {
                var A = int.Parse(Console.ReadLine());
                var B = int.Parse(Console.ReadLine());
                Console.WriteLine(A + B);
            }
        }
    }
}

Measured memory_bytes: 11092