akhauriyash/Code-Regression huggingface dataset:
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next().toString()

    println(abc132a(s))
}

private fun abc132a(s: String): String {
    val ans = s.groupBy { it }
        .all { it.value.count() == 2}
    
    if (ans) return "Yes"

    return "No"
}

Measured memory_bytes: 29352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int H, W;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  ll ans = 1LL << 40;
  for (ll i = 1; i < H; i++) {
    ll A, B, C;
    A = i * W;
    B = ((H - i) / 2) * W;
    C = (H - i) * W - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
    B = (H - i) * (W / 2);
    C = (H - i) * W - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
  }  
  for (ll i = 1; i < W; i++) {
    ll A, B, C;
    A = i * H;
    B = ((W - i) / 2) * H;
    C = (W - i) * H - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
    B = (W - i) * (H / 2);
    C = (W - i) * H - B;
    ans = min(ans, max({A, B, C}) - min({A, B, C}));
  }  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    ll n;
    cin >> n;

    int lim = 4000, cnt = 0;

    REP(x, lim) {
        REP(y, lim) {
            ll x5 = pow(x, 5);
            ll y5 = pow(y, 5);
            //x+, y+
            if(x5-y5 == n) {
                cout << x << " " << y << endl;
                return 0;
            } 
            //x-, y+
            else if ((-x5)-y5 == n) {
                cout << (-x) << " " << y << endl; 
                return 0;
            }
            //x+, y-
            else if (x5+y5 == n) {
                cout << x << " " << (-y) << endl;
                return 0;
            }
            //x-, y-
            else if(y5-x5 == n) {
                cout << (-x) << " " << (-y) << endl;
                return 0;
            } 
        }
    }
    

    return 0;
}


Measured memory_bytes: 4156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	long long s = 0, o = 0;
	for (int i = 1; i <= n; i++) {
		if (i % k == 0) {
			s++;
		}
		else if (i * 2 % k == 0) {
			o++;
		}
	}
	long long ans = s * s * s + o * o * o;
	cout << ans << endl;
	return 0;
}

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

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

	int ans = S.size();
	int a = 0, b = 0;
	rep(i, S.size()) {
		if (S[i] == 'A') break;
		a++;
	}
	ans -= a;
	reverse(all(S));
	rep(i, S.size()) {
		if (S[i] == 'Z') break;
		b++;
	}
	ans -= b;

	dunk(ans);

	return 0;
}

Measured memory_bytes: 720
#include<stdio.h>

int main(){
  int c[100];
  for(int i = 0; i < 100; i++){
    c[i] = 0;
  }
  int N, K;
  scanf("%d %d", &N, &K);
  int d, A[100];
  for(int i = 0; i < K; i++){
    scanf("%d", &d);
    for(int i = 0; i < d; i++){
      scanf("%d", &A[i]);
      c[A[i] - 1] = 1;
    }
  }
  int count = 0;
  for(int i = 0; i < 100; i++){
    if(c[i] == 1) count++;
  }
  printf("%d", N - count);
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#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;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> b(n);
  rep(i, n) b[i] = a[i] - (i+1);
  sort(b.begin(), b.end());
  vector<ll> cum(n+1, 0);
  rep(i, n) cum[i+1] = cum[i] + b[i];
  ll ans = 1e18;
  rep(i, n) {
    ll now = cum[0] - cum[i] + cum[n] - cum[i+1] + (ll)(2*i - n + 1) * b[i];
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6436
S = input()

yyyy = int(S[:4])
mmdd = int(S[5:7] + S[8:])

ans = "TBD"

if  yyyy < 2019:
    ans = "Heisei"
elif yyyy == 2019:
    if mmdd <= 430:
        ans = "Heisei"
        
print(ans)

Measured memory_bytes: 2940
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int N = sc.nextInt(), M = sc.nextInt();
                        for(int i = 0; i < M + 2; i++){
                                System.out.print("#");
                        }
                        System.out.println("");
                        for(int i = 0; i < N; i++){
                                System.out.println("#" + sc.next() + "#");
                        }
                        for(int i = 0; i < M + 2; i++){
                                System.out.print("#");
                        }
                        System.out.println("");
                }
        }
}

Measured memory_bytes: 23380
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

const int MAX_N = 102;
int N;
int128_t x, a[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> x;

    int128_t sum = 0;
    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
        sum += a[i];
    }

    if (sum == x) {
        std::cout << N << std::endl;
        return 0;
    } else if (sum < x) {
        std::cout << N - 1 << std::endl;
        return 0;
    }

    std::sort(a + 1, a + 1 + N);
    int ret = 0;
    for (int i = 1; i <= N; i++) {
        if (a[i] <= x) {
            ret++;
            x -= a[i];
        } else {
            break;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

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

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	
	double prob = 0;
	for(int i = 1; i <= N; i++) {
		int point = i;
		int coin = 0;
		while(point <= K - 1) {
			coin++;
			point *= 2;
		}
		prob += 1 / (N * pow(2, coin));
	}
	
	printf("%.12lf", prob);
	return 0;
}

Measured memory_bytes: 128
/**
 * C - Big Array
 * https://atcoder.jp/contests/abc061/tasks/abc061_c
 **/
#include<iostream>
#include<vector>

using namespace std;

#define ll long long

const int N = 100001;

int main() {
    ll n, k; cin >> n >> k;
    ll ans = 0;
    vector<ll> a(N, 0);
    for(ll i=1; i<n+1; i++) {
        ll ai, bi;
        cin >> ai >> bi;
        a[ai]+=bi;
    }
    for(ll i=1; i<N; i++) {
        if(k<=a[i]) {
            ans = i;
            break;
        }
        k -= a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main (void){
  int N,Y;
  int i,j,k;
  scanf("%d%d",&N,&Y);
  for(i=0;i<=N;i++){
  	for(j=0;j<=N;j++){
      k=N-i-j;
    if(k>=0&&10000*i+5000*j+1000*k==Y){
      printf("%d %d %d",i,j,k);
      return 0;
    }
    }
  }
  printf("-1 -1 -1");
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

bool validate(vector<int>&v, int n) {
  if( v.size() != (size_t)n ) {
    cerr << "!!" << n << " > " << v.size() << endl;
    return false;
  }
  sort(v.begin(), v.end());
  ll tot = v[0], g = v[0];
  for(int i=1; i<n; i++) {
    if( v[i] == v[i-1] ) {
      cerr << "x2 :" << v[i] << endl;
      return false;
    }
    tot += v[i];
    g = __gcd(g, (ll)v[i]);
  }
  if( g > 1 ) {
    cerr << "G" << g << endl;
    return false;
  }
  for(int i=0; i<n; i++) {
    if( v[i] > 30000 ) return false;
    if( __gcd((ll)v[i], tot-v[i]) == 1 ) {
      cerr << v[i] << ',' << tot-v[i]
	   << ':' << __gcd((ll)v[i], tot-v[i]) << endl;
      return false;
    }
  }
  return true;
}

int main () {

  vector<int> a;// = {2, 3, 25};
  int n;
  cin >> n;

  if( n > 19000 ) {
    for(int i=2; i + 28 <= 30000 and a.size()+14 <= n; i+=30) {
      for(int j=0; j<30; j+=2) {
	if( (i + j)%30 == 0 ) continue;
	a.emplace_back(i + j);
      }
    }

    for(int i=3; i + 54 <= 30000 and a.size()+10 <= n; i+=60) {
      for(int j=0; j<60; j+=6) {
	a.emplace_back(i + j);
      }
    }

    for(int i=30; i<=30000 and a.size()+1 <= n; i+=30)
      a.emplace_back(i);
  } else {

    a = {2, 3, 25};

    for(int i=4; i + 28 <= 30000 and a.size()+14 <= n; i+=30) {
      for(int j=0; j<30; j+=2) {
	if( (i + j)%30 == 0 ) continue;
	a.emplace_back(i + j);
      }
    }

    for(int i=9; i + 54 <= 30000 and a.size()+10 <= n; i+=60) {
      for(int j=0; j<60; j+=6) {
	a.emplace_back(i + j);
      }
    }

    for(int i=30; i<=30000 and a.size()+1 <= n; i+=30)
      a.emplace_back(i);    
  }

  for(int &i : a)
    cout << i << ' ';
  cout << endl;

  if( !validate(a, n) ) {
    cout << "WA" << endl;
    return 1;
  }

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 512
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll const MOD = 1e9+7; 

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
      if (n & 1) res = res * a % MOD;
      a = a * a % MOD;
      n >>= 1;
  }
  return res;
}

int main() {
    string s;
    ll anum[100010];
    ll cnum[100010];
    ll anum2[100010];
    ll cnum2[100010];
    Fill(anum,0);
    Fill(cnum,0);

    Fill(anum2,0);
    Fill(cnum2,0);

    std::cin >> s;
    
    ll n = s.length();
    for (int i = 0; i < n; i++) {
        anum[i+1] = anum[i];
        anum2[i+1] = anum2[i];
        if(s[i] == 'A' ){
            anum[i+1]++;
        }
        if(s[i] == '?' ){
            anum2[i+1]++;
        }
    }
    // 0はなにも含まない
    
    // nは何も含まない
    for (int i = n-1; i >= 0; i--) {
        cnum[i] = cnum[i+1];
        cnum2[i] = cnum2[i+1];
        if(s[i] == 'C'){
            cnum[i]++;
        }
        if(s[i] == '?'){
            cnum2[i]++;
        }
    }
    
    ll result = 0;
    for (int i = 1; i < n-1; i++) {
        ll sum = anum2[i]+cnum2[i+1];
        if(s[i] == 'B' || s[i] == '?'){
            result += anum[i]*cnum[i+1]%MOD*modpow(3,sum)%MOD;
            result += anum2[i]*cnum2[i+1]%MOD*modpow(3,sum-2)%MOD;
            result += anum[i]*cnum2[i+1]%MOD*modpow(3,sum-1)%MOD;
            result += cnum[i+1]*anum2[i]%MOD*modpow(3,sum-1)%MOD;
            result %= MOD;
        }
    }
    
    std::cout << result << std::endl;
    
}


Measured memory_bytes: 3584
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[262144];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<(n<<1);i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+(n<<1));
	int l=0,r=n;
	while(l<r)
	{
		int mid=(l+r)>>1;
		bool ok=true;
		for(int i=(mid<<1);i<(n<<1);i++)
		{
			if(a[i]+a[(n<<1)-1-(i-(mid<<1))]<m)
			{
				ok=false;
				break;
			}
		}
		if(ok)
		{
			r=mid;
		}
		else
		{
			l=mid+1;
		}
	}
	int ans=0;
	for(int i=0;i<(l<<1);i++)
	{
		if(a[(l<<1)-i-1]+a[i]>ans)
		{
			ans=a[(l<<1)-i-1]+a[i];
		}
	}
	for(int i=(l<<1);i<(n<<1);i++)
	{
		if(a[i]+a[(n<<1)-1-(i-(l<<1))]-m>ans)
		{
			ans=a[i]+a[(n<<1)-1-(i-(l<<1))]-m;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
#define int long long
#define MOD 1000000007
 
using namespace std;
 
template <class T> ostream &operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for (auto v : V)
        os << v << " ";
    os << "]";
    return os;
}
template <class T> ostream &operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for (auto s : S)
        os << s << " ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for (auto m : M)
        os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}
template <class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}

int getMax(int n) {
    int count = 0;
    while(n % 2 == 0) {
        count ++;
        n /= 2;
    }
    return count;
}
  
void solve() {
    char a;
    cin >> a;
    if(a >= 'a') {
        cout << "a" << endl;
    }
    else cout << "A" << endl;
}
 
int32_t main() {
    int t;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    // cin >> t;
    // while(t--) {
    //     solve();
    // }
    return 0;
}

Measured memory_bytes: 3644
#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 ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  map<string, ll> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;
  return 0;
}

Measured memory_bytes: 19260
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] flds = line.split(" ");
		int n = Integer.parseInt(flds[0]);
		int a = Integer.parseInt(flds[1]);
		int b = Integer.parseInt(flds[2]);
		line = br.readLine();
		int aa = 0;
		int bb = 0;
		for (int i=0; i<n; i++) {
			char ch = line.charAt(i);
			switch (ch) {
			case 'a':
				if (aa + bb < a + b) {
					System.out.println("Yes");
					aa++;
				} else {
					System.out.println("No");
				}
				break;
			case 'b':
				if (aa + bb < a + b && bb < b) {
					System.out.println("Yes");
					bb++;
				} else {
					System.out.println("No");
				}
				break;
			case 'c':
				System.out.println("No");
				break;
			}
		}
		long end = System.currentTimeMillis();
		//System.out.println((end-start) + "ms");
	}

}


Measured memory_bytes: 22476
#include <bits/stdc++.h>
#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()
{
    ll N;
    int digits = 1e5;
    cin >> N;
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            ll A = i;
            ll B = N / i;
            int maxDigits = max((int)to_string(A).length(), (int)to_string(B).length());
            digits = min(digits, maxDigits);
        }
    }

    cout << digits << endl;

    return 0;
}

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

int N;
long long A[200005];

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%lld", &A[i]);
	sort(A + 1, A + N + 1);
	
	long long idx = N, ans = 0;
	for(int i = 1; i < N; i++)
	{
		if(i % 2 == 0)
			idx--;
			
		ans += A[idx];
	}
	
	printf("%lld", ans);
}


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

using namespace std;

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

        if(B<0){
            cout << 0 << endl << 0 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

def gcd(a, b)
  if a < b then
    tmp = a
    a = b
    b = tmp
  end
  return a if b == 0
  r = a % b
  while r != 0 do
    a = b
    b = r
    r = a % b
  end
  return b
end

tmp_l = nil
tmp_r = nil
l_arr = []
r_arr = []
(n+1).times do |i|
  if i == 0 then
    l = 0
    r = 0
  else
    l = gcd(tmp_l, arr[i-1])
    r = gcd(tmp_r, arr[i * (-1)])
  end
  l_arr << l
  tmp_l = l
  r_arr << r
  tmp_r = r
end
r_arr.reverse!

max = 0
n.times do |i|
  m = gcd(l_arr[i], r_arr[i+1])
  max = m if m > max
end

puts max



Measured memory_bytes: 11360
using System;

class Program
{
    static void Main(string[] args)
    {
        var nkq = Console.ReadLine().Split();
        var n = int.Parse(nkq[0]);
        var k = int.Parse(nkq[1]);
        var q = int.Parse(nkq[2]);

        var ans = new int[n];

        for (int i = 0; i < q; i++)
        {
            var a = int.Parse(Console.ReadLine()) - 1;
            ans[a]++;
        }

        for (int i = 0; i < n; i++)
        {
            if (q - ans[i] < k)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 15708
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    ll n;
    cin >> n;
    if(n < 4){
        cout << 1 << endl;
        return;
    }
    for(int i = 0; i < n; i++){
        if(pow(i, 2) > n){
            cout << (int)pow(i-1, 2) << endl;
            return;
        }
    }
}

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

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

int main() {
  string S;
  cin >> S;
  int ans=0;
  for (int i=0; i<6; i++) {
    if (S.at(i)=='1') {
      ans=ans+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;cin>>n>>m;
  ll ans;
  if(n==2||m==2){
    cout<<0<<endl;
    return 0;
  }
  if(n==1&&m==1){
    cout<<1<<endl;
    return 0;
  }
  if(n==1){
    cout<<m-2<<endl;
    return 0;
  }
  if(m==1){
    cout<<n-2<<endl;
    return 0;
  }
  ans=(n-2)*(m-2);
  cout<<ans<<endl;
}

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

int N,A,B,C;
vector<int> l;
int ans=1e9;

void dfs(vector<int> &xabc,int now){
  if(now==N){
    int tmp=0;
    int a=0;
    int b=0;
    int c=0;
    for(int i=0;i<N;i++){
      if(xabc.at(i)==0) continue;
      else if(xabc.at(i)==1){
        if(a!=0)  tmp+=10;
        a+=l.at(i);
      }
      else if(xabc.at(i)==2){
        if(b!=0)  tmp+=10;
        b+=l.at(i);
      }
      else if(xabc.at(i)==3){
        if(c!=0)  tmp+=10;
        c+=l.at(i);
      }
    }
    if(a==0 || b==0 || c==0)  return;
    tmp+=abs(A-a)+abs(B-b)+abs(C-c);
    ans=min(ans,tmp);

    return;
  }

  for(int i=0;i<4;i++){
    xabc.at(now)=i;
    dfs(xabc,now+1);
  }

  return;
}

int main(){
  cin >> N >> A >> B >> C;
  l.resize(N);
  for(int i=0;i<N;i++)  cin >> l.at(i);

  vector<int> xabc(N,0);
  dfs(xabc,0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import deque

n, m = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)
res = []

f_inf = float("inf")
dist = [f_inf for _ in range(n)]
dist[0] = 0
q = deque()
q.append(0)
while q:
    u = q.popleft()
    for nv in tree[u]:
        if dist[nv] == f_inf:
            dist[nv] = dist[u] + 1
            q.append(nv)
if dist[n - 1] <= 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main(){
  int N, A, X, Ans=0;
  cin >> N;
  vector<vector<int>> V(N,vector<int>(N,-1));
  rep(i, N){
    cin >> A;
    rep(j, A){
      cin >> X;
      cin >> V.at(i).at(X-1);
    }
  }
  rep(i, (1<<N)){
    bitset<15> bs(i);
    bool B=1;
    rep(j, N){
      if(bs.test(j)){
        rep(k, N){
          if (V.at(j).at(k)!=-1 && V.at(j).at(k)!=bs[k]){
            B=0;
            break;
          }
        }
      }
    }
    if(B==1) Ans=max(Ans,(int)bs.count());
  }
  cout<< Ans <<endl;
}

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

int main(){
	int n;
	int s;
	int m;
	int g1;
	int g2;
	int cost[101][101];
	int x,y,c,res;
	while(1){
		cin >> n >> m >> s >> g1 >> g2;
		if(n == 0)break;
		res = INF;
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				cost[i][j] = INF;
			}
			cost[i][i] = 0;
		}
		for(int i = 0;i < m;i++){
			cin >> x >> y >> c;
			cost[x][y] = c;
		}
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				for(int k = 1;k <= n;k++){
					cost[j][k] = min(cost[j][k],cost[j][i] + cost[i][k]);
				}
			}
		}
		for(int i = 1;i <= n;i++){
			res = min(res,cost[s][i] + cost[i][g1] + cost[i][g2]);
		}
		cout << res << endl;
	}
	return 0;
}

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

namespace abc158_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var S = CIn.Read();
      var Q = CIn.ReadInt();

      var isFlip = false;
      var front = new List<char>();
      var back = new List<char>();

      for (int i = 0; i < Q; i++)
      {
        var T = CIn.ReadInt();

        if (T == 1)
        {
          isFlip = !isFlip;
        }
        else
        {
          var F = CIn.ReadInt();
          var C = CIn.Read()[0];

          if (F == 1 ^ isFlip)
          {
            front.Add(C);
          }
          else
          {
            back.Add(C);
          }
        }
      }

      if (!isFlip)
      {
        front.Reverse();
        Console.WriteLine(String.Concat(front) + S + String.Concat(back));
      }
      else
      {
        back.Reverse();
        Console.WriteLine(String.Concat(back) + String.Concat(S.Reverse()) + String.Concat(front));
      }
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 21684
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main(){

    int N;
    string S;
    char *c_ptr;

    cin >> N;
    cin >> S;
    c_ptr = (char *)malloc(sizeof(char) * (S.length()));
    c_ptr = (char *)S.c_str();


    for(int i=0; i<S.length(); i++){
        if(c_ptr[i]+N<=90){
            c_ptr[i]=c_ptr[i]+N;
        } else {
            c_ptr[i]=c_ptr[i]+N-26;
        } 
        cout << c_ptr[i]; 
    }
    cout << endl;
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine().ToUpper();
            string s1 = line.Split(' ')[0];
            string s2 = line.Split(' ')[1];
            string s3 = line.Split(' ')[2];
            Console.WriteLine(s1[0].ToString() + s2[0].ToString() + s3[0].ToString());
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <deque>
#include <tuple>
using namespace std;

typedef pair<int, int> ii;
const int MAX = 1010;
const int INF = 1000000000;
 
int main() {
    int H, W, sy, sx, gy, gx;
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    int dist[MAX][MAX];
    char maze[MAX][MAX];
    bool vis[MAX][MAX];
    deque<ii> q;
    cin >> H >> W >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    for (int h = 0;h < H;h++){
        for (int w = 0;w < W;w++){
            dist[h][w] = INF;
            vis[h][w] = false;
            cin >> maze[h][w];
        }
    }
    q.push_front(ii(sx, sy));
    dist[sy][sx] = 0;
    while(!q.empty()) {
        int x, y;
        tie(x, y) = q.front();
        q.pop_front();
        if (vis[y][x]) continue;
        vis[y][x] = true;
        if (x == gx && y == gy) break;
        for(int i = 0;i < 4;i++) {
            int cx = x + dx[i], cy = y + dy[i];
            if(cx < 0 || cx >= W || cy < 0 || cy >= H) continue;
            if(maze[cy][cx] == '#') continue;
            if (dist[y][x] < dist[cy][cx]){
                dist[cy][cx] = dist[y][x];
                q.push_front(ii(cx, cy));
            }
        }
        for(int h = -2; h <= 2; h++){
            for(int w = -2; w <= 2; w++){
                int cx = x + w, cy = y + h;
                if(cx < 0 || cx >= W || cy < 0 || cy >= H) continue;
                if(maze[cy][cx] == '#') continue;
                if (dist[y][x] + 1 < dist[cy][cx]){
                    dist[cy][cx] = dist[y][x] + 1;
                    q.push_back(ii(cx, cy));
                }
            }
        }
    }
    if (dist[gy][gx] == INF) cout << -1 << endl;
    else cout << dist[gy][gx] << endl;
}

Measured memory_bytes: 9588
from math import factorial
from collections import Counter

def combinations_count(n, r):
    if n <= 1:
        return 0
    else:
        return (n * (n-1)) // 2 
        #return factorial(n) // (factorial(n - r) * factorial(r))

N = int(input())
A = list(input().split())
sum = 0
counter = Counter(A)
for key,value in counter.items():
    sum = sum + combinations_count(value,2)

for k in range(N):
    add = 0
    add = sum - combinations_count(counter[A[k]],2) + combinations_count(counter[A[k]]-1,2) 
    print(add)

Measured memory_bytes: 26784
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

class node{
	public:
		int key;
		node *left;
		node *right;
		node(int key):key(key), left(NULL), right(NULL){}
};

class tree{
	public:
		node *root;
		tree():root(NULL){}
};

void insert(tree &t, node *z){
	node *y = NULL;
	node *x = t.root;
	while(x!=NULL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		}else{
			x = x->right;
		}
	}

	if(y==NULL){
		t.root = z;
	}else if(z->key < y->key){
		y->left = z;
	}else{
		y->right = z;
	}
}

void inorder(node *n){
	if(n==NULL)return;
	inorder(n->left);
	cout << " " << n->key;
	inorder(n->right);
}

void preorder(node *n){
	if(n==NULL)return;
	cout << " " << n->key;
	preorder(n->left);
	preorder(n->right);
}

bool find(node *n, int key){
	if(n==NULL)return false;
	if(key==n->key)return true;
	if(key < n->key)return find(n->left, key);
	return find(n->right, key);
}

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	ll sum = 0;
	vector<pll> line;
	bool flag = false;
	rep(i, n){
		ll a, b;
		cin >> a >> b;
		if(a<b){
			ans += b;
			flag = true;
		}else if(a>b){
			line.emplace_back(b, a-b);
		}else{
			sum += b;
		}
	}
	sort(all(line), greater<pll>());
	line.pop_back();
	if(flag){
		foreach(i, line){
			ans += i.first;
		}
		ans += sum;
	}

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




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repn(i, n) for(int i=1;i<=n;i++)

int n, k, a[105], b[105], ans[1005], mn=100000, mx=-100000;
int main(){
	cin >> k;
	repn(i, k){
		cin >> a[i];
		n += a[i];
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	if(2*mn < mx){
		cout << -1 << '\n';
		return 0;
	}
	int las = 0;
	repn(id, n){
		repn(i, k){
			if(a[i] == 0) continue;
			bool OK = 0;
			for(int add=0;add<k;add++){
				if(n-id < add || add+id-las > k) break;
				if(add+id < k) continue;
				memcpy(b, a, sizeof(a));
				b[i]--;
				bool ex[105] = {};
				for(int x=id+add-k+1;x<id;x++) ex[ans[x]] = 1;
				ex[i] = 1;
				int cnt = 0;
				repn(x, k){
					if(!ex[x]){
						cnt++; if(a[x] == 0) cnt++; b[x]--;
					}
				}
				if(cnt != add) continue;
				if(n-id-add <= k){
					bool bad = 0;
					repn(x, k){
						if(b[x] > 1) bad = 1;
					}
					if(!bad){
						repn(x, k){
							if(!ex[x]){
								if(b[x] == 0) b[x]++;
								else bad = 1;
							}
						}
					}
					if(!bad){
						for(int x=id;x>=1;x--){
							int v = (x==id?i:ans[x]);
							if(b[v] >= 1) break;
							else b[v]++;
						}
					}
					bad = 0;
					repn(x, k) if(b[x] != 1) bad = 1;
					if(!bad){
						OK = 1; break;
					}
				}
				else{
					mn = 100000, mx = -100000;
					repn(x, k){
						mn = min(mn, b[x]);
						mx = max(mx, b[x]);
					}
					if(2*mn >= mx){
						OK = 1; break;
					}
					if(2*mn+1 < mx){
						continue;
					}
					bool need[105] = {};
					repn(x, k){
						if(b[x] == mx) need[x] = 1;
					}
					bool bad = 0;
					repn(x, k){
						if(!ex[x]){
							if(need[x] == 1) bad = 1;
							need[x] = 1;
						}
					}
					if(!bad){
						for(int x=id;x>=1;x--){
							int v = (x==id?i:ans[x]);
							if(need[v]) break;
							need[v] = 1;
						}
					}
					bad = 0;
					repn(x, k){
						if(!need[x] && mn == b[x]) bad = 1;
					}
					if(!bad){
						OK = 1; break;
					}
				}
			}
			if(OK){
				ans[id] = i;
				if(id >= k){
					unordered_set<int>S;
					for(int i=id-k+1;i<=id;i++) S.insert(ans[i]);
					if(S.size() == k) las = id;
				}
				a[i]--;
				break;
			}
		}
		cout << ans[id] << ' ';
	}
	cout << '\n';
	return 0;
}

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> A(H, vector<char>(W));
	set<int> Cols, Rows;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
			if (A[i][j] == '#') {
				Cols.insert(i);
				Rows.insert(j);
			}
		}
	}
	for (int c : Cols) {
		for (int r : Rows) cout << A[c][r];
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <fstream>
#define F first
#define S second
#define PI 3.141592653589793238
#define pb push_back

using namespace std;

//doesn't work for arrays
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*const lli mod=1000000007;

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

lli binpow(lli x,lli y,lli m)
{
    if (y==0)
        return 1;
    lli p=binpow(x,y/2,m)%m;
    p=(p*p)%m;
    if(y%2)
        return (x*p)%m;
    else
        return p;
}

lli modi(lli a,lli m)
{
    return binpow(a,m-2,m);
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i,j,tt=1;
    //cin>>tt;
    while(tt--)
    {
        string s,t;
        cin>>s>>t;
        int ns=s.length(),nt=t.length();
        int ans=1e9;
        for(i=0;i<=ns-nt;i++)
        {
            int ct=0;
            for(j=0;j<nt;j++)
            {
                if(s[i+j]!=t[j])
                    ct++;
            }
            ans=min(ans,ct);
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  map<pair<string, string>, int> m;
  REP(i,1<<n) {
    string l, r;
    REP(j,n) {
      if ((i>>j) & 1) {
        l += s[j];
      } else {
        r = s[j] + r;
      }
    }
    ++m[make_pair(l, r)];
  }
  ll cnt = 0;
  REP(i,1<<n) {
    string l, r;
    REP(j,n) {
      if ((i>>j) & 1) {
        l += s[j+n];
      } else {
        r = s[j+n] + r;
      }
    }
    if (m.count(make_pair(r, l))) {
      cnt += m[make_pair(r, l)];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 43648
#include <stdio.h>
#include <math.h>
int n, count = 0;
double rad = M_PI/3;
void draw(double x1, double y1, double x5, double y5, int count);
int main(){
  double x1 = 0.0, x2 = 100.0, x5, y5;
  scanf("%d", &n);
  printf("%f %f\n", x1, x1);
  if(n == 0){
    printf("%f %f\n", x2, x1);
  }
  else draw(x1, x1, x2, x1, count);
return 0; }
void draw(double x1, double y1, double x5, double y5, int count){
  double x2, y2, x3, y3, x4, y4;
  x2 = (2*x1+x5)/3.0;
  y2 = (2*y1+y5)/3.0;
  x4 = (x1+2*x5)/3.0;
  y4 = (y1+2*y5)/3.0;
  x3 = x2+(x4-x2)*cos(rad)-(y4-y2)*sin(rad);
  y3 = y2+(x4-x2)*sin(rad)+(y4-y2)*cos(rad);
  count++;
  if(count < n){
    draw(x1, y1, x2, y2, count);
    draw(x2, y2, x3, y3, count);
    draw(x3, y3, x4, y4, count);
    draw(x4, y4, x5, y5, count);
} else{
    printf("%f %f\n", x2, y2);
    printf("%f %f\n", x3, y3);
    printf("%f %f\n", x4, y4);
    printf("%f %f\n", x5, y5);
} }



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

int main(){
  int n,m,v[110],num[110];
  while(scanf("%d%d",&n,&m),n+m){
    for(int i=0;i<99;i++)num[i] = 0;
    int h=0,w=0;
    for(int i=0;i<n;i++){
      scanf("%d",&v[i]);
      h = max(h,++num[v[i]/m]);
      w = max(w,v[i]/m);
    }
    double res = 0.01;
    for(int i=0;i<w;i++)res += (double)num[i]/h * (double)(w-i)/w;
    printf("%.9lf\n",res);
  }
}

Measured memory_bytes: 1068
N = int(input())
a = list(map(int,input().split()))
Q = int(input())
cnt = [0]*1000001
result = 0
for i in a:
    cnt[i] += 1
    result += i
for j in range(Q):
    b,c = map(int,input().split())
    cnt[c] += cnt[b]
    n = cnt[b]
    cnt[b] = 0
    result += (c-b)*n
    print(result)



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

using namespace std;

int a[100500];
int k;

int check(long long n) {
    for (int i = 0; i < k; i++)
        n -= n % a[i];
    if (n > 2)
      return 1;
    if (n == 2)
        return 0;
    return -1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> k;
    for (int i = 0; i < k; i++)
        cin >> a[i];
    long long l, r, m;
    l = 0; r = 1e18;
    while (l + 1 < r) {
        m = (l + r) >> 1;
        if (check(m) <= 0)
            l = m;
        else
            r = m;
    }
    long long ans1 = l;
    l = -1; r = 1e18;
    while (l + 1 < r) {
        m = (l + r) >> 1;
        if (check(m) < 0)
            l = m;
        else
            r = m;
    }

    long long ans2 = r;

    if (check(ans1) != 0 || check(ans2) != 0) {
        cout << -1;
        return 0;
    }
    cout << ans2 << " "<< ans1;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }
using namespace std;

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;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
using namespace std;

int main() {
    string s;
    cin >> s;
    int fir = stoi(s.substr(0, 2));
    int sec = stoi(s.substr(2, 4));
    if (sec <= 12 && 0 < sec && fir > 0 && fir <= 12) {
        cout << "AMBIGUOUS" << endl;
    } else if (sec <= 12 && sec > 0) {
        cout << "YYMM" << endl;
    } else if (fir <= 12 && fir > 0) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5)
#define INFL LLONG_MAX
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;



int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	FIO;

	// Write your code here

	int t = 1;
	//cin >> t;
	while (t--) {
		ll n, k;
		cin >> n >> k;
		vl v(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}

		vl rep(n + 10, -1);
		//rep[1] = 1;
		ll cur = 1;
		ll lim = 0;
		ll i = 1;
		while (k--) {
			if (rep[cur] != -1) {
				lim = i - rep[cur];
				break;
			} else {
				rep[cur] = i;
				cur = v[cur - 1];
				//cout << cur << " ";
			}
			i++;
		}
		k++;
		if (lim == 0) {
			cout << cur << "\n";
			return 0;
		}
		ll ans = k % lim;
		ll result = cur;
		while (ans--) {
			result = v[cur - 1];
			cur = result;
		}

		cout << result << "\n";
	}


	return 0;
}

Measured memory_bytes: 6344
N, D = list(map(int,input().split()))

X=[]

for i in range(N):
    X.append(list(map(float,input().split())))

num=0
for i in range(N):
    for j in range(i+1,N):
        dis = 0
        for d in range(D):
            dis += (X[i][d]-X[j][d])**2
        dis = dis**0.5
        dis2 = float(round(dis))

        if abs(dis-dis2) < 0.0000000001:
            num+=1
print(num)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005

int n,ans=1;
int t[MAX];
int L[MAX],R[MAX];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&t[i]);
  L[0]=1;
  for(int i=1;i<n;i++){
    L[i]=(t[i]==t[i-1]?1:L[i-1]+1);
    ans=max(ans,L[i]);
  }
  L[n]=L[n-1];
  R[n-1]=1;
  for(int i=n-2;i>=0;i--){
    R[i]=(t[i]==t[i+1]?1:R[i+1]+1);
    ans=max(ans,R[i]);
  }
  R[n]=0;
  
  for(int i=1;i<n;i++){
    int target=i+R[i];    
    ans=max(ans,L[i-1]+R[i]+R[target]);
  }
  printf("%d\n",ans);
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int A[N+2];
  A[0] = 0;
  A[N+1] = 0;
  int S = 0;
  int before = 0;
  for(int i=1;i<N+1;i++) cin >> A[i];
  for(int i=1;i<N+2;i++){
    S += abs(A[i]-A[i-1]);
  }
  for(int i=1;i<N+1;i++){
    cout << S - (abs(A[i+1]-A[i])) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]) << endl;
  }
  /*
  for(int i=0;i<N;i++){
  	sum = 0;
	  before = 0;
	  for(int j=0;j<N;j++){
	    if(i!=j){
	      sum += abs(A[j] - before);
	  	  before = A[j];
	    }
  	}
  	sum += abs(before);
  	cout << sum << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

char s[N];

int main() {
	 scanf("%s",s);
	 if(s[0] == 'A') putchar('T');
	 if(s[0] == 'T') putchar('A');
	 if(s[0] == 'G') putchar('C');
	 if(s[0] == 'C') putchar('G');
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int r;
    R(r);
    if(r<1200)W("ABC");
    else if(r<2800)W("ARC");
    else W("AGC");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int p,q,r;
    cin >> p >> q >> r;
    cout << min(p+q, min(p+r,q+r)) << endl;
}


Measured memory_bytes: 256