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

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 _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

ll modinv(ll a){
    ll b=MOD-2, r=1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}
ll modpow(ll a,ll b){
    ll r=1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}

int n,k;
vi g[125252];

bool used[125252];

ll fact[125252];

int sz[125252];

int dfs(int p, int bef){
    sz[p] = 1;
    for(int to : g[p])if(to != bef && !used[to]){
        sz[p] += dfs(to,p);
    }
    return sz[p];
}
int dfs2(int p, int bef, int s){
    int ret = -1;
    int maxch = 0;
    for(int to : g[p])if(to != bef && !used[to]){
        CHMAX(ret, dfs2(to,p,s));
        CHMAX(maxch, sz[to]);
    }
    if(2*maxch<=s && 2*(s-sz[p])<=s){
        return p;
    }
    return ret;
}
ll f(int p, int bef){
    int s = dfs(p,bef);
    if(sz[p]==1)return k;
    int r = dfs2(p,bef,s);
    ll ans = k;
    int deg = 0;
    used[r] = true;
    for(int to : g[r])if(!used[to]){
        deg++;
        ll x = 1;
        for(int tt : g[to])if(!used[tt]){
            x++;
        }
        ll po = f(to,r);
        ans = ans * po % MOD * max(k-x,0ll) % MOD * modinv(k) % MOD;
    }
    // DEBUG(r);
    // DEBUG(ans);
    if(k-1-deg < 0)return 0;
    ans = ans * fact[k-1] % MOD * modinv(fact[k-1-deg]%MOD*modpow(k-1,deg)%MOD) % MOD;
    // DEBUG(ans);
    return ans;
}

int main(){
    scanf("%d%d",&n,&k);
    REP(i,n-1){
        int a,b;
        scanf("%d%d",&a,&b);
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    fact[0] = 1;
    FOR(i,1,125252)fact[i]=fact[i-1]*i%MOD;
    ll ans = f(0,-1);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 13696
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ( x - r < 0 || W < x + r ) cout << "No" << endl;
    else if ( y - r < 0 || H < y + r ) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 

using namespace std;

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll arr[n];
        for(ll i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        ll dp[n];
        for(ll i=0;i<n;i++) { dp[i]=1e18; }
        dp[0]=0; dp[1]=abs(arr[1]-arr[0]);
       // cout<<dp[0]<<endl<<dp[1]<<endl;
        for(ll i=2;i<=min(k,n);i++)
        {
            for(ll j=i-1;j>=0;j--)
            {
                ll temp=abs(arr[i]-arr[j])+dp[j];
                dp[i]=min(dp[i],temp);
            }
            //cout<<dp[i]<<endl;
        }
        for(ll i=k+1;i<n;i++)
        {
            for(ll j=1;j<=k;j++)
            {
                ll temp=abs(arr[i]-arr[i-j])+dp[i-j];
                dp[i]=min(dp[i],temp);
            }
            //cout<<dp[i]<<endl;
        }
        cout<<dp[n-1];
        
    }
    return 0;
}

Measured memory_bytes: 5108
def solve(n,lst):
    #i行j列はjから連続したi個のうち落とせる個数の最大値
    dp=[[0]*n for _ in range(n+1)]

    #initialize
    for j in range(n-1):
        if abs(lst[j]-lst[j+1])<=1 : dp[2][j]=2
    

    #真ん中2*i個が抜けて上下を落とせる場合と2*(i+1)個を複数の部分に分けて落とせる場合の2通りが考えられる
    for i in range(3,n+1):
        for j in range(n-i+1):
            mx=0
            if i%2==0:
                if abs(lst[j]-lst[j+i-1])<=1:
                    if dp[i-2][j+1]==i-2:
                        dp[i][j]=i
                        continue
                mx=dp[i-2][j+1]                
                for k in range(2,i,2):
                    if mx<dp[k][j]+dp[i-k][j+k]:
                        mx=dp[k][j]+dp[i-k][j+k]
                        if mx==i:break
            else :
                for k in range(1,i,2):
                    if mx<dp[k][j]+dp[i-k][j+k]:
                        mx=dp[k][j]+dp[i-k][j+k]                
            dp[i][j]=mx
    print(dp[n][0])        
    #print(dp) 

                

while 1:
    n=int(input())
    if n==0 : break
    lst=tuple(map(int,input().split()))
    solve(n,lst)  


Measured memory_bytes: 6380
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;
const int MAX=1e5+5;
set<int> help;
int arr[MAX];


int main() 
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
		help.insert(arr[i]);
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(arr[i]==(n-1))
		{
			cnt++;
		}
	}
	if(cnt==n)
	{
		printf("Yes\n");
		return 0;
	}
	if(help.size()>2)
	{
		printf("No\n");
	}
	else if(help.size()==1)
	{
		int mn=1;
		int mx=n/2;
		int val=*(help.begin());
		if((val>=mn&&val<=mx))
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}//correct

	else
	{
		int val=*(help.begin());
		int cnt=0;
		int flg=0;
		for(int i=1;i<=n;i++)
		{
			if(arr[i]==val)
			{
				cnt++;
			}
			else if(arr[i]!=(val+1))
			{
				flg=1;
			}
		}
		if(flg==1)
		{
			printf("No\n");
			return 0;	
		}
		if((n-cnt)<2)
		{
			printf("No\n");
			return 0;
		}
		//printf("cam\n");
		val+=1;
		val-=cnt;
		int mn=1;
		int mx=(n-cnt)/2;
		if(val>=mn&&val<=mx)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}//ans is 4

	return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
	int a, b;
	cin >> a >> b;
	
	int counter = 0;

	rep(i, a, b+1){
		string s = to_string(i);
		string rs = s;
		reverse(ALL(s));
		if ( s ==  rs) ++counter;
	}
	cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	map<string,int> m;
	string s,t,u;
	int A,B;
	cin>>s>>t;
	cin>>A>>B;
	cin>>u;
	m[s]=A;
	m[t]=B;
	m[u]--;
	cout<<m[s]<<" "<<m[t]<<endl;
	return EXIT_SUCCESS;	
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = 0
for i in range(n):
    cnt += b[a[i] - 1]
    if (a[i]-1 == a[i-1])&(i!=0):
        cnt += c[a[i - 1]-1]
print(cnt)

Measured memory_bytes: 3064
input_lines = readlines;
num = input_lines.length;

if num <= 200
  for i in 0..num-1 do
    data_set = input_lines[i].chomp.split(" ");
    a = data_set[0].to_i;
    b = data_set[1].to_i;
    if a>=0 && a<=1000000 && b>=0 && b<=1000000
      sum = a + b;
      keta = sum.to_s.length;
      puts keta;
    end
  end
end



Measured memory_bytes: 6868
n,m=map(int,input().split())
data=[0]*n
count,wa=0,0
for i in range(m):
    p,a=input().split()
    p=int(p)-1
    if type(data[p]) is int:
        if a=='WA':
            data[p]+=1
        else:
            wa+=data[p]
            data[p]=''
            count+=1
print(count,wa)

Measured memory_bytes: 9656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	int n;
	cin >> n;
	long long x = 1, y = 1;
	while(n--) {
		long long a, b;
		cin >> a >> b;
		long long t = max((x + a - 1) / a, (y + b - 1 ) / b);
		x = t * a;
		y = t * b;
	}
	cout << x + y << endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/08/10.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

struct p{
  int a;
  int b;
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<p> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i].a >> v[i].b;
    }
    sort(all(v),[&](p &l, p &r){
        return l.a < r.a;
    });
    priority_queue<int> heap;
    ll ans=0;
    int idx=0;
    for(int now=0;now<=m;now++){
        while(idx<n){
            if(v[idx].a<=now){
                heap.push(v[idx].b);
                idx++;
            }else{
                break;
            }
        }
        if(!heap.empty()){
            ans+=heap.top();
            heap.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n, k; cin >> n >> k;
    vi h(n);
    F0R (i, n) cin >> h[i];
    vi dp(n, 2e9);
    dp[0] = 0;
    FOR (i, 1, n - 1) {
        RFOR (j, i - 1, max(0, i - k)) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1] << endl;

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  long double a, b, x;
  cin >> a >> b >> x;
  
  cout << fixed << setprecision(10);

  long double ans = 0;
  if (a*a*b / 2.0 <= x) {
    x = a*a*b - x;
    ans = atan(((2.0*x)/(a*a)) / a);
  } else {
    ans = atan(b / ((2.0*x)/(a*b)));
  }

  cout << ans * 180.0 / M_PI << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=1;
ll x[100005],y[100005],z[100005];
ll p[1000005];

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];
		if(x[i]%2==0){
			ans*=2;
		}
	}
	e=1;
	for(i=0;i<n;i++)e*=3;
	p(e-ans);
			
	return 0;
}

Measured memory_bytes: 6912
#include <stdio.h>
int main(){
    int n,m,ans,sum;
    scanf("%d %d",&n,&m);
    int a[m];
    sum = 0;
    for(int i=0;i<m;i++){
        scanf("%d",&a[i]);
        sum = sum + a[i];
    }
    ans = n - sum;
    if(ans>=0){
        printf("%d",ans);
    }else{
        printf("-1");
    }
    
    return 0;
}


Measured memory_bytes: 1744
# For taking integer inputs.
import math
from decimal import Decimal


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


x, y = invr()
count = 0
while x <= y:
    x *= 2
    count += 1
print(count)


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

int main()
{
    char s[100], p[100], ring[100];
    char buffer[126];
    int i, j, index;
    int length;
    char *ret;
    
    fgets(buffer, 126, stdin);
    sscanf(buffer, "%s", s);
    fgets(buffer, 126, stdin);
    sscanf(buffer, "%s", p);
    
    length = strlen(s);
    for(i=0;i<length;i++)
    {
        int count;
        for(j=i, count=0;count<length;count++)
        {
            //printf("j s[%d] %c\n", j, s[j]);
            ring[count] = s[j];
            j++;
            j = j % length;
        }
        ring[count]='\0';
        //putchar('\n');
        //printf("%s\n", ring);
        ret = strstr(ring, p);
        if(ret != 0){
            break;
        }
    }
    if(ret != 0){
            printf("Yes\n");
    }
    else printf("No\n");
    
    return(0);
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
  //cin>>tc;
  while (tc--)
  {
    int n;
    cin >> n;
    int a = n - 1;
    if (n == 2)
    {
      cout << 1 << endl;
      return 0;
    }
    int ans = 0;
    for (int i = 2; i * i <= a; i++)
    {
      if (a % i == 0)
      {
        ans++;
        if (i != (a / i))
        {
          ans++;
        }
      }
    }
    ans++;
    for (int i = 2; i * i <= n; i++)
    {
      if (n % i == 0)
      {
        int f = n;
        while (f >= i && f % i == 0)
        {
          f /= i;
        }
        f %= i;
        if (f == 1)
        {
          ans++;
        }
        if (i != (n / i))
        {
          int f = n;
          int c = n / i;
          while (f >= c && f % c == 0)
          {
            f /= c;
          }
          f %= c;
          if (f == 1)
          {
            ans++;
          }
        }
      }
    }
    ans++;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, K; cin >> n >> K;
    int X, Y; cin >> X >> Y;
    int res = X * n + (Y - X) * max(0, n - K);

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int n = s.size();
    int ans = 0;
    int cnt = 0;

    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            ans += cnt + 1;
            s[i+2] = 'A';
            i++;
        }else if(s[i] == 'A') cnt++;
        else cnt = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		int[] M = new int[N];
		for(int i = 0;i < N;i++) {
			M[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(M);
		int sum = 0;
		int cnt = N;
		for(int i = 0;i < N;i++) {
			sum += M[i];
		}
		if(X - sum >= M[0]) {
			do{
				sum += M[0];
				cnt++;
			}while(X - sum >= M[0]);
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22100
#include<iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define MAX 10000

class Data
{
public:
	Data* parent = this;
	int height = 1;
	void Find(Data* other)
	{
		Data* temp = this;
		Data* temp1 = this;
		Data* temp_other = other;
		Data* temp_other1 = other;
		while (1)
		{
			if (temp == temp->parent)break;
			temp = temp->parent;
		}
		while (temp1!=temp)
		{
			temp1->parent = temp;
			temp1= temp->parent;
		}
		while (1)
		{
			if (temp_other == temp_other->parent) break;
			temp_other = temp_other->parent;
		}
		while (temp_other1 != temp_other)
		{
			temp_other1->parent = temp_other;
			temp_other1 = temp_other1->parent;
		}
		if (temp == temp_other)cout << 1 << endl;
		else cout << 0 << endl;
	}
	void Unite(Data* other)
	{
		Data* temp = this;
		Data* temp_other = other;
		while (1)
		{
			if (temp == temp->parent)break;
			temp = temp->parent;
		}
		while (1)
		{
			if (temp_other == temp_other->parent) break;
			temp_other = temp_other->parent;
		}
		if (temp_other->height > temp->height)
		{
			temp->parent = temp_other;
		}
		else if (temp_other->height == temp->height)
		{
			temp->parent = temp_other;
			temp_other->height++;
		}
		else
		{
			temp_other->parent = this;
		}
	}
};
int main()
{
	Data data[MAX];
	int n, q;
	cin >> n >> q;
	REP(i, q)
	{
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)data[x].Unite(&data[y]);
		else
		{
			data[x].Find(&data[y]);
		}
	}
	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define hi ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define emb emplace_back
#define mp make_pair
#define srt(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define count(a, n) count(a.begin(), a.end(), n)
#define reverse(a) reverse(a.begin(), a.end())
#define F first
#define S second
#define pii pair<int, int>
#define vi vector<int>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define de(x) cout << #x << " is " << x << '\n'
typedef long long ll;
using namespace std;
int main()
{
    hi;
    int n;
    cin >> n;
    ll a = 1, b = 1;
    ll x, y;
    rep(i, 1, n + 1)
    {
        cin >> x >> y;
        ll p = max(a / x, b / y);
        while (1)
        {
            if (p * x >= a && p * y >= b)
                break;
            p++;
        }
        a = p * x;
        b = p * y;
    }
    cout << a + b << '\n';
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
S= input()
N = len(S)

def dpinit(ps, val=0):
    res = [val for i in [0]*ps[-1]]
    for i in ps[:-1][::-1]:
        res = [res[:] for k in [0]*i]
    return res
dp = dpinit((N+1,13))

res = [(i*10) % 13 for i in range(13)]

dp[0][0] = 1
for i in range(1,N+1):
    s = S[i-1]
    if s != '?':
        s = int(s)
        for k in range(13):
            new = (res[k] + s) % 13
            dp[i][new] += dp[i-1][k]
    else:
        for s in range(10):
            for k in range(13):
                new = (res[k] + s) % 13
                dp[i][new] += dp[i-1][k]
    for k in range(13):
        dp[i][k] %= MOD
print(dp[N][5])








Measured memory_bytes: 61860
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string s1, s2;
  cin >> s1;
  cin >> s2;

  if((s1[0] == s2[2]) && (s1[1] == s2[1]) && (s1[2] == s2[0]))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
/*
   YOU CAN'T TAKE HELP FROM EDITORIAL               .m.

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

*/

#include "bits/stdc++.h"


#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define pb push_back
#define all(ar) ar.begin(),ar.end() 
#define showp(x) <<showpoint<<setprecision(x)<<fixed<<
#define pii pair<int,int >

using namespace std;
using ll = long long;
using ld = long double;
 

const ll mod = 1e9 + 7;
const ll mxr = 1e5 + 10;

unordered_set<int> ar[200005];
bool vis[200005];

int mx = 0;

void dfs(int i,int &pep){
    vis[i] = true;
    pep += 1;
    for(int r: ar[i]){
        if(!vis[r]) dfs(r,pep);
    }
    return;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif*/
    memset(vis,false,sizeof(vis));
    int n,m; cin>>n>>m;
    while(m--){
        int a,b; cin>>a>>b;
        ar[a].insert(b); ar[b].insert(a);
    }
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            int pep = 0;
            dfs(i,pep);
            mx = max(pep,mx);
        }
    }
    cout<<mx el;
    return 0;
}

Measured memory_bytes: 39696
import math

def kock(n, x1, y1, x2, y2):
    if n == 0:
        return

    angle = math.radians(60)

    sx = (2*x1 + x2)/3
    sy = (2*y1 + y2)/3
    tx = (2*x2 + x1)/3
    ty = (2*y2 + y1)/3
    ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
    uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy

    kock(n-1, x1, y1, sx, sy)
    print sx, sy
    kock(n-1, sx, sy, ux, uy)
    print ux, uy
    kock(n-1, ux, uy, tx, ty)
    print tx, ty
    kock(n-1, tx, ty, x2, y2)

n = input()

p1x = 0.
p1y = 0.
p2x = 100.
p2y = 0.

print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y

Measured memory_bytes: 6716
n, m = map(int, input().split())
cities = []
for i in range(m):
    p, y = map(int, input().split())
    cities.append([p, y, i])
cities = sorted(cities, key=lambda x: (x[0], x[1]))

prev = 0
count = 0
res = []
for city in cities:
    if city[0] != prev:
        count = 0
        prev = city[0]
    count += 1
    res.append(['{:06d}{:06d}'.format(city[0], count), city[2]])
res = sorted(res, key=lambda x: x[1])

for x in res:
    print(x[0])

Measured memory_bytes: 42128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

#define MAX 200010

int fac[MAX],finv[MAX],inv[MAX];
 
void t(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  repi(i,2,MAX){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
 
int calc(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;
}
 


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int ans=1;
  t();
  int a=n-2,b=1;
  rep(i,min(k,n)){
    ans+=calc(n-1,a)*calc(n,b)%MOD;
    //cout<<ans<<endl;
    if(i==0) ans--;
    if(i==1) ans++;
    a--;
    b++;
    ans%=MOD;
  }
  cout<<ans<<endl;
  

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  set<int> st;
  for(int i=0; i<n; i++){
    int num;
   	cin >> num;
    st.insert(num);
  }
  if(st.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    
    if( (n % 2) == 1) {
        int odd = ((n/2)+1);
        double rate = (double)odd / (double)n;
        cout << setprecision(6) << fixed << rate << endl;
    } else {
        cout << 0.5000000000 << endl;
    }
    
}

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

int main(){
    while(1){
    int x,y;
    cin >> x >> y;
    if(x == 0 && y == 0){
        break;
    }
    else{
        if(x < y){
           cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
    }
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll K;
    int  N;
    cin >> K >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    ll ans = LINF;
    rep(i, N) {
        int j = (N - 1 + i) % N;
        int X = A[j];
        if (i > j) {
            X += K;
        }
        ans = min(ans, X - A[i]);

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

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int a,b;

int main(){
	cin>>a>>b;
	if(a==1) a+=13;
	if(b==1) b+=13;
	if(a>b) cout<<"Alice"<<endl;
	else if(a<b) cout<<"Bob"<<endl;
	else cout<<"Draw"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
typedef long long ll;

bool isPalindrome(string s){
  int l=s.size();
  for(int i=0; i<l/2; i++){
    if(s[i]!=s[l-1-i]){
      return false;
    }
  }
  return true;
}

int main(){
  string s, t1, t2;
  cin >> s;
  int n=s.size();
  t1=s.substr(0, (n-1)/2);
  t2=s.substr((n+1)/2, (n-1)/2);
  if(isPalindrome(s)==1&&isPalindrome(t1)==1&&isPalindrome(t2)==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int H = int.Parse(input[0]);
                int W = int.Parse(input[1]);
                if (H == 0 && W == 0)
                {
                    break;
                }
                for (int line = 0; line < H; line++)
                {
                    string raw = "";
                    if (line == 0)
                    {
                        raw = "";
                        for (int i = 0; i < W; i++)
                        {
                            raw += "#";
                        }
                        Console.WriteLine(raw);
                    }
                    else if (line == H - 1)
                    {
                        raw = "";
                        for (int i = 0; i < W; i++)
                        {
                            raw += "#";
                        }
                        Console.WriteLine(raw);
                    }
                    else if (line > 0 && line < H)
                    {
                        raw = "#";
                        for (int i = 0; i < W - 2; i++)
                        {
                            raw += ".";
                        }
                        raw += "#";
                        Console.WriteLine(raw);
                    }


                }
                Console.WriteLine();
            }
        }
    }
}


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

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

    bool color_types[] = {0,0,0,0};
    for (int i = 0; i < N; ++i){
        string color;
        cin >> color;
        if (color == "P"){
            color_types[0] = true;
        } else if (color == "W"){
            color_types[1] = true;
        } else if (color == "G"){
            color_types[2] = true;
        } else if (color == "Y"){
            color_types[3] = true;
        }
    }
    int sum_color_types = 0;
    for (int c : color_types){
        sum_color_types += c;
    }
    if (sum_color_types == 3){
        cout << "Three" << endl;
    } else if (sum_color_types == 4){
        cout << "Four" << endl;
    }
}


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

using namespace std;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(c<a || c>b)
    {
        cout<<"No"<<endl;
    }
    else
    {
         cout<<"Yes"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std; typedef long long ll;const ll INF = 1e18;
typedef pair<ll,ll> P; const int xx[4]={1,-1,0,0}, yy[4]={0,0,1,-1}; struct tp{ll x1,y1,x2,y2;};

int main() {
  string s; cin>>s; int n=s.size();
  deque<char> dq; for(int i=0;i<n;i++) dq.push_back(s[i]);
  int q; cin>>q; bool f=true;
  for(int i=0;i<q;i++) {
    int t; cin>>t;
    if (t==1) f^=true;
    else {
      int g; char c; cin>>g>>c; bool u=g==1;
      if (f == u) dq.push_front(c);
      else dq.push_back(c);
    }
    //cout<<f<<" ";for(char x:dq) cout<<x<<" "; cout<<endl;
  }
  string s2; while(!dq.empty()) {s2+=dq.front(); dq.pop_front();}
  if (!f) reverse(s2.begin(),s2.end());
  cout<<s2<<endl;
}

Measured memory_bytes: 1412
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash(){
    ll n, k;
    cin>>n>>k;
    ll a[n];
    for (ll i = 0; i < n; i++) {
        cin>>a[i];
    }
    ld curr = 0, pre = 0;
    for (ll i = 0; i < k; i++) {
        curr += log(a[i]);
    }
    pre = curr;
    for (ll i = k; i < n; i++) {
        curr -= log(a[i - k]);
        curr += log(a[i]);
        if (curr > pre) {
            cout<<"Yes\n";
        } else {
            cout<<"No\n";
        }
        pre = curr;
    }
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 5484
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string ans = "";
	rep(i, tx - sx) ans += 'R';
	rep(i, ty - sy) ans += 'U';
	rep(i, tx - sx) ans += 'L';
	rep(i, ty - sy) ans += 'D';
	ans += 'D';
	rep(i, tx - sx + 1) ans += 'R';
	rep(i, ty - sy + 1) ans += 'U';
	ans += 'L';
	ans += 'U';
	rep(i, tx - sx + 1) ans += 'L';
	rep(i, ty - sy + 1) ans += 'D';
	ans += 'R';
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// DANG's code //
// LOVEPAL3000 //
//#pragma 03
//#pragma GCC optimize("Os")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
#define lo long
#define ll long long
#define fl float
#define db double;
#define ld long double
#define FORE(i,l,r) for(int i=l;i<=r;++i)
#define BACK(i,l,r) for(int i=l;i>=r;--i)
#define fi first
#define se second
#define fr front()
#define ba back()
#define top top()
#define lb lower_bound
#define ub upper_bound
#define pu push
#define pb push_back
#define eb emplace_back
#define ef emplace_front
#define mp make_pair
#define em empty()
#define sz size()
#define le length()
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
int n,a[3][101],dp[3][101];
signed main(){
	cin>>n;
	FORE(i,1,2){
		FORE(j,1,n){
			cin>>a[i][j];
		}
	}
	FORE(i,1,2){
		FORE(j,1,n){
			if(i==1&&j==1){
				dp[i][j]=a[i][j];
			}
			else if(i==1){
				dp[i][j]=dp[i][j-1]+a[i][j];
			}
			else if(j==1){
				dp[i][j]=dp[i-1][j]+a[i][j];
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
			}
		}
	}
	cout<<dp[2][n];
}

Measured memory_bytes: 3612
N,M,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in [0]*M]
CD = [list(map(int,input().split())) for _ in [0]*K]

import sys
sys.setrecursionlimit(10**7)

class UnionFind:
    def __init__(self,N):
        self.Parent = list(range(N))
    def get_Parent(self,n):
        if self.Parent[n] == n:return n
        p = self.get_Parent(self.Parent[n])
        self.Parent[n] = p
        return p
    def merge(self,x,y):
        x = self.get_Parent(x)
        y = self.get_Parent(y)
        if x!=y: self.Parent[y] = x
        return
    def is_united(self,x,y):
        return self.get_Parent(x)==self.get_Parent(y)

U = UnionFind(N)
E_f = [[] for _ in [0]*N]
for a,b in AB:
    a -= 1
    b -= 1
    U.merge(a,b)
    E_f[a].append(b)
    E_f[b].append(a)
group = [set() for _ in [0]*N]
for i in range(N):
    p = U.get_Parent(i)
    group[p].add(i)

E_b = [[] for _ in [0]*N]
for c,d in CD:
    c -= 1
    d -= 1
    E_b[c].append(d)
    E_b[d].append(c)

ans = [0]*N
for i in range(N):
    p = U.get_Parent(i)
    cnt = 0
    for b in E_b[i]:
        if b in group[p]: cnt += 1
    ans[i] = len(group[p]) -cnt - len(E_f[i]) - 1

print(*ans)

Measured memory_bytes: 131336
#include<stdio.h>
int main(void){int j, N, i, masatoy[5], koutay[5] = { 0,0,0,0,0 }, kaolin = 1, temp, L, S,ruito;scanf("%d", &N);while (1) {if (N == 0000) {break;}ruito = N;if (ruito == 6174) {printf("0\n");scanf("%d", &N);kaolin = 1;}else {masatoy[1] = N / 1000;N = N - (1000 * masatoy[1]);masatoy[2] = N / 100;N = N - (100 * masatoy[2]);masatoy[3] = N / 10;N = N - (10 * masatoy[3]);masatoy[4] = N;for (i = 1; i < 4; i++) {for (j = 4; j > i; j--) {if (masatoy[j] > masatoy[j - 1]) {temp = masatoy[j];masatoy[j] = masatoy[j - 1];masatoy[j - 1] = temp;}}}L = masatoy[1] * 1000 + masatoy[2] * 100 + masatoy[3] * 10 + masatoy[4];S = masatoy[4] * 1000 + masatoy[3] * 100 + masatoy[2] * 10 + masatoy[1];N = L - S;if (N == 6174) {printf("%d\n", kaolin);kaolin = 1;scanf("%d", &N);}else {kaolin++;}if (L == S) {printf("NA\n");scanf("%d", &N);kaolin = 1;}}}return 0;}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int s;
  	cin >> s;
    int l = s/100;
    int r = s%100;
    if(1<=l && l<=12){
        if(1<=r && r<=12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else if(1 <= r && r <= 12){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 110
int n;
struct node{
	string s;
	int p,id;
}r[maxn];
bool cmp(node a,node b){
	if(a.s!=b.s) return a.s<b.s;
	return a.p>b.p;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) {
	cin>>r[i].s>>r[i].p;r[i].id=i;}
	sort(r+1,r+n+1,cmp);
	for(int i=1;i<=n;i++) cout<<r[i].id<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>

using namespace std;
void func() {
    int N,M;
    cin >> N >> M ;
    int sum = 0;
    long long ans = 0;
    map<int ,int> counter;
    counter[0] = 1;
    for (int i = 0; i < N; ++i) {
        int a ;
        cin >> a;
        sum += a;
        sum %= M;
        if(counter[sum]) {
            ans += counter[sum];
            counter[sum] += 1;
        } else {
            counter[sum] = 1;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vll;
typedef vector<char> vc;
typedef vector<vector<char>> vcc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()

int main() {
    unsigned long long n,ans=1; cin >> n;
    vector<unsigned long long> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    sort(all(a));
    rep(i,n){
        if(a[i] <= 1000000000000000000/ans){
            ans *= a[i];
            if(ans == 0){
                cout << 0 << endl;
                return 0;
            }
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3996
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<string, string> S;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
string s;

map<pair<P, S>, ll> memo;

ll calc(int l, int r, string pre0, string pre1) {
    const pair<P, S> key = make_pair(make_pair(l, r), make_pair(pre0, pre1));
    if (l >= r) {
        return (ll)(pre0 == pre1);
    } else {
        if (memo.count(key) == 0) {
            ll res = 0;
            for (int i = l; i <= r; i++) {
                for (int j = i-1; j < r; j++) {
                    if ((i == j) ||
                        (l <= j && i < r && s[i] != s[j]))
                        continue;
                    string npre0 = "";
                    string npre1 = "";
                    for (int k = j+1; k < r; k++) npre0 += s[k];
                    for (int k = i-1; k >= l; k--) npre1 += s[k];
                    npre0 += pre0;
                    npre1 += pre1;
                    const int l0 = npre0.size();
                    const int l1 = npre1.size();
                    if (l0 > 0 && l1 > 0 && 
                        ((l0 <= l1 && npre0 != npre1.substr(l1-l0, l0)) ||
                         (l0 > l1 && npre0.substr(l0-l1, l1) != npre1))) {
                             continue;
                    }
                    res += calc(i+1, j, npre0, npre1);
                }
            }
            memo[key] = res;
        }
        return memo[key];
    }
}

ll solve() {
    return calc(0, 2*n, "", "");
}

void input() {
    cin >> n >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >>N;
    vector<int> a(N); cin >> a;
    int ans = -1;
    int c=0;
    rep(i, N) {
        if (a[i]==c+1) c++;
    }
    if (c != 0) ans = N - c;

    cout << ans << endl;
}


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

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

int main()
{
	int h,n; cin>>h>>n;
	int sum=0;
	rep(i,n){
		int a; cin>>a;
		sum+=a;
	}
	if(h<=sum) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256