akhauriyash/Code-Regression huggingface dataset:
using System;

namespace Contest
{

    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int R;
        private void Scan()
        {
            Scanner sc = new Scanner();
            R = sc.NextInt();
        }


        public void Solve()
        {
            Scan();
            if (R < 1200)
            {
                Console.WriteLine("ABC");
            }
            else if (R < 2800)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("AGC");
            }
        }

        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 11092
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
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<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<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
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

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){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    vvl nz;
    REP(i, N){
        vl tmp;
        while(A[i] != 0 && i < N){
            tmp.pb(A[i]); i++;
        }
        if(tmp.size() > 0) nz.pb(tmp);
    }
    
    ll ans = 0;
    REP(x, nz.size()){
        ll sum = 0;
        REP(k, nz[x].size()) sum += nz[x][k];
        ans += sum /2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3764
from collections import Counter
def main():
    s = input()
    if len(s) == 1:
        print('YES')
        return
    if len(s) == 2:
        if len(set(s)) == 1: print('NO')
        else: print('YES')
        return
    cc = Counter(s)
    if all([cc[cha] >= len(s)//3 for cha in ['a', 'b', 'c']]):
        if len(s)%3 == 2:
            if sum([cc[cha] - len(s)//3 >= 1 for cha in ['a', 'b', 'c']]) >= 2: print('YES')
            else: print('NO')
        else: print('YES')
    else:
        print('NO')
    return

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 3564
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
bool prime(int i){
  int num=0;
  for (int j=1;j<=i;j++)
    if (i % j == 0)
      num++;
  if (num==2) return true;
  return false;
}
int main(){
  int n;
  cin>>n;
  for (int i=2;i<=55555 && n > 0;i++){
   	if (prime(i) && i % 5 == 1){
   	  cout<<i<<" ";
   	  n--;
   }
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
x=[0]*9
for i in a:
    x[min(i//400,8)]+=1
ans=0
for i in range(8):
    if x[i]>0:
        ans+=1
mini=max(1,ans)
maxe=ans+x[8]
print(mini,maxe)



Measured memory_bytes: 61364
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

ac = list(sorted([(a, c) for a, c in Counter(A).items() if c >= 2]))
if len(ac) >= 2:
    if ac[-1][1] >= 4:
        print(ac[-1][0] ** 2)
    else:
        print(ac[-1][0] * ac[-2][0])
else:
    print(0)


Measured memory_bytes: 33520
X, N = map(int, input().split())
p = list(map(int, input().split()))

going = True
c = X # 初期値
co = X
count = 0

if N == 0:
    print(X)
else:
    while going:
        if p.count(c) == 0:
            print(c)
            break
        elif p.count(co) == 0:
            print(co)
            break
        c -= 1
        co += 1
        #count += 1
#print(count)

Measured memory_bytes: 9192
#include<iostream>

int main(){
	int n,a=100000,b;
	std::cin>>n;
	for(b=0;b<n;b++){
		a*=1.05;
		if(a%1000!=0){
			a=a-(a%1000)+1000;
		}
	}
	std::cout<< a <<std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin >>a>>b>>c;
if(a<=b && b<=c){
cout <<a<<" "<<b<<" "<<c<<endl;
}else if(a<=c &&c<=b ){
cout <<a<<" "<<c<<" "<<b<<endl;
}else if(b<=a &&a<=c ){
cout <<b<<" "<<a<<" "<<c<<endl;
}else if(b<=c &&c<=a ){
cout <<b<<" "<<c<<" "<<a<<endl;
}else if(c<=a &&a<=b ){
cout <<c<<" "<<a<<" "<<b<<endl;
}else if(c<=b &&b<=a ){
cout <<c<<" "<<b<<" "<<a<<endl;
}
return 0;
}




Measured memory_bytes: 3092
def resolve():
    import sys
    import itertools
    readline = sys.stdin.readline    # 1行だけ文字列にする

    N, M = map(int, readline().split())
    lst = [set(map(int, readline().split())) for _ in [0] * M]
    d = []
    ans = 0
    for i in range(2, N + 1):
        d.append(i)
    for i in itertools.permutations(d, N - 1):
        cnt = 0
        if {1, i[0]} in lst:
            cnt += 1
            for j in range(N - 2):
                if {i[j], i[j + 1]} in lst:
                    cnt += 1
                    pass
                else:
                    break
        if cnt == N - 1:
            ans += 1
    print(ans)
    

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9216
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
ll solve(ll a[],ll dp[],ll n,ll k)
{
	if(dp[n]!=inf)
		return dp[n];
	for(ll i=1;i<=k;i++)
		dp[n]=min(dp[n],n-i<0 ?inf :solve(a,dp,n-i,k)+abs(a[n]-a[n-i]));
	return dp[n];
}
int main()
{
	checkpoint1();
	ll n,k;
	cin>>n>>k;
	ll a[n],dp[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
		dp[i]=inf;
	}
	dp[0]=0;
	cout<<solve(a,dp,n-1,k);
	return 0;
}

Measured memory_bytes: 12976
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.next();
		Set<String> set = new HashSet<>();
		while (sc.hasNext()) {
			set.add(sc.next());
		}
		System.out.println(set.size() > 3 ? "Four" : "Three");
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const int N=1e5+5;
bool f;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    if(len(s)<=n)
        cout<<s;
    else
    {
       cout<<s.substr(0,n)<<"...";
    }
go;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

  if (N == M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
#define MOD 1'000'000'007
using namespace std;
typedef long long ll;
typedef long double ld;

int N;
int a[100];

int main(){
    cin>>N;
    rep(i,N) cin>>a[i];

    int ans=0;
    rep(i,N){
        if(i%2==0 && a[i]%2==1) ans++;
    }

    cout<<ans<<endl;
}

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

void solve(long long N, std::vector<long long> A)
{
    vector<ll> Adash(N + 1);
    for (ll i = 1; i <= N; i++) {
        if (i - A[i] >= 2) {
            Adash[i - A[i]]++;
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (i - A[i] >= 2) { // 自分を削除
            Adash[i - A[i]]--;
        }
        if (i + A[i] <= N) {
            ans += Adash[i + A[i]];
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N+1);
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 6428
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
                        if (a + b == c || b + c == a || c + a == b) {
                                System.out.println("Yes");
                        } else {
                                System.out.println("No");
                        }
                }
        }
}

Measured memory_bytes: 9684
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n = int(input())
    if n%2 == 0:
        print(n//2,n,n)
        return
    for i in range(1,3501):
        for j in range(i + 1,3501):
            if (n * i * j)%(4 * i * j - n * j - n * i) == 0:
                ans = (i ,j , (n * i * j)//(4 * i * j - n * j - n * i))
                break
    
    print(*ans)

if __name__ =='__main__':
    main()  

Measured memory_bytes: 39252
require "prime"
primes = []
Prime.each(1299709){|prime| primes << prime}
arr = [nil, nil, 0]
primes.each_cons(2){|prime1, prime2|
    arr[prime2] = 0
    (prime1 + 1).upto(prime2 - 1){|i| arr[i] = prime2 - prime1}
}
while true
    x = gets.to_i
    break if x == 0
    puts arr[x]
end


Measured memory_bytes: 22848
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Pair[] red = new Pair[n];
        Pair[] blue = new Pair[n];
        for(int i = 0; i < n; i++) {
            red[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        for(int i = 0; i < n; i++) {
            blue[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(red, (pt1, pt2) -> (pt2.y - pt1.y));
        Arrays.sort(blue, (pt1, pt2) -> (pt1.x - pt2.x));

        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (red[j] == null)
                    continue;
                if (red[j].x < blue[i].x && red[j].y < blue[i].y) {
                    red[j] = null;
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}

class Pair {
    int x;
    int y;
    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 28244
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}

function main() {
  const [a, b, c, d] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let ans = "";
  let max = -Infinity;

  const ac = BigInt(a) * BigInt(c);
  if (ac > max) max = ac;
  const ad = BigInt(a) * BigInt(d);
  if (ad > max) max = ad;
  const bc = BigInt(b) * BigInt(c);
  if (bc > max) max = bc;
  const bd = BigInt(b) * BigInt(d);
  if (bd > max) max = bd;

  ans += max;

  console.log(ans);
}


Measured memory_bytes: 29924
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC107A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, x;
            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            x = a - b+1;

            Console.WriteLine(x);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;500*i<=x&&i<=a;i++){
        for(int j=0;500*i+100*j<=x&&j<=b;j++){
            for(int h=0;500*i+100*j+50*h<=x&&h<=c;h++){
                if(500*i+100*j+50*h==x) ans++;
            }
        }
    }
    cout<<ans<<endl;
}    

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int k,x;
	cin >> k >> x;
	
	for(int i=x-k+1; i<=x+k-1; i++)
		cout << i << " ";
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const int INF = 1001;
int main() {
  int n, T;
  cin >> n >> T;
  vector<P> R(n);
  rep(i, n) {
    int c, t;
    cin >> c >> t;
    R[i] = make_pair(c, t);
  }
  sort(all(R));
  int ans = INF;
  rep(i, n) if(R[i].second <= T) ans = min(ans, R[i].first);
  if(ans == INF) {
    cout << "TLE" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <complex>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef complex<double> P;

double cross(const P& a, const P& b) { return imag(conj(a)*b); }
P rot90(const P& p) { return p*P(0, 1); }
P crosspoint(const P& l0, const P& l1, const P& m0, const P& m1) {
    const double A = cross(l1-l0, m1-m0);
    const double B = cross(l1-l0, l1-m0);
    return m0 + B/A * (m1-m0);
}

P center(P a, P b, P c) {
    const P m1 = 0.5*(a+b), m2 = 0.5*(b+c);
    return crosspoint(m1, m1+rot90(b-a), m2, m2+rot90(c-b));
}

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        double x1, y1, x2, y2, x3, y3;
        scanf("%lf%lf", &x1, &y1);
        scanf("%lf%lf", &x2, &y2);
        scanf("%lf%lf", &x3, &y3);
        const P p = center(P(x1, y1), P(x2, y2), P(x3, y3));
        printf("%.3f %.3f %.3f\n", p.real(), p.imag(), abs(p-P(x1, y1)));
    }
    return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a[3][3], i, j;
    for(i=0; i<3; i++) {
    	for(j=0; j<3; j++) {
    		cin>>a[i][j];
    	}
    }
    ll n;
    cin>>n;
    set<ll> s;
    for(i=0; i<n; i++) {
    	ll temp;
    	cin>>temp;
    	s.insert(temp);
    }
    ll b[3][3];
    for(i=0; i<3; i++) {
    	for(j=0; j<3; j++) {
    		b[i][j] = 0;
    		if(s.find(a[i][j]) != s.end()) {
    			b[i][j] = 1;
    		}
    	}
    }
    ll flag = 0;
    for(i=0; i<3; i++) {
    	if(b[i][0] + b[i][1] + b[i][2] == 3) {
    		flag = 1;
    	}
    	if(b[0][i] + b[1][i] + b[2][i] == 3) {
    		flag = 1;
    	}
    }
    if(b[0][0] + b[1][1] + b[2][2] == 3) {
    	flag = 1;
    }
    if(b[2][0] + b[1][1] + b[0][2] == 3) {
    	flag = 1;
    }
    if(flag) {
    	cout<<"Yes\n";
    }else {
    	cout<<"No\n";
    }
}

Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n=int(input())
    a=list(map(int,input().split()))

    ans="APPROVED"
    for i in a:
        if i%2==0:
            if i%3==0 or i%5==0:
                continue
            else:
                ans="DENIED"
                break



    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	var N int
	fmt.Scanf("%d", &N)
	var A, B, C [21]int
	line := nextLine()
	cols := strings.Split(line, " ")
	for i := 1; i <= N; i++ {
		A[i], _ = strconv.Atoi(cols[i-1])
	}
	line = nextLine()
	cols = strings.Split(line, " ")
	for i := 1; i <= N; i++ {
		B[i], _ = strconv.Atoi(cols[i-1])
	}
	line = nextLine()
	cols = strings.Split(line, " ")
	for i := 1; i <= N-1; i++ {
		C[i], _ = strconv.Atoi(cols[i-1])
	}

	ans := 0
	for i := 1; i <= N; i++ {
		ans += B[A[i]]
		if i != N && A[i]+1 == A[i+1] {
			ans += C[A[i]]
		}
	}

	fmt.Printf("%d", ans)
}


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

int a, b;

int main(){
    cin >> a >> b;
    if(a > b){
        if(16 - b * 2 < (a - b) * 2){
            cout << ":(" << endl;
        }else{
            cout << "Yay!" << endl;
        }
    }else{
        if (16 - a * 2 < (b - a) * 2)
        {
            cout << ":(" << endl;
        }
        else
        {
            cout << "Yay!" << endl;
        }
    }
    return 0;
}

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

int main(){
  string S;
  cin>>S;
  int ss=S.size();
  vector<int> N(ss,0);
  N[0]=1;
  if(ss==1){
    cout<<1<<endl;
    return 0;
  }
  if(S[0]==S[1])N[1]=1;
  else N[1]=2;
  if(ss==2){
    cout<<N[1]<<endl;
    return 0;
  }
  if(S[0]==S[1]||S[1]==S[2])N[2]=2;
  else N[2]=3;
  if(ss==3){
    cout<<N[2]<<endl;
    return 0;
  }
  for(int i=3;i<ss;i++){
    if(S[i]==S[i-1])N[i]=N[i-3]+2;
    else N[i]=max(N[i-1]+1,N[i-3]+2);
  }
  cout<<N[ss-1]<<endl;
}

Measured memory_bytes: 1412
h,w,k = list(map(int, input().split()))
masu = [input() for _ in range(h)]
ans = 0

def count_num(m, target, goal):
    for i in range(h):
        count = sum(map(lambda x: x.count(target), m))
    
    return count == goal

def change_row(m, i_row_0):
    m[i_row_0] = 'r'*w    
    return m

def change_col(m, j_col_0):
    for i in range(h):
        if j_col_0 < w:
            m[i] = m[i][:j_col_0]+'r'+ m[i][j_col_0+1:]
    return m




for idx_h in range(2**h):
    for idx_w in range(2**w):
        m = masu.copy()
        for i_row, row in enumerate(m):
            if idx_h & (2 ** i_row) > 0:
                m = change_row(m, i_row)

            for j_col, col in enumerate(row):
                if idx_w & (2 ** j_col) > 0:
                    m = change_col(m, j_col)
        
        #print(m)
        if count_num(m, '#', k):
            ans += 1
        
print(ans)

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

int main(){
  ll N,M;
  cin >> N >> M;
  ll res;
  for(ll p = 1; p * p <= M; p++){
    if(M % p == 0){
      ll tmp;
      if(M/p >= N){
	tmp = p;
	res = max(res, tmp);
      }
      if(p >= N){
	tmp = M/p;
	res = max(res, tmp);
      }
    }
  }
  cout << res << endl;
}


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

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

using namespace std;

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

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

const int MAX_N = TEN(5);
int n;
vec<pii> g[MAX_N];
int col[MAX_N];

int color(int u, int v, int c) {
  int maxc = 0;
  int cur = 1;
  for (auto e : g[u]) {
    if (e.fst == v) continue;
    if (cur == c) cur++;
    col[e.snd] = cur;
    chmax(maxc, color(e.fst, u, cur));
    chmax(maxc, cur);
    cur++;
  }

  return maxc;
}

int main()
{
  fastio();

  cin >> n;
  forn(i,n-1) {
    int a,b; cin >> a >> b;
    a--,b--;
    g[a].emplace_back(b,i);
    g[b].emplace_back(a,i);
  }

  int k = color(0, -1, 0);

  cout << k << '\n';
  for (int i = 0; i < n-1; i++)
    cout << col[i] << '\n';

  return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll n;
    cin>>n;
    ll c=0,tmp=1,z=26;
    while(tmp<=n){
        n-=tmp;
        ++c;
        tmp*=z;
    }
    //cout<<c<<endl;
    string line="abcdefghijklmnopqrstuvwxyz";
    string ans="";
    rep(0,i,c){
        ans+=line[n%(z)];
        n/=z;
        //cout<<n<<endl;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

struct ModCombination {
    vector<mint> Fac;
    vector<mint> Facinv;

    ModCombination(int x) {
        Fac.resize(x+1);
        Facinv.resize(x+1);
        Fac[0] = 1;
        for (long long i = 1; i <= x; i++) Fac[i] = Fac[i-1]*i;
        Facinv[x] = Fac[0]/Fac[x];
        for (long long i = x; i > 0; i--) Facinv[i-1] = Facinv[i]*i;
    }

    mint get(int n, int k) {
        if (k < 0 || k > n) return 0;
        return Fac[n]*Facinv[k]*Facinv[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int r1,r2,c1,c2; cin >> r1 >> c1 >> r2 >> c2;
    ModCombination MC(r2+c2+5);

    mint ans = 0;
    for (int i = r1; i <= r2; ++i) {
        ans += MC.get(i+c2+1,i+1) - MC.get(i+c1,i+1);
    }

    cout << ans.a << ln;
}



Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int ans = 10000;
    
    string S;
    cin >> S;
    rep(i,S.length()-2){
        
        string ss = S.substr(i, 3);
        int a = stoi(ss);
        ans = min(ans, abs(a-753));
        
    }
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

using namespace std;

unordered_map<int, int> memo;

int rec(int n) {
    if (memo.find(n) != memo.end()) {
        return memo[n];
    }
    if (n == 1) {
        return memo[n] = 0;
    }
    if (n % 2 == 0) {
        return memo[n] = 1 + rec(n / 2);
    } else {
        return memo[n] = 1 + rec(n * 3 + 1);
    }
}

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << rec(n) << endl;
    }
}


Measured memory_bytes: 3048
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second

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){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl as(N+1, 0); REP(i, N) cin >> as[i+1];
    vl sum(N+1, 0), xo(N+1, 0); sum[0] = 0; xo[0] = 0; ll s = 0, x = 0;
    REP(i, N){
        s += as[i+1]; x = x ^ as[i+1];
        sum[i+1] = s; xo[i+1] = x;
    }
    ll l = 0, r = 1, pre_r = r, ret = 1;
    while(l < N){
        ll pl = 0;
        while(r <= N){
            if(sum[r] - sum[l] != (xo[r] ^ xo[l])){
                break;
            }
            r++;
        }
        r -= 1; pl = r - pre_r;
        ret += (r-l-pl) * pl + pl + pl * (pl-1) / 2;
        pre_r = r;
        l++; r = max(r, l+1);
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 4992
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;
import java.util.OptionalInt;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B1DimensionalWorldsTale solver = new B1DimensionalWorldsTale();
        solver.solve(1, in, out);
        out.close();
    }

    static class B1DimensionalWorldsTale {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt(), x = in.nextInt(), y = in.nextInt();
            int xm = IntStream.range(0, n).map(z -> in.nextInt()).max().orElse(0);
            int ym = IntStream.range(0, m).map(z -> in.nextInt()).min().orElse(0);
            if (x < ym && xm < y && xm < ym) {
                out.println("No War");
            } else {
                out.println("War");
            }
        }

    }
}



Measured memory_bytes: 28880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    int turn=0;
    string s;cin>>s;
    int q;cin>>q;
    vector<char> a,b;
    rep(i,q){
        int t;cin>>t;
        if(t==1)turn=1-turn;
        else{
            int w;cin>>w;w--;
            char c;cin>>c;
            if(w+turn==1)b.pb(c);
            else a.pb(c);
        }
    }
    if(turn){
        for(int i=b.size()-1;i>=0;i--)cout<<b[i];
        for(int i=s.size()-1;i>=0;i--)cout<<s[i];
        for(char c:a)cout<<c;
    }
    else{
        for(int i=a.size()-1;i>=0;i--)cout<<a[i];
        for(char c:s)cout<<c;
        for(char c:b)cout<<c;
    }
    cout<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int A,B,C,ans;
  scanf("%d %d %d",&A,&B,&C);
  if(A>=B && A>=C){
    ans=A*10+B+C;
  }else if(B>=A && B>=C){
    ans=A+B*10+C;
  }else if(C>=A && C>=B){
    ans=A+B+C*10;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int t;
    cin >> t;
    map<string,int>mp;
    while(t--)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout<<"AC"<<" x "<<mp["AC"]<<'\n';
    cout<<"WA"<<" x "<<mp["WA"]<<'\n';
    cout<<"TLE"<<" x "<<mp["TLE"]<<'\n';
    cout<<"RE"<<" x "<<mp["RE"]<<'\n';
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cctype>

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

using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int start = max(A, C);
    int end = min(B, D);

    cout << max(end - start, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int soma(num){
  int soma = 0;

  while (num != 0) {
    soma   += num % 10;
    num  = num / 10;
  }

  return soma;
}

int main(void) {
  int n, a, b, menor;

  scanf("%d", &n);
  a = 1;
  b = n-1;
  menor = soma(a) + soma(b);

  while (a < b){
    int somaTemp = soma(a) + soma(b);
    if( somaTemp < menor){
      menor = somaTemp;
    }

    a++;
    b--;
  }

  printf("%d", menor);


  return 0;
}

Measured memory_bytes: 256
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

using namespace std;

void solve()
{
    ll n, k;
    cin >> n >> k;
    vector <ll> d(k), a[k], v(n + 1, 0);
    for(ll i = 0; i < k; i++)
    {
        cin >> d[i];
        a[i].resize(d[i]);
        for(ll j = 0; j < d[i]; j++)
        {
            cin >> a[i][j];
            v[a[i][j]]++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++)
        if(v[i] == 0)
            ans++;
    cout << ans << endl;
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <math.h>
#include<string>

using namespace std;

int main(){
    string ss;
    int count = 0, temp = -1, cout_temp=0;

    cin >> ss;

    ss = ss + 'S';

    for (int i = 0; i < ss.length(); i++){
        if(ss[i]=='R' && temp==-1){ 
            temp = i;
            cout_temp += 1;
            count = max(count, cout_temp);
        }
        else if(ss[i]=='R' && i==temp+1){
            temp = i;
            cout_temp += 1;
            count = max(count, cout_temp);
        }
        else{
            temp = -1;
            cout_temp = 0;
        }
    }

    cout << count;
}

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

int main() {
    int N, ans=0;
    string tmp;
    cin >> N;
    // vector<string> s(N);
    set<string> s;

    for(int i=0; i<N; i++){
	cin >> tmp;
	s.insert(tmp);
    }
    
    cout << s.size() << endl;
} 




Measured memory_bytes: 19040
#include <stdio.h>

int main(void) {
	char eibun[1100];
	int i;
	fgets(eibun,sizeof(eibun),stdin);
	for(i=0;eibun[i+4]!=0;i++) {
		if(eibun[i]=='a' && eibun[i+1]=='p' && eibun[i+2]=='p' &&
			eibun[i+3]=='l' && eibun[i+4]=='e') {
			eibun[i]='p';
			eibun[i+1]='e';
			eibun[i+2]='a';
			eibun[i+3]='c';
			eibun[i+4]='h';
			continue;
		}
		if(eibun[i]=='p' && eibun[i+1]=='e' && eibun[i+2]=='a' &&
			eibun[i+3]=='c' && eibun[i+4]=='h') {
			eibun[i]='a';
			eibun[i+1]='p';
			eibun[i+2]='p';
			eibun[i+3]='l';
			eibun[i+4]='e';
		}
	}
	printf("%s",eibun);
	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

class Node implements Comparable<Node> {
  int a;
  int originalIndex;
  
  Node(int a, int originalIndex) {
    this.a = a;
    this.originalIndex = originalIndex;
  }
  
  public int compareTo(Node node) {
    return this.a - node.a;
  }
}

public class Main {
  private static int solve(int[] as) {
    Node[] nodes = new Node[as.length];
    for (int i = 0; i < as.length; i++) {
      nodes[i] = new Node(as[i], i);
    }
    Arrays.sort(nodes);
    
    int paritySum = 0;
    for (int i = 0; i < nodes.length; i++) {
      if (nodes[i].originalIndex % 2 != i % 2) {
        paritySum++;
      }
    }
    return paritySum / 2;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = new int[n];
    for (int i = 0; i < n; i++) {
      as[i] = reader.nextInt();
    }
    out.println(solve(as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



Measured memory_bytes: 40840
A, B = list(map(int, input().split()))

ans = 0


for i in range(1, 41):
    m = 2 ** (i-1)
    n = 2 * m
    a = (A // n) * m + max(0, A % n - m)
    b = ((B+1) // n) * m + max(0, (B+1) % n - m)

    if (b-a) % 2 == 1:
        ans += m

print(ans)


Measured memory_bytes: 38384
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18


void solve(int tt){
	ll a, b, x;
	cin>>a>>b>>x;
	ll tmp = min(b,x);
	ll ans = 0;
	if(tmp != 1){
		if(tmp == b) tmp--;
		ans = ((a*tmp)/b) - (a*(tmp/b));
	}
	else{
		ans = ((a*tmp)/b) - (a*(tmp/b));
	}
	cout<<ans<<endl;
}


int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve(i);
	return 0;
}

Measured memory_bytes: 3652
import math
N = int(input())

minlen = 10**12
for i in range(1, int(math.sqrt(N))+1):
    if N%i == 0:
        minlen = min(minlen, i + N//i - 2)

if minlen == 10**9:
    print(N-1)
else:
    print(minlen)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int>z;
  for(int i=0;i<n;i++)
  {
    if(s[i]=='R')
      z.push_back(1);
    else if(s[i]=='B')
      z.push_back(2);
    else
      z.push_back(3);
  }
  int x[4]={0};
  for(int i=0;i<n;i++)
  {
    if(s[i]=='R')
      x[1]++;
    else if(s[i]=='B')
      x[2]++;
    else
      x[3]++;
  }
  int tot=0;
  int temp[4]={0};
  for(int i=0;i<n;i++)
  {
    if(z[i]==1)
    {
      tot+=temp[2]*(x[3]-temp[3]);
      tot+=temp[3]*(x[2]-temp[2]);
    }
    else if(z[i]==2)
    {
      tot+=temp[1]*(x[3]-temp[3]);
      tot+=temp[3]*(x[1]-temp[1]);
    }
    else
    {
      tot+=temp[2]*(x[1]-temp[1]);
      tot+=temp[1]*(x[2]-temp[2]);
    }
    int ini1=i-1,ini2=i+1;
    while (ini1>=0&&ini2<=n-1)
    {
      if(z[ini1]+z[ini2]+z[i]==6 &&z[i]!=z[ini1] &&z[i]!=z[ini2]&&z[ini1]!=z[ini2])
        tot--;
      ini1--;
      ini2++;
    }        
    temp[z[i]]++;
  }
  cout<<tot;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll b[200005],w[200005],bb[200005],ww[200005];
ll ans;
int main(void){
	ll n; cin>>n;
	string s; cin>>s;
	int k=1,l=1;
	if(s[0]=='#'){
		k=1;
	}else{
		l=1;
	}
	for(int i=0;i<n;i++){
		if(s[i]=='#'){
			b[k]++;
			if(s[i]!=s[i-1]){
				l++;
				if(i==0){
					l--;
				}
			}
		}else{
			w[l]++;
			if(s[i]!=s[i-1]){
				k++;
				if(i==0){
					k--;
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		bb[i]=bb[i-1]+b[i];
		ww[i]=ww[i-1]+w[i];
	}
	ans=10000000000000;
	//cout<<bb[1]<<" "<<ww[3]<<" "<<ww[2]<<endl;
	if(s[0]=='#'){
		for(int i=0;i<n;i++){
			ans=min(ans,bb[i]+ww[l]-ww[i]);
		}
	}else{
		for(int i=0;i<n;i++){
			ans=min(ans,bb[i]+ww[l]-ww[i+1]);
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 6660
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    K = int(input())
    q = deque()
    for i in range(1, 10):
        if K == 1:
            print(i)
            exit()
        K -= 1
        q.append(i)
    while q:
        v = q.popleft()
        sv = v % 10
        for i in (-1, 0, 1):
            if 0 <= sv + i < 10:
                if K == 1:
                    print(v * 10 + sv + i)
                    exit()
                K -= 1
                q.append(v * 10 + sv + i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6084