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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            //W, H, x, y, r
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            if (isInRange(arr))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            
        }

        private static bool isInRange(int[] arr)
        {
            //left
            if (arr[2] - arr[4] < 0) return false;
            //top
            if (arr[3] - arr[4] < 0) return false;
            //right
            if (arr[2] + arr[4] > arr[0]) return false;
            //bottom
            return arr[3] + arr[4] <= arr[1];
        }
    }
}



Measured memory_bytes: 18416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000999 // 10^11 + 999 1000億999
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template<class T>
void combination(const vector<T>& seed, int target_size, bool (*callback)(const vector<T>&)) {
    vector<int> indices(target_size);
    const int seed_size = seed.size();
    int start_index = 0;
    int size = 0;

    while (size >= 0) {
        for (int i = start_index; i < seed_size; ++i) {
            indices[size++] = i;
            if (size == target_size) {
                vector<T> comb(target_size);
                for (int x = 0; x < target_size; ++x) {
                    comb[x] = seed[indices[x]];
                }
                if (callback(comb)) return;
                break;
            }
        }
        --size;
        if (size < 0) break;
        start_index = indices[size] + 1;
    }
}

///////////////// How to use

bool my_callback(const vector<ll>& comb) {
    int n = comb.size();
    for (int i=0; i<n; ++i)
        cout << comb[i] << " ";
    cout << endl;
    return false;
}

vector<ll> a;
ll ans = INF;
ll N;

bool raise(const vector<ll>& comb) {
  vector<ll> b(0);
  rep(i, N){
    b.push_back(a.at(i));
  }
  ll n = sz(comb);
  ll h = 0;
  rep(j, comb.at(0)){
    chmax(h, b.at(j));
  }
  ll m = 0;
  rep(i, n){
    if(i == 0){
      if(h >= b.at(comb.at(0))){
        m += h-b.at(comb.at(0))+1;
        b.at(comb.at(0)) = h+1;
      }
    }
    else{
      h = b.at(comb.at(i-1));
      rep(j, comb.at(i)){
        chmax(h, b.at(j));
      }
      if(h >= b.at(comb.at(i))){
        m += h-b.at(comb.at(i))+1;
        b.at(comb.at(i)) = h + 1;
      }
    }
  }
  chmin(ans, m);
  return false;
}

int main(){
  ll K;
  cin >> N >> K;
  a.resize(N);
  rep(i, N){
    cin >> a.at(i);
  }
  vector<ll> vals;
  rep(i, N){
    vals.push_back(i);
  }
  combination(vals, K, raise);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
#define test int testcase; cin>>testcase; while(testcase--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deci(n) fixed << setprecision(n)
#define REP(i,a,b) for(ll i=a;i<=b;++i)
#define REV(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define F first
#define S second
#define mp make_pair
#define pb push_back
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<int>v(n);
    REP(i,0,n-1)
    {
        v[i]=i+1;
    }
    unordered_set<int>m(v.begin(),v.end());
    while(k--)
    {
        ll d,x;
        cin>>d;
        vector<int>a;
        REP(i,0,d-1)
        {
          cin>>x;
          a.pb(x);
        }
        REP(i,0,d-1)
        {
            if(m.count(a[i]))
            {
                m.erase(a[i]);
                //cout<<a[i];
            }
        }
    }
    ll l =m.size();
    cout<<l;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<stdio.h>
#include <iostream>
#include <cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i<10) ans++;
		else if(i>=100&&i<1000)	ans++;
		else if(i>=10000&&i<100000) ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
A = [list(input()) for _ in range(H)]

MAXY = 0
tmp = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            tmp += 1
            if tmp==K:
                MAXY = i
                break
    if MAXY != 0:
        break

ANS = [[-1]*W for _ in range(H)]

num = 1
for y in range(MAXY+1):
    for x in range(W):
        if (ANS[y][x]!=-1):continue
        nx,ny = x,y
        while (ny<H and nx < W and A[ny][nx]=='.'):
           nx += 1
           if (nx == W):
               nx = x
               ny += 1
        if ny>=H:
            ny -= 1
        else:
            nx += 1
            while (nx<W and A[ny][nx]=='.'):
                nx += 1
            nx -= 1
        for i in range(x,nx+1):
            for j in range(y,ny+1):
                ANS[j][i] = num
        num += 1

if MAXY < H-1:
    for y in reversed(range(MAXY+1,H)):    
        for x in range(W):
            if (ANS[y][x]!=-1):continue
            nx,ny = x,y
            while (ny>=MAXY and nx < W and A[ny][nx]=='.'):
               nx += 1
               if (nx == W):
                   nx = x
                   ny += -1
            num = ANS[ny][nx]
            nx += 1
            while (nx<W and A[ny][nx]=='.'):
                nx += 1
            nx -= 1
            for i in range(x,nx+1):
                for j in range(ny,y+1):
                    ANS[j][i] = num
            

    
    
    

for i in range(H):
    print(*ANS[i])
    
            
              
        
        

Measured memory_bytes: 56280
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int n;
    cin >> n;
    vector<int> v;
    REP(i,n) {
        int a;
        cin >> a;
        if (i%2==0) v.push_back(a);
        else v.insert(v.begin(),a);
    }
    if (n%2==1) reverse(ALL(v));
    REP(i,n-1) {
        cout << v[i] << " ";
    }
    cout << v[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  vector<int> c(n+1);//候補数の配列
  c[0] = 3;
  mint ans = 1;
  REP(i,n){
    ans *= c[a[i]];
    c[a[i]]--;
    c[a[i]+1]++;
  }

  cout << ans.x << endl;
  return 0;

}


Measured memory_bytes: 4016
#include<cstdio>
#include<cstring>
#define maxn 200100
char s[maxn],t[maxn];
int q[maxn],pre[maxn],ptr,l,r,vis[maxn],n,lst[maxn][26];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=n;i>=1;--i){
		for(int j=0;j<26;++j)
			lst[i][j]=lst[i+1][j];
		lst[i][s[i]-'a']=i;
	}
	q[r++]=0;
	while(l<r){
		int u=q[l++];
		for(int i=0;i<26;++i)if(!lst[u+1][i]){
			t[ptr++]=i+'a';
			for(int j=u;j;j=pre[j])
				t[ptr++]=s[j];
			for(int j=ptr-1;j>=0;--j)putchar(t[j]);
			return 0;
		} else if(!vis[lst[u+1][i]])pre[q[r++]=lst[u+1][i]]=u,vis[lst[u+1][i]]=true;
	}
}

Measured memory_bytes: 23040
n, k = map(int, input().split())
mod = 10**9 + 7

def comb(n, k):
    return fact[n] // (fact[k] * fact[n-k])

i = 1
fact = [1]
while i < n+1:
    fact.append(i * fact[-1])
    i += 1

j = 1
while j < k+1:
    print((comb(n-k+1, j) * comb(k-1, j-1)) % mod)
    j += 1


Measured memory_bytes: 5748
n = int(input())

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

height = h[0]

q = 0

for i in h:
    if i < height:
        q = 1
        break
    elif i > height:
        height = i-1
    else:
        height = i
        
if q == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 20700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define  pb push_back
#define sort1(v) sort(v.begin(),v.end())
#include <sstream>
//gap between 2 primes is less than 300 for n<=10^9
//cout<<fixed<<setprecision(n)<<number - for n digits after decimal
//for all numbers less than 10^9 there are at max 10 distinct prime factors
void multiply(int n,int v[],int res[],int l)
{
    if(n==1)
    {
        res[l]=v[0];
        return ;
    }
    else
    {
        int a[n/2],b[n/2];
        for(int i=0;i<n/2;i++)
        {
            a[i]=v[i]+v[n/2+i];
            b[i]=v[i]-v[n/2+i];
        }
        multiply(n/2,a,res,l);
        multiply(n/2,b,res,l+n/2);
        return ;
    }
}
int main()
{
   string s;
   cin>>s;
   int n=s.size();
   if(s[n-1]=='s')
    s+="es";
   else
    s+="s";
   cout<<s;
}


Measured memory_bytes: 3588
#include<stdio.h>
int search(int A[],int n,int key,int idx){
    int i;
    for(i=0;i<n;i++){
	if(A[i]==key&&i!=idx) return 0;
    }
    return 1;
}

int main(void){
    int n,A[200],B[200],C[200];
    int i,score;

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


    for(i=0;i<n;i++){
	score=0;
	if(search(A,n,A[i],i)) score+=A[i];
	if(search(B,n,B[i],i)) score+=B[i];
	if(search(C,n,C[i],i)) score+=C[i];
	printf("%d\n",score);
    }

    return 0;
}

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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());

            int n = int.Parse(Console.ReadLine());

            string s = Console.ReadLine();

            var r = new List<int>();
            var g = new List<int>();
            var b = new List<int>();

            for(int i = 0; i < n; i++)
            {
                if (s[i] == 'R') r.Add(i);
                else if (s[i] == 'G') g.Add(i);
                else if (s[i] == 'B') b.Add(i);
            }

            /* Console.WriteLine("[{0}]", string.Join(",", r));
             Console.WriteLine("[{0}]", string.Join(",", g));
             Console.WriteLine("[{0}]", string.Join(",", b));*/

            int bcount = b.Count;

            long ans = 0;

            for(int rn = 0; rn < r.Count; rn++)
            {
                for(int gn=0; gn < g.Count; gn++)
                {
                    int temp = bcount;
                    int def = r[rn] > g[gn] ? r[rn] - g[gn] : g[gn] - r[rn];
                    if (def % 2 == 0)
                    {
                        if (b.Contains((r[rn] + g[gn]) / 2)) { temp--; }
                    }
                    if (b.Contains(Max(r[rn], g[gn]) + def)) temp--;
                    if (b.Contains(Min(r[rn], g[gn]) - def)) temp--;

                    ans += temp;
                }
            }

            Console.WriteLine(ans);
            //ここまで
        }

        static int Max(int a, int b)
        {
            if ( a >= b) return a;
            else return b;
        }

        static int Min (int a, int b)
        {
            if (a <= b) return a;
            else return b;
        }

        

    }

}


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

int main()
{
	int maxlen = 0;
	int templen = 0;
	string b;
	cin >> b;
	for (int i=0; i<b.length(); i++)
	{
		if (b.at(i) == 'A' || b.at(i) == 'G' || b.at(i) == 'T' || b.at(i) == 'C')
			templen += 1;
		else
		{
			maxlen = max(maxlen, templen);
			templen = 0;
		}
	}
	
	cout << max(templen, maxlen);
}

Measured memory_bytes: 256
#!ruby -an
t=->i,*a{a.to_s.tr',[]"',"+-*"[i]+"() "}
m=->f,a,r{r.permutation(2).flat_map{|b|i,j=b
(0..2).map{|n|[t[n,a[i],a[j]],*(r-b).map{|k|a[k]}]}}}
r=->i,a{a.flat_map{|b|m[m,b,[*0..i]]}}
$_[?0]||puts(r[1,r[2,r[3,[$F]]]].find{|s|10==eval(*s)}||0)

Measured memory_bytes: 10864
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {
	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		long x = ir.nextLong();
		long a = x / 500;
		long b = (x % 500) / 5;
		out.println(a * 1000 + b * 5);
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
		out.flush();
	}
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/


int main(){
    
    _cin;
    cout << setprecision(15);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n;
    vll a(n);
    mapll f;
    tot=0;
    fo(i,n){
        cin >> a[i];
        f[a[i]]++;
    }
    for(auto p : f){
        tie(x,y)=p;
        tot+=y*(y-1)/2;
    }
    vll dp(n);
    fo(i,n){
        dp[i] = tot - f[a[i]]*(f[a[i]]-1)/2 + (f[a[i]]-1)*(f[a[i]]-2)/2;
    }
    fo(i,n) cout << dp[i] << endl;


}
    return 0;
}


Measured memory_bytes: 12672
function Main(input) {
  const args = input.split(" ").map((x) => parseInt(x, 10));
  const n = args[0];
  const a = args[1];
  const b = args[2];

  let ans = 0;
  for (let i = 1; i <= n; i++) {
    let digit_sum = 0;
    let t = i;
    while (t != 0) {
      digit_sum += t % 10;
      t = parseInt(t / 10, 10);
    }
    if (a <= digit_sum && digit_sum <= b) {
      ans += i;
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7616
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main() {
	int vn,en,r;
	cin >> vn >> en >> r;
	vector<int> d(vn,INF);
	vector<vector<pair<int,int>>> e(vn);
	for(int i=0; i<en; i++){
		int a,b,dist;
		cin >> a >> b >> dist;
		e.at(a).push_back({dist,b});
	}
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
	d.at(r) = 0;
	for(auto i:e.at(r)) q.push(i);
	while(!q.empty()){
		auto p = q.top();
		q.pop();
		if(d.at(p.second)<p.first) continue;
		d.at(p.second) = p.first;
		for(auto j:e.at(p.second)) q.push({j.first+p.first,j.second});
	}
	for(auto i:d) {
		if(i==INF) cout << "INF" << endl;
		else cout << i << endl;
	}
}


Measured memory_bytes: 14016
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll s, w;
    cin>>s>>w;
    if(w >= s){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
	int N,i;
    long long int  ans =1;

    scanf("%d",&N);

    for(i=0;i<N;++i)
    {
    	ans = (ans * (i+1))% 1000000007;
    }
    // ans = ans % 100000007;

    printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  if(N%2==0) {
    cout << N << endl;
  } else {
    cout << N*2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  
  for(int i=1; i<=9; i++){
    for(int j=1; j<=9; j++){
      if(i*j==n){
        printf("Yes");
        return 0;
      }
    }
  }
  
  printf("No");
  return 0;
}

Measured memory_bytes: 128
fn main() {
    println!("{:?}", solve(input()));
}

fn input() -> f64 {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.pop();
    let l: f64 = buf.parse().unwrap();
    l
}

fn solve(l: f64) -> f64 {
    let a = l / 3.0;
    a * a * a
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    int A,B,M;
    cin>>A>>B>>M;
    int a[A];
    for(int i=0;i<A;i++){
        cin>>a[i];
    }
    int b[B];
    for(int k=0;k<B;k++){
        cin>>b[k];
    }
    int x[M],y[M],c[M];
    for(int q=0;q<M;q++){
        cin>>x[q]>>y[q]>>c[q];
    }
    int ans1[M];
    for (int w=0;w<M;w++){
        ans1[w]=a[(x[w]-1)]+b[(y[w]-1)]-c[w];
    }
    int ans2=ans1[0];
    for(int t=0;t<M;t++){
        if(ans2>ans1[t]){
            ans2=ans1[t];
        }
    }
    int as=a[0];
    for(int e=0;e<A;e++){
        if(as>a[e]){
            as=a[e];
        }
    }
    int bn=b[0];
    for (int r=0;r<B;r++){
        if(bn>b[r]){
            bn=b[r];
        }
    }
    if(ans2>(as+bn))cout<<as+bn<<endl;
    else if (ans2<=(as+bn))cout<<ans2<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

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

   string s1 = s.substr(0,2);
   string s2 = s.substr(2,2);

   bool is_yy = false;
   bool is_mm = false;

   if(stoi(s1) > 12 || stoi(s1) <= 0){
      is_yy = true;
      if(0 >= stoi(s2) || stoi(s2) > 12){
         is_yy = false;
         cout << "NA" << endl;
         return 0;
      }
   }

   if(1 <= stoi(s1) && stoi(s1) <= 12){
      is_mm = true;
      is_yy = true;
      if(stoi(s2) > 12 || stoi(s2) <= 0){
         is_yy = false;
      }
   }

   if(is_mm && is_yy){cout << "AMBIGUOUS" << endl;}
   else if(is_mm){cout << "MMYY" << endl;}
   else if(is_yy){cout << "YYMM" << endl;}
   else{cout << "NA" << endl;}


   return 0;
}

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

using namespace std;

struct Board{
	set<pair<int,int> > pos;
	set<int> r,c,d,cd;
	bool avail(int x, int y){
		return !r.count(x)&&!c.count(y)&&!d.count(x-y)&&!cd.count(x+y);
	}
	bool push(int x,int y){
		if(avail(x,y)){
			r.insert(x);
			c.insert(y);
			d.insert(x-y);
			cd.insert(x+y);
			pos.insert({x,y});
			return true;
		} else return false;
	}
	bool pop(int x, int y){
		assert(!avail(x,y));
		r.erase(x);
		c.erase(y);
		d.erase(x-y);
		cd.erase(x+y);
		pos.erase({x,y});
	}
	void dump(){
		for(int x=0;x<8;++x){
			for(int y=0;y<8;++y){
				if(pos.count({x,y})) cout<<"Q";
				else cout<<".";
			}
			cout<<"\n";
		}
	}
};

int main(){
	Board b;
	int n; cin>>n;
	vector<bool> vis(n,0);
	for(int i=0;i<n;++i){
		int r,c; cin>>r>>c;
		vis[r] = true;
		b.push(r,c);
	}
	function<void(int)> f = [&](int r){
		if(r==8) b.dump();
		if(vis[r]) f(r+1);
		for(int c=0;c<8;++c){
			if(b.push(r,c)){
				f(r+1);
				b.pop(r,c);
			}
		}
	};
	f(0);
	return 0;
}



Measured memory_bytes: 3100
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt");
    if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B;
    cout << lcm(A, B) << endstr;
    return 0;
}


Measured memory_bytes: 256
using System;
namespace HelloWorld
{
    internal class Circle
    {
        internal double X { get; set; }
        internal double Y { get; set; }
        internal double R { get; set; }
    }
    class Program
    {
        static void Main()
        {
            const int DATA = 6;
            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; ++i)
            {
                var a = Console.In.ReadLine().Split();
                double[] tmp = new double[DATA];
                for (int j = 0; j < DATA; ++j)
                {
                    tmp[j] = double.Parse(a[j]);
                }
                Circle A = new Circle { X = tmp[0], Y = tmp[1], R = tmp[2] };
                Circle B = new Circle { X = tmp[3], Y = tmp[4], R = tmp[5] };
                double rel = Math.Sqrt(Math.Pow(A.X - B.X, 2) + Math.Pow(A.Y - B.Y, 2));
                Console.Out.WriteLine(CoincidCk(rel, A, B));
            }
        }
        static int CoincidCk(double rel, Circle A, Circle B)
        {
            if (rel > A.R + B.R)
                return 0;
            else if (rel + B.R < A.R)
                return 2;
            else if (rel + A.R < B.R)
                return -2;
            else
                return 1;
        }
    }
}



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

int main(){

    string S;
    cin >> S;

    int findex, rindex;

    findex = S.find("keyence");
    rindex = S.rfind("keyence");
    if(findex == 0 || rindex == (S.length() - 7)){
        cout << "YES" << endl;
        return 0;
    }

    findex = S.find("k");
    rindex = S.rfind("eyence");
    if(findex == 0 && rindex == (S.length() - 6)){
        cout << "YES" << endl;
        return 0;
    }

    findex = S.find("ke");
    rindex = S.rfind("yence");
    if(findex == 0 && rindex == (S.length() - 5)){
        cout << "YES" << endl;
        return 0;
    }

    findex = S.find("key");
    rindex = S.rfind("ence");
    if(findex == 0 && rindex == (S.length() - 4)){
        cout << "YES" << endl;
        return 0;
    }

    findex = S.find("keye");
    rindex = S.rfind("nce");
    if(findex == 0 && rindex == (S.length() - 3)){
        cout << "YES" << endl;
        return 0;
    }

    findex = S.find("keyen");
    rindex = S.rfind("ce");
    if(findex == 0 && rindex == (S.length() - 2)){
        cout << "YES" << endl;
        return 0;
    }

    findex = S.find("keyenc");
    rindex = S.rfind("e");
    if(findex == 0 && rindex == (S.length() - 1)){
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll _8 = 1;
  ll _9 = 1;
  ll _10 = 1;
  for (ll i = 0; i < N; i++) {
    _8 *= 8;
    _8 %= Mod;
    _9 *= 9;
    _9 %= Mod;
    _10 *= 10;
    _10 %= Mod;
  }
  ll ans = _10 - _9 - _9 + _8;
  ans %= Mod;
  if (ans < 0) ans += Mod;
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
    int i;
	long long int L[86];
	L[0] = 2;
	L[1] = 1;
	int n;
	cin >> n;
	for(i=2; i<=n; i++){
		L[i] = L[i-1] + L[i-2]; 
	}
	cout << L[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<queue>

using namespace std;

const int INF = 100000000;
const int MAX_H = 20;
const int MAX_W = 20;

char maze[MAX_H][MAX_W];

int d[MAX_H][MAX_W];

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int bfs(int H, int W,
        int sx, int sy,
        int gx, int gy) {
    queue<pair<int, int> > que;

    // 初期化
    for (int y = 0; y < H; y++) {
        for(int x = 0; x < W; x++) {
            d[y][x] = INF;
        }
    }

    que.push(make_pair(sx, sy));

    d[sy][sx] = 0;

    while (que.size()) {
        pair<int, int> p = que.front();
        que.pop();

        if(p.first == gx && p.second == gy) {
            break;
        }

        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(0 <= nx && nx < W && 0 <= ny && ny < H &&
               maze[ny][nx] != '#' && d[ny][nx] == INF) {
                que.push(make_pair(nx, ny));
                d[ny][nx] = d[p.second][p.first] + 1;
            }
        }
    }

    return d[gy][gx] == INF ? -1 : d[gy][gx];
}

int main() {
    int H, W;
    cin >> H >> W;

    for (int y = 0; y < H; y++) {
        string line;
        cin >> line;
        for (int x = 0; x < W; x++) {
            maze[y][x] = line[x];
        }
    }

    int ans = 0;
    for (int sy = 0; sy < H; sy++) {
        for (int sx = 0; sx < W; sx++) {
            for (int gy = 0; gy < H; gy++) {
                for (int gx = 0; gx < W; gx++) {
                    if (maze[sy][sx] == '.' && maze[gy][gx] == '.') {
                        int result = bfs(H, W, sx, sy, gx, gy);
                        ans = ans < result ? result : ans;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,M = map(int,input().split())

AB = [[int(x) for x in input().split()] for _ in range(M)]

# (x,y)をすることは、(1,x),(1,y)とすることと同じ

counter = [0] * (N+1)
for x,y in AB:
    counter[x] += 1
    counter[y] += 1

answer = 'NO' if any(x&1 for x in counter) else 'YES'
print(answer)

Measured memory_bytes: 21936
package main
import (
  "fmt"
)

func reverse(s string) string {
  runes := []rune(s)
  for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
    runes[i], runes[j] = runes[j], runes[i]
  }
  return string(runes)
}

func main() {
  var (
    S string
    index int
  )
  fmt.Scan(&S)
  S = reverse(S)
  for index < len(S) {
    index_pre := index
    if index + 7 <= len(S) && S[index: index + 7] == "remaerd" {
      index += 7
    }
    if index + 5 <= len(S) && S[index: index + 5] == "maerd" {
      index += 5
    }
    if index + 6 <= len(S) && S[index: index + 6] == "resare" {
      index += 6
    }
    if index + 5 <= len(S) && S[index: index + 5] == "esare" {
      index += 5
    }
    if index_pre == index {
      fmt.Println("NO")
      return
    }
  }
  fmt.Println("YES")
}


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

using namespace std;
using ll = long long;
using indx = size_t;
#define endl '\n'

int main() {
    int n, m;
    cin >> n >> m;
    ll a = n/2;
    ll b = a + 1;
    while(m) {
        m--;
        if (n == 2*(b-a) or n == 2*(b-a-1))
            b++;
        cout << a << " " << b << endl;
        a--, b++;
    }
}


Measured memory_bytes: 3604
#include<cstdio>
const int N=100005;
typedef long long ll;
int n,A[N];
ll f0,f1,f2;
char op[N];
int main()
{
	scanf("%d%d",&n,A);
	for(int i=1;i<n;i++)scanf(" %c%d",op+i,A+i);
	f0=A[0];f1=f2=-(1ll<<60);
	for(int i=1;i<n;i++)
	{
		if(op[i]=='-')
		{
			f0-=A[i],f1+=A[i],f2-=A[i];
			if(f1>f2)f2=f1;
			if(f0>f1)f1=f0;
		}
		else
			f0+=A[i],f1-=A[i],f2+=A[i];
		if(f1>f0)f0=f1;
		if(f2>f1)f1=f2;
	}
	printf("%lld\n",f0);
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <climits>
#include <random>
#include<algorithm>

#define int_max 2147483647;

void A(void)
{
    int x, y;
    std::cin >> x >> y;
    std::cout << x + y / 2 << std::endl;
    return ;
}

void B(void)
{
    int N,T,A;
    std::cin>> N ;
    std::cin>>T>>A;
    std::vector<int> vec (N);
    for(int i = 0; i < N ; i ++)
    {
        std::cin>>vec[i];
    }

    float min = int_max;
    int index = 0;
    float num = 0;
    for(int i = 0; i < N ; i ++)
    {
        num = float(T) - 0.006*(vec[i]);
        num = std::abs(A - num);
        if(num <= min)
        {
            min = num;
            index = i;
        }
    }

    std::cout<<index+1<<std::endl;
    return ;
}
int main(int argc, char const *argv[])
{
    
    B();

    return 0;
}

Measured memory_bytes: 256
def get_height x
    px, hx = x, 0
    while px != @parent[px][0]
        hx += @parent[px][1]
        px = @parent[px][0]
    end
    return [px, hx]
end

n, q = gets.chomp.split.map(&:to_i)

@parent = []
0.upto(n - 1){|i| @parent[i] = [i, 0]}

q.times{
    command, x, y, z = gets.chomp.split.map(&:to_i)
    px, hx = get_height(x)
    py, hy = get_height(y)

    case command
    when 0
        next if px == py
        if px < py
            @parent[py] = px, hx - hy + z
        else
            @parent[px] = py, hy - hx - z
        end
    when 1
        puts (px != py) ? "?" : hy - hx
    end
}


Measured memory_bytes: 17796
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  vs data(n);
  rep(i,n) cin >> data[i];
  rep(i,n) sort(all(data[i]));
  in6 ans = 0;
  sort(all(data));
  string here = data[0];
  in6 count = 0;
  repa(i,1,n) {
    if(here == data[i]) count++;
    else {
      here = data[i];
      ans += (count+1)*count/2;
      count = 0;
    }
  }
  ans += (count+1)*count/2;
  cout << ans;
  hinata;
}

Measured memory_bytes: 6440
N = int(input())
S = input()
L = [chr(ord('a') + i) for i in range(26)]
cnt = [0]*26
for i in range(len(S)):
  cnt[ord(S[i])-97] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
ans = 1
for i in range(len(D)):
  ans *= (D[i]+1)
  ans = ans%(10**9+7)
print((ans-1)%(10**9+7))

Measured memory_bytes: 3188
S=input()
x=dict()
if len(S)==1:
    print("YES")
    exit()

for i in range(len(S)):
    s=S[i]
    if s in x:
        x[s]+=1
    else:
        x[s]=1
l=[]
cnt=0
for idx in x:
    l.append(x[idx])
    cnt+=1
if len(S)==2 and cnt!=1:
    print("YES")
    exit()

if cnt!=3:
    print("NO")
    exit()
l.sort()
x=l[0]
y=l[1]
z=l[2]
y=y-x
z=z-x
if y>1 or z>1:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 39540
N, K = map(int, input().split())
k_n = N // K

sum = k_n*k_n*k_n
if K % 2 == 0:
    if K * (N // K) + K // 2 <= N:
        sum += (k_n + 1) ** 3
    else:
        sum *= 2

print(sum)


Measured memory_bytes: 2940
def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

a,b=map(int,input().split())
c=gcd(a,b)
ans = 1
div = 2
first_flag=1
while c>1:
    if  div**2 > c:
        ans +=1
        break
    while c%div == 0:
        c /= div
        if first_flag == 1:
            ans += 1
            first_flag = 0 
    div += 1
    first_flag = 1
print(ans)

Measured memory_bytes: 3064
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    n,d=map(int,input().split())
    ct=0
    for _ in range(n):
        x,y=map(int,input().split())
        if((x*x+y*y)**(0.5)<=d):
            ct+=1
    print(ct)


BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 79948
from collections import Counter

def get_smallest_power_of_2_over_N(N):
    i=2
    while i<=N:
        i*=2
    return i

N = int(input())
A = list(map(int,input().split()))


A = sorted(A)

ans=0
D=Counter(A)

for i in reversed(range(N)):
    pair_val = get_smallest_power_of_2_over_N(A[i]) - A[i]
    if D[A[i]]<=0:
        continue
    elif pair_val==A[i] and D[pair_val]>=2 or pair_val!=A[i] and  D[pair_val]>=1:
        ans+=1
        D[pair_val]-=1
        D[A[i]]-=1

print(ans)


Measured memory_bytes: 33424
#include <iostream>
#include <vector>
#include <set>

using namespace std;

vector<long long> cost(10, -1);
set<int> s;

long long dfs(int n, vector<vector<long long> > &c) {
    s.insert(n);
    long long rec = 1e9;
    if (cost[n] != -1) {
        rec = min(cost[n], rec);
        s.erase(n);
    }
    
    else if (n == 1) {
        rec = min(cost[1] = 0, rec);
        s.erase(n);
    }
    
    else  {
        for (int i = 0; i < 10; i++) {
            if (s.find(i) == s.end())
                rec = min(rec, dfs(i, c) + c[n][i]);
        }
        s.erase(n);
    }
    return rec;
}

int main() {
    int h, w;   cin >> h >> w;
    vector<vector<long long> > c(10, vector<long long>(10)), a(h, vector<long long>(w));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++)
            cin >> c[i][j];
    }

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

    for (int i = 0; i < 10; i++) {
        cost[i] = dfs(i, c);
    }

    long long ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] != -1)
                ans += cost[a[i][j]];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3952
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main()
{
  char s[26], len;
  bool same = false;
  scanf("%s", s);
  len = strlen(s);
  int i, j;
  for(i = 0; i < len; i++){
    for(j = i + 1; j < len; j++){
      if(s[i] == s[j]) same = true;
    }
  }
  if(same) printf("no\n");
  else     printf("yes\n");
  return 0;
}


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

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

	long long int a,b,k;

	cin >> a >> b >> k;

	long long int m = min(a,k);

	a-=m;
	k-=m;

	if(k>0)
	{
		m = min(b,k);
		b-=m;
		k-=m;
	}

	cout << a << ' ' << b << '\n';
	
	return 0;

}

Measured memory_bytes: 256
import numpy as np
#入力値を読み取る
N = input()
j = []
for i in range(int(N)):
    d = input()
    j = np.append(j,int(d))

#読み込んだjを降順にsort
sort = np.sort(j)
z = [sort[0]]
for i in range(len(j)-1):
    if (sort[i]<sort[i+1]):
        z = np.append(z,sort[i+1])
print(len(z))


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n;
    cin >> n;
    int A[n];
    FOR(i,0,n)
        cin >> A[i];
    int res=0,prev=0;

    FOR(i,0,n){
        if(prev<A[i])
            res+=A[i]-prev;
        prev=A[i];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toLong()}
    val A = readLine()!!.split(" ").map{it.toLong()}

    val B = Array(N.toInt() + 1) { 0L }
    val mp = TreeMap<Long, ArrayList<Int>>()

    mp[0] = ArrayList()
    mp[0]!!.add(0)
    for (i in A.indices) {
        B[i + 1] = (B[i] + A[i]) % K

        val b = ((i + 1) - B[i + 1] + K) % K

        if (mp[b] == null) {
            mp[b] = ArrayList()
            mp[b]!!.add(i + 1)
        } else {
            mp[b]!!.add(i + 1)
        }
    }

    var res = 0L

    for (list in mp.values) {
        val Q = ArrayDeque<Int>()

        for (v in list) {
            while (Q.isNotEmpty() && v - Q.first >= K) {
                Q.removeFirst()
            }
            res += Q.size
            Q.addLast(v)
        }
    }

    println(res)
}


Measured memory_bytes: 142364
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int x=0,r,g,b;
  cin>>r>>g>>b;
  x+=r*100+g*10+b;
  if(x%4==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256