akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in1(n);
	int arr[n];
	rep(i, 0, n) cin>>arr[i];
	int ans = 0;
	rep(i, 1, n)
	{
		if(arr[i-1] > arr[i])
		{
			ans += (arr[i-1] - arr[i]);
			arr[i] = arr[i-1];
		}
	}
	cout<<ans<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 5212
// C++ 14
#include <math.h>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>

#define ll long long
#define Int ll
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.000000001
#define fequals(a,b) (fabs((a) - (b)) < EPS)

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (const Vector2 v) const { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (const Vector2 v) const { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (const double k) const { return Vector2(x * k, y * k); }
  Vector2 operator / (const double k) const { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 const v) { return x * v.x + y * v.y; }
  double cross (Vector2 const v) { return x * v.y - y * v.x; }
  
  bool parallel(Vector2 &other) {
    return fequals(fabs(dot(other)), length() * other.length());
  }
  
  bool orthogonal(Vector2 &other) {
    return fequals(0, dot(other));
  }
  
  bool operator < (const Vector2 &v) {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

double p2Seg(Vector2 start_, Vector2 end_, Vector2 p) {
  if ((p - start_).dot(end_ - start_) < 0.0) return (p - start_).length();
  if ((p - end_).dot(start_ - end_) < 0.0) return (p - end_).length();
  return abs((end_ - start_).cross(p - start_)) / (end_ - start_).length();
}


double distance(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4) {
  double t3 = (p1.x - p2.x) * (p3.y - p1.y) + (p1.y - p2.y) * (p1.x - p3.x);
  double t4 = (p1.x - p2.x) * (p4.y - p1.y) + (p1.y - p2.y) * (p1.x - p4.x);
  double t1 = (p3.x - p4.x) * (p1.y - p3.y) + (p3.y - p4.y) * (p3.x - p1.x);
  double t2 = (p3.x - p4.x) * (p2.y - p3.y) + (p3.y - p4.y) * (p3.x - p2.x);
  if (t3 * t4 < 0 && t1 * t2 < 0) return 0.0;
  double min_ = -1;
  min_ = min<double>(p2Seg(p1, p2, p3), p2Seg(p1, p2, p4));
  min_ = min<double>(min_, p2Seg(p3, p4, p1));
  min_ = min<double>(min_, p2Seg(p3, p4, p2));
  return min_;
}

#define MAX_N 1001
Int N;
Vector2 p1, p2, p3, p4;

void input() {
  cin >> N;
  while (cin >> p1 >> p2 >> p3 >> p4) {
    cout << distance(p1, p2, p3, p4) << endl;
  }
}

int main() {
  cout.precision(15);
  input();
}


Measured memory_bytes: 3256
A = input()
B = input()
C = input()

pa, pb, pc = 0, 0, 0
player = 0
while True:
    if player == 0:
        if pa == len(A):
            print('A')
            break
        player = ord(A[pa]) - ord('a')
        pa += 1
    elif player == 1:
        if pb == len(B):
            print('B')
            break
        player = ord(B[pb]) - ord('a')
        pb += 1
    else:
        if pc == len(C):
            print('C')
            break
        player = ord(C[pc]) - ord('a')
        pc += 1


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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int a, b;
  cin >> a >> b;
  
  cout << 6 - a -b<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

string s;

int main()
{
    cin >> s;
    int N = s.size();
    vector<int> a(N);
    for (int i = 1; i < N; i++)
    {
        if (s[i - 1] == 'R' && s[i] == 'L')
        {
            int left = i - 1, right = i, cnt = 0;
            vector<int> leftc(2), rightc(2);
            while (left >= 0 && s[left] == 'R')
            {
                cnt++;
                leftc[cnt % 2]++;
                left--;
            }
            cnt = 0;
            while (right < N && s[right] == 'L')
            {
                cnt++;
                rightc[cnt % 2]++;
                right++;
            }
            a[i - 1] = leftc[1] + rightc[0];
            a[i] = leftc[0] + rightc[1];
        }
    }
    for (int i = 0; i < N; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

LL mygcd(LL a,LL b){
    if(a < b){
        swap(a,b);
    }
    if(b == 0){
        return a;
    }
    return mygcd(b,a%b);
}

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

    LL n,x;
    cin >> n >> x;

    vector<LL> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    vector<LL> b;
    for(int i = 0; i < n; i++){
        b.push_back(abs(a[i]-x));
    }

    LL ans = b[0];
    for(int i = 1; i < n; i++){
        ans = mygcd(ans,b[i]);
    }

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

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, a, b, tc;
    string s;
    const LL M = 1000000;
    LL freq[M + 1] = {0};
    cin >> n;
    vector<LL> v(n);
    for (i = 0; i < n; i++)
    {
        cin >> v[i];
        freq[v[i]]++;
    }
    sort(all(v));
    LL cnt = 0;
    vector<bool> truth(M + 1, false);
    vector<bool> perf(M+1,false);
    for (i = 0; i < n; i++)
    {
        //part;

        LL num = v[i];
        //debug(num);
        //cnt++;
        if (freq[num] > 1 && perf[num]==false)
        {
            // cout << "same\n";
            //cnt--;
            perf[num]=true;
            for (j = num; j <= M; j += num)
            {
                truth[j] = true;
            }
            continue;
        }
        if (truth[num] == false)
        {
            cnt++;
            //debug(num);
            for (j = num; j <= v[n-1]; j += num)
            {
                truth[j] = true;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 12968
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long ans1 = 0;
    long ans2 = 0;
    long ans3 = 0;
    for(long i = 1; i <= 3500; i++) {
      for(long j = i; j <= 3500; j++) {
        if(((4 * i * j - n * i - n * j) > 0) && ((n * i * j) % (4 * i * j - n * i - n * j) == 0)) {
          ans1 = i;
          ans2 = j;
          ans3 = (n * i * j) / (4 * i * j - n * i - n * j);
          break;
        }
      }
      if(ans1 > 0) break;
    }
    System.out.print(ans1 + " ");
    System.out.print(ans2 + " ");
    System.out.print(ans3);
  }
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S,T;
	scan(S);scan(T);
	int StoT[26][26]={{0}};
	int TtoS[26][26]={{0}};
	rep(i,S.size()){
		StoT[S[i]-'a'][T[i]-'a']=1;
		TtoS[T[i]-'a'][S[i]-'a']=1;
	}
	int flag=1;
	rep(i,26){
		int sum1=0,sum2=0;
		rep(j,26){
			sum1+=StoT[i][j];
			sum2+=TtoS[i][j];
		}
		//printf("StoT[%c]:%d, TtoS[%c]:%d\n",'a'+i,sum1,'a'+i,sum2);
		if(sum1>=2||sum2>=2){
			flag=0;
			break;
		}
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 776
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse = True)

def check(x):
  k = K
  for i in range(N):
    if a[i] * b[i] > x: k += (x - a[i] * b[i]) // b[i]
  return k >= 0

ok = 10 ** 12
ng = -1
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)

Measured memory_bytes: 102724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int t=stoi(S);
    int th=t/1000;
    int hu=t%1000/100;
    int te=t%1000%100/10;
    int one=t%1000%100%10;
    int f=10*th+hu;
    int l=10*te+one;
    if((l>=1 && l<=12) && (f>12 || f<1))
        cout << "YYMM" << endl;
    else if((f>=1 && f<=12) && (l>12 || l<1))
        cout << "MMYY" << endl;
    else if((f>=1 && f<=12) && (l<=12 && l>=1))
        cout << "AMBIGUOUS" << endl;
    else 
        cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;


ll gcd(ll a,ll b){
  if( b == 0 ) return a;
  return gcd(b,a%b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int cnt = 0;
  set<string> sets1;
  REP(i,n) {
    string s;
    cin >> s;
    if( sets1.count(s) == 0 ) {
      sets1.insert(s);
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 15512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_
const ll int N=300005;
ll cr[N],cc[N];
set<pll>s;
set<ll>sr,sc;
// vector<vector<ll>>vr,vc;
int TLE_TERROR()
{
 	ll int h,w,m,l,r,mr=1,mc=1,ans,z,y;
 	cin>>h>>w>>m;
 	for(ll int i=0;i<m;i++)
 	{
 		cin>>l>>r;
 		cr[l]++;
 		cc[r]++;
 		s.insert({l,r});
 		amax(mr,cr[l]);
 		amax(mc,cc[r]);
 	}
 	ans=mr+mc;
 	// cout<<ans<<endl;
 	for(ll int i=1;i<=h;i++)
 	{
 		if(cr[i]==mr)
 		{
 			sr.insert(i);
 		}
 	}
 	for(ll int i=1;i<=w;i++)
 	{
 		if(cc[i]==mc)
 		{
 			sc.insert(i);
 		}
 	}
 	for(auto it=sr.begin();it!=sr.end();it++)
 	{
 		for(auto itr=sc.begin();itr!=sc.end();itr++)
 		{
 			z=(*it);
 			y=(*itr);
 			if(!s.count({z,y}))
 			{
 				cout<<ans;
 				return 0;
 			}
 		}
 	}
 	ans-=1;
 	cout<<ans;

 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

Measured memory_bytes: 55160
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
  ll n;
  cin >> n;
  ll sum = 0;
  while(1){
    n--;
    if(n < 0){
      cout << sum << endl;
      return 0;
    }
    sum += n;
  }
}

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

int main() {
    int l[3];
    int N;
    cin >> N;
    for(int i=0; i<N; ++i) {
        cin >> l[0] >> l[1] >> l[2];
        sort(begin(l), end(l));
        cout << (l[0]*l[0] + l[1]*l[1] == l[2]*l[2] ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 3132
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

int main()
{
    int n, q;
    long long ans = 0;
    std::cin >> n;
    std::array<int, 100001> dat {};
    for (int i = 0; i < n; i++) {
        int input;
        std::cin >> input;
        ans += static_cast<long long>(input);
        dat[input]++;
    }
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        long long from, to;
        std::cin >> from >> to;

        ans += (static_cast<long long>(to - from) * static_cast<long long>(dat.at(from)));
        dat.at(to) += dat.at(from);
        dat.at(from) = 0;
        std::cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3552
import sys

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


def main():
    N, *A = map(int, read().split())

    B = [False] * (N + 1)

    for i, a in reversed(list(enumerate(A, 1))):
        tmp = 0
        for j in range(2 * i, N + 1, i):
            tmp ^= B[j]
        B[i] = a ^ tmp

    ans = [i for i in range(1, N + 1) if B[i]]
    print(len(ans))
    if len(ans) > 0:
        print(' '.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 33688
import java.util.Scanner;

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

        while (sc.hasNextLong()) {
            long n = sc.nextLong();
            long m = sc.nextLong();

            long ans = Math.min(n, m / 2);

            m -= ans * 2;

            if (m > 0) {
                ans += m / 4;
            }

            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23124
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      s1: Chars,
      s2: Chars,
   }

   let mut prev = 0;
   let mut now = if s1[0] == s2[0] { 1 } else { 2 };
   let mut ans:usize = if now == 1 { 3 } else { 6 };
   while now < n {
      if s1[now] == s2[now] {
         if now - prev == 1 {
            ans *= 2;
         }
         prev = now;
         now += 1;
      } else {
         if now - prev == 1 {
            ans *= 2;
         } else {
            ans *= 3;
         }
         prev = now;
         now += 2;
      }
      ans %= 1000000007;
   }
   println!("{}", ans);
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>A(N);
    rep(i,N)cin>>A[i];
    ll ans = 0;

    rep(i,N){
        ans+=A[i]-1;
    }
   
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3588
<?php
$h = STDIN;

$n = trim(fgets($h));
$d = array_map(function ($i) {
    return (int)$i;
}, explode(' ', trim(fgets($h))));


//3
//3 1 2
$cacheA = [];
$ans = 0;
foreach ($d as $k => $v) {
    foreach ($d as $kk => $vv) {
        if ($k === $kk){continue;}
        if (($cacheA[$k][$kk] ?? false) || ($cacheA[$kk][$k] ?? false)) {
            continue;
        }
        $ans += $v * $vv;

        $cacheA[$k][$kk] = true;
        $cacheA[$kk][$k] = true;
    }
}

echo $ans;

Measured memory_bytes: 4728
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>> s(H,vector<char>(W));
    REP(i,H) REP(j,W) cin>>s[i][j];
    vector<vector<ll>> dp(H+1,vector<ll>(W+1,INF));
    if(s[0][0]=='.') dp[0][0]=0;
    else dp[0][0]=1;
    REP(i,H){
        REP(j,W){
            if(i-1>=0){
                if(s[i-1][j]=='.'&&s[i][j]=='#') dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
                else dp[i][j]=min(dp[i][j],dp[i-1][j]);
            }

            if(j-1>=0){

                if(s[i][j-1]=='.'&&s[i][j]=='#') dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
                else dp[i][j]=min(dp[i][j],dp[i][j-1]);
            
            }
        }
    }
    cout<<dp[H-1][W-1]<<endl;
}

Measured memory_bytes: 3728
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
struct node
{
	long long d;int p;
}a[100010];
struct bian
{
	int x,y,next;
}e[100010];int len,last[100010];
void ins(int x,int y)
{
	len++;
	e[len].x=x;e[len].y=y;
	e[len].next=last[x];last[x]=len;
}
bool cmp(node a,node b){return a.d<b.d;}
int n;
bool v[100010];
inline int erfen(long long x)
{
	int l=1,r=n,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(a[mid].d<=x)ans=mid,l=mid+1;
		else r=mid-1;
	}
	if(a[ans].d==x)return ans;
	else return -1;
}
int tot[100010];
long long sum=0;
void dfs(int x,int dis)
{
	sum+=dis;
	for(int k=last[x];k;k=e[k].next)
	{
		int y=e[k].y;
		dfs(y,dis+1);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i].d),a[i].p=i;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)tot[i]=1;
	bool bk=true;
	for(int i=n;i>1;i--)
	{
		long long ul=a[i].d-n+2*tot[i];
		int y=erfen(ul);
		if(y==-1 || y==i){bk=false;break;}
		ins(a[y].p,a[i].p);
		tot[y]+=tot[i];
	}
	dfs(a[1].p,0);
	if(bk==false || sum!=a[1].d)printf("-1\n");
	else for(int i=1;i<=len;i++)printf("%d %d\n",e[i].x,e[i].y);
    return 0;
}

Measured memory_bytes: 6400
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;//<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	set<string> st;
	string s;
	cin >> s;
	int k;
	cin >> k;
	rep(i, s.size()) {
		for (int j = 1; j <= k && i + j - 1 < s.size(); j++) {
			st.insert(s.substr(i, j));
		}
	}
	auto itr = st.begin();
	rep(i, k - 1) {
		itr++;
	}
	cout << *itr << endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  vi D(n);
  rep(i,n) cin>>D[i];
  int ans=0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      ans+=D[i]*D[j];
    }
  }
  cout(ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define INF 2100000000
#define MAXN 100006
using namespace std;
int n,k,a[MAXN],ans;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	ans=INF;
	for(int i=1;i<=n-k+1;i++)
	{
		int nowans;
		if(a[i]>=0) nowans=a[i+k-1];
		if(a[i]<0&&a[i+k-1]>0) nowans=a[i+k-1]-a[i]+min(abs(a[i]),a[i+k-1]);
		if(a[i+k-1]<=0) nowans=-a[i];
		ans=min(ans,nowans);
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int min = N;

  // 各iでの、それより左側でWの人の数を数える
  int W[300010];
  W[0] = 0;
  //cout << 0 << "," << W[0] << endl;
  for (int i = 1; i < N; i++) {
    W[i] = W[i-1];
    if (S[i-1] == 'W') {
      W[i]++;
    }
    //cout << i << "," << W[i] << endl;
  }
  //cout << "--------------" << endl;
  // 各iでの、それより右側でEの人の数を数える
  int E[300010];
  E[N-1] = 0;
  for (int i = N-2; i >= 0; i--) {
    E[i] = E[i+1];
    if (S[i+1] == 'E') {
      E[i]++;
    }
    //cout << i << "," << E[i] << endl;
  }

  //cout << "--------------" << endl;
  for (int i = 0; i < N; i++) {
    int count = 0;
    count = W[i] + E[i];
    if (count < min) {
      min = count;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 3068
N = int(input())
d = {'AC' : 0, 'WA' : 0, 'TLE' : 0, 'RE' : 0}

for i in range(N):
    S = input()
    d[S] = d.get(S, 0) + 1

for x, y in d.items():
    print(x, 'x', y)


Measured memory_bytes: 9176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Prac
{
    class Prog
    {
        public static void Main()
        {
            var input = Console.ReadLine();
            var output = new string((input.ToCharArray().Select<char, char>(x =>
                {
                    if (char.IsLower(x))
                        return char.ToUpper(x);
                    if (char.IsUpper(x))
                        return char.ToLower(x);
                    return x;
                }).ToArray()));
            Console.WriteLine(output);
        }
    }
}

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



int main(void){
    
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    
    long long P[A];
    long long Q[B];
    long long R[C];
    vector<long long> vec;
    for(int i = 0; i < A;i++)cin >> P[i];
    for(int i = 0; i < B;i++)cin >> Q[i];
    for(int i = 0; i < C;i++)cin >> R[i];
    
    sort(P,P+A,greater<int>());
    sort(Q,Q+B,greater<int>());
    
    for(int i = 0; i < X;i++)vec.push_back(P[i]);
    for(int i = 0; i < Y;i++)vec.push_back(Q[i]);
    for(int i = 0; i < C;i++)vec.push_back(R[i]);
    
    sort(vec.begin(),vec.end(),greater<int>());
    
    long long sum = 0;
    for(int i = 0; i < X+Y;i++)sum += vec[i];
    cout << sum <<endl;
}

Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
    // 配列の最大値を取得
    int max = *max_element(vec.begin(), vec.end());
    // 配列の最大値のイテレータを取得
    vector<int>::iterator maxIt = max_element(vec.begin(), vec.end());
    // 配列の最大値までの距離を取得
    int maxIndex = distance(vec.begin(), maxIt);
    // 隣り合う重複要素を削除し、末尾のゴミを削除
    // (uniqueは、重複を取り除いた範囲の末尾の次を指すイテレータを返す)
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
*/

int main() {
    int h, w;
    cin >> h >> w;
    char a[h][w];

    vector<int> row(h, 1);
    vector<int> cols(w, 1);

    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            cin >> a[i][j];
            if (a[i][j] == '#') {
                row[i] = 0;
                cols[j] = 0;
            }
        }
    }

    for (int i=0; i<h; ++i) {
        if (row[i]) continue;
        for (int j=0; j<w; ++j) {
            if (cols[j]) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

vector<int> Z_algo(string &s) {
	int n = s.size();
	vector<int> z(n);
	int L = 0, R = 0;
	for (int i = 1; i < n; i++) {
		if (i > R) {
			L = R = i;
			while (R < n && s[R - L] == s[R]) R++;
			z[i] = R - L; R--;
		}
		else {
			int k = i - L;
			if (z[k] < R - i + 1) z[i] = z[k];
			else {
				L = i;
				while (R < n && s[R - L] == s[R]) R++;
				z[i] = R - L; R--;
			}
		}
	}
	return z;
}

int main() {
	string w;
	cin >> w;
	int n = w.size();
	bool same = 1;
	for (int i = 1; i < n; i++) {
		if (w[i] != w[0]) {
			same = 0;
			break;
		}
	}
	if (same) {
		cout << n << endl;
		cout << 1 << endl;
		return 0;
	}
	vector<int> z = Z_algo(w);
	vector<bool> G1(n + 1);
	for (int i = 1; i <= n; i++) G1[i] = true;
	for (int p = 1; p < n; p++) {
		if (!G1[p]) continue;
		for (int k = 2; (k - 1)*p <= z[p]; k++) G1[k*p] = false;
	}
	reverse(w.begin(), w.end());
	z = Z_algo(w);
	vector<bool> G2(n + 1);
	for (int i = 1; i <= n; i++) G2[i] = true;
	for (int p = 1; p < n; p++) {
		if (!G2[p]) continue;
		for (int k = 2; (k - 1)*p <= z[p]; k++) G2[k*p] = false;
	}
	if (G1[n]) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (G1[i] && G2[n - i]) ans++;
	}
	cout << 2 << endl;
	cout << ans << endl;
}


Measured memory_bytes: 4740
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

const int mod = 1000003;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // cout << fixed << setprecision(20);
    //前計算をする
    //1,000,003まで階乗modを前計算する
    vector<mint> facl(3*mod);
    for(ll i = 0;i < 3*mod;i++){
        if(i == 0)facl[i] = (mint)1;
        else facl[i] = facl[i-1] * (mint)i;
    }
    //計算する
    int t;cin >> t;
    REP(_,t){
        //入力を受け取る
        ll x,d,n;cin >> x >> d >> n;
        if(x == 0){
            cout << 0 << '\n';
            continue;
        }
        if(d == 0){
            mint X = (mint)x;
            X = X.pow(n);
            cout << X.x << '\n';
            continue;
        }else{
            mint q = (mint)x / (mint)d;
            //[q,q+(n-1)]に1'000'003の倍数があるか?
            if((n-1) != (q.x + n - 1 % mod) - (q.x % mod)){
                cout << 0 << '\n';
            }else{
                mint D = d;
                D = D.pow(n);
                if(q.x == 0 or q.x + (n-1) >= 3*mod){
                    cout << 0 << '\n';
                    continue;
                }
                D *= facl[q.x+ (n-1)] * facl[q.x-1].inv();
                cout << D.x << '\n';
            }
        }
    }
    return 0;
}


Measured memory_bytes: 24320
import copy
n,m=map(int,input().split())
g=[set([]) for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    g[a].add(b)
    g[b].add(a)

ans=0
def dfs(v,used):
    usedi=copy.deepcopy(used)
    usedi[v]=True

    nexti=g[v]
    for i in nexti:
        if(usedi[i]):
            continue
        else:
            dfs(i,usedi)

    if(usedi[1:].count(True) == n):
        global ans
        ans+=1

dfs(1,[False for _ in range(n+1)])
print(ans)

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

int main()
{
    int a, b;
    
    cin >> a >> b;
    
    if (a < b)
    cout << "a < b" << endl;
    else if (a > b)
    cout << "a > b" << endl;
    else
    cout << "a == b" << endl;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    string ans="";
    REP(i,s.size()){
        if(i==0){
            ans+=s[i];
        }else{
            if(s[i]==ans[ans.size()-1])continue;
            ans+=s[i];
        }
    }
    cout<<ans.size()<<endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    int t = 0, ao = 0;
    t = c % b ? (c / b) + 1 : c / b;
    ao = a % d ? (a / d) + 1 : a / d;
    
    //cout << t << " " << ao;
    
    if(t > ao)
        cout << "No";
    else
        cout << "Yes";

    return 0;
}

Measured memory_bytes: 3648
local r = 99999999
local n = tonumber(io.read("*l"))
for _ in io.read("*l"):gmatch("%d+") do
  local r0 = 0
  local k = tonumber(_)
  while k % 2 < 1 do
    r0 = r0 + 1
    k = k / 2
  end
  if r > r0 then
    r = r0
  end
end
return print(r)


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	int n; cin >> n;
	vector<long long int> a(n);
	vector<long long int> b(n);
	vector<long long int> c(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) cin >> c[i];
	int j = 0;
	vector<long long int> s(n + 2, 0);
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	for (int i = 0; i < n; ++i) {
		//b > cとなる部品の数をカウントする
		while (j < n && b[i] >= c[j]) j++;
		s[i] = n - j;
	}
	long long int ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		//累積和を取り、任意の部品を選んだ時の
		//使用可能な部品の全ての種類数を算出する
		s[i] += s[i + 1];
	}
	//a < bとなる部品を選んで合計することで
	//a < b < cの制約の中で作成できる祭壇の種類数を求めることができる
	for (int i = 0; i < n; ++i) {
		ans += s[upper_bound(b.begin(), b.end(), a[i]) - b.begin()];
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 3328
import sys

if sys.platform =='ios':
	sys.stdin=open('input_file.txt')
	
n=int(input())

a=n//10000
b=(n-10000*a)//1000
c=(n-10000*a-1000*b)//100
d=(n-10000*a-1000*b-100*c)//10
e=(n-10000*a-1000*b-100*c-10*d)


if n==100000:
	print(90909)

elif a==0:
	if b==0:
		if c==0:
			if d==0:
				print(n)
			else:
				print(9)
		else:
		  print(n-90)
	else:
		print(909)
else:
	print(n-9090)
	

Measured memory_bytes: 3064
x1,y1,x2,y2 = map(int,input().split())
side1 = abs(x2 - x1)
side2 = abs(y2 - y1)
if x1 < x2:
    y3 = y2 + side1
    y4 = y1 + side1
else:
    y3 = y2 - side1
    y4 = y1 - side1
if y1 < y2:
    x3 = x2 - side2
    x4 = x1 - side2
else:
    x3 = x2 + side2
    x4 = x1 + side2
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))

Measured memory_bytes: 3064
function readInt(str){
  return parseInt(str, 10);
}
function Main(raw: string) {
  const input = raw.split("\n");
  const [N,K] = input[0].split(" ").map(readInt);

  //出力
  console.log(N-K+1);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n,m=map(int,input().split())
j = 0
if n % 2 == 1:
  for i in range(m):
    print(1+i, n-i-j)
else:
  for i in range(m):
    if 2*((n-i) - (1+i)) - n >= 2:
      print(1+i, n-i-j)
    else:
      j = 1
      print(1+i, n-i-j)

Measured memory_bytes: 69396
#include<iostream>
using namespace std;
int main() {
	int c = 0, n;
	cin >> n;
	while (true) {
		if (n >= 500) {
			n -= 500;
			c += 1000;
		}
		else  if (n >= 5  && n<500) {
			n -= 5;
			c += 5;
		}
		else
			break;
	}
	cout << c;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
inline ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }



int main(void)
{
   // cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b; scanf("%2d%2d", &a, &b);
    if(1 <= a && a <= 12 && 1 <= b && b <= 12)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if(1 <= a && a <= 12)
    {
        cout << "MMYY" << endl;
    }
    else if(1 <= b && b <= 12)
    {
        cout << "YYMM" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <algorithm>
#include <map>
using namespace std;

int next(int a, int L) {
    stringstream ss;
    ss<<a;
    string s = ss.str();
    s = string(L-s.length(), '0') + s;
    sort(s.begin(), s.end());
    int m = atoi(s.c_str());
    reverse(s.begin(), s.end());
    int mm = atoi(s.c_str());
    return mm - m;
}

int main() {
    int a, L;
    while(cin>>a>>L, a|L) {
        map<int, int> m; m[a] = 0;
        for (int j=1; ; j++) {
            int p = next(a, L);
            if (m.find(p) != m.end()) {
                cout<<m[p]<<" "<<p<<" "<<j-m[p]<<endl;
                break;
            }
            m[p] = j;
            a = p;
        }
    }
}

Measured memory_bytes: 1248
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n,ans=0;
    cin >> n;
    for(int j=1;j<=n;j++){
        int cnt=0;
        for(int i=1;i<=j;i++){
            if(j%i==0)
                cnt++;
        }
        if(cnt==8 && j%2!=0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool S=false;
  if(a==7 && b==5 && c==5) S=true;
  if(a==5 && b==7 && c==5) S=true;
  if(a==5 && b==5 && c==7) S=true;
  if(S) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k=0;
  cin >> n;
  int a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b,b+n,greater<int>());
  for(int i=0;i<n;i++){
    if(b[0]==a[i])cout << b[1] << endl;
    else cout << b[0] << endl;
  }
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  vector<P> b;
  for (auto e : mp) b.emplace_back(make_pair(e.first, e.second));
  sort(b.begin(), b.end(), greater<P>());
  int m = b.size();
  ll res = 0;
  for (int i = 0; i < m; i++) {
    int cnt = b[i].second;
    ll h = b[i].first;
    if (cnt >= 4) {
      cout << h * h << endl;
      return 0;
    }
    if (cnt >= 2) {
      for (int j = i + 1; j < m; j++) {
        if (b[j].second >= 2) {
          cout << h * (ll)b[j].first << endl;
          return 0;
        }
      }
      cout << 0 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 6136
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu_alter
const int N=605;
int dx[]={1,-1,-1,1};
int dy[]={-1,1,-1,1};
int n,cnt[2][2];
int col[N][N][2];
vector<pii >g[N][N];
bool vis[N][N];
//
inline bool isvalid(int x,int y){
	if(x<0||x>=2*n||y<0||y>=2*n)return false;
	return true;
}
void go(int x,int y,int z,int c){
	col[x][y][z]=c;
	vis[x][y]=true;
	rep(i,g[x][y].size()){
		pii u=g[x][y][i];
		if(!vis[u.first][u.second]){
			go(u.first,u.second,z,c^1);
		}
	}
}
void solve(int d,int x){
	rep(i,2*n)rep(j,2*n)g[i][j].clear();
	rep(i,2*n)if(i*i<=d){
		int j=sqrt(d-i*i);
		if(j*j+i*i!=d)continue;
		rep(x,2*n)rep(y,2*n)rep(k,4){
			int fx=x+i*dx[k],fy=y+j*dy[k];
			if(!isvalid(fx,fy))continue;
			g[x][y].push_back(mp(fx,fy));
		}
	}
	rep(i,2*n)rep(j,2*n)vis[i][j]=false;
	rep(i,2*n)rep(j,2*n)if(!vis[i][j]){
		go(i,j,x,0);
	}
}
int main(){
	n=getint();
	rep(i,2){
		int x=getint();
		solve(x,i);
	}
	rep(i,2*n)rep(j,2*n)cnt[col[i][j][0]][col[i][j][1]]++;
	rep(i,2)rep(j,2)if(cnt[i][j]>=n*n){
		int c=0;
		rep(x,2*n)rep(y,2*n){
			if(col[x][y][0]==i&&col[x][y][1]==j){
				printf("%d %d\n",x,y);
				++c;
			}
			if(c==n*n)return 0;
		}
		return 0;
	}
	return 0;
}


Measured memory_bytes: 122624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
int main()
{
    int N;
    cin >>N;
    int a=N%10;
    if(a==0||a==1||a==6||a==8){
        cout << "pon"<<endl;
    }else if (a==3){
        cout <<"bon"<<endl;
    }else{
        cout <<"hon"<<endl;
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    vector<int> a(N+2);
    for(int i=1;i<=N;i++)cin>>a.at(i);
    vector<int> left(N+1),right(N+1);
    for(int i=1;i<=N;i++)left.at(i)=left.at(i-1)+abs(a.at(i)-a.at(i-1));
    for(int i=N-1;i>=0;i--)right.at(i)=right.at(i+1)+abs(a.at(i+1)-a.at(i+2));
    for(int i=1;i<=N;i++)
        cout<<left.at(i-1)+right.at(i)+abs(a.at(i+1)-a.at(i-1))<<endl;
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,sum=0,maxi=0,mini=1000000;
  long long int a[100000];
  cin>>n;
  if(n==1)
  {
    cin>>a[0];
    cout<<a[0]<<" "<<a[0]<<" "<<a[0]<<endl;
  }
  else
  {
  for(long long int i=0;i<n;i++)
  {
    cin>>a[i];
    sum=sum+a[i];
    mini=min(a[i],mini);
    maxi=max(a[i],maxi);
  }
  cout<<mini<<" "<<maxi<<" "<<sum<<endl;
}
}



Measured memory_bytes: 3212
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int NC = 5e3 + 5;
int N, A, B, p[NC];
ll dp[NC][NC];
int main()
{
	scanf("%d%d%d", &N, &A, &B);
	for (int i = 1; i <= N; ++i) scanf("%d", &p[i]);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 1; i <= N; ++i)
		for (int j = 0; j <= N; ++j)
		{
			if (p[i] > j)
			{
				dp[i][j] = min(dp[i][j], dp[i-1][j] + A);
				dp[i][p[i]] = min(dp[i][p[i]], dp[i-1][j]);
			}
			else dp[i][j] = min(dp[i][j], dp[i-1][j] + B);
		}
	ll ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1; i <= N; ++i) ans = min(ans, dp[N][i]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 198948
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
bool cmp1(char a,char b){
	return a<b;
}
bool cmp2(char a,char b){
	return a>b;
}
int main(){
	char a[105],b[105];
	cin>>a>>b;
	int cnt1=0;
	for(int i=0;;i++){
		if(a[i]!='\0'){
			cnt1++;
		}else{
			break;
		}
	}
	int cnt2=0;
	for(int i=0;;i++){
		if(b[i]!='\0'){
			cnt2++;
		}else{
			break;
		}
	}
	sort(a,a+cnt1,cmp1);
	sort(b,b+cnt2,cmp2);
	int cnt3=max(cnt1,cnt2);
	if(strcmp(a,b)<0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
n = int(input())
s = input()
b_total = 0
w_total = 0
ans = 0
for i in range(n):
  if s[i] == '#':
    b_total += 1
  if s[i] == '.':
    w_total += 1
if b_total == n:
  print(0)
else:
  b_cnt = 0
  w_cnt = 0
  ans = b_cnt + (w_total - w_cnt)
  for i in range(n):
    if s[i] == '#':
      b_cnt += 1
    if s[i] == '.':
      w_cnt += 1
    cnt = b_cnt + (w_total - w_cnt)
    ans = min(ans, cnt)
  print(ans)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (int i = 0; i < N/2; i++) {
    ans += a.at(2*i) - a.at(2*i + 1);
  }
  if (N%2 == 1) {
    ans += a.at(N - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  string temp="";int k=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]=='0'||s[i]=='1')
    {
      temp = temp+s[i];
      k++;
    }
    if(s[i]=='B')
    {
      if(temp.empty())
        continue;
         
      temp = temp.substr(0,k-1);
      k--;
    }
  }
  cout<<temp;
      
  return 0;
}

Measured memory_bytes: 256