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

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    var h = new HashSet<string>();
    var sb = new StringBuilder();
    for (int i = 0; i < n; i++) {
      var s = Console.ReadLine().Split();
      if(s[0][0] == 'i') h.Add(s[1]);
      else if (h.Contains(s[1])) sb.AppendLine("yes");
      else  sb.AppendLine("no");
    }
    Console.Write(sb);
  }
}


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

int main(){
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int a[n][m];
  for(i=0;i<m;i++)cin>>b[i];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int cnt=0,sum;
  for(i=0;i<n;i++){
    sum=c;
    for(j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    if(sum>0)cnt++;
  }
  cout<<cnt;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    if(K == 1) {
        cout << 0 << endl;
    } else if(N == K) {
        cout << 0 << endl;
    } else {
        cout << (N - K) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#define ROP(i,n) for(int i=0;i<n;i++)
#define ROOP(i,n) for(int i=1;i<=n;i++)
#define llong long long
using namespace std;
queue<char> que;
int main(){
  char S[51],prev;
  scanf("%s",S);
  int L=strlen(S),cnt=0;
  ROP(i,L){
    if(prev=='A'&&S[i]=='A'){
      printf("NO\n");return 0;
    }
    if(prev=='K'&&S[i]=='A'){
      printf("NO\n");return 0;
    }
    if(prev=='I'&&S[i]=='A'){
      printf("NO\n");return 0;
    }
    if(S[i]!='A') que.push(S[i]);
    prev=S[i];
  }
  char a,b,c,d,e;
  a=que.front();que.pop();
  b=que.front();que.pop();
  c=que.front();que.pop();
  d=que.front();que.pop();
  e=que.front();que.pop();
  if(a=='K'&&b=='I'&&c=='H'&&d=='B'&&e=='R'&&que.size()==0){
    printf("YES\n");return 0;
  }
  printf("NO\n");
  return 0;
}


Measured memory_bytes: 256
fn solve(aa: &mut Vec<usize>) -> Vec<usize> {
    let ac = aa.clone();

    let n = aa.len();
    aa.sort();

    let mut ans = Vec::new();

    for a in ac.iter() {
        ans.push(if aa[n - 1] == *a {
            aa[n - 2]
        } else {
            aa[n - 1]
        });
    }

    ans
}

#[test]
fn solve_test() {
    assert_eq!(solve(&mut vec![1, 4, 3]), vec![4, 3, 4]);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);
    let mut aa = (0..n).map(|_| parse_line!(usize)).collect::<Vec<_>>();

    let ans = solve(&mut aa);
    for a in ans {
        println!("{}", a);
    }
}


Measured memory_bytes: 14128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

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

    bool is_ok = true;
    rep(i, s.size()) {
        if (i % 2 == 0 && s[i] == 'L') is_ok = false;
        if (i % 2 != 0 && s[i] == 'R') is_ok = false;
    }
    if (is_ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
int main()
{
    char a[10]={'\0'},b[10]={'\0'},c[10]={'\0'};
        int i,j;
        scanf("%s",&a);
        scanf("%s",&b);;
        if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
            printf("YES\n");
        else
            printf("NO\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    long long n, i, j, f;

    string s;

    long long m[5] = {0};

    long long k = 0;

         
    cin >> n;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> s;

         if( s.at(0) == 'M' ) m[0] += 1;

         else if( s.at(0) == 'A' ) m[1] += 1;

         else if( s.at(0) == 'R' ) m[2] += 1;

         else if( s.at(0) == 'C' ) m[3] += 1;

         else if( s.at(0) == 'H' ) m[4] += 1;

         }


    for( i = 0 ; i < 3 ; i = i + 1 ){

         for( j = i + 1 ; j < 4 ; j = j + 1 ){

              for( f = j + 1 ; f < 5 ; f = f + 1 ){

                   k += m[i] * m[j] * m[f];

                   }

              }

         }


    cout << k << endl;


    return 0;
                                                          
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a[3];    scanf("%d%d%d", &a[0], &a[1], &a[2]);
    int sum = a[0] + a[1] + a[2];

    if(sum % 2 != 0){
        puts("No");
    }

    else{
        int i;
        int check = 0;
        for(i = 0; i < 3; i++){
            if(sum / 2 == a[i]){
                check = 1;
            }
        }
        if(check == 1){
            puts("Yes");
        }
        else{
            puts("No");
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

string s;
ll K;

int main(){
    cin >> s;
    cin >> K;
    for(int i=0;i<s.size();i++){
        ll c = s[i] - 'a';
        if(c == 0) continue;
        if(K < 26-c) continue;
        s[i] = 'a';
        K -= (26-c);
    }
    K %= 26;
    s[s.size()-1] += K;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back

int lp[65536];
int rp[65536];
int V;

int n;
pp arr[20010];

void in(){
	read(n);
	for(int i=1; i<=n; ++i){
		int x, y; read(x, y);
		arr[2*i-1] = {x, 2*i};
		arr[2*i] = {y, 2*i+1};
	}
}

vector<int> e_base[65536];
vector<int> e_temp[65536];

void bt(int l, int r, int p){
	int mid = (l+r)/2;
	if(l == mid) e_base[p].pb(lp[p] = arr[l].second ^ 1);
	else lp[p] = ++V, e_base[p].pb(V), bt(l, mid, V);
	if(mid+1 == r) e_base[p].pb(rp[p] = arr[r].second ^ 1);
	else rp[p] = ++V, e_base[p].pb(V), bt(mid+1, r, V);
}

void build(){
	sort(arr+1, arr+2*n+1);
	V = 2*n+1;
	bt(1, 2*n, ++V);
}

int isang(int x){ return lower_bound(arr+1, arr+2*n+1, pp{x, -1}) - arr; }
int iha(int x){ return lower_bound(arr+1, arr+2*n+1, pp{x+1, -1}) - arr - 1; }

void draw(int l, int r, int from, int ml, int mr, int mp){
	if(l<=ml && mr<=r){
		e_temp[from].pb(mp);
		return;
	} else if(r<ml || mr<l) return;
	int mid=(ml+mr)/2;
	draw(l, r, from, ml, mid, lp[mp]);
	draw(l, r, from, mid+1, mr, rp[mp]);
}

int ind[65536];
int low[65536];
bool onstk[65536];
int stk[65536];
int cind[65536], cn;
int top;
int nt;

void dfs(int x){
	ind[x] = low[x] = ++nt;
	onstk[x]=1; stk[top++]=x;
	auto f=[&](int y){
		if(!ind[y]) dfs(y), low[x]=min(low[x], low[y]);
		else if(onstk[y]) low[x]=min(low[x], ind[y]);
	};
	for(int y:e_base[x]) f(y);
	for(int y:e_temp[x]) f(y);
	if(ind[x] == low[x]){
		++cn;
		while(top){
			int a=stk[--top];
			onstk[a]=0;
			cind[a]=cn;
			if(a == x) break;
		}
	}
}

bool can(int d){
	--d;
	for(int i=1; i<=V; ++i) e_temp[i].clear();
	for(int i=1; i<=2*n; ++i){
		int l=arr[i].first - d, r = arr[i].first + d;
		int me = arr[i].second;
		l = isang(l); r = iha(r);
		draw(l, i-1, me, 1, 2*n, 2*n+2);
		draw(i+1, r, me, 1, 2*n, 2*n+2);
	}
	nt=cn=top=0;
	for(int i=1; i<=V; ++i) ind[i]=0;
	for(int i=1; i<=V; ++i) if(!ind[i]) dfs(i);
	for(int i=1; i<=n; ++i){
		if(cind[2*i] == cind[2*i+1]) return 0;
	}
	return 1;
}

int main()
{
    in();
    build();
    ll l=0, r=2e9;
    while(l+1 < r){
		int mid=(l+r)/2;
		if(can(mid)) l=mid;
		else r=mid;
    }
    printf("%lld\n", l);
    return 0;
}


Measured memory_bytes: 11776
#include <iostream>

using namespace std;

int main(){
  string str;
  cin >> str;
  bool contain_AB = str.find("AB") != std::string::npos;
  bool contain_BA = str.find("BA") != std::string::npos;
  if(contain_AB || contain_BA) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  double limit = min(a, min(b, min(c, min(d, e))));
  ll times = ceil(double(n/limit));
  cout << times + (ll)4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
	int u;
	int k;
	int v[100];
}point;

int main(void){
	int n,i,j,box;
	point p[100];
	int graph[100][100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&p[i].u,&p[i].k);
		for(j=0;j<p[i].k;j++){
			scanf("%d",&p[i].v[j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<p[i].k;j++){
			box = p[i].v[j];
			if(box != 0){
				graph[i][box-1] = 1;
			}
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			printf("%d",graph[i][j]);
			if(j != n-1)printf(" ");
			else printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2016
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1000003;
int f[N], invf[N], lg[N], d[N], a[N];
int cnt;
vector < int > g[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int cnk(int n, int k){
    return f[n] * invf[n - k] % mod * invf[k] % mod;
}
void dfs(int v, int p = -1){
    cnt++;
    d[v] = a[cnt];
    for (auto u: g[v]){
        if (u != p) dfs(u, v);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    cout << n - k + 1;
}


Measured memory_bytes: 71936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i < (n); ++i)
#define repD(i, a, n) for(ll i = a; i > (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
// #define mp make_pair
#define pb push_back
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
long long Ceil(long long a, long long b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
float E = 0.00000000000001;
ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    if(y%2==0){
        ll q=power(x,y/2);
        q=q%p;
        return (q*q)%p;
    }
    ll q=power(x,y/2);
    q=q%p;
    return ((x%p)*((q*q)%p))%p; 
}
bool isPowerOfTwo (long long x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}  

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a); 
}
long long int mod(long long int a, long long int b) {
    long long int ret = a%b; return ret>=0? ret: ret+b; 
}
int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){ 
        string s;
        cin>>s;
        int num = 0;
        for(auto x:s){
            int a = x-'0';
            num += a;
            num %= 9;
        }
        if(num)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 1000010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}

int pow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;b>>=1;
	}
	return ans;
}

int cal(int n){
	int s=0;
	while(n){
		s+=n%10,n/=10;
	}
	return s;
}
int main(){
	//cout<<setprecision(6)<<fixed;
	clock_t start=clock();
	int ca=0,T,k,i,j,K=0,n,m=0;
	scanf("%d",&n);
	int ans=-1;
	rep(a,1,n){
		int b=n-a;
		if(b<a)break;
		int x=cal(a)+cal(b);
		if(ans==-1||ans>x)ans=x;
	}
	printf("%d\n",ans);
}



Measured memory_bytes: 256
def divisible(n):
 ans = 0
 while n%2 == 0:
  n /= 2
  ans += 1
 return ans
 
N = int(input())
 
b = 0

c = 1
 
for i in range(1,N+1):
    if(divisible(i) > b):
      b = divisible(i)
      c = i
    
print(c)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

i64 f(i64 n) {
    i64 res = (n / 2) & 1;
    if (n & 1) res ^= (n - 1);
    return res;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(i64, A, B);
    print(f(B + 1) ^ f(A));

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int change(int *a,int *b)
{
    int temp;

    if(*a > *b){
        temp = *a;
        *a = *b;
        *b = temp;
    }

    return 0;
}

int main(void)
{
    int a,b,c;

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

    change(&b,&c);
    change(&a,&b);
    change(&b,&c);

	printf("%d %d %d\n",a,b,c);

    return 0;
}


Measured memory_bytes: 2644
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s;
    cin >> s;
    map<char,ll> mp;
    rep(i,s.size()){
        mp[s[i]]++;
    }
    bool good = true;
    for(auto c:mp){
        if(c.second % 2 != 0) good = false;
    }
    if(good) cout << "Yes" << endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define PB push_back
#define MOD 10000007
#define PI 3.14159265359

using namespace std;

int main(){


    int s,w;
    cin >> s >> w;

    if(s>w){
        puts("safe");
    }else{
        puts("unsafe");
    }
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cstdlib> 
using namespace std;
int main() {
  int N;
  cin>>N;
  bool ans=true;
  vector<int> T(N+1),X(N+1),Y(N+1);
  T.at(0)=0,X.at(0)=0,Y.at(0)=0;
  for(int i=0;i<N;i++){
    cin>>T.at(i+1)>>X.at(i+1)>>Y.at(i+1);}
  for(int i=0;i+1<=N;i++){
    if(T.at(i+1)-T.at(i)<abs(X.at(i+1)-X.at(i))+abs(Y.at(1+i)-Y.at(i))
       ||(X.at(i+1)-X.at(i)+Y.at(i+1)-Y.at(i)+T.at(i+1)-T.at(i))%2==1){
      ans=false;}
  }
  if(ans){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


Measured memory_bytes: 1408
def main():
    n = int(input())
    s = input()
    r_set, g_set, b_set = set(), set(), set()

    for i, c in enumerate(s):
        if c == "R":
            r_set.add(i)
        elif c == "G":
            g_set.add(i)
        elif c == "B":
            b_set.add(i)

    cnt = 0
    for j in range(1, n):
        for i in range(j):
            k = 2 * j - i
            if k >= n:
                continue
            if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
                continue
            cnt += 1

    print(len(r_set) * len(g_set) * len(b_set) - cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73484
/*  
	If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

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

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

ll MOD = 1e9+7;

ll add(ll a, ll b){a+=b; a%=MOD;if(a<0) a+=MOD;return a;}
//doesn't work for neg numbers

ll mult(ll a, ll b){if(a>MOD) a%=MOD;if(b>MOD) b%=MOD;ll ans=(a*b)%MOD;if(ans<0) ans+=MOD;return ans;}
//doesn't work for neg numbers

ll pw(ull a, ull b){ll r=1;while(b){if(b&1) r=mult(r,a);a=mult(a,a);b>>=1;}return r;}
//doesn't work for neg numbers

void solve(){
	string s;
	cin>>s;
	int n = s.length();
	string tmp1 = "", tmp2="";
	for(int i=0;i<((n-1)/2);i++) tmp1+=s[i];
	for(int i=((n+3)/2)-1;i<n;i++) tmp2+=s[i];
	//cout<<tmp1<<" "<<tmp2<<endl;
	string x=tmp1, y=tmp2, z=s;
	reverse(tmp1.begin(), tmp1.end());
	reverse(tmp2.begin(), tmp2.end());
	reverse(all(s));
	if(s==z && tmp1 == x && tmp2 == y) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

int main(){
/*	#if ONLINE_JUDGE
	  freopen("inputf.in", "r", stdin);
	  freopen("outputf.in", "w", stdout);
	#endif
*/
    fast_io;
    ll t, k=0;
    t=1;
    while(t--){
        //k++;        
        //cout<<"Case "<<k<<": ";
        solve();
    }
}


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

int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N+1, vector<ll>(100001, 1e15));
    dp[0][0] = 0;
    for(ll i=0; i<N; i++) {
        for(ll j=0; j<=100000; j++) {
            if(v[i] > j) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
        }
    }

    ll res = 0;
    rep(i, 100001) {
        if(dp[N][i] <= W) res = i;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 80256
#include<iostream>

using namespace std;

int gcd(int x,int y) {//??????????????????????????????
	int r;
	if (x < y)swap(x, y);
	while (y > 0) {
		r = x%y;
		x = y;
		y = r;
	}
	return x;
}

int main() {
	int a, b, c;
	while (cin >> a >> b) {
		c = gcd(a, b);
		cout << a+b+1-c <<endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890LL
#define ll long long
#define MOD 1000000007

ll pw(ll a, ll n)
{
	ll ret = 1;
	while(n)
	{
		if (n&1) ret=ret*a%MOD;
		a=a*a%MOD;
		n>>=1;
	}
	return ret;
}

ll inv(ll a)
{
	return pw(a, MOD-2);
}

int N, K, zero = 0;
vector<ll> add, sub;

int main()
{
	scanf("%d %d", &N, &K);
	for(int i=1; i<=N; i++)
	{
		ll t;
		scanf("%lld", &t);
		if (t > 0) add.push_back(t);
		else if (t < 0) sub.push_back(abs(t));
		else zero++;
	}

	// 답이 양수가 되는 경우 (음수 = 짝수)
	if ((int)add.size() + min(K, (int)sub.size())-min(K, (int)sub.size())%2 >= K)
	{
		sort(add.rbegin(), add.rend());
		while(add.size() > K) add.pop_back();

		sort(sub.rbegin(), sub.rend());
		while(sub.size() > K) sub.pop_back();

		ll res = 1;
		int i = 0;
		while (i < (int)sub.size()-(int)sub.size()%2) // 짝수
		{
			res *= sub[i];
			res %= MOD;
			i++;
		}
		int j = 0;
		while (i+j < K)
		{
			res *= add[j];
			res %= MOD;
			j++;
		}
		assert(i%2==0);

		while(i > 1 && j+1 < add.size())
		{
			ll dec = sub[i-1] * sub[i-2];
			ll inc = add[j] * add[j+1];
			if (inc <= dec) break; // 더 이상 이득을 볼 수 없음

			dec %= MOD; inc %= MOD;
			res *= inv(dec); res %= MOD;
			res *= inc; res %= MOD;

			i -= 2; j += 2;
		}
		res %= MOD; res += MOD; res %= MOD;
		printf("%lld", res);
		return 0;
	}
	else if (add.size() + sub.size() >= K) // 답이 음수가 되는 경우
	{
		// 음수만 홀수 개 고르면 된다.
		sort(add.begin(), add.end());
		while(add.size() > K) add.pop_back();

		sort(sub.begin(), sub.end());
		while(sub.size() > K) sub.pop_back();

		ll res = 1;
		int i = 0;
		while (i < (int)sub.size()-(1-(int)sub.size()%2)) // 홀수
		{
			res *= sub[i];
			res %= MOD;
			i++;
		}
		int j = 0;
		while (i+j < K)
		{
			res *= add[j];
			res %= MOD;
			j++;
		}
		assert(i%2==1);

		while(i > 1 && j+1 < add.size())
		{
			ll dec = sub[i-1] * sub[i-2];
			ll inc = add[j] * add[j+1];
			if (inc >= dec) break; // 더 이상 이득을 볼 수 없음

			dec %= MOD; inc %= MOD;
			res *= inv(dec); res %= MOD;
			res *= inc; res %= MOD;

			i -= 2; j += 2;
		}
		res = -res;
		res %= MOD; res += MOD; res %= MOD;

		// 음수보다 0이 나은가?
		if (zero) printf("0");
		else printf("%lld", res);
		return 0;
	}
	else
	{
		printf("0");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 5544
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n)     for(auto i = 0; i != n; ++i)
#define REP(i, k, n)  for(auto i = k; i != n; ++i)
#define rrep(i, n)    for(auto i = n; i != 0; --i)
#define RREP(i, n, k) for(auto i = n; i != k; --i)

#define debug(x) cerr << #x << " " << x << endl
#define spc << " " <<

#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

bool occupied[2020];
Vi pos_A;

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

    int N, M; cin >> N;
    pos_A = Vi(N);
    rep(i, N) {
        int buff;
        cin >> buff;
        pos_A[i] = buff;
        occupied[buff] = true;
    }

    cin >> M;
    rep(i, M) {
        int buff, Ai;
        cin >> buff;
        buff--;
        Ai = pos_A[buff];
        if (occupied[Ai + 1] || Ai == 2019) continue;
        occupied[Ai] = false;
        occupied[Ai+1] = true;
        pos_A[buff] += 1;
    }

    rep(i, N) cout << pos_A[i] << endl;

    return 0;
}



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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

int main() {
    fast;
    cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w" , stdout);
#endif*/
    lld a, b, c, d;
    cin >> a >> b >> c >> d;
    lld t, aa;
    if (c % b == 0) {
        t = (c / b);
    }
    else t = (c / b) + 1;
    if (a % d == 0)
        aa = (a / d);
    else aa = (a / d) + 1;
    if (t <= aa) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3652
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';

void solve()
{
    int x, n;
    cin >> x >> n;
    vector<int> a(n);
    vector<int> mark(200, 0);
    rep(i, 0, n){
    	cin >> a[i];
    	mark[a[i]] = 1;
    }
    int ans = 0;
    for(int i = x; i >= 0; i--){
    	if(!mark[i]){
    		ans = i;
    		break;
    	}
    }
    int ans2 = 0;
    for(int i = x; i <= 101; i++){
    	if(!mark[i]){
    		ans2 = i;
    		break;
    	}
    }
    //cout << ans << " " << ans2 << " ";
    if(x - ans <= ans2 - x){
    	cout << ans;
    	return;
    }
    cout << ans2 << '\n';
}

int32_t main(){
ios_base::sync_with_stdio(false); 
cin.tie(0); cout.tie(0);
int tst = 1;
//cin >> tst;
while(tst--)
{
	solve();
}
}

Measured memory_bytes: 3648
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var h = int.Parse(_[0]);
            var w = int.Parse(_[1]);

            var m = new char[h,w];
            for(var i = 0; i < h; i++){
                var s = Console.ReadLine().ToCharArray();
                for(var j = 0; j < w; j++){
                    m[i,j] = s[j];
                }
            }

            var f = new bool[h,w];
            Check1(h, w, m, f);
            Check2(h, w, m, f);

            for(var i = 0; i < h; i++){
                var r = false;
                for(var j = 0; j < w; j++){
                    if(!f[i,j]){
                        r = true;
                        Console.Write(m[i,j]);
                    }
                }
                if(r){
                    Console.Write("\n");
                }
            }
        }

        static void Check1(int h, int w, char[,] m, bool[,] f){
            for(var i = 0; i < h; i++){
                var count = 0;
                for(var j = 0; j < w; j++){
                    if(m[i,j] == '.'){
                        count++;
                    }
                }

                if(count == w){
                    for(var j = 0; j < w; j++){
                        f[i,j] = true;
                    }
                }
            }
        }

        static void Check2(int h, int w, char[,] m, bool[,] f){
            for(var j = 0; j < w; j++){
                var count = 0;
                for(var i = 0; i < h; i++){
                    if(m[i,j] == '.'){
                        count++;
                    }
                }

                if(count == h){
                    for(var i = 0; i < h; i++){
                        f[i,j] = true;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 11180
#include<bits/stdc++.h>
#define ll long long
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b;
    cin>>a>>b;
    if(a==1||b==1) cout<<1<<endl;
    else{
        if((a*b)%2==0) cout<<(a*b)/2<<endl;
        else cout<<((a*b)/2)+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define maxn 309
using namespace std;
int dp[maxn][maxn][maxn];
const int MOD=1e9+7;
inline void add(int &x,int y){
    x+=y;
    if(x>=MOD)
        x-=MOD;
}
int main(){
    int n,m;
    cin>>n>>m;
    
    dp[0][1][1]=1;
    for(int i=0;i<m;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=j;k++){
                if(dp[i][j][k]){
                    add(dp[i+1][j+1][k],1LL*dp[i][j][k]*(n-j)%MOD);
                    add(dp[i+1][j][k],1LL*dp[i][j][k]*(j-k)%MOD);
                    add(dp[i+1][j][j],1LL*dp[i][j][k]*k%MOD);
                }
            }
        }
    }
    cout<<dp[m][n][n]<<endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 55936
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int n,i,j;
        n=input.nextInt();
        int[] a=new int[n];
        for(i=0; i<n; i++){
            a[i]=input.nextInt();
        }
        for(j=n-1; j>=0; j--){
            System.out.print(a[j]);
            if(j!=0) 
            System.out.print(" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26400
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> vc;
  int n;
  cin >> n;
  int i;
  for(i = 0;i < n;i++) {
    int x;
    cin >> x;
    vc.push_back(x);
  }
  double res;
  res = 0.0;
  for(i = 0;i < n;i++) {
    res += 1.0 / vc[i];
  }
  cout << 1/res << '\n';
 }


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

using namespace std;

typedef long long ll;

int main(){
  string S;
  cin >> S;
  
  for(int i=0; i<S.size(); i++){
    if(S[i] == '?') S[i] = 'D';
  }
  
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=l;i<r;i++)
#define LINF (ll)1e18
#define INF (int)1e9
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
    int n;
    in(n);
    out(n&1?n<<1:n);
}



















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

int main(){

    int N,K,X,Y;
    int i,sum;
    cin >> N >> K >> X >> Y;
    sum = 0;
    for(i=1;i<=N;i++){
        if(i<=K){
            sum = sum + X;
        }
        else if((K+1 <= i)&&(i <= N)){
            sum = sum + Y;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    if(n&1){
    	ll sum=0;
    	for(int i=0;i<n;i++){
    		if(!(i&1))sum+=a[i];
    	}
    	ll dp[n]; dp[0]=0;
    	for(int i=1;i<n;i++){
    		if(i&1){
    			ll num=a[i]-a[i-1];
    	    	dp[i]=max(dp[i-1]+num,0LL);
    		}
    		else dp[i]=dp[i-1];
    	}
    	ll m=-1e18;
    	for(int i=0;i<n;i++){
    		if(i&1){
    			dp[i]-=a[i+1];
    			m=max(dp[i],m);
    		}
    	}
    	ll ans=sum-a[0];
    	ans=max(ans,sum+m);
    	cout << ans <<endl;
    }
    else{
    	ll b[n+1];
    	b[n]=0;
    	for(int i=n-1;i>=0;i--){
    		b[i]=b[i+1];
    		if(i&1)b[i]+=a[i];
    	}
    	ll sum=0;
    	ll ans=-1e18;
    	for(int i=0;i<n-1;i++)if(!(i&1))ans=max(ans,sum+b[i+1]),sum+=a[i];
        ans=max(ans,sum);
        cout << ans <<endl;
    }
    return 0;
}


Measured memory_bytes: 6748
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N, A[3], B[3];

int main() {
	cin >> N;
	for (int i = 0; i < 3; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < 3; ++i) {
		cin >> B[i];
	}
	vector<ll>v(N + 1, 0);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (A[j] < B[j] && i + A[j] <= N) {
				v[i + A[j]] = max(v[i + A[j]], v[i] + B[j]);
			}
		}
	}
	ll M = 0;
	for (int i = 0; i <= N; ++i) {
		M = max(M, v[i] + N - i);
	}
	v = vector<ll>(M + 1, 0);
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (B[j] < A[j] && i + B[j] <= M) {
				v[i + B[j]] = max(v[i + B[j]], v[i] + A[j]);
			}
		}
	}
	for (int i = 0; i <= M; ++i) {
		N = max(N, v[i] + M - i);
	}
	cout << N << endl;
}

Measured memory_bytes: 195584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int bit = 0;
		for (int i=0; i<N; i++) {
			bit |= sc.nextInt();
		}
		System.out.println(Integer.numberOfTrailingZeros(bit));;
	}
}


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

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

    int a, b;
    cin >> a >> b;

    if(a+b == 15) puts("+");
    else if(a*b == 15) puts("*");
    else puts("x");

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;
		int n = cin.nextInt();
		int[][] abcs = new int[n - 1][];
		for (int i = 0; i < abcs.length; i++)
			abcs[i] = new int[] { cin.nextInt(), cin.nextInt(), cin.nextInt() };
		int q = cin.nextInt();
		int k = cin.nextInt();
		int[][] xys = new int[q][];
		for (int i = 0; i < xys.length; i++)
			xys[i] = new int[] { cin.nextInt(), cin.nextInt() };

		long start = now();

		long[] ans = solve(n, abcs, q, k, xys);
		String ansstr = Arrays.stream(ans).mapToObj(Objects::toString)
				.collect(Collectors.joining(System.lineSeparator()));

		cout.println(ansstr);
		trace("elapsed", now() - start);
	}

	private static long[] solve(int n, int[][] abcs, int q, int k, int[][] xys) {
		List<List<int[]>> edges = new ArrayList<>();
		for (int i = 0; i < n + 1; i++)
			edges.add(new ArrayList<>());
		for (int[] abc : abcs) {
			edges.get(abc[0]).add(new int[] { abc[1], abc[2] });
			edges.get(abc[1]).add(new int[] { abc[0], abc[2] });
		}

		// 始点Kからの最短経路
		// ダイクストラ法
		long[] dist = new long[n + 1];
		Arrays.fill(dist, -1L);
		PriorityQueue<long[]> pq = new PriorityQueue<>(Comparator.comparingLong(vals -> vals[1]));
		pq.add(new long[] { k, 0 });
		while (!pq.isEmpty()) {
			long[] arg = pq.poll();
			int v = (int) arg[0];
			long c = arg[1];
			if (dist[v] != -1)
				continue;
			dist[v] = c;
			for (int[] e : edges.get(v)) {
				int to = e[0];
				if (dist[to] != -1)
					continue;
				pq.add(new long[] { to, c + e[1] });
			}
		}

		long[] ans = Arrays.stream(xys).mapToLong(xy -> dist[xy[0]] + dist[xy[1]]).toArray();
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 84004
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

type item struct {
	a, b, c, d int
}

var ans int

func f(n, N, M int, a []int, nn []item, cc chan []int) {
	if len(a) == N {
		cc <- a
		return
	}

	for i := n; i <= M; i++ {
		f(i, N, M, append(a, i), nn, cc)
	}
}

func ff(n, N, M int, a []int, nn []item, cc chan []int) {
	f(n, N, M, a, nn, cc)
	close(cc)
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, Q := getInt(), getInt(), getInt()
	nn := make([]item, Q)
	for i := 0; i < Q; i++ {
		a, b, c, d := getInt(), getInt(), getInt(), getInt()
		nn[i] = item{a, b, c, d}
	}

	a := make([]int, 0)
	ch := make(chan []int)

	go ff(1, N, M, a, nn, ch)

	for v := range ch {
		cost := 0
		Q := len(nn)
		for j := 0; j < Q; j++ {
			f := nn[j].a - 1
			t := nn[j].b - 1
			if v[t]-v[f] == nn[j].c {
				cost += nn[j].d
			}
		}
		// out(cost)
		ans = max(ans, cost)
	}

	out(ans)
}


Measured memory_bytes: 5892
// ※※※ 解答不能 ※※※
// ksun48氏.
// https://atcoder.jp/contests/cf17-final/submissions/1804620
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
vector<pair<int, int>> ints[410000];

int main(){
    int n;
    scanf("%d", &n);
    int N = (1 << n);
    int g[N];
    map<int, int> used;
    rep(j, N){
        scanf("%d", &g[j]);
        g[j]--;
        used[g[j]] = 1;
    }
    int maxval[N], minval[N], ok = 1;
    repr(j, N - 1, 0){
        maxval[j] = N - 1;
        if(g[j] != -1) maxval[j] = g[j];
        rep(i, n){
            if((1 << i) & j) continue;
            maxval[j] = min(maxval[j], maxval[j ^ (1 << i)]);
        }
    }
    rep(j, N){
        minval[j] = 0;
        if(g[j] != -1) minval[j] = g[j];
        rep(i, n){
            if(((1 << i) & j) == 0) continue;
            minval[j] = max(minval[j], minval[j ^ (1 << i)]);
        }
    }
    rep(j, N){
        if(minval[j] > maxval[j]){
            puts("NO");
            return 0;
        }
        ints[minval[j]].push_back({maxval[j], j});
    }
    set<pair<int, int>> d;
    rep(i, N){
        rep(f, ints[i].size()) d.insert(ints[i][f]);
        if(d.empty()){
            puts("NO");
            return 0;
        }
        pair<int, int> b = *d.begin();
        d.erase(d.begin());
        if(b.first < i){
            puts("NO");
            return 0;
        }
        g[b.second] = i;
    }
    puts("YES");
    rep(j, N){
        vector<int> f;
        int cj = j;
        int r = 0;
        rep(i, n){
            r = 2 * r + (cj % 2);
            cj /= 2;
        }
        printf("%d ", g[r] + 1);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 34688
def read_input():
	n = int(input())
	ls = list(map(int, input().split()))
	
	return n, ls
	
	
def submit():
	n, ls = read_input()
	
	max_l = max(ls)
	rests = sum(ls) - max_l

	if max_l < rests:
		print('Yes')
	else:
		print('No')

if __name__ == '__main__':
	submit()

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

int32_t main(){
	int x;
	cin >> x;
	cout << (x / 500 * 1000 + (x % 500 / 5 * 5));
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int a=gi();
        int b=gi();
        
	    
	    
        //System.out.println(s.replace("2017", "2018"));
        if ((a*b) %2==0) {
        	System.out.print("Even");
        }else {
        	System.out.print("Odd");
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35492
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		ArrayDeque<Character> deque = new ArrayDeque<>();
		Character c = ' ';
		for (int i = 0; i < s.length; i++) {
			if (deque.isEmpty()) {
				deque.push(s[i]);
			} else {
				c = deque.peek();
				if (c == '(' && s[i] == ')') {
					deque.pop();
				} else {
					deque.push(s[i]);
				}
			}
		}
		String str1 = "", str2 = "";
		while (!deque.isEmpty()) {
			c = deque.poll();
			if (c == ')') {
				str1 += "(";
			} else {
				str2 += ")";
			}
		}
		sb.append(str1);
		sb.append(s);
		sb.append(str2);
		System.out.println(sb);
	}
}


Measured memory_bytes: 22868
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    int diff = abs(A - B);
    if (diff % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    }
    else {
        cout << min(A, B) + diff / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def binarySearch (arr, l, r, x): 
  
    # Check base case 
    if r >= l: 
  
        mid = l + (r - l) // 2
  
        # If element is present at the middle itself 
        if arr[mid] == x: 
            return mid 
          
        # If element is smaller than mid, then it  
        # can only be present in left subarray 
        elif arr[mid] > x: 
            return binarySearch(arr, l, mid-1, x) 
  
        # Else the element can only be present  
        # in right subarray 
        else: 
            return binarySearch(arr, mid + 1, r, x) 
  
    else: 
        # Element is not present in the array 
        return -1
n,k=map(int,input().split( ))
s=input().split( )
p=[]
g=0
while binarySearch(p,0,len(p)-1,int(g))==-1:
    p.append(int(g))
    g=int(s[int(g)])-1
x=p.index(g)
y=len(p)
if k>=y:
    k+=1
    u=p[x:y]
    k-=x
    v=(k)%(y-x)
    print(u[v-1]+1)
else:
    print(p[k]+1)


Measured memory_bytes: 96536
import java.util.*;
 
class Main {
 
    public static void main (String args[])
    {
        Scanner in = new Scanner(System.in);
       

        String compet = in.nextLine();

        if(compet.equals("ABC"))
        System.out.println("ARC");
       else if(compet.equals("ARC"))
        System.out.println("ABC");
        
        
    }
}

Measured memory_bytes: 35672
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> h(n);
  for (int i = 0; i < n; ++i)
    std::cin >> h.at(i);

  for (int i = 0; i < n - 1; ++i) {
    if (h.at(i) == h.at(i + 1))
      continue;
    --h.at(i + 1);
    if (h.at(i) <= h.at(i + 1))
      continue;
    std::cout << "No" << std::endl;
    return 0;
  }

  std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

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

using namespace std;
const long long INF = 1LL << 61;

int main() {
	string S, T; cin >> S >> T;
	int count = 0;
	rep(i, S.size())if (S[i] == T[i])++count;
	cout << count;
}

Measured memory_bytes: 256