akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>
 
#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
using ll = long long;
using pii = std::pair<int,int>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;
 
const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 10241024;
const ll INFL = (1ll << 62) - 1;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//
 
template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}
 
//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}
 
inline void IN(void){
  return;
}
 
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}
 
inline void OUT(void){
  cout << "\n";
  return;
}
 
template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}
//_____________________　following sorce code_________________________//
int n,m,k;
//vvll dp(400, vll(400));
string S;
vll cost(1 << 16);
int a,b,c;
int h,w;
vvi v;
vi u;
int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  u = vi(3);
  rep(i,3){
    IN(u[i]);
  }
  sort(All(u));
  if(u[0] == u[1]){
    if(u[1] != u[2]){
      OUT("Yes");
      return 0;
    }
  }
  reverse(All(u));
  if(u[0] == u[1]){
    if(u[1] != u[2]){
      OUT("Yes");
      return 0;
    }
  }
  OUT("No");
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}

Measured memory_bytes: 768
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

a,b=MI()
if (a+b)%2==0:
    print((a+b)//2)
else:
    print("IMPOSSIBLE")

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

namespace CS.Solve
{
    class Program
    {
        static void Main(string[] args)
        {
            var givenN = int.Parse(Console.ReadLine());
            var TA = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            var givenT = TA[0];
            var givenA = TA[1];
            var givenH = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            var MinTemp = double.MaxValue;
            int result = 0;
            for(int i = 0; i < givenN; i++)
            {
                double tmpTemp = givenT - 0.006 * givenH[i];
                double diff = Math.Abs(tmpTemp - givenA);
                if(diff < MinTemp)
                {
                    MinTemp = diff;
                    result = i;
                }
            }
            Console.WriteLine(result + 1);
        }
    }
}


Measured memory_bytes: 13312
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ppb pop_back
typedef long long ll;
const int N=200000;
int n;
int a[N+1];
vector<int> nei[N+1];
int sz[N+1],cc_sz[N+1],cc_sz1[N+1];
int fa[N+1];
vector<int> stk,stk_c[N+1];
void dfs(int x=1){
//	cout<<x<<"\n";
	sz[x]=1;
	stk_c[a[x]].pb(stk.size());
	stk.pb(x);
	for(int i=0;i<nei[x].size();i++){
		int y=nei[x][i];
		if(y==fa[x])continue;
		fa[y]=x;
		dfs(y);
		sz[x]+=sz[y];
	}
	stk.ppb();
	stk_c[a[x]].ppb();
	if(stk_c[a[x]].size()>1)cc_sz[stk[stk_c[a[x]].back()+1]]-=sz[x];
	else cc_sz1[a[x]]-=sz[x];
}
ll ans[N+1];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		nei[x].pb(y);nei[y].pb(x);
	}
	stk.pb(0);
	for(int i=1;i<=n;i++)stk_c[i].pb(0);
	dfs();
	for(int i=1;i<=n;i++)cc_sz[i]+=sz[i],cc_sz1[i]+=n;
//	for(int i=1;i<=n;i++)cout<<cc_sz[i]<<" ";puts("");
//	for(int i=1;i<=n;i++)cout<<cc_sz1[i]<<" ";puts("");
	for(int i=1;i<=n;i++)ans[i]=1ll*n*(n+1)/2;
	for(int i=2;i<=n;i++)ans[a[fa[i]]]-=1ll*cc_sz[i]*(cc_sz[i]+1)/2;
	for(int i=1;i<=n;i++)ans[i]-=1ll*cc_sz1[i]*(cc_sz1[i]+1)/2;
	for(int i=1;i<=n;i++)cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 51396
#include<iostream>

using namespace std;
int main() {
  long int n, max,min,sum=0,a;
  cin >> n;
  for(int i=0; i<n ;i++) {
    cin >> a;
    if(i == 0) {
      min = a;
      max = a;
    }
    if(a < min) min = a;
    if(a > max) max = a;
    sum += a;
  }
  cout << min << ' ' << max << ' ' << sum << endl;
  return 0;
}



Measured memory_bytes: 3100
// Approach: count the number of size-k partitions of the integer n
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> P(2, vector<int>(N + 1));
  P[0][0] = 1;
  for (int k = 1; k <= K; ++k) {
    for (int i = 0; i <= N; ++i) {
      if (i < k)
        P[k % 2][i] = 0;
      else
        P[k % 2][i] = (P[!(k % 2)][i - 1] + P[k % 2][i - k]) % 1000000007;
    }
  }
  cout << P[K % 2][N] << endl;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  if(A == 0 && B == 0) {
    cout << 0 << endl;
  }
  else {
    ll Q = N % (A+B);
    if(Q > A) {
      cout << (N / (A+B) + 1) * A << endl;
    }
    else {
      cout << (N / (A + B)) * A + Q << endl;
    }
  }
}


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

int N, A, B, C;
vector<int> l;
int dfs(int n, int a, int b, int c) {
	if (n == N) {
		if (a == 0 || b == 0 || c == 0) {
			return 2e5;
		}
		int tmp = abs(a-A) + abs(b-B) + abs(c-C) - 30;
		return tmp; 
	}

	int ans1 = dfs(n+1, a, b, c);
	int ans2 = dfs(n+1, a+l[n], b, c) + 10;
	int ans3 = dfs(n+1, a, b+l[n], c) + 10;
	int ans4 = dfs(n+1, a, b, c+l[n]) + 10;

	return min({ans1, ans2, ans3, ans4});
}


int main() {
	cin >> N >> A >> B >> C;
	l.resize(N);
	rep(i, N) cin >> l[i];

	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

// 最大公約数
ll gcd(ll a, ll b) {
    if(a==0) return b;
    if(b==0) return a;
    if(a<b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    ll r = a%b;
    while(r!=0) {
        ll tmp_r = r;
        r = b % r;
        b = tmp_r;
    }
    return b;
}

int main() {
    int n; cin >> n;
    vector<ll> a(n+2);
    for(int i=1; i<n+1; i++) cin >> a[i];
    vector<ll> gcds(n);
    ll ans = 0;
    vector<int> l(n+2, 0), r(n+2, 0);
    for(int i=1; i<n+1; i++) {
        l[i] = gcd(l[i-1], a[i]);
        r[n-i+1] = gcd(r[n-i+2], a[n-i+1]);
    }

    for(int i=1; i<n+1; i++) {
        ans = max(ans, gcd(l[i-1], r[i+1]));   
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	char a;
	cin>>a;
	if(a=='A'){
		cout<<"T"<<endl;
	}
	if(a=='T'){
		cout<<"A"<<endl;
	}
	if(a=='C'){
		cout<<"G"<<endl;
	}
	if(a=='G'){
		cout<<"C"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int, int>;

int main() {
  char a, b;
  cin >> a >> b;
  if ((a=='H' && b=='H') || (a=='D' && b=='D')) {
    cout << 'H' << endl;
  }
  else {
    cout << 'D' << endl;
  }
}


Measured memory_bytes: 3456
n,k = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(n)]
k_ = k.bit_length()
ans = sum(b for a,b in l if k|a == k)
for i in range(k_):
  if k&2**i == 0:
    continue
  nk = ((k>>i)<<i) - 1
  ac = 0
  for a,b in l:
    if nk|a == nk:
      ac += b
  if ac > ans:
    ans = ac
print(ans)

Measured memory_bytes: 18628
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;




int main() {

	
	string p, a;
	cin >> p >> a;
	if (a.size() > p.size()) {
		cout << "UNRESTORABLE" << endl;

		return 0;

	}
	for (int i = p.size() - a.size(); i >=0; i--) {
		
		bool f = 1;
		string x = p.substr(i,a.size());
	//	cout << x << endl;

		for (int j = 0; j < x.size(); j++) {
			if (a[j] != x[j]&&x[j]!='?')f = 0;
		}
		//cout << f;
		if (f) {
			for (int j = 0; j < i; j++) {
				if (p[j] != '?')cout << p[j];
				else cout << 'a';
			}
			cout << a;
			for (int j = i + a.size(); j < p.size(); j++) {
				if (p[j] != '?')cout << p[j];
				else cout << 'a';
			}
			cout << endl;
			return 0;

		}

	}
	cout << "UNRESTORABLE" << endl;

		return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[110];
    cin >> N;
    rep(i,0,N) cin >> a[i];
    sort(a,a+N);
    print(a[N-1]-a[0]);
}

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

int main() {
  int N;
  scanf("%d", &N);

  string ans = "";
  while (N != 0) {
    if (N % 2 != 0) {
      N--;
      ans = "1" + ans;
    } else {
      ans = "0" + ans;
    }
    N /= -2;
  }

  if (ans == "") ans = "0";

  printf("%s", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    int n;
    cin >> n;
    int a[n + 1], ans[n + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        ans[a[i]] = i;
    }
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


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

namespace atcoder_BegginerContest95_Question1
{
    class Program
    {
        static void Main(string[] args)
        {
            var price = 700;
            string str = Console.ReadLine();
            foreach (var s in str)
            {
                if (s == 'o') price += 100;
            }

            Console.WriteLine(price);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator() (int n, int k) {
        if ( k < 0 || k > n ) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
} comb(500005);


int N, M, K;

int main() {
    cin >> N >> M >> K;
    mint res = 0;
    rep(i,N) {
        res += mint(i) * mint(N - i) * mint(M).pow(2);
    }
    rep(j, M) {
        res += mint(j) * mint(M - j) * mint(N).pow(2);
    }
    cout << res*comb(M*N-2, K-2) << endl;
}

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

namespace atcoder1124
{
    static class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] frames = new int[N];
            for (int i = 0; i < N; i++)
            {
                frames[i] = int.Parse(input[i]);
            }
            frames.Average();
            List<int> inputList = frames.ToList<int>();
            int sumbnail = Program.Nearest(frames, (float)inputList.Average());

            for (int i = 0; i < N; i++)
            {
                if (frames[i] % sumbnail == 0)
                {
                    Console.WriteLine(i);
                    break;
                }
            }
        }

        public static int Nearest(this IEnumerable<int> self, float target)
        {
            var min = self.Min(c => Math.Abs(c - target));
            return self.First(c => Math.Abs(c - target) == min);
        }
}
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

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

		int num = sc.nextInt();
		int[] intArray = new int[num];

		for(int i = 0; i < num; i++)
		{
			intArray[i] = sc.nextInt();
		}

		long humidai = 0;
		int targetNum = 0;
		for(int i = 0; i < num; i++)
		{
			if(targetNum < intArray[i]) {
				targetNum = intArray[i];
				continue;
			}

			humidai += targetNum - intArray[i];
		}

		System.out.print(humidai);
	}
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

int main() {
    struct s{
        int c;
        int s;
        int f;
    };
    int n;
    cin >> n;
    vector
 v(n-1);
    rep(i, n-1) cin >> v[i].c >> v[i].s >> v[i].f;

    rep(i, n){
        int sec = 0;
        for(int j = i; j < n-1; j++){
            if(sec < v[j].s){ //始発発車前
                sec = (v[j].s + v[j].c);
            }else{
                if(sec % v[j].f == 0) sec += v[j].c;
                else sec += v[j].f + v[j].c - (sec % v[j].f);
            }
        }
        cout << sec << endl;
    }
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>

signed main(){
	int n,t; cin>>n>>t;
	int ans=INF;
	for(int i=0; i<n; i++){
		int a,b; cin>>a>>b;
		if(b<=t) ans=min(ans,a);
	}
	if(ans!=INF) cout<<ans<<en;
	else cout<<"TLE"<<en;
}



Measured memory_bytes: 256
def solve():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    X.sort()
    diff = []
    for i in range(M-1):
        diff.append(X[i+1] - X[i])
    
    diff.sort(reverse=True)
    print(X[-1] - X[0] - sum(diff[:min(N,M)-1]))

if __name__ == '__main__':
    solve()

Measured memory_bytes: 13968
N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
AA = A[:]
AA.remove(A_max)
A_max_2nd = max(AA)
for num in A:
    if num != A_max:
        print(A_max)
    else:
        print(A_max_2nd)

Measured memory_bytes: 14060
import java.util.*;


class Main{

    Main(){
        Scanner sc = new Scanner(System.in);
        
        int x=sc.nextInt(),y=sc.nextInt();
        int ans=0;
        
        for(int i=0;i<100000000;i++){
            ans++;
            ans--;
        }
        
        for(int i=0;i<x;i++){
            for(int j=0;j<y;j++){
                ans++;
            }
        }
            
        System.out.println(ans);
    }
    
    public static void main(String[] args){
        new Main();
    }
}

Measured memory_bytes: 19060
#include<stdio.h>
int main(void)
{
	int a,b,c,i;
	scanf("%d%d%d",&a,&b,&c);

	
	
	for(i=1; i<=a-b; i++){
		c--;
		if(c==0)
		break;
	}
		
	
	printf("%d",c);
	
	return 0;
}

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

int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%1000000007;
  	int memo=modpow(a,b/2);
	return memo*memo%1000000007;
}
int inv(int x){
    x=modpow(x,1000000005);
    return x;
}
signed main(){
	int n;
	int a[10000];
	map<int,int>m;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        int b=a[i];
        for(int j=2;j*j<=b;j++){
            int cnt=0;
            while(b%j==0){
                b/=j;
                cnt++;
            }
            m[j]=max(m[j],cnt);
        }
        if(b!=1)m[b]=max(m[b],1ll);
    }
  	int pr=1;
    for(pair<int,int> p:m){
        pr*=modpow(p.first,p.second);
      	pr%=1000000007;
    }
	int ans=0;
	rep(i,n){
		ans+=pr*inv(a[i]);
      ans%=1000000007;
    }
  	cout<<ans%1000000007<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  bool iskeep = true;
  for (int i = 0; i < N; ++i) {
    cin >> S[i];
    if (i == 0) continue;
    if (S[i -1].back() != S[i][0]) iskeep = false;
  }
  sort(S.begin(), S.end());
  for (int i = 1; i < N; ++i) {
    if (S[i - 1] == S[i]) iskeep = false;
  }
  cout << (iskeep ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [i32; n]
    }

    solve(k, &mut p);
}

fn solve(k: usize, p: &mut [i32]) {
    p.sort();

    let mut s = 0;
    for i in 0..k {
        s += p[i];
    }

    println!("{}", s);
}


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

int main() {

    string s,t,u;
    int a,b;

    cin >> s >> t >> a >> b >> u;

    if (u == s) {
        cout << (a-1) << " " << b << endl;
    }

    if (u == t){
        cout << a << " " << (b-1) << endl;
    }

}

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

using namespace std;

int n,a,b,c;
int res=1000000000;
vector<int> v;

int ab(int e)
{
    if(e>=0) return e;
    else return -e;
}

int solve(vector<int> x,int len)
{
    int cnt=1000000000;
    for(int o=1;o<(1<<x.size());o++)
    {
        int temp=0;
        int y=0;
        int op=-1;
        for(int i=0;i<(int)x.size();i++)
        {
            if((o>>i)&1)
            {
                y+=x[i];
                op++;
            }
        }
        temp=10*op+ab(y-len);
        cnt=min(cnt,temp);
    }
    return cnt;
}

int distribute(vector<int> x)
{
    set<int> s;
    for(int i=0;i<n;i++) s.insert(x[i]);
    if(s.size()<3) return 1000000000;
    vector<int> d[3];
    for(int i=0;i<n;i++) d[x[i]].push_back(v[i]);
    int cnt=solve(d[0],a)+solve(d[1],b)+solve(d[2],c);
    return cnt;
}

void p(int idx,vector<int> x)
{
    if(idx==n) res=min(res,distribute(x));
    else
    {
        for(int i=0;i<3;i++)
        {
            x[idx]=i;
            p(idx+1,x);
        }
    }
}

int main()
{
    cin >> n >> a >> b >> c;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin >> temp;
        v.push_back(temp);
    }
    vector<int> x(n);
    p(0,x);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
char ss[100];
ll num[maxn];
ll sum=0;
start{
    /**double a,b,t;
    cin>>a>>b>>t;
    double sum=0,temp=a;
    while(a<=(t+0.5)){
        sum+=b;
        a+=temp;
    }
    cout<<sum;**/
    ll n=read;

    for(int i=1;i<=n;i++) num[i]=read;
    for(int i=1;i<=n-1;i++){
        if(num[i]<0){
            num[i+1]*=-1;
            num[i]*=-1;
        }
        sum+=num[i];
    }
    sum+=num[n];
    ///ll temp=*min_element(num+1,num+n);
    sort(num+1,num+n);
    ll temp=num[1];
    if(num[n]<0) sum=max(sum,sum-2*num[n]-2*temp);
    printf("%lld\n",sum);
	end;
}


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

using namespace std;

int main() {
	// your code goes here
	
	int n,m;
	cin>>n>>m;
	
	vector<int>tasks[m+1];
	
	priority_queue<int,vector<int>> pq;
	
	for(int i=1;i<=n;i++){
		
		int a,b;
		cin>>a>>b;
		
		if(a<=m)
			tasks[a].push_back(b);
	
	}
	
	long long ans=0;
	
	for(int i=1;i<=m;i++){
		
		for(auto x:tasks[i]){
			pq.push(x);	
		}
		
		if(!pq.empty()){
			ans+=pq.top();
			pq.pop();
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
   long long n;
   cin >> n;
   int ans = 0;
   for(int i = 2; i <= 1000000;i++)
   {
       int cur = 0;
       while(n%i==0)
       {
           cur++;//gaunu kiek kartu galiu n padalint is i laipsnio
           n/=i;
       }
       for(int j = 1; j <= 10000; j++)
       {
           if(cur<j)break;
           ans++;cur-=j;//atimineju kiekvieno pirminio laipsnius
       }
   }
   if(n>1)ans++;
    cout << ans;
}


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

using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> v(n + 1, 0);
    for (int i = 0; i < n; i++) scanf("%d", &v[i]);
    sort(v.begin(), v.end());
    int zero = find(v.begin(), v.end(), 0) - v.begin();

    int res = 1e9;
    if(zero >= k){
        res = min(res, abs(v[zero - k]));
    }
    if(zero + k < v.size()){
        res = min(res, v[zero + k]);
    }
    for(int i=zero; i<zero + k && i < v.size(); i++){

        int aft = v[i];
        int rem = k - (i - zero);
        if(zero - rem < 0) continue;
        int bef = -v[zero - rem];
        res = min(res, min(aft * 2 + bef, bef * 2 + aft));
    }
    printf("%d\n", res);
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long H1 = long.Parse(str[0]);
		long M1 = long.Parse(str[1]);
		long H2 = long.Parse(str[2]);
		long M2 = long.Parse(str[3]);
		long K = long.Parse(str[4]);
		long ans = (H2-H1)*60+(M2-M1)-K;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17892
N = int(input())
lr = []
for i in range(N):
    x,l = map(int,input().split())
    LR = [x-l,x+l]
    lr.append(LR)
lr.sort(key=lambda x:x[1])
ans = 1
rb = lr[0][1]
for i in range(1,N):
    if lr[i][0] >= rb:
        rb = lr[i][1]
        ans += 1
print(ans)


Measured memory_bytes: 21336
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

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

	if(N%2==1){
		if(N/2 >= K-1){
			puts("YES");
		}else{
			puts("NO");
		}
	}else{
		if(N/2 >= K){
			puts("YES");
		}else{
			puts("NO");
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    int n;
    int a[100005], b[100005];
    cin >> n;
    rep(i,n) cin >> a[i] >> b[i];

    long long ans = 0, sum = 0;
    for(int i = n - 1; i >= 0; i--){
        int plus = b[i] - (sum + a[i]) % b[i];
        if(plus == b[i]) continue;
        ans += plus;
        sum += plus;
    }
    cout << ans << endl;
}


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

int main() {
    string name[9];
    int c[9], d[9];
    for (int i = 0, a, b; i < 9; i++) {
        cin >> name[i] >> a >> b;
        c[i] = a + b;
        d[i] = 200 * a + 300 * b;
    }
    for (int i = 0; i < 9; i++) {
        cout << name[i] << ' ' << c[i] << ' ' << d[i] << endl;
    }
}


Measured memory_bytes: 3172
# Union-Find木（サイズ付き）
class UnionFind():
    def __init__(self, n):  # n要素で初期化　初めは全ての頂点が別々の木の根
        self.parent = [None] * n # 親
        self.rank = [None] * n   # 木の深さ
        self._size = [1] * n # 要素が属する集合の大きさ（根の要素のみ参照すること）
        for i in range(n):
            self.parent[i] = i
            self.rank[i] = 0

    # 木の根を求める
    def root_of(self, x):
        children = [x]
        while self.parent[x] != x:
            x = self.parent[x]
            children.append(x)

        for ch in children: # 根の子供として張りなおす
            self.parent[ch] = x

        return x

    # xとyの属する集合を併合
    def unite(self, x, y):
        rx = self.root_of(x)
        ry = self.root_of(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]: # ランクの小さい木から大きい木の根に辺を張る
            self.parent[rx] = ry  # rxをryの子とする
            self._size[ry] += self._size[rx]
        elif self.rank[rx] == self.rank[ry]:
            self.parent[ry] = rx
            self.rank[rx] += 1
            self._size[rx] += self._size[ry]
        else:
            self.parent[ry] = rx
            self._size[rx] += self._size[ry]

    # 同じ集合に属するかどうか
    def is_same(self, x, y):
        return self.root_of(x) == self.root_of(y)

    # 頂点xが属する集合のサイズ
    def size(self, x):
        return self._size[self.root_of(x)]

# 入力
N, M = [int(x) for x in input().split()]
A = [None] * M
B = [None] * M
for i in range(M):
    A[i], B[i] = [int(x) - 1 for x in input().split()]


# 島同士が全く繋がっていない状態からスタート
# M-1番目, M-2番目, ..., , 2番目, 1番目の橋の順に橋をかけていく
inconv = [-1] * (M - 1) + [N * (N - 1) // 2]    # 不便さ

uf = UnionFind(N)

for i in range(M - 1, 0, -1):
    # i番目の橋をかける
    if not uf.is_same(A[i], B[i]):
        size_a = uf.size(A[i]) # A[i]が属する集合の大きさ
        size_b = uf.size(B[i]) # B[i]が属する集合の大きさ
        inconv[i - 1] = inconv[i] - size_a * size_b
        uf.unite(A[i], B[i])
    else:
        inconv[i - 1] = inconv[i]

for i in range(M):
    print(inconv[i])

Measured memory_bytes: 78580
#include <iostream>
#include <algorithm>
#include <array>

int main()
{
	std::array<int,10> mh;
	for (int &el : mh){
		std::cin >> el;
	}
	std::sort(mh.begin(), mh.end());

	std::cout << *(mh.end() -1) << std::endl;
	std::cout << *(mh.end() - 2) << std::endl;
	std::cout << *(mh.end() - 3) << std::endl;

}

Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vi v;
    int hoge=0;
    for(int i=1; i<=n; i++){
        if(i+hoge>n){break;}
        v.push_back(i);
        hoge+=i;
    }
    int num=n-hoge;
    for(int i =0; i<num;i++){
        v[v.size()-1-i]+=1;
    }
    rep(i,v.size())cout<<v[i]<<endl;
    
}


Measured memory_bytes: 384
/**
*    created: 01.07.2020 13:55:46
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int mod = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    set<char> a{s[0],s[1],s[2]};
    set<char> b{'a','b','c'};
    if (a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

struct Node{
    int key;
    Node *parent;
    Node *left;
    Node *right;
};

Node *root, *NIL;

void inorder(Node *T){
    if (T == NIL) 
        return;
    inorder(T->left);
    std::cout << ' ' << T->key;
    inorder(T->right);
}

void preorder(Node *T){
    if (T == NIL) 
        return;
    std::cout << ' ' << T->key;
    preorder(T->left);
    preorder(T->right);
}

void infree(Node *T){
    if (T == NIL)   
        return;
    infree(T->left);
    delete T;
    infree(T->right);
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = new Node;
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while (x != NIL){
        y = x;
        if (x->key < z->key) 
            x = x->right;
        else 
            x = x->left;
    }
    z->parent = y;
    if 
        (y == NIL) root = z;
    else if (z->key > y->key) 
        y->right = z;
    else 
        y->left = z;
    return;
}

Node* find(int k){
    Node *a = root;
    while (a != NIL){
        if (a->key == k){
            return a;
        }
        else if (a->key < k) 
            a = a->right;
        else if (a->key > k) 
            a = a->left;
    }
    return NIL;
}

Node* getmin(Node *t){
    while(t->left != NIL) 
        t = t->left;
    return t;
}

Node* getnext(Node *t){
    if (t->right != NIL) 
    return getmin(t->right);
    Node *x = t->parent;
    while(x != NIL && t == x->right){
        t = x;
        x = x->parent;
    }
    return x;
}

void delnode(int k){
    //x:削除対象Node
    //y:実際に削除するNode
    //z:yの子Node
    Node *z = find(k);
    Node *y;
    Node *x;
    if (z->left == NIL || z->right == NIL)
        y = z;
    else
        y = getnext(z);
    if (y->left != NIL)
        x = y->left;
    else
        x = y->right;
    if (x != NIL)
        x->parent = y->parent;
    if (y->parent == NIL)
        root = x;
    else if (y->parent->left == y)
        y->parent->left = x;
    else if (y->parent->right == y)
        y->parent->right = x;
    if (y != z)
        z->key = y->key;
    delete y;
    return;
}

int main(){
    int m;
    std::cin >> m;
    std::string s;
    int k;
    for (int i = 0; i < m; i++){
        std::cin >> s;
        if (s == "insert"){
            std::cin >> k;
            insert(k);
        }
        else if (s == "print"){
            inorder(root);
            std::cout << std::endl;
            preorder(root);
            std::cout << std::endl;
        }
        else if (s == "find"){
            std::cin >> k;
            if (find(k) != NIL) 
                std::cout << "yes" << std::endl;
            else 
                std::cout << "no" << std::endl;
        }
        else if (s == "delete"){
            std::cin >> k;
            delnode(k);
        }
    }
    infree(root);
    return 0;
}


Measured memory_bytes: 21912
#include <iostream>
#include <stdio.h>
using namespace std;
main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int n=S.size();
  int ans=0;
  for(int i=0;i<=n-3;i++){
    ans+=((S.at(i)=='A')&&(S.at(i+1)=='B')&&(S.at(i+2)=='C'));
  }
  cout<<ans;
}

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

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

using ll = long long; using vll = vector<ll>;

int main(void) {
    ios::sync_with_stdio(false); cin.tie(0);
    ll n; cin >> n;
    string t; cin >> t;
 
    vll l(n+1), r(n+1), in(n+1);
    rep(i, n) {
        l[i+1] = l[i] + (t[i] == 'M');
        r[i+1] = r[i] + (t[i] == 'C');
        in[i+1] = in[i] + l[i] * (t[i] == 'C');
    }

    ll q; cin >> q;
    rep(_, q) {
        ll k; cin >> k;
        ll ret = 0;
        rep(i, n) if (t[i] == 'D') {
            ll j = min(n, i+k);
            ret += (-in[i]+r[i]*l[i])+in[j]-l[i]*r[j];
        }
        cout << ret << endl;
    }
 
    return 0;
}


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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a,b) << " ";
  if(a+b >= n) cout << a+b-n << endl;
  else cout << 0 << endl;
}

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

int main() {
    int T, D, L;
    while (cin >> T >> D >> L, T | D | L) {
        int x, cnt = 0, sum = 0;
        for (int i = 0; i < T; i++) {
            cin >> x;
            if (x >= L) {
                cnt = D;
            } else {
                cnt--;
                cnt = max(cnt, 0);
            }
            if (cnt > 0) sum++;
        }
        if (cnt > 0) sum--;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
fs = require('fs');
input = fs.readFileSync('/dev/stdin', 'utf8');
tmp = input.split(" ");
a = parseInt(tmp[0],10);
b = parseInt(tmp[1],10);
c = parseInt(tmp[2],10);
k = parseInt(tmp[3],10);
s = 0;
if(k <= a) s=k; else if(k <= a+b) s=a; else s=a-(k-a-b)
console.log(s);


Measured memory_bytes: 30096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   vector<int> a(3);
   for (int i = 0; i < 3; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
 
  int sum= a[1]-a[0] + a[2] -a[1];
 
  
cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int func(vector<vector<char> >&, int, int);
bool can(vector<vector<char> >&, int, int);
int slide(vector<vector<char> >&, int);
void flat(vector<vector<char> >&, int, int);
class point {
public:
	vector<int> dp;
	point() {
		dp.resize(1 << 8, -1);
	}
};
vector<vector<point> > dp;
int main() {
	int H, N;
	cin >> H >> N;
	vector<vector<char> > map(4, vector<char>(H,false));
	dp.resize(4);
	for (int i = 0; i < 4; ++i) {
		dp[i].resize(H);
	}
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		map[x][y] = true;
	}
	cout << func(map, 0, 0) << endl;
	return 0;
}

bool can(vector<vector<char> >&map, int x, int y) {
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			if (map[x + i][y + j]) {
				return false;
			}
		}
	}
	return true;
}

int slide(vector<vector<char> >&map, int y) {
	int res = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = y; j < y + 2; ++j) {
			if (map[i][j]) {
				res |= 1 << (i * 2 + j-y);
			}
		}
	}
	return res;
}

int func(vector<vector<char> >&map, int x, int y) {
	if (y == map[0].size() - 1) {
		return 0;
	}
	int sli = slide(map, y);
	if (dp[x][y].dp[sli] >= 0) {
		return dp[x][y].dp[sli];
	}
	int res = 0;
	int nx, ny;
	if (x == 2) {
		nx = 0;
		ny = y + 1;
	}
	else {
		nx = x + 1;
		ny = y;
	}
	if (can(map, x, y)) {
		flat(map, x, y);
		res = 1+func(map, nx, ny);
		flat(map, x, y);
	}
	res = max(func(map, nx, ny), res);
	dp[x][y].dp[sli] = res;
	return res;
}

void flat(vector<vector<char> >&map, int x, int y) {
	for (int i = x; i < x + 2; ++i) {
		for (int j = y; j < y + 2; ++j) {
			map[i][j] = !map[i][j];
		}
	}
}

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

// state 0 => {} , state 1 => {A} 
//ABCACCBABCBCAABCB
ll solution(int pos, int state,int cnt) {
	ll ret = 0;
	if (pos == N) return 0;
	if (state == 0) {
		if (pos < N - 2) {
			if (str[pos] == 'A' && str[pos + 1] == 'B' && str[pos + 2] == 'C') {
				ret = (1 + solution(pos + 3, 1, 1));
			}
			else if (str[pos] == 'A') {
				ret = solution(pos + 1, 1, 1);
			}
			else {
				ret = solution(pos + 1, 0, 0);
			}
		}
		else {
			ret = solution(pos + 1, 0, 0);
		}
	}
	else if (state == 1) {
		if (pos < N - 1) {
			if (str[pos] == 'B' && str[pos + 1] == 'C') {
				return ret = (cnt + solution(pos + 2,1, cnt));
			}
		}
		if (str[pos] == 'A') {
			ret = solution(pos + 1, 1, cnt + 1);
		}
		else {
			ret = solution(pos + 1, 0, 0);
		}
	}
	return ret;
}

int main() {
	cin >> str;
	N = str.size();

	ll ans = solution(0, 0, 0);
	printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	string s;
	cin >> s;
	int x = stoi(s.substr(0,2));
	int y = stoi(s.substr(2,2));
	bool a = (1<=x && x<=12);
	bool b = (1<=y && y<=12);
	if(a&b) cout<<"AMBIGUOUS"<<endl;
	else if(a) cout<<"MMYY"<<endl;
	else if(b) cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;
}


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

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

	int n,x;
	string s;
	cin>>n;
	int p[101];
	vector<pair<string,int>> v;
	for(int i=0;i<n;i++){
		cin>>s>>x;
		p[x]=i+1;
		v.push_back({s,-x});
	}
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		x=v[i].second;
		cout<<p[-x]<<"\n";
	}
	
	return 0;
}

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

Measured memory_bytes: 584
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use itertools::Itertools;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut count = [0; 4];
    
    for _ in 0..3{
        let a: usize = read!();
        let b: usize = read!(); 
        
        count[a-1]+=1;
        count[b-1]+=1;
    }
    
    let c = count.iter().filter(|&&c| c%2!=0).count();
    
    println!("{}", if c == 0 || c == 2 { "YES" } else { "NO" });
}

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

int main()
{
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >>E;
    long min_var = min({A, B, C, D, E});

    cout << (N + min_var - 1) / min_var + 4 << endl;
    

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    private Scanner sc;

    private void solve() {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        boolean flag = true;
        int cnt = 0;
        int i = 0;
        while (flag) {
            flag = false;
            for (int j = N - 1; j >= i + 1; j--) {
                if (A[j] < A[j - 1]) {
                    int tmp = A[j - 1];
                    A[j - 1] = A[j];
                    A[j] = tmp;
                    flag = true;
                    cnt++;
                }
            }
            i++;
        }

        String ans = "";
        for (int num : A) {
            ans += num;
            ans += " ";
        }
        System.out.println(ans.trim());
        System.out.println(cnt);
    }

}

Measured memory_bytes: 26328
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {

  cout << fixed << setprecision(16);

  double N, M, D;
  cin >> N >> M >> D;

  double ans;
  if( D == 0 ){
    ans = (M-1.0)/N;
    cout << ans << endl;
  }else{
    ans = 2.0*(N-D)*(M-1.0)/(N*N);
    cout << ans << endl;
  }
}



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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 1e6 + 34;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = k; i < n; i++)
    {
        if (a[i] > a[i - k]) cout << "Yes\n";
        else cout << "No\n";
    }
}


Measured memory_bytes: 4044
n, k = map(int, input().split())

ans = 0
for i in range(1, n+1):
    a = ((i//k + 1)*k - i)
    if a <= n and (a * 2) % k == 0:
        p = (n - a) // k + 1
        ans = ans + p**2
print(ans)

Measured memory_bytes: 9132
#include<stdio.h>
int gcd(int x,int y){
    int r;
	if (x < y){
        r=x;
        x=y;
        y=r;
    }
    while (y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",(x+1)+(y+1)-(gcd(x,y)+1));
	return 0;
}



Measured memory_bytes: 2728