akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define PI 3.14159265359
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
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;
}
vector<int> Eratosthenes(const int N)
{
    vector<bool> is_prime(N+1, true);
    vector<int> P;
    for(int i=2; i<=N; i++) {
        if (is_prime[i]) {
            for(int j=2*i; j<=N; j+=i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

int main() {
    int n,m;
    cin >> n;
    cin >> m;
    vector<ll> A(n);
    vector<ll> B(n);
    rep(i,n) {
        cin >> A[i] >> B[i];
    }
    vector<ll> C(m);
    vector<ll> D(m);
    rep(i,m) {
        cin >> C[i] >> D[i];
    }
    vector<int> total(n);
    rep(i,n) {
        ll mn = INF;
        int num = 0;
        ll t = 0;
        rep(j,m) {
            t = abs(A[i]-C[j])+abs(B[i]-D[j]);
            if (t < mn) {
                mn = t;
                num = j+1;
            }
        }
        total[i] = num;
    }
    rep(i,n) {
        cout << total[i] << "\n";
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll n = s.size()-1;
  ll ans = 0;

  for(int i=0;i<(1<<n);i++) {
    string cur = "";
    cur += s[0];
   // cout << i << endl;
    for(int j=0;j<n;j++) {
      if((i >> j) & 1) {
        //cout << "cur: " << cur << endl;
        ans += stoll(cur);
        cur = "0";
      }
      cur += s[j+1];
    }
    ans += stoll(cur);
    //cout << i << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int h[100005],pd[100005];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(h[a]>=h[b])
		{
			pd[b]=1;
		}
		if(h[b]>=h[a])
		{
			pd[a]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(pd[i]==0)
		{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 2504
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s,c,x;
    int y,a,b;
    cin >> s >> y;
    for(int t=0;t < y;t++){
        cin >> c >> a >> b;
        if(c == "print"){
            cout << s.substr(a,b-a+1) << endl;
        }else if(c =="reverse"){
            string k =s.substr(a,b-a+1);
            int n = k.size();
            for(int i =0;i<n;i++) s[i+a]=k[n-i-1];
        }else if (c == "replace"){
            cin >> x;
            s = s.replace(a,b-a+1,x);
        }
        
    }
}


Measured memory_bytes: 3216
#include "bits/stdc++.h"
using namespace std;
vector<int> to,head,nxt;
vector<long long> f,g;
vector<vector<long long> > tmp;
vector<vector<long long> > pre,bac;
int mod,tot=0;
void addedge(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    to[tot]=v;
    head[u]=tot;
}
void dfs(int index,int father)
{
    int i,len;
    f[index]=1;
    for(i=head[index];i;i=nxt[i])
    {
	if(to[i]==father)
	{
	    continue;
	}
	dfs(to[i],index);
	f[index]=f[index]*(f[to[i]]+1)%mod;
        tmp[index].push_back(f[to[i]]);
    }
    len=tmp[index].size();
    if(len==0)
    {
	return;
    }
    pre[index].resize(len+1);
    bac[index].resize(len+1);
    pre[index][0]=1;
    for(i=1;i<len;i++)
    {
	pre[index][i]=pre[index][i-1]*(tmp[index][i-1]+1)%mod;
    }
    bac[index][len-1]=1;
    for(i=len-2;i>=0;i--)
    {
	bac[index][i]=bac[index][i+1]*(tmp[index][i+1]+1)%mod;
    }
}

void dfs1(int index,int father,long long value)
{
    int len,i,j=0;
    long long ret;
    len=tmp[index].size();
    for(i=head[index];i;i=nxt[i],j++)
    {
	if(to[i]==father)
	{
	    j--;
	    continue;
	}
	g[to[i]]=((value*pre[index][j])%mod*bac[index][j]+1)%mod;
	dfs1(to[i],index,g[to[i]]);
    }
} 
int main()
{
    int n,m;
    int i,x,y;
    scanf("%d %d",&n,&mod);
    m=n-1;
    tmp.resize(n+1);
    f.resize(n+1);
    g.resize(n+1);
    to.resize(2*m+1);
    nxt.resize(2*m+1);
    head.resize(n+1);
    pre.resize(n+1);
    bac.resize(n+1);
    for(i=1;i<=m;i++)
    {
	scanf("%d %d",&x,&y);	
        addedge(x,y);
        addedge(y,x);
    }
    dfs(1,0);
    g[1]=1;
    dfs1(1,0,1);
    for(i=1;i<=n;i++)
    {
        printf("%lld\n",f[i]*g[i]%mod);
    }
    return 0;
}

Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  X--; Y--;
  vector<int> ans(N-1);
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      int dist = j - i;
      dist = min(abs(i-X) + abs(Y-j) + 1, dist);
      dist = min(abs(i-Y) + abs(X-j) + 1, dist);
      ans.at(dist-1)++;
    }
  }
  for(int i=0; i<N-1; i++){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 256
while True:
    h,w =map(int,input().split())
    
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h-1:
            print('#'* w)
        else:
            print('#' + '.' * (w -2) + '#') 
    print()           
  


Measured memory_bytes: 5612
#include <stdio.h>
#include <string.h>

int main() {
    long long int tmin, mod;
    char finalname[50];
    scanf("%lld", &tmin);
    int i = 0;
    while (tmin > 0) {
        mod = (tmin - 1) % 26;
        finalname[i++] = 'a' + mod;
        tmin = (tmin - mod) / 26;
    }
    finalname[i] = '\0';
    int len = strlen(finalname);
    for (len--; len >= 0; len--) {
        printf("%c", finalname[len]);
    }
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int k,s; cin >> k >> s;

  int z;
  int ans = 0;
  for (int x = 0; x <= k; x++) for (int y = 0; y <= k; y++) {
    z = s - x - y;
    if(0 <= z && z <= k) ans++;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vii;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define in insert
#define sz(v) v.size()
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 5;
 
void solve(){
    int n;
    cin>>n;
    vector<string> v;
    for(int i = 0; i < n; i++){
        string s;
        cin>>s;
        sort(all(s));
        v.pb(s);
    }
    map<string,int> m;
    for(string it : v){
        m[it]++;
    }
    ll ans=0;
    for(auto it : m){
        ans+=((ll)it.S*((ll)it.S-1))/2;
    }
    cout<<ans;
}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 12020
#include <iostream>

using namespace std;

const int maxN = 100000;
int N, M;
bool isBroken[maxN+1];
int dp[maxN+1];

int rec(int dan) {
    if (dan == N) {
        return 1;
    }

    if (dan > N) return 0;
    
    int res = 0;
    if (!isBroken[dan+1]) {
        int c;
        if (dp[dan+1] != -1) {
            c = dp[dan+1];
        } else {
            c = rec(dan+1);
            dp[dan+1] = c;
        }

        res += c % 1000000007;
    }
    if (!isBroken[dan+2]) {
        int c;
        if (dp[dan+2] != -1) {
            c = dp[dan+2];
        } else {
            c = rec(dan+2);
            dp[dan+2] = c;
        }

        res += c % 1000000007;
    }
    res = res % 1000000007;

    return res;
}

int main() {
    cin >> N >> M;

    for (int i = 0; i < N+1; ++i) {
        isBroken[i] = false;
        dp[i] = -1;
    }
    
    for (int i = 0; i < M; ++i) {
        int a;
        cin >> a;
        isBroken[a] = true;
    }

    cout << rec(0) << endl;

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
//他の方のを参考にしました(>_<)
int main(){
  int K, S, ans=0;
  cin >> K >> S;
  
  for(int i=0 ; i<=K ; i++)
    for(int j=max(0, S-K-i) ; j<=min(K, S+K-i) ; j++) //←ここは自分で考えました、結構いい感じだと思います
      if(S-K<=i+j && i+j<=S)              //←ここはパクリました
        ans++;
  
  cout << ans << endl;
}

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

using namespace std;

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

	ll n, ans=0;
	cin >> n;
	for(ll i=1; i<=n; i++){
        ll m=n/i;
        ans+=((ll)i*m*(m+1))/2;
	}
	cout << ans << endl;

	return 0;
}


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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, n) for(int i = 0; i < n; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // vvvi V (50, vvi(50, vi(2500)));
    int N;
    ll ans = 0;
    cin >> N;
    for(int i = 1; i <= N; ++i){
        if( i % 3 == 0){
        }
        else if( i % 5 == 0){

        }
        else{
            ans += i;
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3608
package main

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

func main() {
	N := ReadInt()
	P = ReadInts(N)
	Q = ReadInts(N)
	remainder := make([]int, N)
	for i := 0; i < N; i++ {
		remainder[i] = i + 1
	}
	dfs(make([]int, 0, N), remainder)
	fmt.Println(Abs(pth - qth))
}

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var P, Q []int
var c, pth, qth int = 0, -1, -1

func dfs(prefix []int, remainder []int) {
	if pth >= 0 && qth >= 0 {
		return
	}
	if len(remainder) == 0 {
		if pth == -1 && eq(prefix, P) {
			pth = c
		}
		if qth == -1 && eq(prefix, Q) {
			qth = c
		}
		c++
	}

	for i := 0; i < len(remainder); i++ {
		prefix = append(prefix, remainder[i])
		rem := append([]int{}, remainder[:i]...)
		rem = append(rem, remainder[i+1:]...)
		dfs(prefix, rem)
		prefix = prefix[:len(prefix)-1]
	}
}

func eq(a, b []int) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

var reader = bufio.NewReader(os.Stdin)

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


Measured memory_bytes: 2880
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void init(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<P> a(m);
    REP(i,m){
        a[i].first = in() - 1;
        a[i].second = in() - 1;
        swap(a[i].first, a[i].second);
    }
    sort(ALL(a));

    BIT bit(n);
    int ans = 0;
    REP(i,m){
        // cout << a[i].first << " " << a[i].second << endl;
        if (bit.sum(a[i].second, a[i].first) == 0){
            ans++;
            bit.add(a[i].first - 1, 1);
        }
        // REP(j,n) cout << bit.sum(j, j+1);
        // cout << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int MaxA, MaxB, MaxC, X;
	int a, b, c, sum, cnt;
	
	scanf("%d", &MaxA);
	scanf("%d", &MaxB);
	scanf("%d", &MaxC);
	scanf("%d", &X);

	cnt = 0;
	for(a = 0; a <= MaxA; a++){
		sum = 500 * a;
		if(sum > X)	break;
		if(sum == X){
			b = 0;
			c = 0;
			cnt++;
			break;
		}
		for(b = 0; b <= MaxB; b++){
			sum = 500 * a + 100 * b;
			if(sum > X)	break;
			if(sum == X){
				c = 0;
				cnt++;
				break;
			}
			for(c = 0; c <= MaxC; c++){
				sum = 500 * a + 100 * b + 50 * c;
				if(sum == X) cnt++;
			}
		}
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	long double r, a[101][101], dp[101][101];
	
	while(cin>>n>>m && (m+n)){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> a[i][j];
			}
		}
		fill(&dp[0][0], &dp[n][m], 0);
		
		for(int i = 0; i < n; i++){
			dp[i][0] = 1.0;
		}
		
		for(int k = 1; k < m; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					dp[i][k] = max(dp[i][k], dp[j][k-1]*a[j][i]);
				}
			}
		}
		
		r = 0.0;
		for(int j = 0; j < n; j++){
			r = max(r, dp[j][m-1]);
		}
		
		printf("%.2Lf\n", r);
	}
	
	return 0;
}

Measured memory_bytes: 1220
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <functional>
#include <stdio.h>
using namespace std;

int main()
{
	string str;
	cin >> str;
	bool n = false;
	bool w = false;
	bool e = false;
	bool s = false;

	int i = 0;
	for (int i = 0; i < str.length(); i++) {
		switch (str[i]) {
		case 'N':
			n = true;
			break;
		case 'W':
			w = true;
			break;
		case 'E':
			e = true;
			break;
		case 'S':
			s = true;
			break;
		}
	}
	if ((n^s) || (e^w)) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,j,now,nt[240001][26],f[500001];
char s[500001];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	memset(f,44,sizeof(f));
	f[n+1]=1;f[n+2]=0;
	for(i=0;i<26;i++)nt[n+1][i]=n+1;
	for(i=n;i;i--){
		for(j=0;j<26;j++)nt[i][j]=nt[i+1][j];
		nt[i][s[i]-'a']=i;
	}
	for(i=n;i;i--)
	 for(j=0;j<26;j++)f[i]=min(f[i],f[nt[i][j]+1]+1);
	now=1;
	for(j=f[1];j;j--)
	 for(i=0;i<26;i++)if(f[now]==f[nt[now][i]+1]+1){
	 	printf("%c",i+'a');
	 	now=nt[now][i]+1;
	 	break;
	 }
}

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

const int INF = 2147483647;

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(){
    int N; cin >> N;
    cout << (N+1)/2 << endl;
}

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

using namespace std;

const int N = 1e3+7;
const int M = 5e3+7;

int n, k;
int dp[N][M];

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    dp[0][0] = 1;
    for (int i = 1; i <= n/100; ++i) {
        for (int j = 0; j <= 5; ++j) {
            for (int k = j; k <= 5*i; ++k) {
                dp[i][k] |= dp[i-1][k-j];
            }
        }
    }
    for (int i = 0; i <= n/100; ++i) {
        if (dp[i][n-100*i]) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 18304
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n, k;
	cin >> n >> k;
	int a[n] = {};
	REP(i, n){
		cin >> a[i];
	}
	REP(i, n-k){
		if(a[i] < a[i + k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	//cout << ans << endl;
}

Measured memory_bytes: 4412
#include <stdio.h>

int main(void)
{
	int mark[4][13];
	int n;
	int i;
	char str[3];
	int x;
	int j;
	
	for (i = 0; i < 4; i++){
		for (j = 0; j < 13; j++){
			mark[i][j] = 0;
		}
	}
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%s %d", str, &x);
		if (str[0] == 'S'){
		    mark[0][x - 1] = 1;
		}
		else if (str[0] == 'H'){
		    mark[1][x - 1] = 1;
		}
		else if (str[0] == 'C'){
			mark[2][x - 1] = 1;
		}
		else if (str[0] == 'D'){
			mark[3][x - 1] = 1;
		}
	}
	
	for (i = 0; i < 4; i++){
		for (j = 0; j < 13; j++){
			if (mark[i][j] != 1){
				switch (i){
				  case 0:
				    printf("S %d\n", j + 1);
					break;
					
				  case 1:
				    printf("H %d\n", j + 1);
					break;
					
				  case 2:
				    printf("C %d\n", j + 1);
					break;
					
				  case 3:
				    printf("D %d\n", j + 1);
					break;
				}
			}
		}
	}
	
	return (0);
	}

Measured memory_bytes: 1752
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{   int n,m,i;string s;
	cin>>n;
	cin>>s;
	int ss=0;
	for(i=0;i<n-2;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
		ss++;
	}
	cout<<ss<<endl;
}

Measured memory_bytes: 256
S = input()
if 0 < int(S[:2]) <= 12 and 0 < int(S[2:]) <= 12:
    print('AMBIGUOUS')
elif 0 < int(S[:2]) <= 12:
    print('MMYY')
elif 0 < int(S[2:]) <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
size = int(input())
src = input()
values = [int(value) for value in src.split(' ')]
count = 0

while True:
    flg = True
    for value in values:
        if value % 2 != 0:
            flg = False
            break
        
    if flg:
        values = [value / 2 for value in values]
        count += 1
    else:
        break

print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

long f(long b,long n){
  if(b<2)
    return -1;
  if(n<b)
    return n;
  else
    return f(b,n/b)+n%b;
}

int main(){
  long n,s;
  scanf("%ld %ld",&n,&s);
  if(n==s){
    printf("%ld\n",n+1);
    return 0;
  }
  for(long i=2;i<=sqrt(n);i++)
    if(f(i,n)==s){
      printf("%ld\n",i);
      return 0;
    }
  for(long i=sqrt(n);i>0;i--)
    if(((n-s)/i)*i==n-s&&f((n-s)/i+1,n)==s){
      printf("%ld\n",(n-s)/i+1);
      return 0;
    }
  printf("-1\n");
}

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

using namespace std;

int m, h, w, n, ans = 0;

int main()
{
    cin>>h>>w>>n;
    if(h < w) swap(h, w);
    if(n <= h) {
        cout<<"1";
        return 0;
    }
    else {
        ans += n / h;
        n %= h;
        if(n == 0) {
            cout<<ans;
            return 0;
        }
        if(n % (h - ans) == 0) m = n / (h - ans);
        else m = n / (h - ans) + 1;
    }
    cout<<ans + m;
    return 0;
}

Measured memory_bytes: 256
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, K = In.ints()
A = [0]+In.ints()

cur = 1
seen = set()
seen.add(cur)
circleStart = 0

i = 0
while i<K:
    cur = A[cur]

    if cur not in seen:
        seen.add(cur)
    else:
        circleStart = cur
        i+=1
        break
    i+=1

if i == K:
    Out.int(cur)
else:
    K-=i

    dist = dict()
    dist[0] = circleStart
    cur_dist = 0
    longest = 0

    i = 0
    while i<K:
        cur_dist+=1

        cur = A[cur]

        if cur!=circleStart:
            dist[cur_dist] = cur
            longest = max(cur_dist, longest)
        else:
            i+=1
            break

        i+=1

    if i == K:
        Out.int(cur)
    else:
        K-=i
        Out.int(dist[K%(longest+1)])


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 119672
while 1:
    k=input().split()
    n=int(k[0])
    x=int(k[1])
    if n==0 and x==0 :
        break
    m=0
    for i1 in range(1,n-1):
        for i2 in  range(i1+1,n):
            for i3 in  range(i2+1,n+1):
                if (i1!=i2 and i2!=i3) and (i3!=i1 and x==i1+i2+i3):
                    m+=1
    print(m)


Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <cassert>
using namespace std;
typedef long long LL;
const int M = 1e6 + 5;
const int N = 1e5 + 5;
const LL mod = 1e9 + 7;
const int MAX = 5e5 + 5;
const int MAXV = 100000 + 5;
const LL INF = (1LL << 62);
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.);
int n, m;
int a[N];
LL ans[N];
LL revd[N];
LL rans[N];
LL d[N];
int main() {
#ifdef local
    freopen("input", "r", stdin);
//    freopen("w", "w", stdout);
//    freopen("input", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)cin >> a[i];
    for(int i = 2; i <= n; i++) {
        int l = a[i - 1], r = a[i];
        if(r > l) {
            int step = r - l;
            //[1,l]
            ans[1] += step;
            ans[l + 1] -= step;

            //[l+1,r]
            revd[r]++;
            revd[l]--;
            rans[l] -= step;

            //[r+1,m]
            ans[r + 1] += step;
            ans[m + 1] -= step;
        } else {
            int step = m - l + r;
            //[r + 1, l]
            ans[r + 1] += step;
            ans[l + 1] -= step;

            //[l + 1,m]
            ans[l + 1] += r;
            ans[m + 1] -= r;
            revd[m]++;
            revd[l]--;
            rans[l] -= m - l;

            //[1,r]
            revd[r]++;
            revd[0]--;
            rans[0] -= r;
        }
    }
    for(int i = m; i >= 1; i--) {
        revd[i] += revd[i + 1];
        rans[i] += revd[i];
    }
    for(int i = 1; i <= m; i++) {
        d[i] += d[i - 1];
        ans[i] += d[i];
    }
    for(int i = m; i >= 1; i--){
        rans[i] += rans[i + 1];
    }
    LL anss = INF;
    for(int i = 1; i <= m; i++){
        ans[i] += ans[i - 1];
    }
    for(int i = 1; i <= m; i++){
//        cout<<ans[i] + rans[i]<<endl;
        anss = min(anss,ans[i] + rans[i]);
    }
    cout<<anss<<endl;
}



Measured memory_bytes: 3840
A, B, Q = map(int, input().split())
s = []
for _ in range(A):
    s.append(int(input()))
t = []
for _ in range(B):
    t.append(int(input()))
x = []
for _ in range(Q):
    x.append(int(input()))

def binsearch(threshold, lst):
    left, right = -1, len(lst)

    while right - left > 1:
        mid = (left + right) // 2
        if lst[mid] > threshold:
            right = mid
        else:
            left = mid
    return (left, right)

for q in x:
    ans = 10 ** 11
    for i in range(2):
        for j in range(2):
            a = binsearch(q, s)[i]
            b = binsearch(q, t)[j]
            #print(i, j, a, b)
            if 0 <= a <= A - 1 and 0 <= b <= B - 1:
                    #print(s[a], t[b], q)
                    ans = min(ans, abs(s[a] -t[b]) + min(abs(s[a]-q), abs(t[b]-q)))
    print(ans)

Measured memory_bytes: 95832
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

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

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  vector<vector<int> > e(n);
  vector<int> d(n,0);
  for(int t=0;t<n-1+m;t++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--,b--;
    e[a].push_back(b);
    d[b]++;
  }
  queue<int> Q;
  vector<int> ans(n);
  for(int i=0;i<n;i++){
    if(d[i]==0){
      Q.push(i);
      ans[i]=-1;
    }
  }
  while(!Q.empty()){
    int i=Q.front();
    Q.pop();
    for(int x=0;x<e[i].size();x++){
      int j=e[i][x];
      d[j]--;
      if(d[j]==0){
	Q.push(j);
	ans[j]=i;
      }
    }
  }
  for(int i=0;i<n;i++){
    printf("%d\n",ans[i]+1);
  }
  return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

int main(){
    ll N,flag=0;
    cin >> N;
    vector<ll> A(N,0);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());

    for(ll i=0;i<N-1;i++){
        if(A[i]==A[i+1]){
            flag = 1;
        }
    }

    if(flag == 1){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }


    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
n, m = map(int, input().split())
demands = [
    tuple(map(int,
              line.strip().split())) for line in sys.stdin.readlines()
]
demands.sort(key=lambda demand: demand[1])

x = -1
cnt = 0
for ai, bi in demands:

    if ai <= x:
        continue

    else:
        x = bi - 1
        cnt += 1

print(cnt)


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

int main() {
  char c, ans;
  cin >> c;
  switch(c) {
    case 'A':
      ans = 'T';
      break;
    case 'T':
      ans = 'A';
      break;
    case 'G':
      ans = 'C';
      break;	
    case 'C':
      ans = 'G';
      break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
(defparameter n (read))
(defparameter a '())
(defparameter members (make-array n :adjustable t :fill-pointer 0))

(dotimes (i (1- n))
	(push (read) a))

(dotimes (i n)
	(vector-push '() members))

(dolist (e a)
	(push e (aref members (1- e))))

(map nil (lambda (m) (format t "~A~%" (length m))) members)

(defun main ())

Measured memory_bytes: 81536
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define for(i,a,b) for(int i=a;i<b;i++)
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a + b) >= c) { cout << b + c << endl; }
	else { cout << a + b * 2+1 << endl; }
}

Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(3)]

ans = 0
table = [2, 1, 10 * 9 + 7, 0]
for i in range(N):
    score = 0
    if S[0][i] == S[1][i]: score += 1
    if S[1][i] == S[2][i]: score += 1
    if S[2][i] == S[0][i]: score += 1
    ans += table[score]

print(ans)


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

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> v[200002];
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        v[x].push_back(y);
    }
    for(int i = 0; i < n; i++) sort(v[i].begin(), v[i].end());
    int l = 1;
    for(int i = 1; i < h; i++){
        int p = lower_bound(v[i].begin(), v[i].end(), l) - v[i].begin();
        if(p){
            cout << i << endl;
            return 0;
        }
        if((int)v[i].size() != p)
            if(v[i][p] == l) continue;
        if(l < w) l++;
    }
    cout << h << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n;
  cin>>n;
  int x[n],y[n];
  int u[n],v[n];
  int p;
  bool flag = true;
  REP(i,n){
    cin>>x[i]>>y[i];
    u[i] = x[i] + y[i];
    v[i] = x[i] - y[i];
    if(i == 0){
      p = (u[i]%2 + 2)%2;
    }else{
      if((u[i]%2 + 2)%2 != p){
        flag = false;
      }
    }
  }
  if(!flag){
    cout<<-1<<endl;
    return 0;
  }
  if(p == 0){//左に1ずらす。あとで右に1ずらす。
    REP(i,n){
      u[i]--;v[i]--;
    }
  }
  int m = 31;
  int d[m+1];
  REP(i,m){
    d[i] = (1<<i);
  }
  bool up[n][m+1] = {};
  bool vp[n][m+1] = {};
  vector<string> w;
  REP(j,n){
    REP(i,m){
      if((u[j] + (1<<31) - 1)/2 & (1<<i)){
        up[j][i] = true;
      }
    }
    REP(i,m){
      if((v[j] + (1<<31) - 1)/2 & (1<<i)){
        vp[j][i] = true;
      }
    }
  }
  REP(j,n){
    string temp = "";
    REP(i,m){
      if(!up[j][i] && !vp[j][i]){
        temp += 'L';
      }else if(up[j][i] && vp[j][i]){
        temp += 'R';
      }else if(!up[j][i] && vp[j][i]){
        temp += 'D';
      }else{
        temp += 'U';
      }
    }
    if(p == 0){
      temp += 'R';
    }
    w.push_back(temp);
  }
  if(p == 1){
    cout<<m<<endl;
  }else{
    cout<<m+1<<endl;
  }
  REP(i,m){
    cout<<d[i]<<' ';
  }
  if(p == 0){
    cout<<1;
  }
  cout<<endl;
  REP(i,n){
    cout<<w[i]<<endl;
  }
  return 0; 
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15);

signed main(){
    int n; cin >> n;
    vstr s(n);
    rep(i,n){
        cin >> s[i];
    }
    map<string,int> map;
    int res=0;
    rep(i,n){
        sort(all(s[i]));
        res+=map[s[i]];
        map[s[i]]++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 18176
# -*- coding: utf-8 -*-
N, M, V, P = map(int, input().split())
A_list = list(map(int, input().split()))

A_list.sort(reverse = True)
# print(A_list)
ans = P
border = A_list[P - 1]
sum_over_A = border

if P < N:
    before_A = border
    for i in range(P, N):
        if before_A == A_list[i]:
            ans += 1
#             print(1, i, A_list[i])
        elif border <= (A_list[i] + M):
            over_V = V - (P + N - (i + 1))
            if over_V > 0:
                sum_over = sum_over_A + over_V * M
                round_up_sum_over = -(-sum_over // (i + 1 - P))
                if A_list[i] + M >= round_up_sum_over:
                    ans += 1
#                     print(2, i, A_list[i], round_up_sum_over, over_V, sum_over)
                else:
#                     print("NG", i, A_list[i], round_up_sum_over, over_V)
                    break
            else:
                ans += 1
#                 print(3, i, A_list[i])
            before_A = A_list[i]
        else:
            break
        sum_over_A += A_list[i]
print(ans)

Measured memory_bytes: 14964
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60
// #define PI 3.14159265
// # define PI 3.141592653589793238462643383279502884L
const double PI  =3.141592653589793238463;
int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double h_arg = 2 * PI * double(H* 60 + M) / double(12 * 60);
    double m_arg = 2 * PI * double(M) / 60;
    double diff = h_arg - m_arg;
    if(diff >= PI) {
        diff  = 2 * PI - diff;
    }
    double ans = sqrt(A*A + B*B - 2 * A * B * cos(diff));
    printf("%.20f\n", ans);
    return 0;
}
// 4.56425719433005567605: ans
// 4.56425719433005561143

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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());

  ll ans = A[0];
  ll l = 1;
  for (ll i = 1; i < N - 1; i++) {
    ans += A[l];
    if (i % 2 == 0) l++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4788
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <functional>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;

template<class T, class F>
T bSearch(T l, T r, F func, T diff = 1){
    while ((r - l) > diff) {
        T m = (l + r) / 2;
        (func(m) ? r : l) = m;
    }
    return r;
}


int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, K;

    cin >> N >> K;

    vector<ll> a(N), f(N);

    for0(i, N){
        cin >> a[i];
    }
    for0(i, N){
        cin >> f[i];
    }

    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    cout << bSearch(-1ll, (ll)1e12,
                    [&](ll x) -> bool{
                        ll c = 0;
                        for (ll i = 0; i < N; ++i) {
                            ll t = a[i] * f[i] - x;
                            c += t > 0 ?
                                t / f[i] + (t % f[i] == 0 ? 0 : 1): 0;
                        }
                        return K >= c;
             });

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int int64_t
using namespace std;
map<int, int> mp;
signed main()
{
     int n;
     cin >> n;
     for (int i = 0; i < n; ++i) {
          int x;
          cin >> x;
          mp[x]++;
     }
     int ans = 0;
     for (auto el : mp) {
          if (el.second >= el.first) {
               ans += el.second - el.first;
          } else {
               ans += el.second;
          }
     }
     cout << ans << endl;
     return 0;
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<stdlib.h>

int max_left(int end, int array[]){
    int sum=0;
    for(int i=0;i<end;i++){
        sum += array[i];
    }
    return sum;
}
int max_right(int start, int end, int array[])
{
    int sum = 0;
    for(int i=start;i<end;i++){
        sum += array[i];
    }
    return sum;
}

int main(void){
    int n, min;
    int w[100];
    scanf(" %d",&n);
    min = 65536;
    for(int i=0;i<n;i++){
        scanf(" %d",&w[i]);
    }
    for(int i=0;i<n-1;i++){
        int left = max_left(i+1,w);
        int right = max_right(i+1,n,w);
        min = min > abs(left-right) ? abs(left-right) : min; 
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)

{	
	int a,a2,b,b2,c,d,r;
	while (scanf("%d %d",&a2,&b2)!= EOF) {
	
	a = a2 ;
	b = b2 ;
	if(a2<b2){
	c = a2 ;
	a2 = b2 ;
	b2 = c ;}
	
	r = 1;
		while(r!=0){
		r = a2 % b2 ;
		a2 = b2 ;
		b2 = r ;
	}
	
	d = a/a2*b;
	printf("%d %d\n", a2,d);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int c[26];
int main(void) {
  for(int i = 0; i < 26; i++) {
    c[i] = 0;
  }

  char ch;
  while(cin >> ch) {
    if('a' <= ch && ch <= 'z')
      c[ch - 'a']++;
    if('A' <= ch && ch <= 'Z')
      c[ch - 'A']++;
  }

  for(char i = 'a'; i < 'z' + 1; i++) {
    cout << i << " : " << c[i - 'a'] << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,k;cin>>n>>k;
	vector<ll> a(n);
	vector<ll> b;
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	
	vector<ll> x(n,0);
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			if (a[i] > a[j]){
				x[i]++;
			}
		}
	}
	vector<ll> y(n,0);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if (a[i] > a[j]){
				y[i]++;
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if ( k % 2 == 0){
			ll tmp = k / 2;
			ans += (((k * x[i]) % mod) + ((y[i] * ((tmp * (k - 1) % mod))) % mod) % mod);
		}
		else{
			ll tmp = (k - 1) / 2;
			ans += (((k * x[i]) % mod) + ((y[i] * ((k * tmp % mod))) % mod) % mod);
		}
		
		ans %= mod;
	}

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

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

int main(void)
{
    char c[4];
    for (size_t i = 0; i < 4  ; ++i)
    {
        cin >> c[i];
    }

    int i_0 = 0;
    for (size_t i = 1; i < 4  ; ++i)
    {
        if(c[i] == c[0]) {
            i_0++;
        }
    }
    if (i_0 != 1){
        cout << "No" <<endl;
        return 0; 
    } 

    if(c[1] == c[0]){
        if(c[2] != c[3]){
            cout << "No" <<endl;
            return 0;
        }
    }

    if(c[2] == c[0]){
        if(c[1] != c[3]){
            cout << "No" <<endl;
            return 0;
        }
    }

    if(c[3] == c[0]){
        if(c[1] != c[2]){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
    return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    int a, b, c;
    
    cin >> a >> b >> c;
    
    // ラムダ式を使っている
    auto maxNumber = max({a, b, c});
    
    printf("%d\n", a + b + c - maxNumber);
    
    return 0;
}


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


int main()
{
int n,count=0;
scanf("%d",&n);
int a[n];
int c[9] ={0};
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]<400)
c[0]=1;
else if(a[i]<800)
c[1]=1;
else if(a[i]<1200)
c[2]=1;
else if(a[i]<1600)
c[3]=1;
else if(a[i]<2000)
c[4]=1;
else if(a[i]<2400)
c[5]=1;
else if(a[i]<2800)
c[6]=1;
else if(a[i]<3200)
c[7]=1;
else
{
	count++;
c[8]=1;
}
}
int max,min=0;
for(int i=0;i<8;i++)
if(c[i]==1)
min++;
max=min;

if(c[8]==1)
max=min+count;
if(count==n)
min=1;
printf("%d %d",min,max);
}


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

const int maxn = 2e5 + 10;
int f[maxn], g[maxn], ans[maxn];

void init()
{
   for(int i = 0; i < maxn; i++)
        f[i] = i, g[i] = i;
}

int getf(int *data, int u)
{
    if(data[u] == u) return u;
    return data[u] = getf(data, data[u]);
}

void Merge(int *data, int u, int v)
{
    int t1 = getf(data, u);
    int t2 = getf(data, v);
    data[t2] = t1;
}

vector<int> root[maxn];
map<int, int> p;

int main()
{
    int n, k, l, u, v;
    scanf("%d %d %d", &n, &k, &l);
    init();
    for(int i = 0; i < k; i++)
    {
        scanf("%d %d", &u, &v);
        Merge(f, u, v);
    }
    for(int i = 0; i < l; i++)
    {
        scanf("%d %d", &u, &v);
        Merge(g, u, v);
    }

    for(int i = 1; i <= n; i++)
    {
       root[getf(f, i)].push_back(i);
    }
    for(int i = 1;  i <= n; i++)
    {
         p.clear();
        int len = root[i].size();
        for(int j = 0; j < len; j++)
        {
            p[getf(g, root[i][j])]++;
        }
        for(int j = 0; j < len; j++)
            ans[root[i][j]] += p[getf(g, root[i][j])];
    }
    for(int i = 1; i <= n; i++)
        printf("%d%c", ans[i], i == n ? '\n' : ' ');
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

ll f(vector<int> a, int n, int bit){
    vector<ll> res;
    res.push_back(a[0]);

    for(int i=0;i<a.size()-1;i++){
        if ((bit >> i) & 1) {
            res.push_back(0);
        } else {
            res[res.size() - 1] *= 10;
        }
        res[res.size() - 1] += a[i + 1];
    }

    dbg(join(res));
    ll ans = 0;
    for(auto x : res){
        ans += x;
    }
    return ans;
}

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

    vector<int> a(s.size());
    rep(i, s.size()) a[i] = s[i] - '0';

    int n = s.size() - 1;

    ll ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        ans += f(a, n, bit);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
	int a, b, c, d;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	if((a+b) > (c+d)){
		cout << "Left" << endl;
	}
	else if((a+b) == (c+d)){
		cout << "Balanced" << endl;
	}
	else{
		cout << "Right" << endl;
	}
	return 0;
}

Measured memory_bytes: 256