akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PokerPlaying {
    class Player {
        static void Main(string[] args) {
            int iter = int.Parse(Console.ReadLine());
            for (int i = 0; i < iter; i++) {
                string data = Console.ReadLine();
                string[] splitData = data.Split(' ');
                int[] intHand = toIntData(splitData);
                Bottol b = new Bottol();
                string result = b.fallBall(intHand);
                Console.WriteLine(result);
            }
            
        }

        public static int[] toIntData(string[] data) {
            
            int[] intData = new int[data.Length];
            for (int i = 0; i < data.Length; i++) {
                intData[i] = int.Parse(data[i]);
            }
            return intData;
        }

    }

    class Bottol { 
        int[] perm_Ball;
        List<int> leftBottom;
        List<int> rightBottom;

        public Bottol() {
            perm_Ball = new int[10];
            leftBottom = new List<int>();
            leftBottom.Add(0);
            rightBottom = new List<int>();
            rightBottom.Add(0);
        }


        public string fallBall(int[] balls) {

            perm_Ball = balls;
            for (int i = 0; i < perm_Ball.Length; i++) {
                bool isAbleToLeft = false;
                bool isAbleToRight = false;

                if (i == 0 || perm_Ball[i] > leftBottom.Last()) {
                    isAbleToLeft = true;
                }
                if (i == 0 || perm_Ball[i] > rightBottom.Last()) {
                    isAbleToRight = true;
                }

                if (!isAbleToLeft && !isAbleToRight) {
                    break;
                }  

                if (isAbleToLeft) {
                    leftBottom.Add(perm_Ball[i]);
                } else if (!isAbleToLeft && isAbleToRight) {
                    rightBottom.Add(perm_Ball[i]);
                }

                if (i == perm_Ball.Length - 1) {
                    return "YES";
                }
            }
                
            return "NO";
            
            
        }
    }
}

Measured memory_bytes: 9192
N = int(raw_input())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
cae = 0
cao = 0
cb = 0
for i in range(N):
  if A[i]>B[i]:
    cb += A[i]-B[i]
  elif A[i]<B[i]:
    ca = B[i]-A[i]
    cae += ca // 2
    cao += ca % 2
print "Yes" if cae>=cb else "No"

Measured memory_bytes: 3696
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  int a[3];
  rep(i,3) cin >> a[i];
  sort(a,a+3,greater<int>());
  int x = 10*a[0]+a[1]+a[2];
  printf("%d\n", x);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  string S;
  cin >> S;
  int y, m, d;
  y = stoi(S.substr(0, 4));
  m = stoi(S.substr(5, 2));
  d = stoi(S.substr(8, 2));
  if (y > 2019)
    cout << "TBD" << endl;
  else if (y == 2019)
  {
    if (m >= 5)
      cout << "TBD" << endl;
    else
      cout << "Heisei" << endl;
  }
  else
    cout << "Heisei" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 int H,N,i,total=0;
 
 scanf("%d %d",&H,&N);
 
  int A[N];
  for(i=0;i<N;i++)
  scanf("%d ",&A[i]);
 
 
 //qsort(A,N,sizeof(long int),compa);
 for(i=0;i<N;i++)
 {
  H -= A[i];
  if(H <=0) 
  {
    printf("Yes\n"); 
    return 0;
  }
 }  
  printf("No\n");
 return 0;
}

Measured memory_bytes: 512
import math

n = int(input())
a_list = [int(i) for i in input().split()]
sum = 0
ans = 0
mini = 10000000000
count = 0
for i in range(n):
    if a_list[i]<0:
        count += 1
    mini = min(mini,abs(a_list[i]))
    sum += abs(a_list[i])

if count%2==1:
    print(sum - 2*mini)
else:
    print(sum)


Measured memory_bytes: 14436
#include<bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
using namespace std;
int n,a[200004];
vector<int>g[200004];
int ans[200004],len;
int pos[200004],lst[200004];
int ret[200004];
void dfs(int x,int par){
	if(ans[len]<a[x])pos[x]=len+1,lst[x]=0,ans[++len]=a[x];
	else{
		pos[x]=lower_bound(ans+1,ans+1+len,a[x])-ans;
		lst[x]=ans[pos[x]];
		ans[pos[x]]=a[x];
	}
	ret[x]=len;
	for(int i=0;i<g[x].size();i++)if(g[x][i]!=par)
		dfs(g[x][i],x);
	if(lst[x]==0)len--;
	else ans[pos[x]]=lst[x];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		g[u].push_back(v),g[v].push_back(u);
	}
	dfs(1,-1);
	for(int i=1;i<=n;i++)printf("%d\n",ret[i]);
}

Measured memory_bytes: 32044
import sys
def input(): return sys.stdin.readline().rstrip()
def run_length(s):
    ans=[]
    if len(s)==1:
        ans.append((s,1))
        return ans
    s_pre=s[0]
    cunt=1
    for i,ss in enumerate(s[1:],1):
        if ss==s_pre:
            cunt+=1
        else:
            ans.append((s_pre,cunt))
            cunt=1
            s_pre=ss
    ans.append((s_pre,cunt))
    return ans
    
def main():
    s=input()
    run_s=run_length(s)
    n=len(s)
    ans=[0]*n
    index=-1
    for i in range(len(run_s)//2):
        index+=run_s[2*i][1]
        ans[index]+=(run_s[2*i][1]+1)//2+run_s[2*i+1][1]//2
        ans[index+1]+=run_s[2*i][1]//2+(run_s[2*i+1][1]+1)//2
        index+=run_s[2*i+1][1]
    print(*ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 58016
#include <iostream>
#include <stdlib.h>
using namespace std;

int Euclid(int x, int y) {
	if (x == y)return x;
	else {
		Euclid(((x > y) ? y : x), abs(x-y));
	}
}

int main(void){
	int x, y;
	cin >> x >> y;

	int max = Euclid(x, y);

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
typedef vector<int> vi; 
typedef vector<bool> vb; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
 
#define sz(x) (int)(x).size()
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define endl '\n'
 
const ll MOD = 1e9+7; // 998244353;
const ll INF = 1e18;
 
int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   ll a, b, c, d; cin >> a >> b >> c >> d;
   cout << max(max(a * c, a * d), max(b * c, b * d));
   return 0;
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	string s;
	int ret = 0;
	cin >> s;
	for (auto c : s) {
		if (c == '2')ret++;
	}
	cout << ret;
	return 0;
}

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

int f(vector<int> &v,int n){
  vector<int> k(n);
  for(int i=0;i<n;i++)k[i]=i+1;
  int cnt=0;
  do{
    bool f=true;
    for(int i=0;i<n;i++)if(k[i]!=v[i])f=false;
    if(f)return cnt;
    cnt++;
  }while(next_permutation(k.begin(),k.end()));
  return cnt;
}

signed main(){
  int n;cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++)cin>>p[i];
  for(int i=0;i<n;i++)cin>>q[i];
  int a=f(p,n),b=f(q,n);
  cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
n = int(input())
 
MAX = 0
MAX_index = []
MAX_sec = 0
for i in range(n):
    a = int(input())
    if MAX == a:
        MAX_index.append(i)
    elif MAX < a:
        if len(MAX_index)==i:
            MAX_sec = MAX
        MAX_index = [i]
        MAX = a
    elif MAX_sec < a:
        MAX_sec = a
    
#print(MAX_index)
        
if len(MAX_index)==1:
    for i in range(n):
        if i==MAX_index[0]:
            print(MAX_sec)
        else:
            print(MAX)
else:
    for i in range(n):
        print(MAX)

Measured memory_bytes: 12520
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main()
{
	int n,k,temp=0,i=1,x,h;
	vector<int> v;
	cin>>h;
	while(h>0)
	{
		h=h/2;
		temp=temp+i;
		i=2*i;
	}
	cout<<temp<<endl;
	return 0;
}

Measured memory_bytes: 256
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		int p;
		cin >> p;
		a[i] = p - i;
	}
	sort(a.begin(), a.end());
	ll ans = 0, sub;
	if (n % 2) {
		sub = a[(n - 1) / 2];
		rep(i, n) {
			ans += abs(a[i] - sub);
		}
		cout<<ans << endl;
	}
	else {
		sub = a[n / 2];
		rep(i, n) {
			ans += abs(a[i] - sub);
		}
		ll ans2 = 0;
		sub = a[n / 2 - 1];
		rep(i, n) {
			ans2 += abs(a[i] - sub);
		}
		cout << min(ans, ans2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline

INF = 10**9 + 7

N, M = map(int, readline().split())
key = [()] * M

for i in range(M):
    a, b = map(int, readline().split())
    c = map(int, readline().split())
    num = 0
    for j in c:
        num += 1 << (j - 1)
    key[i] = (num, a)


def solve():

    dp = [INF for _ in range(2**N)]
    dp[0] = 0

    for i in range(M):
        num, a = key[i]
        for j in range(2**N):
            next_num = j | num
            dp[next_num] = min(dp[next_num], dp[j] + a)

    if dp[2**N - 1] == INF:
        ans = -1
    else:
        ans = dp[2**N - 1]

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40688
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	while(cin>>n,n){
		rep(i,9){
			int t;
			cin>>t;
			n-=t;
		}
		cout<<n<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3104
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

char inpu[120];
pair<pair<string,int>,int> p[110];
int main(){
  int n;
  in n;
  rep(i,n){
  int t;
  scanf("%s%d",inpu,&t);
  string tmp=inpu;
  p[i]=make_pair(make_pair(inpu,-t),i);
  }
  sort(p,p+n);
  rep(i,n)printf("%d\n",p[i].second+1);
}


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

class Baseball
{
   public Baseball()
   {
      scoreList.Add(0);
      runnerList[0] = true;
   }

   private List<int> scoreList = new List<int>();
   public List<bool> runnerList = new List<bool>(Enumerable.Repeat(false, 4));

   public int Inning { get; private set; }
   public int[] Score { get { return scoreList.ToArray();} }
   public int OutCount { get; private set; }
   public bool[] Runner { get { return runnerList.ToArray(); } }

   public void Hit()
   {
      int Third = runnerList.Count - 1;
      if (runnerList[Third])
      {
         scoreList[Inning]++;
         runnerList[Third] = false;
      }

      for (int i = Third - 1; i >= 0; i--)
      {
         if (!runnerList[i]) { continue; }

         runnerList[i + 1] = true;
         runnerList[i] = false;
      }
         
      runnerList[0] = true;
   }   

   public void Homerun()
   {
      int Third = runnerList.Count - 1;
      for (int i = 0; i <= Third; i++)
      {
         if (!runnerList[i]) { continue; }

         scoreList[Inning]++;
         runnerList[i] = false;
      }

      runnerList[0] = true;
   }

   public void Out()
   {
      OutCount++;
      if (OutCount < 3) { return; }

      int Third = runnerList.Count - 1;
      for (int i = 1; i <= Third; i++)
      {
         runnerList[i] = false;
      }
      scoreList.Add(0);
      Inning++;
      OutCount = 0;
   }   
}

class MainClass
{
   static void Main(string[] args)
   {
      var stringbuilder = new StringBuilder();

      var baseboll = new Baseball();

      int n = int.Parse(Console.ReadLine());
      while (baseboll.Inning < n)
      {   
         string evnt = Console.ReadLine();
         switch (evnt)
         {
            case "HIT":
               baseboll.Hit();
               break;
            case "HOMERUN":
               baseboll.Homerun();
               break;
            case "OUT":
               baseboll.Out();
               break;
         }
      }

      var scores = baseboll.Score;
      for (int i = 0; i < baseboll.Inning; i++)
      {
         stringbuilder.AppendLine(scores[i].ToString());
      }

      Console.Write(stringbuilder.ToString());
   }
}

Measured memory_bytes: 9436
from itertools import permutations
from math import sqrt
n = int(input())
town = []
for i in range(n):
    town_i = list(map(int,input().split()))
    town.append(town_i)

cnt = 0
length = 0
for j in permutations(range(n)):
    x,y = town[j[0]][0],town[j[0]][1]
    for k in range(1,n):
        length += sqrt((x-town[j[k]][0])**2+(y-town[j[k]][1])**2)
        x = town[j[k]][0]
        y = town[j[k]][1]
    cnt += 1

print(length/cnt)

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

int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	rep(i, n) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 1;i < n;++i) {
		ans = (ans + v[i]) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
import math
N = int(input())
x_y = {i : list(map(int, input().split())) for i in range(N)}
P = list(itertools.permutations(range(N)))
tmp = 0
for p in P:
    for n in range(N-1):
        #print(tmp)
        tmp += math.sqrt((x_y[p[n]][0] - x_y[p[n+1]][0])**2 + (x_y[p[n]][1] - x_y[p[n+1]][1])**2)

print(tmp/len(P))



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

#define INF int(100100)

int main(){
    while(1){
        int n;
        cin >> n;
        
        if(n==0)  break;          //終了の判断

        int time[10][10];

        for(int i=0;i<10;i++){           //配列の初期化
            for(int j=0;j<10;j++){
                if(i==j)
                    time[i][j] = 0;
                else
                    time[i][j] = INF;
            }
        }

        int count(0);
        for(int i=0;i<n;i++){           //配列の設定
            int a,b,c;
            cin >> a >> b >> c;
            time[a][b] = time[b][a] = c;
            if(a+1>count)   count = a+1;
            if(b+1>count)   count = b+1;
        }

        for(int k=0;k<count;k++){           //最短距離に書き換え
            for(int i=0;i<count;i++){
                for(int j=0;j<count;j++){
                    if(time[i][j]>(time[i][k]+time[k][j]))
                        time[i][j] = time[i][k]+time[k][j];
                }
            }
        }

        int v(0),atotal(INF);
        for(int i=0;i<count;i++){
            int total(0);
            for(int j=0;j<count;j++){
                total += time[i][j];
            }
            if(total<atotal){
                v = i;
                atotal = total;
            }
        }
        cout << v << " " << atotal << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long
#define maxn 2005
using namespace std;
ll mo=924844033;
int n,k;
ll f[maxn];
ll g[maxn][maxn][2][2];
ll a[maxn],cnt;
ll ans;
ll jc[maxn];

ll cal(){
	ll ff=-1;
	ll res=0;
	for(int i=1;i<=n;i++){
		ff=-ff;
		res=res+ff*f[i];
		res=(res+mo)%mo;
	}
	return res;
}

int main(){
	scanf("%d%d",&n,&k);
	jc[0]=1;
	for(int i=1;i<=n;i++)jc[i]=jc[i-1]*(i%mo)%mo;
	for(int i=0;i<k;i++){
		int j=i;
		if(!i)j+=k;
		while(j<=n){
			a[++cnt]=j;
			j+=k;
		}
	}
//	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
//	cout<<endl;
	g[0][0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			if(a[i+1]%k!=a[i]%k||!i){
				for(int f1=0;f1<=1;f1++){
					(g[i+1][j][0][0]+=g[i][j][f1][0])%=mo;
					(g[i+1][j+1][0][1]+=g[i][j][f1][0])%=mo;
				}
			}
			else{
				for(int f1=0;f1<=1;f1++){//aiÊÇ·ñÓÃ¹ý 
					for(int f2=0;f2<=1;f2++){//a(i+1)ÊÇ·ñÓÃ¹ý 
						if(!f1)(g[i+1][j+1][f2][0]+=g[i][j][0][f2])%=mo;
						(g[i+1][j+1][f2][1]+=g[i][j][f1][f2])%=mo;
						(g[i+1][j][f2][0]+=g[i][j][f1][f2])%=mo;
					}
				}
			}
		}
	}
	
	/*
	for(int i=1;i<=n;i++){
		cout<<i<<endl;
		for(int j=0;j<=i;j++){
			cout<<j<<" "<<g[i][j][0][0]<<" "<<g[i][j][0][1]<<" "<<g[i][j][1][0]<<" "<<g[i][j][1][1]<<endl;
		}
	}	
	cout<<endl;
	*/
	
	for(int i=1;i<=n;i++){
		(f[i]+=g[n][i][0][0])%=mo;
		(f[i]+=g[n][i][1][0])%=mo;
		(f[i]*=jc[n-i])%=mo;
	}
	
	/*
	for(int i=1;i<=n;i++)cout<<f[i]<<" ";
	cout<<endl;
	*/
	
	ans=jc[n];
	ans-=cal();
	ans=(ans+mo)%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 123776
#include <bits/stdc++.h>
using namespace std;
int k,f[100005],d[200005],e[100005],l,r;
int main(){
	scanf("%d",&k);
	for (int i=0;i<k;++i) f[i]=50;
	for (int i=9;i;--i) f[i%k]=i,e[i%k]=1;
	l=r=1;
	for (int i=1;i<=9;++i) if (f[i]) d[r++]=i;
	while (l!=r){
		for (int i=0,j;i<=9;++i)
		if (f[j=(d[l]*10+i)%k]>f[d[l]]+i){
			f[j]=f[d[l]]+i;
			if (!e[j]) e[j]=1,d[r++]=j;
			if (r==200000) r=1;
		}
		e[d[l++]]=0; if (l==200000) l=1;
	}
	printf("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int root(int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};
int main(){
	int N;
	scan(N);
	UnionFind uf(2*N);
	rep(i,N-1){
		ll u,v,w;
		scan(u>>v>>w);
		u--; v--;
		if(w%2){
			uf.unite(u,v+N);
			uf.unite(u+N,v);
		}
		else{
			uf.unite(u,v);
			uf.unite(u+N,v+N);
		}
	}
	rep(i,N){
		if(uf.same(0,i)) prin(0);
		else prin(1);
	}
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B;
        cin >> A >> B; 
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    double A,B,C,D;
    cin >> A >> B >> C >> D;
    
    
    
    
    if(std::ceil(A/D) < std::ceil(C/B)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}


Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll A, B;
    cin>>A>>B;
    cout<<A*B<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    int n,k;
    long long m,c;
    cin >>n>>k;
    m=(n-n%k)/k;
    c=m*m*m;
    if(k%2==0){
        if(n%k>=k/2){
            m+=1;
        }
        c+=m*m*m;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18;
int main(){
	ll H,W,K;
	cin>>H>>W>>K;
	vector<vector<ll>> s(H,vector<ll>(W,0));
	ll k=1;
	REP(i,H){
		REP(j,W){
			char tmp;
			cin>>tmp;
			if(tmp=='#'){
				s[i][j]=k;
				k++;
			}
		}
	}
	//test(s);
	
	REP(i,H){
		ll now=0;
		ll first=0;
		REP(j,W){
			if(s[i][j]!=0){
				now=s[i][j];
				if(first==0)first=s[i][j];
			}else{
				s[i][j]=now;
			}
			//cout<<s[i][j];//
		}
		REP(j,W){
			if(s[i][j]!=0){
				break;
			}else{
				s[i][j]=first;
			}
		}
		//cout<<endl;//
		if(s[i][0]==0 && i!=0){
			REP(j,W)s[i][j]=s[i-1][j];
		}
	}
	REP(i,H){
		if(s[i][0]!=0){
			for(ll j=i;j>0;j--){
				REP(m,W)s[j-1][m]=s[j][m];
			}
			break;
		}
	}
	REP(i,H){
		REP(j,W){
			cout<<s[i][j]<<" ";
		}
		cout<<endl;
	}	
	return 0;
}


Measured memory_bytes: 1536
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n>>k>>x>>y;
     if(k>n){
        p=n;
        l=0;
     }
     else{
        l=n-k;
        p=k;
     }
     cout<<p*x+l*y<<endl;


     return EXIT_SUCCESS;
}



Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

int main()
{
	
	for (int i = 0; i < 3000; i++) {
		int a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			continue;
		}
		else if (a < b) {
			cout << a << " " << b << endl;
		}
		else {
			cout << b << " " << a << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

string N;

int main(){
    cin>>N;

    ll sum=0;
    rep(i,N.size()) sum+=N[i]-'0';

    string ans="No";
    if(sum%9==0) ans="Yes";

    cout<<ans<<endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  deque<char> deq;
  rep(i,s.size()){
    deq.push_back(s[i]);
  }
  ll q; cin>>q;
  bool now=0;
  rep(i,q){
    ll a; cin>>a;
    if(a==1){
      now^=1;
    }else{
      ll b; char c; cin>>b>>c;
      if(now==0){
        if(b==1) deq.push_front(c);
        else deq.push_back(c);
      }else{
        if(b==1) deq.push_back(c);
        else deq.push_front(c);
      }
    }
  }
  
  ll n=deq.size();
  string ans="";
  rep(i,n){
    ans+=deq[i];
  }
  if(now) reverse(all(ans));
  cout<<ans<<endl;
}

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

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] str = stdR.readLine().split(" ");
        int H = Integer.parseInt(str[0]);
        int W = Integer.parseInt(str[1]);
        str = stdR.readLine().split(" ");
        int h = Integer.parseInt(str[0]);
        int w = Integer.parseInt(str[1]);
        System.out.println((H - h) * (W - w));
    }
}


Measured memory_bytes: 22612
use proconio::*;
use proconio::marker::*;

use std::collections::VecDeque;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize, M: usize,
        mut AB: [(Usize1, Usize1); M],
    }
    let mut edges = vec![vec![]; N];
    for &(A, B) in AB.iter() {
        edges[A].push(B);
        edges[B].push(A);
    }
    let mut q = VecDeque::new();
    q.push_front(0);
    let mut numbers = vec![std::usize::MAX; N];
    while q.len() != 0 {
        let room = q.pop_back().unwrap();
        for &each in edges[room].iter() {
            if numbers[each] == std::usize::MAX {
                numbers[each] = room;
                q.push_front(each);
            }
        }
    }
    println!("Yes");
    for &number in numbers[1..].iter() {
        println!("{}", number + 1);
    }
}


Measured memory_bytes: 17216
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public struct Pair<T> { public T x, y; public Pair(T x, T y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        long N = NextLong();
        int M = NextInt();
        List<Tuple<int, int>> e = Enumerable.Range(0, M).Select(v => new Tuple<int, int>(NextInt() - 1, NextInt() - 1)).ToList();
        e.Reverse();
        UnionFind UF = new UnionFind((int)N);
        List<long> ans = new List<long>();
        long sum = N * (N - 1) / 2;
        ans.Add(sum);
        for (int i = 0; i < M - 1; i++)
        {
            //くっつけていく
            long a = UF.GetItem(e[i].Item1);
            long b = UF.GetItem(e[i].Item2);
            if (UF.IsSameGroup(e[i].Item1, e[i].Item2)) { ans.Add(Math.Max(sum, 0)); continue; }
            else ans.Add(Math.Max(0, sum - a * b));
            sum -= a * b;
            UF.Unite(e[i].Item1, e[i].Item2);
        }
        ans.Reverse();
        ans.ForEach(Console.WriteLine);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class UnionFind
{
    private int[] data;

    public UnionFind(int size)
    {
        data = new int[size];
        for (int i = 0; i < size; i++) data[i] = -1;
    }

    public bool Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);

        if (x != y)
        {
            if (data[y] < data[x])
            {
                var tmp = y;
                y = x;
                x = tmp;
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

    public bool IsSameGroup(int x, int y)
    {
        return Root(x) == Root(y);
    }
    public int GetItem(int x)
    {
        return -data[Root(x)];
    }
    private int Root(int x)
    {
        return data[x] < 0 ? x : data[x] = Root(data[x]);
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,m; cin>>n>>m;
	int a = 1900 * m + 100 * (n - m);
	cout<<a * (1 << m)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n,k;
  cin >> n >> k;
  int temp;
  int count = 0;
  rep(i,n){
    cin >> temp;
    if(temp == 1){
      count = i + 1;
    }
  }
 
    if((n - k) % (k - 1) != 0)cout << (n - k) / (k - 1) + 2 << endl;
    else cout << (n - k) / (k - 1) + 1 << endl;
  
  
  return 0;
}


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

int main(){
    int N,M,C;
    cin>>N>>M>>C;
    vector<int> B(M);
    for(int i=0;i<M;i++) cin>>B[i];
    vector<vector<int>> A(N,vector<int>(M));
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++) cin>>A[i][j];
    }

    int sum=0,ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            sum+=A[i][j]*B[j];
        }
        if(sum+C>0) ans++;
        sum=0;
    }
    cout<<ans<<endl;
}

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

#define _ cin.tie(0);ios::sync_with_stdio(false);
using namespace std;
using LL = long long;
const int N = 100000 + 5;

LL tree[N << 1];
LL read(int k){
    LL sum = 0;
    while(k){
        sum += tree[k];
        k -= k&-k;
    }
    return sum;
}

void add(int k,LL num){
    while(k <= N){
        tree[k] += num;
        k += k&-k;
    }
}
vector<LL> a, b, c;
int main(){ _
    LL  n, m;
    memset(tree, 0, sizeof(tree));
    cin >> n;
    for(int i = 0; i < n; i++) { cin >> m; a.push_back(m); }
    for(int i = 0; i < n; i++) { cin >> m; b.push_back(m); }
    for(int i = 0; i < n; i++) { cin >> m; c.push_back(m); }
    sort(a.begin(), a.end()); sort(b.begin(), b.end()); sort(c.begin(), c.end());

    for(int i = 0; i < n; i++){
        auto tmp = lower_bound(a.begin(), a.end(), b[i]);
        int num = distance(a.begin(), tmp);
        add(i + 1, num);

    }
    LL sum = 0;
    for(auto &i : c){
        auto tmp = lower_bound(b.begin(), b.end(), i);
        int cur = distance(b.begin(), tmp);
        LL num = read(cur);
        sum += num;
    }
    cout << sum << endl;
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int main(){ 
	int n,a[N],i,j,ansa,ansb; 
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	ansa=a[n-1];
	for(i=n-2;i>=0;i--)
	{
		if(!i)
			ansb=a[i];
		if(min(a[i],a[n-1]-a[i])>=min(a[i-1],a[n-1]-a[i-1]))
		{
			ansb=a[i];
			break;
		}
	}
	cout<<ansa<<" "<<ansb<<endl;
	return 0;
}

Measured memory_bytes: 640
N,Q=map(int,input().split())
S=input()
k = [0] * (N+1)

for i in range(N-1):
  v = 1 if S[i:i+2] == 'AC' else 0
  k[i+1] = k[i] + v
for _ in range(Q):
  f,l = map(int,input().split())
  print(k[l-1] - k[f-1])


Measured memory_bytes: 9156
#include<iostream>
using namespace std;
int main(){
	char c[100][100];
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>c[i][j];
	for(int i=-1;i<=h;i++){
		cout<<"#";
		for(int j=0;j<w;j++)
			if(i+1&&i-h)cout<<c[i][j];
			else cout<<"#";
		cout<<"#"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int,input().split()))

from collections import defaultdict
d = defaultdict(int)
for i in a:
    d[i]+=1
ret = 0
for k,v in d.items():
    if k > v:
        ret += v
    elif k < v:
        ret += (v-k)
print(ret)

Measured memory_bytes: 18164
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
    f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int a,b,c;
int main()
{   
    read(a),read(b),read(c);
    if((a==b && b!=c) || (a==c && c!=b) || (b==c && a!=c)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main(void){

    int a,b,d,r;
    double f;

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


    if(!b) {
        printf("division by zero");
        exit(1);
    }

    printf("%d %d %5f\n",a/b, a%b, (double)a/b);

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
signed main()
{
	int n = in();
	vector<int>s(n);
	REPC(&i, s)i = in();
	int q = in();
	vector<int>t(q);
	REPC(&i, t)i = in();
	int ans = 0;
	REPC(i, t)if (binary_search(ALL(s), i))ans++;
	cout << ans << endl;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << w * h * 0.5 << ' ';
  cout << (x == w/2 && y == h/2) << endl;
}


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

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    string S;
    cin >> S;
    if(S=="AAA" || S=="BBB") cout << "No";
    else cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

int const inf = 1e9+9;
int const N = 305;
int d[N][N];
bool vis[400];
int n,m,l,res;
using namespace std;



int main(){

    cin>>n>>m>>l;

    int i,j,k;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(i==j) d[i][j] = 0;
            else d[i][j] = inf;
        }
    }

    
    int a,b,c;
    while(m--){
        cin>>a>>b>>c;
        d[a][b] = c;
        d[b][a] = c;
    }

    for(k=0;k<N;k++){
        for(i=0;i<N;i++){
            for(j=0;j<N;j++){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
    }
    }

    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(d[i][j]<=l) d[i][j] = 1;
            else d[i][j] = inf;
        }
    }

    for(k=0;k<N;k++){
        for(i=0;i<N;i++){
            for(j=0;j<N;j++){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
    }

    }

    int s,t,q;
    cin>>q;
    while(q--){
        cin>>s>>t;
        
        if(d[s][t]==inf) cout<<-1<<endl;
        else cout<<d[s][t]-1<<endl;
    }
   

}



Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

#ifndef ANSWER
#define ANSWER  2
#endif

struct Point
{
    int X;
    int Y;
    int A;
};

ll solve(const int W, const int H, const std::vector<Point>& P)
{
#if ANSWER == 1
    std::vector<std::vector<int>> A(H, std::vector<int>(W, 0));
    for (auto itr = P.begin(); itr != P.end(); ++itr)
    {
        switch (itr->A)
        {
        case 1: // X < Xi
            for (int x = 0; x < itr->X; x++)
            {
                for (int y = 0; y < H; y++)
                {
                    A[y][x] = 1;
                }
            }
            break;

        case 2: // X > Xi
            for (int x = itr->X; itr->X - 1 < x && x < W; x++)
            {
                for (int y = 0; y < H; y++)
                {
                    A[y][x] = 1;
                }
            }
            break;

        case 3: // Y < Yi
            for (int x = 0; x < W; x++)
            {
                for (int y = 0; y < itr->Y; y++)
                {
                    A[y][x] = 1;
                }
            }
            break;

        case 4: // Y > Yi
            for (int x = 0; x < W; x++)
            {
                for (int y = itr->Y; itr->Y - 1 < y && y < H; y++)
                {
                    A[y][x] = 1;
                }
            }
            break;
        }
    }
#if DEBUG1
    for (auto itr1 = A.begin(); itr1 != A.end(); ++itr1)
    {
        std::cout << "DEBUG1: ";
        for (auto itr2 = itr1->begin(); itr2 != itr1->end(); ++itr2)
        {
            std::cout << *itr2;
        }
        std::cout << std::endl;
    }
#endif

    return std::accumulate(A.begin(), A.end(), 0, [](const int a, const std::vector<int>& v){
        return std::accumulate(v.begin(), v.end(), a, [](const int a, const int v){
            if (0 == v)
            {
                return a + 1;
            }
            return a;
        });
    });
#elif ANSWER == 2
    int w = W;
    int h = H;
    int x = 0;
    int y = 0;
    for (auto itr = P.begin(); itr != P.end(); ++itr)
    {
        switch (itr->A)
        {
        case 1: // X < Xi
            x = std::max(x, itr->X);
            break;

        case 2: // X > Xi
            w = std::min(w, itr->X);
            break;

        case 3: // Y < Yi
            y = std::max(y, itr->Y);
            break;

        case 4: // Y > Yi
            h = std::min(h, itr->Y);
            break;
        }
    }
#if DEBUG1
    std::cout << "DEBUG1: w: " << w << " x: " << x << " h: " << h << " y: " << y << std::endl;
#endif
    if ((w - x) < 1 || (h - y) < 1)
    {
        return 0;
    }
    return (w - x) * (h - y);
#endif
}

int main(void)
{
    int W, H, N;
    std::cin >> W >> H >> N;

    std::vector<Point> P(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> P[i].X >> P[i].Y >> P[i].A;
    }
    std::cout << solve(W, H, P) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int n, k;
int h[100100], dp[100100];

int max(int a, int b) {
    return (a > b ? a : b);
}

int min(int a, int b) {
    return (a < b ? a : b);
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = 1e9;
        for (int j = i - 1; j >= max(i - k, 0); j--) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 896
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int main(){
	
	int a[3],b[2];
	
	for(int i=0;i<3;i++)
		cin>>a[i];
	
	for(int j=0;j<2;j++)
		cin>>b[j];
	
	sort(a,a+3);
	sort(b,b+2);
	
	cout<<a[0]+b[0]-50<<endl;

}

Measured memory_bytes: 1176
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W,K;
    cin >> H >> W >> K;
    vector<string> G(H);
    for(int i=0; i<H; i++) cin >> G[i];
    int sy,sx;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(G[i][j] == 'S'){
                sy = i;
                sx = j;
            }
        }
    }
    queue<P> que;
    que.emplace(sy,sx);
    vector<vector<int>> dist(H,vector<int>(W,-1));
    dist[sy][sx] = 0;
    while(que.size()){
        int y,x;
        tie(y,x) = que.front();
        que.pop();
        for(int k=0; k<4; k++){
            int ny = y + dy[k];
            int nx = x + dx[k];
            if(ny<0 || ny>=H || nx<0 || nx>=W) continue;
            if(G[ny][nx] == '#') continue;
            if(dist[ny][nx] != -1) continue;
            dist[ny][nx] = dist[y][x] + 1;
            que.emplace(ny,nx);
        }
    }
    int mn = inf;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(dist[i][j]==-1 || dist[i][j]>K) continue;
            chmin(mn,i);
            chmin(mn,j);
            chmin(mn,H-1-i);
            chmin(mn,W-1-j);
        }
    }
    if(mn == 0){
        cout << 1 << "\n";
    }else{
        cout << (mn+K-1)/K + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 3456