akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <iostream>

using namespace std;

int main()
{
	int N, M;

	char A, B, C;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		map<char, char> converse;

		for (char i = '0'; i <= 'z'; i++)
		{
			converse[i] = i;
		}

		for (int i = 0; i < N; i++)
		{
			cin >> A >> B;

			converse[A] = B;
		}

		cin >> M;

		for (int i = 0; i < M; i++)
		{
			cin >> C;

			cout << converse[C];
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
#cant fix re, just copy and paste.
n = int(input())
a = list(map(int, input().split()))
a.sort()
free=0
cset=set()
for rate in a:
    color = int(rate / 400)
    if color >=8:
        free+=1
    else:
        cset.add(color)

colormin=len(cset)
colormax=colormin+free
 
print(str(max(1,colormin)), colormax)  

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, k;
int a[1000];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    forn(i, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    int sum = 0;
    forn(i, k) {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
	int n;
  	cin >> n;
  	//処理
    //出力
    cout << "ABC" << n << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;
 
int main(){
  ll N,M;
  cin >> N >> M;
  vector<int> H(N+1);
  for(int i=1;i<N+1;i++){
    cin >> H[i];
  }
  map<int,int> ans;
  map<int,int> cnt;
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    cnt[A]++;
    cnt[B]++;
    if((H[A] - H[B]) > 0){
      ans[A]++;
    }else if(H[B] - H[A] > 0){
      ans[B]++;
    }
  }

  int num=0;
  for(int i=1;i<N+1;i++){
    if(cnt[i] == ans[i]) num++;
  }
  cout << num << endl;

}

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

using namespace std;

using int64 = long long;

int main() {
  int C, N, M, S[10000], P[10000];
  cin >> C >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> S[i] >> P[i];
  }

  vector< int64 > dp1(C + 1);
  for(int i = 0; i < N; i++) {
    for(int j = C; j >= S[i]; j--) {
      dp1[j] = max(dp1[j], dp1[j - S[i]] + P[i]);
    }
  }

  for(int i = 1; i <= M; i++) {
    int64 ret = 0;
    for(int j = 1; j <= C; j++) {
      if(i * j > C) continue;
      ret = max(ret, dp1[j]);
    }
    cout << ret * i << endl;
  }
}



Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

ll F(ll a, ll b) {
	return max(GetDigit(a), GetDigit(b));
}

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

	int N;
	cin >> N;
	int h[100010];
	int d[100010];


	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
	}

	d[0] = 0;

	for (int i = 1; i < N; i++)
	{
		if (i == 1) {
			d[i] = abs(h[i] - h[i - 1]);
		}
		else {
			d[i] = min(abs(h[i] - h[i - 1]) + d[i - 1], abs(h[i] - h[i - 2]) + d[i - 2]);
		}
	}

	/*for (int i = 0; i < N; i++)
	{
		cout << d[i] << " ";
	}*/

	cout << d[N - 1] << endl;

	return 0;
}

Measured memory_bytes: 1152
import sys

n,m = input().split()
n,m = int(n), int(m)


list = []

count = 0
lMin, rMax = -1, -1

for i in range(0,m) :
    l, r = input().split()

    list.append((int(l),int(r)))

    if lMin == -1 and rMax == -1:
        lMin, rMax = list[i]
    else:
        if lMin < list[i][0] :
            lMin = list[i][0]
            
        if rMax > list[i][1] :
            rMax = list[i][1]

count = rMax - lMin +1

if count < 0 : 
    count = 0

print(count)

Measured memory_bytes: 16584
using System;
using System.Collections.Generic;


namespace ConsoleApplication29
{
    class Program
    {
        static void Main(string[] args)
        {
           while(true) 
           {
            string[] str = Console.ReadLine().Split(' ');
            int m = int.Parse(str[0]);
            int f = int.Parse(str[1]);
            int r = int.Parse(str[2]);

                    if ((m == -1) && (f == -1) && (r == -1))
                    {
                        break;
                    }
                    else if ( ((m == -1) || (f == -1)))
                    {
                        Console.WriteLine("F");
                    }
                    else if (m + f >= 80)
                    {
                        Console.WriteLine("A");
                    }
                    else if (65 <= m + f && m + f < 80)
                    {
                        Console.WriteLine("B");
                    }
                    else if (50 <= m + f && m + f < 65)
                    {
                        Console.WriteLine("C");
                    }
                    else if (r >= 50)
                    {
                        Console.WriteLine("C");
                    }
                    else if (30 <= m + f && m + f < 50)
                    {
                        Console.WriteLine("D");
                    }
                    else if (m + f < 30)
                    {
                        Console.WriteLine("F");
                    } 
            }
        }
    }
}

Measured memory_bytes: 8828
#include<stdio.h>
#include<stdlib.h>

int main(){
	int* data=(int*)(malloc(sizeof(int)*60000));
	int* head=data-1;
	do{
		head++;
		scanf("%d",head);
	}while(*head!=0);
	head=data;
	while(*head!=0){
		printf("Case %d: %d\n",((int)(head-data))+1,*head);
		head++;
	}
	return 0;
}

Measured memory_bytes: 640
n, k, q = gets.split.map(&:to_i)

as = Array.new(n, 0)
q.times do
  as[gets.to_i - 1] += 1
end

(1..n).each do |p|
  if k - (q - as[p - 1]) > 0
    puts "Yes"
  else
    puts "No"
  end
end


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

int main() {
  int n;
  string s;
  cin >> n >> s;

  int min_v = 0;
  int cur = 0;
  rep(i, n) {
    cur += (s[i] == '(' ? +1 : -1);
    min_v = min(min_v, cur);
  }
  rep(i, -min_v) cout << '(';
  cout << s;
  rep(i, cur - min_v) cout << ')';
  cout << endl;
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long long read(){
    long long ret=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-f;ch=getchar();}
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*f;
}
int a,b; 
int main(){
	//ios::sync_with_stdio(false);
    cin>>a>>b;
    cout<<max((a+b),max((a*b),(a-b)));
}


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

int main()
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	cout << min(a,k) - max(k-a-b,0) << endl;
	return 0;
}

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

typedef long long ll;
int N;
ll R;
ll x[200010], y[200010];
unordered_map<ll, unordered_set<ll>> g;
set<pair<ll,ll>> vis;

void dfs(ll y, ll x){
    vis.insert(make_pair(y,x));
    // cout << x*R << " " << y*R << endl;
    rep(i,3)rep(j,3){
        int dx = i-1;
        int dy = j-1;
        if(dx == 0 && dy == 0) continue;
        if(g.count(y+dy) == 0) continue;
        if(g[y+dy].count(x+dx) == 0) continue;
        if(vis.count(make_pair(y+dy, x+dx))) continue;
        dfs(y+dy, x+dx);
    }
}

int solve(){
    vis.clear();
    g.clear();
    rep(i,N){
        g[y[i]/R].insert(x[i]/R);
    }
    int ans = 0;
    for(const auto &row : g){
        for(const auto &x : row.second){
            ll y = row.first;
            if(vis.count(make_pair(y,x))) continue;
            ans++;
            // cout << "b" << endl;
            dfs(y,x);
        }
    }
    return ans;
}

int conv(string s){
    s.erase(s.find('.'),1);
    stringstream ss(s);
    ll x;
    ss >> x;
    return x;
};


int main(){
    string RR;
    while(cin >> N >> RR){
        R = conv(RR);
        rep(i,N){
            string xx, yy;
            cin >> xx >> yy;
            x[i] = conv(xx), y[i] = conv(yy);
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 50184
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 1200100;
int n, a[N];
vector <int> f[N];

bool func(int x, int y) {
	return a[x] > a[y];
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	for(int i = 0; i < (1 << n); i++)
		cin >> a[i];

	for(int i = 0; i < (1<<n); ++i)
		f[i].push_back(i);
	
	for(int i = 0;i < n; ++i) 
		for(int mask = 0; mask < (1<<n); ++mask){
			if(mask & (1<<i)) {
				for(auto j : f[mask^(1<<i)])
					f[mask].push_back(j);
				sort(f[mask].begin(), f[mask].end(), func);
				f[mask].resize(2);
			}
	}

	// dbg_v(f, 3);
	int ans = a[0] + a[1];
	for(int i = 1; i < (1 << n); i++) {
		ans = max(ans, a[f[i][0]] + a[f[i][1]]);
		cout << ans << '\n';
	}
}	

	

Measured memory_bytes: 41984
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
    string s;
    cin >> s;
    char prev='\0';
    bool two = true, err = false;
    int cnt=0;
    for (auto c:s) {
        if (err) {
            cnt++;
            two = true;
            err = false;
        }
        else if (two || c != prev) {
            cnt++;
            two = false;
        }
        else {
            err = true;
        }
        prev = c;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 640
def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353

    dp = [[0]*3001 for _ in [0]*n]
    dp[0][a[0]] = 1
    for j, i in enumerate(a[1:]):
        dp[j+1][i] += (j+2)
        for k in range(3001-i):
            dp[j+1][i+k] = (dp[j+1][i+k]+dp[j][k]) % mod
        for k in range(3001):
            dp[j+1][k] = (dp[j+1][k]+dp[j][k]) % mod
    print(sum([dp[i][s] for i in range(n)]) % mod)


main()

Measured memory_bytes: 112092
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,flag=0;
    cin>>n;
    for(int i=1;i<=9;i++)
      for(int j=1;j<=9;j++)
      {
          x=i*j;
          if(x==n)
            flag++;
      }
      if(flag==0)
        cout<<"No";
      else 
        cout<<"Yes";
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	long ans = -1;
	long sum = 0;
	int N = rei();
	for(int i=0;i<N;i++){
		int D = rei();
		long C = rel();
		ans += C;
		sum += D*C;
	}
	ans += (sum-1) / 9;
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

using namespace std;


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<long long > A(N);
	for(int i=0;i<N;i++)cin >> A[i];
	sort(A.begin(),A.end());
	int ok = N;
	int ng = -1;
	while(abs(ok-ng)>1){
		int mid = (ok+ng)/2;
		long long now = A[mid];
		bool can = 1;
		for(int i=0;i<N;i++){
			if(i==mid)continue;
			if(now*2>=A[i])now += A[i];
			else {
				can = 0;
				break;
			}
		}
		if(can)ok = mid;
		else ng = mid;
	}
	cout << N - ok << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

ll n,m,p,dp[2510],dp2[2510],visit[2510]={};
vector<ll> v[2510],vinv[2510],c[2510];

void init(){
	cin>>n>>m>>p;
	rep(i,m){
		ll a,b,x;
		cin>>a>>b>>x;
		v[a].push_back(b);
		vinv[b].push_back(a);
		c[a].push_back(x-p);
	}
	reg(i,1,n){
		dp[i]=-1e18;
		dp2[i]=-1e18;
	}
	dp[1]=0;
}

int main(void){
	init();
	bool update=false;
	// nに行けないなら無関係。到達不能な点を検出
	queue<ll> Q;
	Q.push(n);
	visit[n]=1;
	while(not Q.empty()){
		ll a = Q.front();Q.pop();
		for(ll q:vinv[a]){
			if(visit[q]==0){
				visit[q]=1;
				Q.push(q);
			}
		}
	}
	// 1から行けない点も考える必要なし
	Q.push(1);
	visit[1]=2;
	while(not Q.empty()){
		ll a = Q.front();Q.pop();
		for(ll q:v[a]){
			if(visit[q]==1){
				visit[q]=2;
				Q.push(q);
			}
		}
	}
	// reg(i,1,n)cerr<<visit[i]<<" ";
	// cerr<<endl;
	// ベルマンフォード
	reg(cnt,1,2*n){
		reg(i,1,n){
			if(visit[i]!=2)continue;
			rep(j,v[i].size()){
				// if(visit[v[i][j]]!=2)continue;
				if(dp2[v[i][j]]<dp[i]+c[i][j]){
					if(cnt>=n+1){
						update=true;
						break;
					}
					dp2[v[i][j]]=dp[i]+c[i][j];
				}
			}
		}
		reg(i,1,n)dp[i]=dp2[i];
	}
	cout<<(update?-1:max(dp[n],0LL))<<endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
        
using namespace std;
        
typedef long long ll;
#define mp make_pair
#define pub push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db double


  
int main(){ 
    srand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N' + time(NULL));
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("spoiler.in", "r", stdin);
    //freopen("spoiler.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
	string s;
	cin >> s;
	if (s.size() < 4) cout << "No", exit(0);
	if (s[0] != 'Y') cout << "No", exit(0);
	if (s[1] != 'A') cout << "No", exit(0);
	if (s[2] != 'K') cout << "No", exit(0);
	if (s[3] != 'I') cout << "No", exit(0);
	cout << "Yes";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 1e13;
ll n, k;
vector<vector<ll>> G(100050);
int visited[100050];
ll dfs(int x, int cnt1, int cnt2) {
    ll i, j;
    visited[x] = 1;
    ll vs = G[x].size();
    ll ret = k - cnt1 - cnt2;
    //cout << "yes" << endl;
    for(i = 0; i < vs; i++) {
        if(visited[G[x][i]] == 0) {
            ret *= dfs(G[x][i], 1, cnt1++);
            ret %= MOD;
        }
    }
    return ret;
}

int main() {
    ll i, j, m, h;
    cin >> n >> k;
    for(i = 0; i < n-1; i++) {
        ll a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << dfs(1, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 10752
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int x, cnt, ans = 0;
  for(int i = 0; i < n; i++){
    cin >> x;
    cnt = 0;
    while(x % 2 == 0){
      x /= 2;
      cnt++;
    }
    ans += cnt;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
ll *id,*sz;
void init()
{
     id=new ll[n];
        sz=new ll[n];
        int i;
        for(i=0;i<n;i++)
        {
            id[i]=i;
            sz[i]=1;
        }
}
ll root(ll i)
    {
        ll j=i;
        while(id[j]!=j)
            j=id[id[j]];
        while(i!=j)
        {
            ll newp=id[i];
            id[i]=j;
            i=newp;
        }
        return j;
    }
    bool connected(ll p,ll q)
    {
        return root(p)==root(q);
    }
    void unions(ll p,ll q)
    {
        ll i=root(p);
        ll j=root(q);
        if(i==j)
             return;
         if(sz[i]>sz[j])
         {
             id[j]=i;
             sz[i]+=sz[j];
         }
         else
         {
            id[i]=j;
             sz[j]+=sz[i];
         }
    }
int main()
{
    cin>>n>>m;
    init();
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--;y--;
        unions(x,y);
    }
    ll mx=0;
    for(int i=0;i<n;i++)
        mx=max(mx,sz[i]);
    cout<<mx;
}


Measured memory_bytes: 6760
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	std::string str; std::cin >> str; std::sort(str.begin(), str.end());
	std::cout << ((str == "abc") ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


ll gcd(ll a, ll b){
    if(a<b){
        swap(a,b);
    }
    
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

int main(){
    int N;
    cin >> N;
    ll ans;
    cin >> ans;
    for(int i=0; i<N-1; i++){
        ll A;
        cin >> A;
        ans = gcd(A,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
a.sort()
tmp = float('inf')
index = 0
for i, aa in enumerate(a):
    v = abs(a[-1] / 2 - aa)
    if v < tmp:
        tmp = v
        index = i
print(a[-1], a[index])


Measured memory_bytes: 12828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,tot;
ll k;
ll a[N],b[N],hs[N],t[N<<2];
int vis[N];
void build(int l,int r,int k)
{
    if(l==r) {t[k]=vis[l];return;}
    int m=l+r>>1;
    build(l,m,k<<1);build(m+1,r,k<<1|1);
    t[k]=t[k<<1]+t[k<<1|1];
}
ll query(int l,int r,int k,ll x)
{
    if(hs[l]>x||!t[k]) return -1;
    if(l==r) {t[k]--;return hs[l];}
    int m=l+r>>1;
    ll ans=query(m+1,r,k<<1|1,x);
    if(ans==-1) ans=query(l,m,k<<1,x);
    t[k]=t[k<<1]+t[k<<1|1];
    return ans;
}
ll querymn(int l,int r,int k)
{
    t[k]--;
    if(l==r) return hs[l];
    int m=l+r>>1;
    if(t[k<<1]) return querymn(l,m,k<<1);
    return querymn(m+1,r,k<<1|1);
}
bool judge(ll m)
{
    ll p=k;
    build(1,tot,1);
    for(int i=n;i>=1;i--)
    {
        ll x=query(1,tot,1,m/a[i]);
        if(x==-1)
        {
            x=querymn(1,tot,1);
            x=m/x;
            p-=a[i]-x;
            if(p<0) return false;
        }
    }
    return true;
}
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++) scanf("%lld",&b[i]),hs[i]=b[i];
    sort(a+1,a+1+n);
    sort(hs+1,hs+1+n);
    tot=unique(hs+1,hs+1+n)-hs-1;
    for(int i=1;i<=n;i++) b[i]=lower_bound(hs+1,hs+1+tot,b[i])-hs;
    for(int i=1;i<=n;i++) vis[b[i]]++;
    ll l=0,r=1e12,ans;
    while(l<=r)
    {
        ll m=l+r>>1;
        if(judge(m)) ans=m,r=m-1;
        else l=m+1;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 11904
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
    int n,dpw[200011]={},dpb[200011]={},ans=2001000;
    char s[200100];
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++){
        dpw[i+1]=dpw[i];
        if(s[i]=='#'){
            dpw[i+1]++;
        }
    }
    for(int i=n-1;i>=0;i--){
        dpb[n-i]=dpb[n-1-i];
        if(s[i]=='.'){
            dpb[n-i]++;
        }
    }
    for(int i=0;i<=n;i++){
        ans=min(ans,dpb[i]+dpw[n-i]);
    }
    printf("%d\n",ans);
}

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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

// Reads a 1D vector
template <class T>
void read1d(vector<T> & arg) {
	const int l = arg.size();
	for (int i = 0; i < l; ++i) cin >> arg[i];
}

void read() {}
// Reads arbitrary values
template <class T1, class... T2>
void read(T1& var1, T2&... var2) { cin >> var1; read(var2...); }



void pln() { cout << (DEBUG ? "]\n" : "\n"); }
template <class T1, class... T2>
void pln(const T1& var1, const T2& ... var2) { cout << var1 << " "; pln(var2...); }

// Prints arbitrary values and goes to next line
template <class T1, class... T2>
constexpr void print(const T1& var1, const T2& ... var2) { cout << (DEBUG ? " [ " : ""); pln(var1, var2...); }

// Prints arbitrary values and goes to next line ONLY IF IN DEBUG MODE
template <class T1, class... T2>
constexpr void debug(const T1& var1, const T2& ... var2) { if (!DEBUG) return;  cout << " debug : [ "; pln(var1, var2...); }





using ll = long long;
using ull = unsigned long long;


#define all(x) begin(x), end(x)

const bool MULTIPLE_TEST_CASES = 0;


void exec() 
{
	ll n, d;
	read(n, d);

	d *= d;

	int score = 0;
	for (int i = 0; i < n; ++i) {
		ll a, b;
		cin >> a >> b;

		ll dist = (a * a) + (b * b);
		if (dist <= d) ++score;
	}

	print(score);
}

















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

	if (!MULTIPLE_TEST_CASES)
		exec();
	else {
		int n;
		cin >> n;

		while (n--)
			exec();
	}

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>

using namespace std;

int main() {
	int h, w, m; cin >> h >> w >> m;
	set<pair<int, int> > st;
	vector<pair<int,int> > hcnt(h), wcnt(w);
	for (int i = 0; i < h; ++i) hcnt[i].second = i;
	for (int i = 0; i < w; ++i) wcnt[i].second = i;
	for (int i = 0; i < m; ++i) {
		int h, w; cin >> h >> w;
		--h, --w;
		st.emplace(h, w);
		++hcnt[h].first;
		++wcnt[w].first;
	}
	sort(hcnt.begin(), hcnt.end(), greater());
	sort(wcnt.begin(), wcnt.end(), greater());
	int maxhw = hcnt[0].first + wcnt[0].first;
	for (int i = 0; i < h; ++i) {
		if (hcnt[0].first != hcnt[i].first) break;
		for (int j = 0; j < w; ++j) {
			if (wcnt[0].first != wcnt[j].first) break;
			if (st.find(pair(hcnt[i].second, wcnt[j].second)) == st.end()) {
				cout << maxhw << endl;
				return 0;
			}
		}
	}
	cout << maxhw - 1 << endl;

	return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S;
signed main() {
    cin >> S;
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) { cout << "Bad" << endl; }
    else { cout << "Good" << endl; }
}


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

#define ll long long int
#define li int64_t

int main()
{
	int n;
	cin>>n;
	li count = n-1;
	for(int i=2;i<n;i++)
	{
		if(n%i == 0)
		{
			count += (n/i)-1;
		}
		else
		{
			count+= (n/i);
		}
	}	
	cout<<count;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n;
    cin >> n;
    vi b(n + 1);
    b[0] = 0;
    for (int i = 1; i < n + 1; i++)
    {
        cin >> b[i];
    }

    bool flg = true;
    vi ans(n + 1);
    for (int i = n; i >= 1 && flg; i--)
    {
        for (int j = i; j >= 1; j--)
        {
            flg = false;
            if (b[j] == j)
            {
                ans[i] = j;
                b.erase(b.begin() + j);
                flg = true;
                break;
            }
        }
    }

    if (flg)
    {
        for (int i = 1; i < n + 1; i++)
        {
            cout << ans[i] << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
S=input()
if S[0]!="A":
    print("WA")
    exit()
else:
    if S[2:-1].count("C")!=1:
        print("WA")
        exit()
    else:
        x=S.index("C")
        for i in range(len(S)):
            if i==0 or i==x:
                pass
            else:
                if 65<=ord(S[i])<=90:
                    print("WA")
                    exit()
print("AC")

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


int main() {
 int a;
 int b;
 cin >> a >> b;
  int x;
  x = (a + b) / 2 ;
  if (2*x < a + b){
    x = x + 1;
  }
  cout << x << endl;
}


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

int main() {
	int line, s[4], front, back;
	cin>>line;
	for(int i=0;i<4;i++){
		s[3-i]=line%10;
		line/=10;
	}
	front = s[0]*10 + s[1];
	back = s[2]*10 + s[3];
	if(!(0<front && front<=12) && (0<back && back<=12)) cout<<"YYMM";
	else if((0<front && front<=12) && !(0<back && back<=12)) cout<<"MMYY";
	else if((0<front && front<=12) && (0<back && back<=12)) cout<<"AMBIGUOUS";
	else cout<<"NA";
	
	return 0;
}

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

int main() {
	int n,m;
	cin >>n >>m;
	
	vector<vector<int>> s;
	
	
	for(int i=0; i<m; i++){
		int k;
		cin >>k;
		vector<int> T(k);
		for(int j=0; j<k; j++){
			cin >>T[j];
		}
		s.push_back(T);
	}
	
	vector<int> p(m);
	for(int i=0; i<m; i++){
		cin >>p[i];
	}
	
	int b = 0;

    for(int bit = 0 ; bit<(1<<n);bit++){
        bool miss = false;
        for(int i=0;i<m;i++){
            int a= 0;
            for(int j=0;j<s[i].size();j++){
                if((1<<(s[i][j]-1))&bit)a++;
            }
            
            if(a%2!=p[i]){
            	miss = true;
            	break;
            }
        }
if(!miss)b++;
    }

    cout << b << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a=list(map(int, input().split()))

if max(a)<=1:
    print(N)
else:
    cnt=[0]*(max(a)+1)
    for val in a:
        cnt[val]+=1
    #print(cnt)

    tri=[cnt[i]+cnt[i+1]+cnt[i+2] for i in range(len(cnt)-2)]
    #print(tri)
    print(max(tri))

Measured memory_bytes: 13964
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = std::priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = std::priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1E5, 1E6); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 1 << 18;

int32_t main() {
    fastIO();
    
    int n, tok = 0;
    cin >> n;
    
    vector<pii> vp(n);
    vector<int> ans(n), ins(n); /// x -> id
    for (auto &[x, y] : vp) cin >> x >> y, --x, y = n-y, ins[x] = tok++;
    sort(ALL(vp));
    
    int maxY = 0, cnt = 0;
    for (auto [x, y] : vp) {
        // cout << x << " " << y << "\n";
        if (x > maxY) {
            // cout << "color : " << x - cnt << " " << x - 1 << "\n";
            for (int i = x-cnt; i < x; ++i) ans[ins[i]] = cnt;
            cnt = 0;
        }
        maxY = max(maxY, y), ++cnt;
    }
    for (int i = n-cnt; i < n; ++i) ans[ins[i]] = cnt;
    
    for (auto x : ans) cout << x << "\n";
    
    return 0;
}

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

int main() {
        int N; string S; cin >> N >> S;
        int white[N+1], black[N+1], cnt = 0;

        white[0] = 0;
        for (int i = 0; i < N; ++i) {
                if (S[i] == '#') cnt++;
                white[i+1] = cnt;
        }

        cnt = 0;
        for (int i = N-1; i >= 0; --i) {
                if (S[i] == '.') cnt++;
                black[i] = cnt;
        }
        black[N] = 0;

        cnt = N+1;
        for (int j=N; j >= 0; --j) {
                cnt = min(cnt, white[j]+black[j]);
        }
        cout << cnt << "\n";
        return 0;
}


Measured memory_bytes: 2180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
map<int, int> a;
int ans;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	while(n--) {
		int x;
		scanf("%d", &x);
		a[x]++;
	}
	while(!a.empty()) {
		auto it = a.end();
		it--;
		int x = it->first;
		if (a[x] == 0) {
			throw;
		}
		a[x]--;
		if (a[x] == 0) a.erase(x);
		int z = 1;
		while(z <= x) z <<= 1;
		if (a.count(z - x) > 0) {
			a[z - x]--;
			if (a[z - x] == 0) a.erase(z - x);
			ans++;
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 9600
#include <atcoder/math>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

bool ok(ll k, ll n) {
  ll kk = k + 1;
  if (k % 2 == 0) k /= 2;
  else kk /= 2;

  n /= gcd(k, n);
  n /= gcd(kk, n);

  return n == 1;
}

void check(const ll K, const ll N) {
  assert(ok(K, N));
  for (ll k = 1; k < K; k++) {
    assert(!ok(k, N));
  }
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif

  ll n;
  cin >> n;
  ll ans = 2 * n - 1;

  ll z = n;
  ll p = 2;
  while (z % 2 == 0) {
    z /= 2;
    p *= 2;
  }
  assert(z % 2 == 1);

  for (ll a = 1; a * a < z; a++) {
    if (z % a != 0) continue;
    ll b = z / a;
    if (gcd(a, b) != 1) continue;

    for (int _ : {0, 1}) {
      (void) _;

      if (b % 2 == 1) {
        // k = pt; a | t; b | pt + 1
        ll ip = b - atcoder::inv_mod(p, b);
        ip %= b;
        ll t = atcoder::crt({0, ip}, {a, b}).fst;
        if (t > 0) ans = min(ans, p * t);
      }
      if (b % 2 == 1) {
        // k = pt - 1; a | t; b | pt - 1
        ll ip = atcoder::inv_mod(p, b);
        ll t = atcoder::crt({0, ip}, {a, b}).fst;
        if (t > 0) ans = min(ans, p * t - 1);
      }

      swap(a, b);
    }
  }

#ifdef LOCAL_EXEC
  check(ans, n);
#endif

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

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

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);

    int s = sqrt(g);
    int cnt = !(g % 2);
    while(g % 2 == 0)
        g /= 2;
    

    for(int i = 3; i <= s; i+=2){
        bool bb = false;
        while(g % i == 0){
            g /= i, bb=true;
        }
        cnt += bb;
    }
    
    cout << cnt + (g > 1) + 1 << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
ans=[]
for i in range(h):
  for j in range(w-1):
    if a[i][j]%2:
      a[i][j+1]+=1
      ans.append([i+1,j+1,i+1,j+2])
  if i<h-1 and a[i][w-1]%2:
    a[i+1][w-1]+=1
    ans.append([i+1,w,i+2,w])
print(len(ans))
for t in ans:
  print(*t)

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


#define MAX 100

int arr[MAX];
int N;

void print() {
    for (int i = 0; i < N; i++) {
        if (i) std::printf(" ");
        std::printf("%d", arr[i]);
    }
    std::printf("\n");
}


void insertionSort() {
    int i, j, v;
    for (int i = 1; i < N; i++) {
        v = arr[i];
        j = i - 1;
        while (j >= 0 && arr[j] > v) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = v;
        print();
    }
}


int main()
{

    std::scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        std::scanf("%d", &arr[i]);
    }
    print();
    insertionSort();

    return 0;
}



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

typedef struct Trie_node
{
	int count;                    // 统计单词前缀出现的次数
	struct Trie_node* next[26];   // 指向各个子树的指针
	bool exist;                   // 标记该结点处是否构成单词  
}TrieNode, * Trie;
int cn[100005];
TrieNode* createTrieNode()
{
	TrieNode* node = (TrieNode*)malloc(sizeof(TrieNode));
	node->count = 0;
	node->exist = false;
	memset(node->next, 0, sizeof(node->next));    // 初始化为空指针
	return node;
}

void Trie_insert(Trie root, char* word)
{
	Trie node = root;
	char* p = word;
	int id;
	while (*p)
	{
		id = *p - 'a';
		if (node->next[id] == NULL)
		{
			node->next[id] = createTrieNode();
		}
		node = node->next[id];  // 每插入一步，相当于有一个新串经过，指针向下移动
		++p;
		node->count += 1; 
		// 这行代码用于统计每个单词前缀出现的次数（也包括统计每个单词出现的次数）
		if (node->exist == true) {
			cn[node->count - 1]--;
			cn[node->count]++;
		}
		
	}
	node->exist = true;        // 单词结束的地方标记此处可以构成一个单词
}





int main(void)
{
	memset(cn, 0, sizeof(cn));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	Trie root = createTrieNode();     // 初始化字典树的根节点
	char str[12];
	int n;
	cin >> n;
	while (n--) {
		cin >> str;
		sort(str, str + 10);
		Trie_insert(root, str);
	}
	long long ans=0;
	for (long long i = 2; i < 100001; i++) {
		for (int j = 0; j < cn[i]; j++)ans += i * (i - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long int
#define str string

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
ll A[10000000] = {}, X[1000000] = {};
ll aiti[10000];
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 0,n = 0,sum = 0, max = INF;
str S;
int ans = 0;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                sum += n%10;
                n /= 10;
                i++;
        }
        return i;
}


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

cin >> a >> b >> c;

if(a == b && b == c)cout << "Yes" << endl;
else cout << "No" << endl;
  //Code Line
        return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1]&&s[1]==s[2]){
    cout << "Yes" << endl;
  }else if(s[1]==s[2]&&s[2]==s[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3584
# AOJ ITP2_3_B: Min-Max Element
# Python3 2018.6.24 bal4u

n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
	com, b, e = map(int, input().split())
	if com == 0: print(min(a[b:e]))
	else:        print(max(a[b:e]))


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

int main(void){
    
    int A,B,C;
    cin >> A >> B >> C;
    string ans ="No";
    
    if(A==B && B!=C)ans ="Yes";
    if(A==C && B!=C)ans ="Yes";
    if(C==B && A!=C)ans ="Yes";
    
    cout <<ans <<endl;
    
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N, M, S, T;
vector<vector<int>> g;

int solve() {
    vector<vector<int>> dist(N, vector<int>(3, -1));
    queue<pii> q;
    q.push({S, 0});
    dist[S][0] = 0;
    while (!q.empty()) {
        pii cur = q.front();
        q.pop();
        int node_num = cur.first, node_type = cur.second;
        for (auto target : g[node_num]) {
            int target_type = (node_type + 1) % 3;
            if (dist[target][target_type] == -1) {
                dist[target][target_type] = dist[node_num][node_type] + 1;
                q.push({target, target_type});
            }
        }
    }
    if (dist[T][0] == -1)
        return -1;
    else
        return dist[T][0] / 3;
}

int main() {
    cin >> N >> M;
    g.assign(N, vector<int>());
    int u, v;
    for (int i = 0; i < M; i++) {
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
    }
    cin >> S >> T;
    S--;
    T--;
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int rec(int pos) {
    if(pos == 1) return 1;
    return 2 * rec(pos / 2) + 1;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    cout<<rec(n);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	Dice dice;
    	dice = new Dice();
    	int v = 0;
    	int up;
    	int front;

    	for(int j = 0; j < 6; j++){
    		dice.S[j] = scan.nextInt();
    	}
    	int qustion = scan.nextInt();
    	
    	for(int m = 0; m < qustion; m++){
    		up = scan.nextInt();
    		front = scan.nextInt();
    		for(int i = 0; i < 4; i++){
    			for(int j = 0; j < 4; j++){
    				for(int k = 0; k < 4; k++){
    					dice.vRoll();
			    			if(up == dice.S[0] && front == dice.S[1]) {
			    				v = dice.S[2];
			    				break;
			    			}
			        }
			    	dice.yRoll();
		    	}
		    	dice.v2Roll();				
    		}
    		System.out.println(v);
    	}
     }
}

class Dice{
	int[] S = new int[6];
	
	public void vRoll(){
		int temp3 = S[0];
		S[0] = S[1];
		S[1] = S[5];
		S[5] = S[4];
		S[4] = temp3;
	}
	
	public void yRoll(){
		int temp2 = S[0];
		S[0] = S[3];
		S[3] = S[5];
		S[5] = S[2];
		S[2] = temp2;
	}
	
	public void v2Roll(){
		int temp = S[0];
		S[0] = S[1];
		S[1] = S[5];
		S[5] = S[4];
		S[4] = temp;
	}
}

Measured memory_bytes: 26216
#include <cmath>
#include <iostream>

using namespace std;

int main() {
    int N;
    double T, A;
    cin >> N >> T >> A;

    int ans = 0;
    double min = 1e9;

    for (int i = 0; i < N; i++) {
        double h;
        cin >> h;
        auto t = T - h * 0.006;
        auto y = abs(A - t);
        if (min > y) {
            min = y;
            ans = i;
        }
    }

    cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
oreno_initializer() {
	cin.tie(0);
	ios::sync_with_stdio(0);
}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

char a, b;

signed main() {
	cin >> a >> b;
	cout << (a==b ? 'H' : 'D') << ln;
}

Measured memory_bytes: 256
#---We Love Golf

K = int(input())
a, b = map(int, input().split())

#judge = b - a

q_1, mod_1 = divmod(a,K)
q_2, mod_2 = divmod(b,K)

if(K == 1 or b == K or a == K or mod_1 == 0 or mod_2 == 0):
  print("OK")
  exit()

if(q_1 != q_2):
  print("OK")
else:
  print("NG")


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

int main(void) {
    string S;
    cin>>S;
    string S_R = S;
    reverse(S_R.begin(), S_R.end());
    int cnt = 0;
    for (int i = 0; i < S.size() / 2; i++) {
        if (S[i] != S_R[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256