akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define lnt long long int
#define mod 1000000007
int main()
{
   lnt n,k;
   cin>>n>>k;

   map<lnt,vector<lnt> > m;
   lnt options[n];
   for(int i=0;i<n-1;i++)
   {

       lnt a,b;
       cin>>a>>b;
       a--;
       b--;
       m[a].push_back(b);
       m[b].push_back(a);
   }

   queue <lnt> q;
   q.push(0);
   options[0]=k;
   lnt vis[n]={0};
   vis[0]=1;
   lnt ans=k;
   while(!q.empty())
   {
       lnt curr = q.front();
       //cout<<curr<<endl;
       q.pop();
       lnt l = m[curr].size();
       lnt cnt=0,cnt1=0;
       for(int i=0;i<l;i++)
       {
           lnt node = m[curr][i];
           if(vis[node]!=0)
           {
               cnt++;

           }
           else
           {
               cnt1++;
               vis[node]=1;
               q.push(node);
           }

       }
       cnt++;
       //cout<<cnt<<" "<<cnt1<<" "<<ans<<endl;
       for(int i=0;i<cnt1;i++)
       {

           ans=(ans*(k-cnt-i))%mod;
       }
       //cout<<ans<<endl;
   }
   cout<<ans;



}


Measured memory_bytes: 13556
#include <bits/stdc++.h>
  
using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int n, m, use[100000];
vector<int> e[100000];
vector<int> p;
int main() {
   iostream::sync_with_stdio(0);
   //freopen("a.in", "r", stdin);
   cin >> n >> m;
   forn (i, m) {
   		int a, b;
   	 	cin >> a >> b;
   	 	a--;
   	 	b--;
   	 	e[a].push_back(b);
   	 	e[b].push_back(a);
   }
   p.push_back(0);
   use[0] = 1;
   forn (i, sz(p)) {
   		for (int v : e[p[i]]) {
   			if (use[v] == 0) {
   				p.push_back(v);
   				use[v] = 1;
   				break;
   			}
   		}
   }
   reverse(p.begin(), p.end());
   for (int i = sz(p) - 1; i < sz(p); i++) {
   		for (int v : e[p[i]]) {
   			if (use[v] == 0) {
   				p.push_back(v);
   				use[v] = 1;
   				break;
   			}
   		}
   }
   cout << sz(p) << "\n";
   for (int v : p)
   		cout << v + 1 << " ";
}



Measured memory_bytes: 7160
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static int numberOfSwap = 0;
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ')
                                    .Select(val => int.Parse(val))
                                    .ToArray();
        SelectionSort(ref A, n);
        Console.WriteLine(String.Join(" ", A.Select(val => val.ToString()).ToArray()));
        Console.WriteLine(numberOfSwap);
    }

    static void SelectionSort(ref int[] arr, int n){
        for (int i = 0; i < n; i++)
        {
            int minj = i;
            for (int j = i; j < n; j++)
            {
                if(arr[j] < arr[minj]) minj = j;
            }
            if(i != minj) Swap(ref arr, i, minj);
        }
    }

    static void Swap(ref int[] arr, int index1, int index2){
        int tmp = arr[index1];
        arr[index1] = arr[index2];
        arr[index2] = tmp;
        numberOfSwap++;
    }
}

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

int main() {
  int N;
  char S;
  cin >> N;
  
  int P = 0;
  int Y = 0;
  int W = 0;
  int G = 0;
  for (int i = 0; i < N; i++) {
    cin >> S;
	if(S == 'P') {
      P++;
    }
    if(S == 'Y') {
      Y++;
    }
    if(S == 'W') {
      W++;
    }
    if(S == 'G') {
      G++;
    }
  }
  int kinds = 0;
  if(P > 0) {
    kinds++;
  }
  if(Y > 0) {
    kinds++;
  }
  if(W > 0) {
    kinds++;
  }
  if(G > 0) {
    kinds++;
  }
  switch(kinds) {
    case 1:
      cout << "One" << endl;
      break;
    case 2:
      cout << "Two" << endl;
      break;
    case 3:
      cout << "Three" << endl;
      break;
    case 4:
      cout << "Four" << endl;
      break;
    default:
      cout << "Zero" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int K;
int A[200011];
int B[200011];

void MAIN() {
    scanf("%d%d", &N, &K);
    REP (i, N) scanf("%d", A+i);

    REP (t, K) {
	memset(B, 0, sizeof B);

	REP (i, N) {
	    int left = max(0, i - A[i]);
	    int right = min(N, i + A[i] + 1);
	    B[left]++;
	    B[right]--;
	}
	REP (i, N) {
	    B[i+1] += B[i];
	    A[i] = B[i];
	}

	if (*min_element(A, A+N) == N) break;
    }
    rprintf("%d", A, A+N);
    
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 5380
list = []
n = gets.to_i

n.times do
  command = gets.split
  case command[0]
  when "insert"
    num = command[1].to_i
    list.unshift(num)
  when "delete"
    num = command[1].to_i
    index = list.find_index {|val| val == num}
    if index != nil
      list.delete_at(index)
    end
  when "deleteFirst"
    list.shift
  when "deleteLast"
    list.pop
  end
end

puts list.join(" ")



Measured memory_bytes: 21348
#include <stdio.h> // C++???????????????
#include <string.h> // c++???????????????
#include <math.h> // c++???????????????
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

typedef long long int lli;
#define PI 3.1415926535897932
#define N 100
#define MAX(a,b) ((a>b)?(a):(b)) // ?????§????????????
#define MIN(a,b) ((a<b)?(a):(b)) // ????°?????????????
#define INRANGE(a,b,c) ((a<=b&&b<=c)?(1):(0)) // a<=b<=c??????????????????????????????


void swap(int &a, int &b) { // c??????*
	int w = a;
	a = b;
	b = w;
}

int getdigit(int num) { // ??´??°????????°?????????
	int i, j;
	if (num<0) num *= -1; // ?????°???????????¢
	if (num == 0)return 1;
	for (i = 10, j = 1;; i *= 10, j++) {
		if (INRANGE(i / 10, num, i - 1))return j;
	}
	return 0; // ????????¨??????
}

int getN(int num, int digit) {
	int i = 1, j;
	for (j = 1; j<digit; i *= 10, j++);
	return (num / i) % 10;
}

int zeller(int y, int m, int d) { // 0????????\????????§??????
	if (m<3) { y--; m += 12; }
	return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7;
}

int gcd(int a, int b) {	// ?????§??¬?´???°
	if (b == 0) return a;
	return gcd(b, a%b);
}

int lcm(int a, int b) {	// ????°???¬?????°
	return a*b / gcd(a, b);
}

int stoi(const string str) { // ?????????????????´??°
	int i = 0, j;
	int len = str.length();
	int w = 0;
	for (i = 1, j = 1; i <= len && INRANGE('0', str[len - i], '9'); i++, j *= 10) {
		w += (str[len - i] - '0')*j;
	}
	if (str[0] == '-')w *= -1;
	return w;
}

string itos(int a) { // ??´??°???????????????
	int i;
	string str = "";
	int keta;
	if (a<0) { str += '-'; a *= -1; } // ?????°??????????????????
	for (keta = 10; a / keta != 0; keta *= 10);
	for (i = keta / 10; i != 0; i /= 10) {
		str += ((a / i) % 10) + '0';
	}
	return str;
}

int main(void) {
	int max;
	map<int, int> m;
	map<int,int>::iterator it;
	int a;
	int n = 3;
	while (cin >> a,n--) {
		m[a]++;
	}
	max = 0;
	for (it = m.begin(); it != m.end(); it++) {
		max = MAX(max, it->second);
	}
	for (it = m.begin(); it != m.end(); it++) {
		if (max == it->second) cout << it->first<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	ll arr[n];
	for(ll i=0;i< n ;i++)cin>>arr[i];
	map<ll,ll> mp;
	for(ll i=0;i< n ; i++){
		mp[arr[i]]++;
	}
	ll ans = 0 ;
	for(auto x: mp){
		ans+=(x.s)*(x.s-1)/2;
	}
	for(ll i=0;i< n ;i++){
		ll temp=ans;
		temp -= (mp[arr[i]]-1)*(mp[arr[i]])/2;
		temp+=(mp[arr[i]]-1)*(mp[arr[i]]-2)/2;
		cout<<temp<<endl;
	}


	return 0;
}

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

#define st first
#define nd second
#define pb push_back
#define mp make_pair
typedef pair< int ,int > pii;
typedef vector< pii > vii;
typedef long long ll;
typedef map<int,int> mii;
typedef set<pii> sii;
typedef set<int> si;
typedef vector< int > vi;

const ll MOD = 119 << 23 | 1;

ll gcd(ll x, ll y){
    if(!y)
        return x;
    return gcd(y,x%y);
}

ll inv(ll x) {
    ll r = 1ll, t = x, k = MOD - 2ll;
    while (k) {
        if (k & 1ll) r = (long long) r * t % MOD;
        t = (long long) t * t % MOD;
        k >>= 1;
    }
    return r;
}

const int nax = 2e5+13;

void read(){

}

void solve(){
    int n,k,a,res=0;
    cin >> k >>n;
    vi vec;
    for(int i=0; i<n; i++){
        cin >> a;
        vec.pb(a);
    }
    for(int i=1; i<n; i++){
        res=max(res,vec[i]-vec[i-1]);
    }
    res=max(res,vec[0]+k-vec[n-1]);
    cout << k-res<<endl;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int t=1;
    //cin >> t;
    while(t--){
        read();
        solve();
    }

    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
string a[10]={
  "",
  ".,!? ",
  "abc",
  "def",
  "ghi",
  "jkl",
  "mno",
  "pqrs",
  "tuv",
  "wxyz"
};

string s;

string solve(){
  string t="";

  int key=0,cnt=0;
  for(int i=0;i<(int)s.size();i++){
    int S=s[i]-'0';
    if(S==0){
      if(key!=0){
	cnt--;
	int len=a[key].size();
	t.push_back(a[key][cnt%len]);
      }
      cnt=key=0;
    }else if(key==S){
      cnt++;
    }else{
      key=S;
      cnt=1;
    }
  }
  return t;
}

int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>s;
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    int h[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }

    qsort(h, n, sizeof(int), comp);

    long long int sum = 0;

    for(int i = 0; i < (n - k); i++){
        sum += h[i];
    }

    printf("%lld", sum);
}


Measured memory_bytes: 1788
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main()
{
	int a, p;
	int tot;

	scanf("%d %d", &a, &p);

	tot = a * 3 + p;

	printf("%d\n", tot / 2);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

// aとbの最大公約数
long long gcd(long long a, long long b){
  if (a%b == 0)
    return(b);
  else
    return(gcd(b, a%b));
}


int main(){
  long long N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;
  // 入力終了

  // NとMの最大公約数
  long long L;
  L = N*M/gcd(N, M);

  long long n = L/N, m = L/M;

  long long MAX = max(N, M);
  long long min_nm = min(n, m);
  long long max_nm = max(n, m);
  
  string longstr = S;
  string shortstr = S;
  if(N < M)
    longstr = T;
  else
    shortstr = T;
  
  // SとTのうち，文字列長が長い方を見る
  for(long long i=0; i<MAX; i++){
    // 文字列Xの中で何文字目か
    long long l = i*min_nm;
    
    // 文字列Sのi文字目(文字列Xのl文字目)がTに関連する場合のみ見ればOK
    if( l % max_nm == 0)
      // 文字列Sのi文字目に対応するSとTの
      // それぞれの文字が一致しなければNG
      if(longstr[i] != shortstr[l/max_nm]){
	cout << -1 << endl;
	return 0;
      }
  }
  
  // 解答
  cout << L << endl;

  return 0;
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n,k;cin>>n>>k;

  vector<ll> v[200001];

  ll a[n];
  for(ll i=0;i<n;i++){
    cin>>a[i];
    v[a[i]].pb(i);
  }

  ll count = 0;
  ll now = a[0];
  while(true){
    auto Iter = upper_bound(v[now].begin(),v[now].end(),count%n);
    if(Iter == v[now].end()){
      count += v[now][0] + n - count%n;
      //cout<<" sff"<<now<<" "<<v[now][0]<<endl;
      //now = v[now][0];
    }else{
      count += *Iter - count%n;
      //now = *Iter;
    }

    count++;
    now = a[count%n];
    //cout<<count+1<<"  "<<now<<endl;
    if(count%n==0){
      break;
    }

  }

  ll loop = count/n;

  k %= loop;
  k *= n;

  count = 0;
  now = a[0];
  vector<ll> ans;

  for(ll i = count;i<k;i++){
    now = a[i%n];
    auto Iter = upper_bound(v[now].begin(),v[now].end(),i%n);
    if(Iter != v[now].end()){
      i += *Iter - i%n;
    }else{
      ll next = i + v[now][0] + n - i%n;
      if(next>=k){
        ans.pb(now);
      }else{
        i = next;
      }
    }
  }
/*

  while(count<k){
    auto Iter = upper_bound(v[now].begin(),v[now].end(),count);
    ll l;
    if(Iter == v[now].end()){
      l = count + v[now][0] + n - count%n;
      //now = v[now][0];
    }else{
      l = count + *Iter - count%n;
      //now = *Iter;
    }

    if(l>=k)break;
    count = l;

    count++;
    now = a[count%n];
  }


  for(ll i = count;i<k;i++){
    now = a[i%n];
    auto Iter = upper_bound(v[now].begin(),v[now].end(),i%n);
    if(Iter != v[now].end()){
      i += *Iter - i%n;
    }else{
      ans.pb(now);
    }
  }
*/

  for(ll i = 0;i<ans.size();i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;


 

  return 0;
}

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

int main(void)
{
	int w, n, l, r;
	char sep;

	cin >> w >> n;

	vector<int> a;
	for (int i = 0; i < w; i++) a.push_back(i+1);

	for (int i = 0; i < n; i++) {
		cin >> l >> sep >> r;
		swap(a[l-1], a[r-1]);
	}

	for (int i = 0; i < w; i++)
		cout << a[i] << endl;

	return 0;
}


Measured memory_bytes: 1216
#include<stdio.h>
int W,H,x,y,r;
main(){
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if(x-r>=0&&y-r>=0&&x<W&&y<H&&r<=W&&r<=H)printf("Yes\n");
	else printf("No\n");
    
    
    
    
    return 0;

}


Measured memory_bytes: 2108
#include <stdio.h>
int main(void)
{
	int n;
	int i;
	int pm;
	int pe;
	int pj;
	char pc[10000];
	int heikin;
	
	scanf("%d", &n);
	while(n != 0) {
		for(i = 0; i < n; i++) {
			scanf("%d %d %d", &pm, &pe, &pj);
			heikin = pe + pm + pj;
			if ( (pm == 100 || pe == 100 || pj == 100) || (pe + pm >= 180) || (pm + pe + pj >= 240)) {
				pc[i] = 'A';
			}else if ( (pm + pj + pe >= 210) || ( (heikin >= 150) && ( (pm >= 80) || (pe >= 80) ) ) ) {
				pc[i] = 'B';
			}else {
				pc[i] = 'C';
			}
		}
		for(i = 0; i < n; i++) {
			printf("%c\n", pc[i]);
		}
		scanf("%d", &n);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    ll x;
    cin >> x;
    ll a=360;
    while(a%x!=0){
        a+=360;
    }
    cout << a/x << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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;
    if(n%2==0){
        cout<<0.5<<endl;
    }
    else{
        cout<<(double)((double)(n/2+1)/n)<<endl;
    }




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

set<int>S;
void init(){
    S.clear();
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    */
    
    int n,H, val;   
    while(scanf("%d %d",&H, &n)==2){
        //init();
        int sum = 0;
        for(int i=0;i<n;i++) {
            scanf("%d",&val);
            //S.insert(val);
            sum+=val;
        }
        //for(int x : S) 

        printf("%s\n", sum >= H ? "Yes" : "No");    
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    ll N = S.size();
    for (ll i = 0; i < N; i++) {
        if (S.at(i) != T.at(i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

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


def solve(A: "List[int]"):
    A.sort()
    return A[-1] - A[0]


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 5124
n = gets.to_i
x , y = n.times.map{gets.chomp.split.map(&:to_i)}.transpose
sub = Array.new(n){Array.new(n,nil)}
n.times do |i1|
  n.times do |i2|
    sub[i1][i2] = (x[i1] - x[i2]).to_s + "," + (y[i1] - y[i2]).to_s if i1 != i2
  end
end

max = 0
n.times do |i1|
  n.times do |i2|
    cnt = 0
    str = sub[i1][i2]
    if str != nil then
      n.times do |i3|
        n.times do |i4|
          cnt += 1 if str == sub[i3][i4]
        end
      end
      max = cnt if max < cnt
    end
  end
end

puts n - max

Measured memory_bytes: 2044
l, r = map(int, input().split())
rem_list = []
if 4038 > r-l+1 >= 2019:
    print(1)
elif r-l+1 <= 2019:
    frag = 0
    for i in range(r-l+1):
        rem = (l+i)%2019
        if rem == 0:
            frag = 1
            continue
        rem_list.append(rem)
    if frag == 1:
        print(min(rem_list))
    else:
        re_rem_list = []
        for i in range(len(rem_list)-1):
             for j in range(len(rem_list)-i-1):
                re_rem_list.append((rem_list[i]*rem_list[i+j+1])%2019)
        print(min(re_rem_list))
else:
    print(0)

Measured memory_bytes: 75436
#include <stdio.h>

int max(int a, int b) {
  return a > b ? a : b;
}
  
int main(void) {
  int n, i, j;
  scanf("%d", &n);
  int d[n];
  for(i = 0; i < n; ++i) {
    scanf("%d", &d[i]);
    d[i] /= 10;
  }
  int now = 0, s = 0;
  while(1) {
    int max = 0, maxn;
    if(!d[now]) {
      printf("no\n");
      return 0;
    }
    for(i = now; i <= now + d[now] && i < n; ++i) {
      if(i == n - 1) {
        s = 1;
        break;
      }
      if(max <= i + d[i]) max = i + d[i], maxn = i;
    }
    if(s) break;
    now = maxn;
  }
  s = 0, now = n - 1;
  //printf("2\n");
  while(1) {
    int min = 999999999, maxn;
    if(!d[now]) {
      printf("no\n");
      return 0;
    }
    for(i = now; i >= now - d[now] && i >= 0; --i) {
      if(i == 0) {
        s = 1;
        break;
      }
      if(min >= i - d[i]) min = i - d[i], maxn = i;
    }
    if(s) break;
    now = maxn;
  }
  printf("yes\n");
  return 0;
}


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

void key0(string &str){
    str.push_back('0'); 
}

void key1(string &str){
    str.push_back('1'); 
}

void keyb(string &str){
//    str.pop_back();  // c++11 g++  -std=c++11  abc043_b.cpp
    if (str.empty()){
        return;
    }
    str.erase(str.end()-1);
}

int main()
{
    string str = "";

    string in_str;
    cin >> in_str;
    for (int i = 0; i < in_str.size(); i++){
//        cout << in_str[i] << endl;
        if (in_str[i] == '0'){
            key0(str);
        }else if (in_str[i] == '1'){
            key1(str);
        }else if (in_str[i] == 'B'){
            keyb(str);
        }
    }
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 110;

int n, m, d[N][N], f[N][N], dd[N][N];

int main()
{
    scanf("%d%d", &n, &m);
    FOR(i, 1, n) FOR(j, 1, m) scanf("%d", &d[i][j]);
    FOR(i, 0, 100) FOR(j, 0, 100) FOR(ii, 1, n) FOR(jj, 1, m)
        f[i][j] = max(f[i][j], d[ii][jj] - i * ii - j * jj);
    FOR(ii, 1, n) FOR(jj, 1, m)
    {
        dd[ii][jj] = 1e9;
        FOR(i, 0, 100) FOR(j, 0, 100)
            dd[ii][jj] = min(dd[ii][jj], i * ii + j * jj + f[i][j]);
        if (dd[ii][jj] != d[ii][jj]) {puts("Impossible"); return 0;}
    }
    puts("Possible"); puts("202 10401");
    FOR(i, 1, 100) printf("%d %d X\n", i, i + 1);
    FOR(i, 102, 201) printf("%d %d Y\n", i, i + 1);
    FOR(i, 0, 100) FOR(j, 0, 100) printf("%d %d %d\n", i + 1, 202 - j, f[i][j]);
    puts("1 202");
    return 0;
}


Measured memory_bytes: 256
N=gets.to_i
px=py=pt=0
r=true
N.times{
    t,x,y=gets.split.map(&:to_i)
    dx=(x-px).abs
    dy=(y-py).abs
    dt=(t-pt).abs
    if dx+dy>dt
        r=false
    end
    if (dx+dy) % 2 != dt % 2
        r=false
    end
    px=x
    py=y
    pt=t
}
puts r ? "Yes" : "No"


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

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b;
	while(cin>>a>>b){
		int64_t g=gcd(a,b);
		cout<<g<<" "s<<a/g*b<<"\n"s;
	}
}


Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int b=gi();


        System.out.println(2*b-a);
//        if (a==b) {
//        	System.out.print(c);
//        }else if(a==c){
//            System.out.print(b);
//        } else {
//        	System.out.print(a);
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

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

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

  int cur = 0;

  rep(i, n) {
    int x;
    cin >> x;

    cur += 2 * min(x, abs(k - x));
  }

  cout << cur << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int a[3], total = 0;
    for(int i = 0; i < 3; ++i)
    {
        scanf("%d", &a[i]);
    }
    sort(a, a + 3);
    for(; a[0] != a[1] || a[1] != a[2] || a[0] != a[2]; ++total)
    {
        if(a[1] == a[0])
        {
            ++a[1];
            ++a[0];
        }
        else if(a[2] == a[1])
        {
            if((a[1] - a[0]) % 2)
            {
                ++a[2];
                ++a[1];
            }
            else
            {
                a[0] += 2;
            }
        }
        else if((a[1] - a[0]) % 2)
        {
            ++a[2];
            ++a[0];
        }
        else
        {
            a[0] += 2;
        }
    }
    printf("%d\n", total);
}

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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;

  int x = 0;
  int max = 0;
  
  REP(i, S.length()){
    if(S[i] == 'I'){
      x++;
    }else{
      x--;
    }
    max = MAX(max, x);
  }
  cout << max << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int A,B,C,D,ans=0;
    cin >> A >> B >> C >>D;
    
    if(A<B){
        ans += A;
    }else{
        ans += B;
    }
    if(C<D){
        ans += C;
    }else{
        ans += D;
    }
    
    cout << ans << endl;
    return 0;
}




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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 17

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
#define mt make_tuple

// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>
#define iii pair <ii, int>

// get value
#define FF first
#define SS second
#define get(x, a) get<(x)>(a)

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int& a, const int& b) {return a > b;}

bool check[107][107];

int main() {
//    #ifndef ONLINE_JUDGE
//        freopen("tmp.inp", "r", stdin);
//        freopen("tmp.out", "w", stdout);
//    #endif // ONLINE_JUDGE

    int n, m;
    scanf("%d%d", &n, &m);

    fto (i, 1, m) {
        int x, y;
        scanf("%d%d", &x, &y);
        check[x][y] = check[y][x] = 1;
    }

    vi vc;
    fto (i, 2, n) vc.pb(i);

    int cnt = 0;
    do {
        int res = 1;
        int cur = 1;
        fto (i, 0, n-2) {
            if (!check[cur][vc[i]]) {
                res = 0;
                break;
            }
            cur = vc[i];
        }
        cnt += res;
    }
    while (next_permutation(vc.begin(), vc.end()));

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

    return 0;
}


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

using namespace std;

typedef long long int ll;

long long int a[100010];

double comb(ll n, ll r) {
	double x = 1, y = 1;
	for (int i = 0; i < r; i++) {
		x *= (i + 1);
		y *= (n - i);
	}
	return y / x;
}

ll binary_search(ll x, int n) {
	int ng = -1, ok = n - 1;
	int mid = 0;
	while (abs(ok - ng) > 1) {
		mid = (ok + ng) / 2;
		if (a[mid] >= x) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	ll r = a[mid];
	ok = 0, ng = n;
	while (abs(ok - ng) > 1) {
		mid = (ok + ng) / 2;
		if (a[mid] <= x) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	ll l = a[mid];
	if (abs(r - x) > abs(l - x)) {
		return l;
	}
	else {
		return r;
	}
}


int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	/*
	double max = 0;
	ll x = 0, y = 0;
	for (int i = n - 1; i > 0; i--) {
		ll r = binary_search(a[i] / 2, a[i]);
		double c = comb(a[i], r);
		if (max < c) {
			max = c;
			x = a[i];
			y = r;
		}
	}
	*/
	cout << a[n - 1] << " " << binary_search(a[n - 1] / 2, n) << endl;
	//system("pause");
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

bool dfs(int u,int t,int dep,vector<vector<int>>& G){
    if(dep == 2)return false;
    for(auto next: G[u]){
        if(next == t)return true;
        if(dfs(next,t,dep+1,G)){
            return true;
        }
    }
    return false;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i = 0; i < M;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(dfs(0,N-1,0,G)){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 12016
loop do
  h, w = gets.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  count_w = 0
  h.times {
    if count_w == 0 || count_w == h - 1
      puts "#" * w
    else
      puts "#" + "."*(w-2) + "#"
    end
    count_w += 1
  }
  puts
end


Measured memory_bytes: 6948
#!/usr/bin/env python3
import sys
INF = float("inf")

import math


class SegmentTree(object):
    # セグメント木

    def __init__(self, N):
        """サイズNの配列を元にしたセグメント木
        """
        # 単位元
        self.idelem = 0
        # 比較関数

        def f(a, b):
            return a | b

        self.func = f

        self.N0 = 1
        while self.N0 < N:
            self.N0 <<= 1
        self.tree = [self.idelem]*(2*self.N0)

    def update(self, k, x):
        """k番目の値をxに更新
        """
        k += self.N0-1
        self.tree[k] = x
        while k > 1:
            k = (k-1)//2
            self.tree[k] = self.func(self.tree[2*k+1], self.tree[2*k+2])

    def query(self, l, r):
        """区間[l, r)の最小値
        """
        l += self.N0-1
        r += self.N0-1
        s = self.idelem
        while l < r:
            if r % 2 == 0:
                r -= 1
                s = self.func(s, self.tree[r])

            if l % 2 == 0:
                s = self.func(s, self.tree[l])
                l += 1
            l //= 2
            r //= 2
        return s

    def __str__(self):
        return str(self.tree[self.N0-1:-1])


def bit_sum(n):
    wa = 0
    while n > 0:
        wa += n & 1
        n >>= 1
    return wa


def main():
    N = int(input())
    S = input()
    Q = int(input())
    query = [input().split() for i in range(Q)]

    seg = SegmentTree(N)
    for i, c in enumerate(S):
        seg.update(i, 1 << (ord(c)-ord('a')))

    for q in query:
        if q[0] == "1":
            seg.update(int(q[1])-1, 1 << (ord(q[2])-ord('a')))
        else:
            ans = seg.query(int(q[1])-1, int(q[2]))
            print(bit_sum(ans))
    pass


if __name__ == '__main__':
    main()


Measured memory_bytes: 74696
import java.util.*;

public class Main {
    // global
    static long fact[];
    static long inverse[];
    static int mod = 1_000_000_007;

    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a%mod;
            }
            a=a*a%mod;
            n>>=1;
        }
        return res;
    }

    static long modinv(long n) {
        return pow(n, mod-2);
    }

    static long comb(int n,int k){
        if(n<0 || k<0 || n<k)return 0;
        return fact[n]*(inverse[k]*inverse[n-k]%mod) %mod;
    }
    static ArrayList<int[]> factorization (int n) {
        ArrayList<int[]> list = new ArrayList<int[]>();
        int tmp= n ;
        for (int i=2;i<=Math.sqrt(n);i++) {
            if (tmp%i==0) {
                int cnt=0;
                while (tmp%i==0) {
                    cnt++;
                    tmp/=i;
                }
                int[] x = {i, cnt};
                list.add(x);
            }
        }
        if (tmp!=1) {
            int[] x = {tmp, 1};
            list.add(x);
        }

        if (list.size()==0) {
            int[] x = {n, 1};
            list.add(x);
        }
        return list;
    }
    public static void main(String[] args) {
        // main method
        fact=new long[200000];
        fact[0]=1;
        inverse=new long[200000];
        inverse[0]=1;
        for(int i=1;i<200000;i++){
            fact[i]=(fact[i-1]*(long)i)%mod;
            inverse[i]=modinv(fact[i]);
        }
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        long ans = 1L;
        for (int[] s : factorization(M)) {
            ans = ans*comb(N-1+s[1], s[1])%mod;
        }
        if (M==1) {
            System.out.println(1);
        } else {
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 27860
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  if(K <= A) {
    cout << A - K << " " << B << endl;
  } else if(K <= A + B) {
    cout << 0 << " " << A + B - K << endl;
  } else {
    cout << 0 << " " << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
def solve(n, aaa, bbb):
    # 最大値が更新された=その山の高さは決定
    max_heights = [0] * n
    fixed = [False] * n
    MOD = 10 ** 9 + 7

    h = 0
    for i, a in enumerate(aaa):
        if h != a:
            max_heights[i] = a
            fixed[i] = True
        else:
            max_heights[i] = a
        h = a
        
    h = 0
    for i, b in reversed(list(enumerate(bbb))):
        if h != b:
            if max_heights[i] < b:
                return 0
            if fixed[i] and max_heights[i] != b:
                return 0
            max_heights[i] = b
            fixed[i] = True
        else:
            max_heights[i] = min(max_heights[i], b)
        h = b

    ans = 1
    for h, f in zip(max_heights, fixed):
        if f:
            continue
        ans = ans * h % MOD
    return ans


n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
print(solve(n, aaa, bbb))


Measured memory_bytes: 23104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int dx[] = { 1,0 };
int dy[] = { 0,1 };


int main() {
	init();

	int H, W; cin >> H >> W;
	vector<string>maze(H);
	rep(i, 0, H)cin >> maze[i];
	bool ans = true;
	rep(i, 0, H) {
		rep(j, 0, W) {
			int cnt = 0;
			rep(k, 0, 2) {
				int nx = j + dx[k], ny = i + dy[k];
				if (out(ny, nx, H, W))continue;
				if (maze[ny][nx] == '#')cnt++;
			}
			if (cnt == 2)ans = false;
		}
	}
	cout << (ans ? "Possible" : "Impossible") << "\n";

	return 0;
}

Measured memory_bytes: 3672
# E - Dividing Chocolate
import sys
sys.setrecursionlimit(10000)

H,W,K = map(int,input().split())
S = [input() for _ in range(H)]
ans = 10000

def check(border, num):
    global H,W,K,S
    now = [0]*(num+1)
    add = 0
    for j in range(W):
        tmp = [0]*(num+1)
        for i in range(H):
            now[border[i]] += int(S[i][j])
            tmp[border[i]] += int(S[i][j])
        if max(now)>K:
            add += 1
            now = tmp
        if max(tmp)>K:
            return 10000
    return num+add

def rec(border, num, i):
    global H,W,K,S,ans
    if i<H:
        border[i] = num
        rec(border, num, i+1)
        border[i] = num+1
        rec(border, num+1, i+1)
    else:
        ans = min(ans, check(border, num))

rec([0]*H, 0, 1)
print(ans)

Measured memory_bytes: 74248
N,M=map(int,input().split())
p=list(map(lambda x:int(x)-1,input().split()))
xy=[list(map(lambda x:int(x)-1,input().split())) for _ in [0]*M]
z=[[i,1] for i in range(N)]

def root_find(a):
    while(a!=z[a][0]):
        a=z[a][0]
    return a

def union(a,b):
    ra=root_find(a[0])
    rb=root_find(b[0])
    if z[ra][1]<=z[rb][1]:
        z[ra][0]=rb
        z[rb][1]=max(z[rb][1],z[ra][1]+1)
    else:
        z[rb][0]=ra
        z[ra][1]=max(z[ra][1],z[rb][1]+1)
    
for i in range(M):
    union(z[xy[i][0]],z[xy[i][1]])

for i in range(N):
    z[i][0]=root_find(z[i][0])

dic=dict()

for i in range(N):
    zz=z[i][0]
    if zz not in dic.keys():
        dic[zz]=[i]
    else:
        dic[zz].append(i)

list1=list(dic.values())
list2=[[p[a] for a in list1[i]] for i in range(len(list1))]

cnt=sum(len(set(list1[i])&set(list2[i])) for i in range(len(list1)))
print(cnt)

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

using namespace std;

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

    int S; cin>>S;
    int l = 0,r = 0;
    l = S / 100; r = S % 100;
    bool lb = l <= 12 and l > 0;
    bool rb = r <= 12 and r > 0;

    if (lb and rb)
        cout << "AMBIGUOUS" << endl;
    else if (lb)
        cout << "MMYY" << endl;
    else if (rb)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#define lowbit(x) ((x)&(-x))
#define sc scanf
#define debug1(x) cout<<x<<" "
#define debug2(x) cout<<x<<"\n"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long ll;
using namespace std;
int gcd(int a,int  b){return b==0?a:gcd(b,a%b);}
char arr[110][1010];
int main()
{
	int h1,h2,m1,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int k1=h1*60+m1;
	int k2=h2*60+m2;
	if(k2-k1>=k)
	cout<<k2-k1-k<<"\n";
	else
	cout<<0<<"\n";
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int l = sc.nextInt();
    
    String[] s = new String[n];
    for(int i = 0;i<n;i++){
      s[i] = sc.next();
    }
    Arrays.sort(s);
    for(int i=0;i<n;i++){
      System.out.print(s[i]);
    }
    System.out.println();
  }
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int n,d;
    cin>>n>>d;
    int ans=0;
    rep(i,0,n){
        ll x,y;
        cin>>x>>y;
        long double dist=sqrt(x*x+y*y);
        if(dist<=d)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3668
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

// vector<vector<int>> data(3, vector<int>(4));

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

  int x, y;
  cin >> x >> y;
  // turu i kame y-i
  int kame;
  int turu;

  turu = 0;
  kame = x - turu;
  // cout << turu << " " << kame<<endl;
  if (turu * 2 + kame * 4 == y) {
    cout << "Yes";
    return 0;
  }

  rep(i, x) {
    turu = i + 1;
    kame = x - turu;
    // cout << turu << " " << kame<<endl;
    if (turu * 2 + kame * 4 == y) {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";

  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>
#include<set>
#include <queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	cout << pow(N, 3);
}

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

int mod = 1000000007;

int main()
{
    string x, y, z;
    cin >> x >> y >> z;
    char a = x[0] - 32;
    char b = y[0] - 32;
    char c = z[0] - 32;

    cout << a << b << c;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define SL(x) scanf("%lld",&(x))
#define SL2(x) scanf("%lld%lld",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define FF first
#define SS second
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
ll sum=0;
rep(i,1,n+1)
	{
		if(i%3==0 && i%5==0){
			continue;
		}
		else if(i%3==0){
			continue;
		}
		else if(i%5==0){
			continue;
		}
		else{
			sum+=i;
		}
	}
cout<<sum;
return 0;
}

Measured memory_bytes: 3652
using System;

public class SelectionSort {

    private int[] array;
    private int change;

    public const int MIN_N = 1;
    public const int MAX_N = 100;
    public const int MIN_A = 0;
    public const int MAX_A = 100;
    
    SelectionSort(int[] _array) {
	this.array = _array;
    }

    void sort() {
	// ????????????????????¢?????´?????????
	for (int i = 0; i <= this.array.Length - 1; i++) {
	    int minj = i;
	    for (int j = i; j <= this.array.Length - 1; j++) {
		if (this.array[j] < this.array[minj]) {
		    minj = j;
		}
	    }
	    if (this.array[minj] < this.array[i]) {
		int tmp = this.array[i];
		this.array[i] = this.array[minj];
		this.array[minj] = tmp;
		this.change++;
	    }
	}

	// ????????????
	for (int i = 0; i < this.array.Length; i++) {
	    if (i == this.array.Length - 1) {
		Console.WriteLine(this.array[i]);
		Console.WriteLine(change);
		continue;
	    }
	    Console.Write(this.array[i] + " ");
	}
    }
    
    public static void Main() {
	int N = 0;
	N = int.Parse(Console.ReadLine());
	N = Math.Max(N, MIN_N);
	N = Math.Min(N, MAX_N);	

	string[] buf = Console.ReadLine().Split(' ');
	int[] input = new int[N];
	
	for (int i = 0; i < N; i++) {
	    input[i] = int.Parse(buf[i]);
	}

	SelectionSort selectionSort = new SelectionSort(input);
	selectionSort.sort();
    }
    
}

Measured memory_bytes: 9180
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    string s;cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]){
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
}


Measured memory_bytes: 3592