akhauriyash/Code-Regression huggingface dataset:
# ABC128-B
# ソートが大事な問題
from operator import itemgetter
a = int(input())
book = []
for i in range(a):
    array = input().split()
    book.append((array[0], int(array[1]) * -1, i))

ans = sorted(book, key=itemgetter(0, 1))

for i in range(a):
    print(ans[i][2] + 1)


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

int main(void) {
  int H, W;
  cin >> H >> W;
  char s[H + 2][W + 2];
  for (int i = 1; i < H; i++) {
    cin >> (s[i] + 1);
  }

  bool flag = true;

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] == '#' && s[i + 1][j] != '#' && s[i - 1][j] != '#' &&
          s[i][j - 1] != '#' && s[i][j + 1] != '#') {
        flag = false;
      }
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static final int MOD = 1000000007;

	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}

	static int sub(int a, int b) {
		int res = a - b;
		return res < 0 ? res + MOD : res;
	}

	static int mul(int a, int b) {
		int res = (int) ((long) a * b % MOD);
		return res < 0 ? res + MOD : res;
	}

	static int fib(int i) {
		int c0 = 0, c1 = 1;
		while (i-- > 0) {
			int c2 = add(c0, c1);
			c0 = c1;
			c1 = c2;
		}
		return c0;
	}

	static void solve() throws Exception {
		int n = scanInt(), m = scanInt();
		String s = scanString();
		char c1 = s.charAt(0);
		boolean diff = false;
		int cnt = 1, cntMin = Integer.MAX_VALUE;
		for (int i = 1; i < m; i++) {
			if (s.charAt(i) == c1) {
				++cnt;
			} else {
				if (cnt % 2 == 1 || !diff) {
					cntMin = min(cntMin, cnt);
				}
				diff = true;
				cnt = 0;
			}
		}
		int ans;
		if (diff) {
			if (n % 2 == 0) {
				n /= 2;
				ans = 0;
				int k = cntMin / 2;
//				System.err.println(n + " " + k);
				int dyn[] = new int[k + 1];
				dyn[0] = 1;
				int sum = 1;
				for (int i = 0; i < n; i++) {
//					System.err.println(i + " " + dyn[i % (k + 1)]);
					if (i + 1 + k >= n) {
						ans = add(ans, mul(dyn[i % (k + 1)], n - i));
					}
					int v = sum;
					sum = sub(sum, dyn[(i + 1) % (k + 1)]);
					dyn[(i + 1) % (k + 1)] = v;
					sum = add(sum, v);
				}
				ans = add(ans, ans);
			} else {
				ans = 0;
			}
		} else {
			ans = add(fib(n - 1), fib(n + 1));
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 27552
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

        int m,n,i,cnt=0,sum=0,x;
        cin>>n>>m;
        vi a(n);
        for(i=0;i<n;i++) {cin>>a[i]; sum+=a[i];}

         x= sum/(4*m) + (sum%(4*m)!=0?1:0);
        for(i=0;i<n;i++) 
        {
        	if(a[i]>=x)
        		cnt++;
        	
        }

        if(cnt>=m)
        	cout<<"Yes";
        else
        	cout<<"No";
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
int N, K;
vector<long long> A;
bool solve(long long mod) {
    vector<long long> B;
    B.resize(N);
    for(int i = 0; i < N; i++) {
        B[i] = A[i] % mod;
    }
    sort(B.begin(), B.end());
    ll b = 0;
    REP(i, N) { b += mod - B[i]; }
    ll a = 0;
    ll need = 1e18;
    REP(i, N) {
        a += B[i];
        b -= mod - B[i];
        need = min(need, max(a, b));
    }
    return need <= K;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    REP(i, N) { cin >> A[i]; }
    //操作によって総和はかわらない
    //和も割り切ることができる
    long long sum = accumulate(A.begin(), A.end(), 0LL);
    // 全部をXの倍数にするために必要な操作回数+Xの倍数
    set<ll> candidates;
    for(int i = 1; i * i <= sum; i++) {
        if(sum % i == 0) {
            candidates.insert(i);
            candidates.insert(sum / i);
        }
    }
    for(auto it = candidates.rbegin(); it != candidates.rend(); it++) {
        if(solve(*it)) {
            cout << *it << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
#define mod 1000000007
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define loop(x,y,z) for(int x=y;x<z;x++)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    str s,s1;
    cin>>s>>s1;
    str s2="";
    f(i,s1.length()-1){
        s2+=s1[i];
    }
    if(s2==s){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t

inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{
	fast();
	lli x,prev,m1=INT_MIN,n,k;
	cin>>n>>k;
	lli a[n];
	rep(i,0,n)
		cin>>a[i];
	lli one=0,zero=0,curr=0;
	for(lli i = 60; i >= 0; i--)
	{
		lli o = 0, z = 0;
		for(lli j = 0; j < n; j++){
			if((1LL << i) & a[j]) o++;
			else z++;
		}
		if(z > o) if(curr + (1LL << i) <= k) curr += (1LL << i);
	}
	lli sum=0;
	
		for(int i = 0; i < n; i++){
		sum += (a[i] ^ curr);
	}
		cout<<sum;
	return 0;
}

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

int main(){
  long long n;
  bool finish = true;
  cin >> n;
  
  vector<char> ab(26);
  for(int i = 0; i < 26; i++){
    ab.at(i) = 'a' + i;
  }
  
  vector<char> vec;
  n--;
  
  while(finish){
    if(n / 26 == 0){
      finish = false;
    }
    
    int idx = n % 26;
    char c = ab.at(idx);
    vec.push_back(c);
    
    n /= 26;
    n--;
  }
  
  reverse(vec.begin(), vec.end());
  string str;
  for(int i = 0; i < vec.size(); i++){
    str.push_back(vec.at(i));
  }
  
  cout << str << endl;
  
}

Measured memory_bytes: 3596
import math

def main():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                tmp = math.gcd(i,j)
                ans += math.gcd(tmp,k)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9192
n,p = map(int,input().split())

a = list(map(int,input().split()))

odd = []
even = []
for i in a:
    if i % 2 != 0:
        odd.append(i)
    else:
        even.append(i)
if len(odd) == 0:
    if p == 1:
        ans = 0
    else:
        ans = 2 ** len(even)
else:
    ans = 2 ** len(even) * 2 ** (len(odd) - 1)
print(ans)

        



Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class DRGBTriplets {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        string s;
        in >> s;
        vector<int> r(n,0),g(n,0),b(n,0);
        rep(i,n){
            if(s[i]=='R') {
                r[i]++;
            }
            if(s[i]=='G') {
                g[i]++;
            }
            if(s[i]=='B') {
                b[i]++;
            }
        }
        rep(i,n-1){
            r[i+1]+=r[i];
            g[i+1]+=g[i];
            b[i+1]+=b[i];
        }
        ll cnt = 0L;
        for(int j=1;j<n-1;j++){
            if(s[j]=='R'){
                cnt+=g[j]*(b.back()-b[j])+b[j]*(g.back()-g[j]);
            }
            if(s[j]=='G'){
                cnt+=b[j]*(r.back()-r[j])+r[j]*(b.back()-b[j]);
            }
            if(s[j]=='B'){
                cnt+=r[j]*(g.back()-g[j])+g[j]*(r.back()-r[j]);
            }
            int t = min(n-j-1,j);
            for(int i=1;i<=t;i++){
                if(s[j]!=s[j-i]&&s[j]!=s[j+i]&&s[j-i]!=s[j+i]){
                    cnt--;
                }
            }
        }
        out << cnt << endl;
	}
};


int main() {
	DRGBTriplets solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a ;
  int m=3*a;
  long long k[m+2]={0};

  for(int i=0;i<m;i++){
    cin >> k[i];
  }
  sort(k,k+m,greater<long long>());
  long long sum=0;

  for(long long i=1,j=0;i<2*a,j<a;i+=2,j++){
    sum+=k[i];
  }
  cout << sum << endl;
}


    
  


Measured memory_bytes: 5940
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto S = readln.chomp;
    auto T = readln.chomp;

    char[char] c0, c1;
    foreach (i; 0..S.length) {
        const s = S[i];
        const t = T[i];
        if (s !in c0 && t !in c1) {
            c0[s] = t;
            c1[t] = s;
        }
        if (s in c0 && c0[s] != t) {
            writeln("No");
            return;
        }
        if (t in c1 && c1[t] != s) {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}



Measured memory_bytes: 2656
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_A = 100000;
const int MAX_N = 100000;
ll n, m;
int a[MAX_N];
ll cnt[MAX_A + 1];
ll sum[MAX_A + 1];

bool check(int x) {
    ll c = 0;
    forn(i, n) {
        int j = max(0, x - a[i]);
        if (j > MAX_A) continue;
        c += cnt[j];
    }
    return c >= m;
}

int main() {
    fastio();

    cin >> n >> m;
    forn(i, n) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    sum[MAX_A] = cnt[MAX_A] * MAX_A;
    for (int i = MAX_A - 1; i >= 0; i--) {
        sum[i] += sum[i + 1] + cnt[i] * i;
        cnt[i] += cnt[i + 1];
    }

    int l = 1, r = 200001;
    while (r - l > 1) {
        int x = (l + r) / 2;
        if (check(x))
            l = x;
        else
            r = x;
    }

    // cout << l << endl;

    ll c = 0;
    ll ans = 0;
    forn(i, n) {
        int j = max(0, l + 1 - a[i]);
        if (j > MAX_A) continue;
        // cout << j << " " << cnt[j] << " " << sum[j] << endl;
        c += cnt[j];
        ans += sum[j] + 1LL * cnt[j] * a[i];
    }

    ans += (m - c) * l;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2176
def main():
  n,m=map(int,input().split())
  x=list(map(int,input().split()))
  xmod=[y%m for y in x]
  from collections import Counter
  cx=dict(Counter(x))
  cxmod=dict(Counter(xmod))
  keys=cxmod.keys()
  ans1,ans2=0,0 # ams1:m倍になるペア、ans2:同数のペア。ans1からもとめる
  for k in keys:
    if k==0:
      ans1+=cxmod[k]//2
      cxmod[k]-=2*(cxmod[k]//2)
    else:
      if k==m-k:
        ans1+=cxmod[k]//2
        cxmod[k]-=2*(cxmod[k]//2)
      elif m-k in keys:
        tmp=min(cxmod[k],cxmod[m-k])
        ans1+=tmp
        cxmod[k]-=tmp
        cxmod[m-k]-=tmp
  for k in cx:
    v=cx[k]
    if v>=2 and cxmod[k%m]>=2:
      tmp=min(v//2,cxmod[k%m]//2)
      ans2+=tmp
      cxmod[k%m]-=tmp*2

  print(ans1+ans2)
if __name__=='__main__':
  main()



Measured memory_bytes: 37408
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int mi=1000;
  
  for(int i=0;i<s.size()-2;i++){
    string ss=s.substr(i,3);
    int ans=stoi(ss);
    mi=min(mi,abs(753-ans));
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int num_queue,num_query;
    scanf("%d %d",&num_queue,&num_query);
    queue<int> queue_array[num_queue];
    
    int command, queue_idx,val;
    for(int i = 0;i < num_query;i++){
        scanf("%d %d",&command,&queue_idx);
        if(command == 0){
            scanf("%d", &val);
            queue_array[queue_idx].push(val);
        }else if(command == 1){
            if(!queue_array[queue_idx].empty()) printf("%d\n",queue_array[queue_idx].front());
        }else{
            if(!queue_array[queue_idx].empty()) queue_array[queue_idx].pop();
        }
    }
    
    return 0;
}


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


int main(){
    vector <vector <long long> > DP;
    int N, WagaMax;
    cin >> N >> WagaMax;
    long long Suma = 0;
    vector <long long> A(N+1);
    vector <long long> W(N+1);
    for (int i = 1; i <= N; i++){
        cin >> W[i] >> A[i];
        Suma += A[i];
    }
    
    DP.resize(N+1, vector <long long>(Suma+1, WagaMax+1)); // dla danej sumy wartosci jaka jest najmniejsza waga
    DP[0][0] = 0;
    for (int i = 1; i<=N; i++){
        long long Wartosc = A[i];
        for (int j = Suma; j>=Wartosc; j--){
            DP[i][j] = min(DP[i][j], DP[i-1][j-Wartosc]+W[i]);
        }
        for (int j = Suma; j>=0; j--){
            DP[i][j] = min(DP[i][j], DP[i-1][j]);
        }
    }

    // for (auto v : DP){
    //     for (auto co : v){
    //         cerr << co << " ";
    //     }
    //     cerr << "\n";
    // }
    // cerr << "===========\n";
    long long Res = 0;
    for (int i = 0; i<=Suma; i++){
        if (DP[N][i] <= WagaMax){
            Res = i;
        }
    }
    cout << Res;



}

Measured memory_bytes: 80256
#include<stdio.h>
int main(void){
  int m,d,w,i;
  int wm[12]={3,1,3,2,3,2,3,3,2,3,2,3};
  
  while(scanf("%d %d",&m,&d),m!=0&&d!=0){
    w=d+2;
    for(i=0;i<m-1;i++)
      w+=wm[i];
    switch(w%7){
    	case 0:printf("Monday\n");break;
    	case 1:printf("Tuesday\n");break;
    	case 2:printf("Wednesday\n");break;
    	case 3:printf("Thursday\n");break;
    	case 4:printf("Friday\n");break;
    	case 5:printf("Saturday\n");break;
    	case 6:printf("Sunday\n");break;
    	}
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef pair<int,int> pi;

const int N=100005;

int n,m,fa[N];
set<int> e[N];
set<pi> o;
inline void add(int u,int v){
	auto it=e[u].find(v);
	if(it!=e[u].end()){
		e[u].erase(it);
		if(u>v)swap(u,v);
		o.insert({u,v});
	}else e[u].insert(v);
}
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}

int main(){
	scanf("%d",&n);
	for(int i=2,u,v;i<2*n;i++)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	for(int i=1;i<=n;i++)fa[i]=i;
	while(o.size()){
		auto p=o.begin();
		int u=find(p->fi),v=find(p->se);
		o.erase(p);
		if(e[u].size()>e[v].size())swap(u,v);fa[u]=v;
		for(int k:e[u])e[k].erase(u),add(v,k),add(k,v);
		e[u].clear();
		m++;
	}
	if(m==n-1)puts("YES");else puts("NO");
	return 0;
}

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

int main() {
    int N,K; cin >> N >> K;
    int ans = 0;
    int h;

    for (int i = 0; i < N; ++i) {
        cin >> h;
        if(h >= K) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

thetaA = H*30+M/60*30
thetaB = M*6

diff = abs(thetaA-thetaB)
th = min(diff, 360-diff)
ans = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(th)))
print(ans)

Measured memory_bytes: 62564
D, G = map(int, input().split())
PnC = [list(map(int, input().split())) for x in range(D)]

counts = []
def calc(i, count, total, last):
  if G <= total:
    counts.append(count)
    return
  if i >= D:
    for x in range(PnC[last][0]):
      if G <= total + 100*x*(last+1):
        counts.append(count + x)
        return
    return
  calc(i+1, count, total, i)
  calc(i+1, count+PnC[i][0], total+PnC[i][1]+100*(i+1)*PnC[i][0], last)

calc(0, 0, 0, 0)
print(min(counts))


Measured memory_bytes: 3064
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Ten = Tuple!(int, "t", int, "x", int, "i");

void main() {
    int N, Q;
    scan(N, Q);

    Ten[] a;

    foreach (i ; 0 .. N) {
        int si, ti, xi;
        scan(si, ti, xi);
        a ~= Ten(si - xi, xi, -1);
        a ~= Ten(ti - xi, xi, -2);
    }

    foreach (i ; 0 .. Q) {
        int di;
        scan(di);
        a ~= Ten(di, inf3, i);
    }

    auto ans = new int[](Q);
    auto rb = redBlackTree!(int)();
    rb.insert(inf3);

    a.sort();

    foreach (ai ; a) {
        if (ai.i == -1) {
            rb.insert(ai.x);
        }
        else if (ai.i == -2) {
            rb.removeKey(ai.x);
        }
        else {
            ans[ai.i] = rb.front;
        }
    }

    ans = ans.map!(x => x == inf3 ? -1 : x).array;

    writefln("%(%s\n%)", ans);
}

















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

const Int INF = 1e18;

Int N, M, L;
vector<vector<Int>> dist(310, vector<Int>(310, INF));
vector<vector<Int>> hokyu(310, vector<Int>(310, INF));

void warshall_floyd1(){
    rep(k, N) rep(i, N) rep(j, N){
        if (dist[i][k] != INF && dist[k][j] != INF){
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
    }
}

void warshall_floyd2(){
    rep(k, N) rep(i, N) rep(j, N){
        if (hokyu[i][k] != INF && hokyu[k][j] != INF){
            hokyu[i][j] = min(hokyu[i][j], hokyu[i][k] + hokyu[k][j]);
        }
    }
}

int main(){ 
    cin >> N >> M >> L;

    rep(i,M){
        int A, B; Int C;
        cin >> A >> B >> C;
        A--; B--;
        if(C <= L){
            dist[A][B] = C;
            dist[B][A] = C;
        }
    }

    warshall_floyd1();
    rep(i,N) rep(j,N){
        if(dist[i][j] <= L) hokyu[i][j] = 1;
    }
    warshall_floyd2();

    int Q; cin >> Q;
    rep(query, Q){
        int s, t; cin >> s >> t; s--; t--;

        if(dist[s][t] == INF){
            cout << -1 << endl;
        } else {
            cout << hokyu[s][t] - 1<< endl;
        }
    }
}

Measured memory_bytes: 2048
#!/usr/bin/env python3
import sys
from itertools import combinations_with_replacement


def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    L = list(combinations_with_replacement(range(1, M+1), N))
    pt = 0
    for l in L:
        tmp = 0
        for ai, bi, ci, di in zip(a, b, c, d):
            if l[bi-1] - l[ai-1] == ci:
                tmp += di
        pt = max(pt, tmp)
    print(pt)
    # dct = {}
    # for ai, bi, ci, di in zip(a, b, c, d):
    #     if (ai, bi) in dct:
    #         dct[(ai, bi)].add((ci, di))
    #     else:
    #         dct[(ai, bi)] = set()
    #         dct[(ai, bi)].add((ci, di))
    # A = [1 for _ in range(N)]
    # Ab = [False for _ in range(N)]
    # Ab[0] = True
    # mx = 0

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 84756
N = int(input())
T = [int(input()) for _ in range(N)]

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

def mylcm(a, b):
    return (a * b) // mygcd(a, b)

ans = T[0]
for i in range(1, N):
    ans = mylcm(ans, T[i])

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void)
{
  int N, M, K, i, j, k, tmp, X[100001], ans;
  double S;
  scanf("%d %d", &N, &M);
  if (N == M)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp;
    cin >> temp;
    return temp;
}


int main() {
    char b(in<char>());
    switch(b) {
        case 'A' : b = 'T';
                 break;
        case 'T' : b = 'A';
                   break;
                  case 'G' : b = 'C';
                             break;
                  case 'C' : b = 'G';
                             break;
    } 
    cout << b << endl;
    return 0;
}




Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    };

    let a_e = {
        let mut res = 0_i64;
        let mut sum = 0_i64;
        for (i, &a_i) in a.iter().enumerate() {
            sum += a_i;
            if i % 2 == 0 {
                if sum > 0 {
                    // do nothing
                } else {
                    res += 1 - sum;
                    sum = 1;
                }
            } else {
                if sum >= 0 {
                    res += 1 + sum;
                    sum = -1;
                } else {
                    // do nothing
                }
            }
        }
        res
    };

    let a_o = {
        let mut res = 0_i64;
        let mut sum = 0_i64;
        for (i, &a_i) in a.iter().enumerate() {
            sum += a_i;
            if i % 2 == 0 {
                if sum >= 0 {
                    res += 1 + sum;
                    sum = -1;
                } else {
                    // do nothing
                }
            } else {
                if sum > 0 {
                    // do nothing
                } else {
                    res += 1 - sum;
                    sum = 1;
                }
            }
        }
        res
    };

    let ans = std::cmp::min(a_e, a_o);
    println!("{}", ans);
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]+a[1]==a[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
typedef long long int unsigned lliu;
typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
#define MAXN 200005
int main(){
	fastIO
	int n, k;
	cin>>n>>k;
	vlli costo(n);
	forn(i, n){
		cin>>costo[i];
	}
	lli inf=1e15;
	vlli mem(n+1, inf);
	mem[n-1]=0;
	mem[n-2]=abs(costo[n-1]-costo[n-2]);
	for(int i=n-3; i>=0; i--){
		lli &res=mem[i];
		for(int j=1; j<=k; j++){
			if(i+j>=n)
				break;
			res = min(res, abs(costo[i] - costo[i+j]) + mem[i+j]);
		}
	}
	cout<<mem[0]<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100000000;

#define cle(n) memset(n,0,sizeof(n))
#define MAXN 1005;

int n,m;


int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a+b)%24<<endl;


}



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

int main() {
  int K,sum=0;
  cin >> K;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int l=1;l<=K;l++){
        sum+=gcd(gcd(i,j),l);
      }
    }
  }
  cout << sum;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main(string[] args) {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var answerList = new List<int>();
        var firstMountain = 0;
        // x1=a1-a2+a3-a4+...+an（nは奇数）
        for(int i = 0; i<n; i++) {
            // iが偶数の時は加算、奇数の時は減算
            var sign = i % 2 == 0 ? 1 : -1;
            firstMountain += a[i] * sign;
        }
        answerList.Add(firstMountain);
        // x2 = (a1 - x1/2) * 2
        int beforeMountain = firstMountain;
        for (int i = 0; i<n-1; i++) {
            int mountain = (a[i] - beforeMountain / 2) * 2;
            answerList.Add(mountain);
            beforeMountain = mountain;
        }
        Console.WriteLine(String.Join(" ", answerList));
    }
}


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

int main(){
  vector<int> data(3);
  for(int i=0; i<3; i++) cin >> data[i];
  sort(data.begin(),data.end());
  int count=0;
  
  while(1){
    if(data[2] > data[1]){
      data[1]++;
      data[0]++;
      count++;
    }else if(data[2] == data[1]){
      if((data[1] - data[0])%2 == 0){
        count += (data[1] - data[0])/2;
        break;
      }else{
        count += (data[1] - data[0])/2;
        count += 2;
        break;
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	scanf("%d %d",&m,&n);
	int ans = 0;
	if(m>1 && n>1)
	ans = (n*(n-1)/2)+ (m*(m-1)/2);
	
	else if(n <= 1)
		ans = (m*(m-1))/2;
		else if(m<=1)
		ans = (n*(n-1)/2); 

	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x - a) < abs(x - b)){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())

A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A = sorted(A)
B = sorted(B)

if N % 2 == 0:
    Amed = A[N//2-1]+A[N//2]
    Bmed = B[N//2-1]+B[N//2]
    print(Bmed-Amed+1)
else:
    Amed = A[N//2]
    Bmed = B[N//2]
    print(Bmed-Amed+1)


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

int main(){
  int N;
  cin >> N;
  vector<int> A;
  int one_cnt=0;
  int num;
  unordered_map<int,bool> mp;
  set<int> dup;
  rep(i,N){
    cin >> num;
    A.push_back(num);
    if(num==1) one_cnt++;
    if(mp[num]==true){
      dup.insert(num);
    }else mp[num]=true;
  }
  
  if(one_cnt==1){
    cout << 1;
    return 0;
  }
  else if(one_cnt>1){
    cout << 0;
    return 0;
  }
  
  sort(A.begin(),A.end());
  if(A.size()==1){
    cout << 1;
    return 0; 
  }
  
  if(A[0]==A[A.size()-1]){
    cout << 0;
    return 0;
  }
  int flag[A[A.size()-1]+3]={0};
  for(auto d:dup){
    for(int j=d;j<=A[A.size()-1];j=j+d) flag[j]=1;
  }
  
  int res=0;
  for(int i=0;i<A.size();i++){
    if(flag[A[i]]==0){
      res++;
      for(int j=A[i];j<=A[A.size()-1];j=j+A[i]) flag[j]=1;
    }
  }
  cout << res;
  return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  
  cout << (n*(n-1)+m*(m-1))/2 << endl;
  return 0;  
}

Measured memory_bytes: 256
puts Array.new(gets.to_i) {|i|
  s, p = gets.split
  [i + 1, s, p.to_i]
}
.sort! {|a, b| 
  (a[1] <=> b[1]).nonzero? || (b[2] <=> a[2]) 
}
.map {|a| a[0] }
.join("\n")

Measured memory_bytes: 1788
N=list(map(int, input().split()))
A=[0]*N[0]
L=0
M=0
for i in range(N[0]):
    A[i]=int(input())
    if A[i]>M:
        if A[i]>L:
            M=L
            L=A[i]
        else:
            M=A[i]
for i in range(N[0]):
    if A[i]==L:
        print(M)
    else:
        print(L)

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

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

const long long INF = 1LL << 60;

int N;
INT dp[100002][3], a[100002][3],ans;

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++)for (int j = 0; j <= 2; j++) {
        cin >> a[i][j];
        dp[i][j] = 0;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= 2; j++) {
            if (i == 1)dp[1][j]=a[1][j];
            for (int k = 0; k <= 2; k++) {
                if (k != j)chmax(dp[i + 1][k],dp[i][j] + a[i+1][k]);
            }
        }
    }

    ans = max(dp[N][0], max(dp[N][1], dp[N][2]));

    cout << ans << endl;
}

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

#define ll long long

int main()
{
  ll k, n;
  cin >> k >> n;

  ll ap;
  cin >> ap;
  ll gap = 0;
  ll z = ap;
  for (int i = 1; i < n; i++)
  {
    ll x;
    cin >> x;
    gap = max(abs(ap - x), gap);
    ap = x;
  }

  gap = max(gap, z + k - ap);

  cout << k - gap << endl;

  return 0;
}

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

using namespace std;
using ll = long long;



int main()
{
    string s;
    cin >> s;
    if(s.size() & 1){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < (int)s.size(); i+= 2){
        if(s[i] != 'h' || s[i + 1] != 'i'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

int main(){
	while(true){
		int m;
		cin >> m;
		if(m == 0){ break; }
		int bx, by;
		cin >> bx >> by;
		set<pii> stars;
		while(--m){
			int x, y;
			cin >> x >> y;
			stars.insert(pii(x - bx, y - by));
		}
		int n;
		cin >> n;
		set<pii> sky;
		while(n--){
			int x, y;
			cin >> x >> y;
			sky.insert(pii(x, y));
		}
		int ax = 0, ay = 0;
		for(set<pii>::iterator it = sky.begin(); it != sky.end(); it++){
			pii base = *it;
			set<pii>::iterator s = stars.begin();
			while(s != stars.end()){
				if(sky.find(pii((*s).first + base.first, (*s).second + base.second)) == sky.end()){
					break;
				}
				s++;
			}
			if(s == stars.end()){
				ax = base.first - bx;
				ay = base.second - by;
				break;
			}
		}
		cout << ax << " " << ay << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N = 105;
const int MOD = 1000000007;

int n,dp[N][N],h[N],w[N],m;

int pow_(int x,int y) {///快速幂求 x的y次方
    int ans = 1;
    if(y > 0) {
        while(y) {
            if(y % 2)ans = (LL)ans * x % MOD;
            x = (LL)x * x % MOD;
            y /= 2;
        }
    }
    return ans;
}

int main() {
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++) {
        scanf("%d",&h[i]);
        w[++ m] = h[i];
    }
    sort(w + 1,w + m + 1);///高度排序
    m = unique(w + 1,w + m + 1) - w - 1;///离散化 m是离散化后的长度
    for(int i = 1;i <= n;i ++) {
        h[i] = lower_bound(w + 1,w + m + 1,h[i]) - w;
    }
    dp[0][0]=1;
    for(int i = 1;i <= n;i ++) {
        for(int j = h[i] + 1;j <= h[i - 1];j ++)
            (dp[i][0] += dp[i - 1][j] * 2 % MOD) %= MOD;
        (dp[i][0] += dp[i - 1][0] * 2 % MOD) %= MOD;///交叉或者不交叉
        for(int j = 1;j <= h[i];j ++) {
            dp[i][j]=(LL)dp[i - 1][j] * pow_(2,w[h[i]] - w[h[i-1]]) % MOD;
            if(h[i - 1] >= j)continue;///如果是高度不超过前一列的位置 量已经确定了
            if(j > 1)(dp[i][j] += (LL)dp[i - 1][0] * (pow_(2,w[j] - w[j - 1]) - 1) % MOD * 2 % MOD * pow_(2,w[h[i]] - w[j]) % MOD) %= MOD;
            else (dp[i][1] += (LL)dp[i - 1][0] * (pow_(2,w[1]) - 2) % MOD * pow_(2,w[h[i]] - w[1]) % MOD) %= MOD;///上一列中无重复的乘上化不超过上一列高度中有重复的
        }
    }
    int ans = 0;
    for(int i = 0;i <= m;i++)
        (ans += dp[n][i]) %= MOD;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
from collections import deque

mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

N,M = MI()
links = [[] for _ in range(N)]

for _ in range(M):
    a, b = MI()
    a -= 1
    b -= 1
    links[a].append(b)
    links[b].append(a)

ans = [-1] * N
ans[0] = 0
q = deque([(0, 0)])
while q:
  room, prev = q.popleft()
  for next_ in links[room]:
    if ans[next_] < 0:
      ans[next_] = room+1
      q.append((next_, room))
print("Yes")
for i in range(1,N):
  print(ans[i])             

Measured memory_bytes: 39008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(0,i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    ll fa=-1;
    rep(0,i,n){
        if(fa==-1){
            fa=a[i];
        }else{
            if(fa==a[i]){
                cout<<"NO"<<endl;
                return 0;
            }
            fa=a[i];
        }
    }
    cout<<"YES"<<endl;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool a = false, b = false;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'A') a = true;
        if(s[i] == 'B') b = true;
    }

    if(a && b){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
    let X = parseInt(input.split("\n")[0]);
    let tf:boolean;
    for(;true;X++){
        tf = true;
        for(let i=2;i<=Math.sqrt(X);i++){
            if(X%i===0){
                tf = false;
                break;
            }
        }
        if(tf) break;
    }
    console.log(X);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  for(int i = 0; i<H; i++){
    for(int j = 0; j<W; j++){
      cin >> a.at(i).at(j);
    }
  }
  vector<bool> row(H,false);
  vector<bool> lin(W,false);
  for(int i = 0; i<H; i++){
    for(int j = 0; j<W; j++){
      if(a.at(i).at(j) == '#'){
        row.at(i) = true;
        lin.at(j) = true;
      }
    }
  }
  for(int i = 0;i<H;i++){
    if(row.at(i)){
      for(int j = 0; j<W;j++){
        if(lin.at(j)){
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
vector<int> G[114514];
vector<int> path;
bool flg;
int c[114514],used[114514];
void dfs(int v,int p){
  path.push_back(v);
  if(v==n-1){
    flg=1;
    return;
  }
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i];
    if(u==p) continue;
    dfs(u,v);
    if(flg) return;
  }
  path.pop_back();
}
signed main(){
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if(n==2){
    cout<<"Snuke"<<endl;
    return 0;
  }
  flg=0;
  dfs(0,-1);
  
  //assert(path.front()==0);
  //assert(path.back()==n-1);
  memset(c,0,sizeof(c));
  memset(used,0,sizeof(used));

  
  queue<int> q[2];
  vector<int> v=path;
  used[0]=used[n-1]=1;

  for(int u:G[0]) q[0].push(u);
  for(int u:G[n-1]) q[1].push(u);
  //for(int u:v) cout<<u<<" ";cout<<endl;
  
  int k=0,t=0;
  while(1){
    k++;
    if(!used[v[k]]){
      used[v[k]]=1;
      //cout<<v[k]<<endl;
      for(int u:G[v[k]]) q[t].push(u);
      t=1;
    }else break;
    //cout<<"k"<<k<<endl;
    if(!used[v[v.size()-1-k]]){
      used[v[v.size()-1-k]]=1;
      //cout<<v[v.size()-1-k]<<endl;
      for(int u:G[v[v.size()-1-k]]) q[t].push(u);
      t=0;
    }else break;
  }
  
  while(1){
    while(!q[t].empty()&&used[q[t].front()]) q[t].pop();
    if(q[t].empty()){
      if(t) cout<<"Fennec"<<endl;
      else cout<<"Snuke"<<endl;
      return 0;
    }
    int x=q[t].front();
    used[x]=1;
    for(int u:G[x]) q[t].push(u);
    t=!t;
  }  
  
  return 0;
}


Measured memory_bytes: 15732
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  qab[0].reserve(10000);
  qab[1].reserve(10000);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
	V<V<bool>> c(2, V<bool>(2,false));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc+1)%2) { c[i][0]=!c[i][0]; }
			if (qc) { c[i][1]=!c[i][1]; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0]&&!c[1-i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 11008
def reads(offset = 0):
	return [int(i) - offset for i in input().split(' ')]
def Judge(vector):
	length = len(vector)-1
	for i in range(length):
		if(vector[i] > vector[i+1]):		
			return 0
	return 1
(N, M) = reads()
Q = int(input())
A = reads(1)
pos = [-1] * M
pat = []
freq = [0] * (M+1)
freq[0] = N
found = set()
counter = 0
for i in A[::-1]:
	if (i not in found):
		pat.append(i)
		found.add(i)
		pos[i] = counter
		counter += 1
for i in range(M):
	if (pos[i] == -1):
		pat.append(i)	
for i in A[::-1]:
	temp = pos[i]
	if (freq[temp] > 0):
		freq[temp] -= 1
		freq[temp+1] += 1
for i in range(M+1):
	if (freq[i] != 0):
		start = i
		break
print("Yes") if Judge(pat[start:]) else print("No")

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e13
#define mod 1000000007

struct UnionFind{
  vector<int> v,l,r;
  UnionFind(int n) : v(n, -1),l(n,0),r(n,0) {}
  void init(){ for(int i = 0;i < (int)v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x]=find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    l[x]=min(l[x],l[y]);
    r[x]=max(r[x],r[y]);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};


ll N,M;
ll A[5011];
ll C[5011][201];
ll sum[5011][5011];

int main(){

  scanf("%lld%lld",&N,&M);
  rep(i,N-1)scanf("%lld",&A[i+1]);
  rep(i,N)rep(j,M)scanf("%lld",&C[i][j]);
  rep(i,N-1)A[i+1]+=A[i];

  UnionFind uf(N);
  rep(i,M){
    vector<int> B(N),ord(N);
    rep(j,N){
      B[j]=C[j][i];
      ord[j]=j;
    }
    sort(all(ord),[=](const ll& a,const ll& b){
      return B[a] < B[b];
    });

    rep(j,N){
      uf.v[j]=-1;
      uf.l[j]=uf.r[j]=j;
    }
    for(ll j:ord){
      if(j>0&&B[j-1]<=B[j])uf.unite(j-1,j);
      if(j+1<N&&B[j]>=B[j+1])uf.unite(j,j+1);

      ll f=uf.find(j);
      ll l1=uf.l[f],l2=j+1;
      ll r1=j+1,r2=uf.r[f]+2;

      sum[l1][r1]+=B[j];
      sum[l1][r2]-=B[j];
      sum[l2][r1]-=B[j];
      sum[l2][r2]+=B[j];

    }
  }

  rep(i,N)rep(j,N+1)sum[i+1][j]+=sum[i][j];
  rep(i,N+1)rep(j,N)sum[i][j+1]+=sum[i][j];

  ll res=-INF;
  rep(l,N)repl(r,l+1,N+1){
    maxch(res,sum[l][r]-(A[r-1]-A[l]));
  }
  cout<<res<<endl;

  return 0;
}


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

int main(){
	int n;
	int val[100];
	int changecount = 0;

	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&val[i]);
	}

	for(int i = 0; i < n; i++){
		int min = i;
		for(int u = i; u < n; u++){
			if(val[u] < val[min]){
				min = u;
			}
		}
		if(min > i){
			int t = val[i];
			val[i] = val[min];
			val[min] = t;
			changecount++;
		}
	}
	
	printf("%d",val[0]);
	for(int i = 1; i < n; i++){
		printf(" %d",val[i]);
	}
	printf("\n");
	printf("%d\n",changecount);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

ll solve() {
    ll n; cin >> n;
    ll cnt = 0, cur = 100;
    while (cur < n) {
        cur += cur / 100;
        cnt++;
    }

    return cnt;
}

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

	cout << solve() << endl;
}


Measured memory_bytes: 3624