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

namespace Aoj.ALDS.Chapter11C
{
    class Program
    {
        public static void Solve()
        {
            int n = int.Parse(Console.ReadLine());
            var nodes = new List<Node>();
            var inputs = new List<int>[n];

            // Node????????????
            for (int i = 0; i < n; i++)
            {
                inputs[i] = new List<int>();
                inputs[i].AddRange(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
                nodes.Add(new Node(inputs[i][0], inputs[i][1]));
            }

            // ???Node??????Node????¨????
            for (int i = 0; i < n; i++)
            {
                var childIds = inputs[i].Skip(2).ToArray();
                foreach (var childId in childIds)
                {
                    nodes[i].Children.Add(nodes[childId - 1]);
                }
            }

            // ???????????¢?´¢
            var queue = new Queue<Node>();
            nodes[0].D = 0;
            queue.Enqueue(nodes[0]);
            Bfs(queue);

            // ??????
            foreach (var node in nodes)
            {
                Console.WriteLine("{0} {1}", node.Id, node.D);
            }
        }


        public static void Bfs(Queue<Node> nodes)
        {
            while(nodes.Count > 0) {
                var current = nodes.Dequeue();
                foreach (var node in current.Children)
                {
                    if (node.D < 0) {
                        node.D = current.D + 1;
                        nodes.Enqueue(node);
                    }
                }
            }
        }

        public static void Main(string[] args)
        {
            Solve();
        }
    }

    class Node
    {
        // ???????????????
        public int Id { get; set; }

        // ????????°
        public int K { get; set; }

        // ????????????
        public int D { get; set; }

        // ?¨??????????????????°
        public bool Visited { get; set; }


        // ??£??\???????????????(???????????????)
        public List<Node> Children { get; set; }

        public Node(int id, int k)
        {
            Id = id;
            K = k;

            D = -1;
            Visited = false;
            Children = new List<Node>();
        }
    }
}

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

using namespace std;

int main()
{
	char c[6];

	for (int i = 0; i < 6; i++) {
		cin >> c[i];
	}

	if (c[0] == c[5] && c[1] == c[4] && c[2] == c[3])
	{
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 1000005
int a,b,c,d,e,f,g,h,i;
bool judge()
{
    int s=a+b+d;
    if(s!=e+c+f||s!=g+h+i||s!=a+e+g)
        return 0;
    if(s!=b+c+h||s!=d+f+i||s!=a+c+i||s!=g+c+d)
        return 0;
    return 1;
}
int main()
{
    cin>>a>>b>>c;
    for(d=1;d<=100;++d){
        h=a-c+d;
        i=b+d-c;
        g=2*c-d;
        e=b+2*d-2*c;
        f=a-d+c;
        if(judge()){
            break;
        }
    }
    printf("%d %d %d\n%d %d %d\n%d %d %d\n",a,b,d,e,c,f,g,h,i);
    return 0;
}


Measured memory_bytes: 384
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



const ll MX=200;

ll n;
vector<vector<ll>> edge;
ll dp[MX+1][MX+1][2*MX+1];
vector<vector<ll>> tree;

void init(){
    for(int i=0;i<=MX;i++){
        for(int j=0;j<=MX;j++){
            for(int k=0;k<=2*MX;k++){dp[i][j][k]=0;}
        }
    }
    dp[1][0][0]=1;
    for(int i=0;i<=MX;i++){
        dp[2][i][0]=1;
        if(i>0){dp[2][i][1]=1;}
    }
    vector<ll> a(2,0);
    for(int i=3;i<=MX;i++){
        for(int k=0;k<=2*MX;k++){
            a[0]=a[1]=0;
            for(int j=0;j<=MX;j++){
                a[0]+=dp[i-1][j][k]; a[0]%=MOD;
                if(k>0 && j>0){a[1]+=dp[i-1][j-1][k-1]; a[1]%=MOD;}
                //if(k>1 && j>1){a[2]+=dp[i-1][j-2][k-2]; a[2]%=MOD;}
                dp[i][j][k]=(a[0]+a[1])%MOD;
            }
        }
    }
    for(int i=0;i<=MX;i++){
        for(int k=2*MX;k>=0;k--){
            a[0]=a[1]=0;
            for(int j=0;j<=MX;j++){
                a[1]+=dp[i][j][k]; a[1]%=MOD;
                //if(k>0 && i>1){a[1]+=dp[i][j][k-1]; a[1]%=MOD;}
                dp[i][j][k]+=a[0]; dp[i][j][k]%=MOD;
                a[0]=a[1];
            }
        }
    }
}

void merge(vector<ll> &ret,vector<ll> A,vector<ll> &B){
    ret.resize(A.size()+B.size()-1);
    for(auto &I:ret){I=0;}
    for(int i=1;i<A.size();i++){
        for(int t=1;t<B.size();t++){
            for(int h=0;h<i+t;h++){
                ret[i+t-h]+=A[i]*B[t]%MOD*dp[i][t][h]%MOD;
                ret[i+t-h]%=MOD;
            }
        }
    }
}

void dfs(ll w){
    for(auto &I:edge[w]){
        dfs(I);
        merge(tree[w],tree[w],tree[I]);
    }
}




int main(){
    init();
    cin>>n;
    edge.resize(n);
    tree.resize(n,{0,1});
    vector<ll> cnt(n,0);
    for(int i=1;i<n;i++){
        ll a,b;
        cin>>a>>b;
        edge[a].push_back(b);
        cnt[b]++;
    }
    ll P=-1;
    for(int i=0;i<n;i++){
        if(cnt[i]==0){dfs(i); P=i; break;}
    }
    ll ans=0;
    for(auto &I:tree[P]){ans+=I; ans%=MOD;}
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 129784
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <queue>
//#include <tr1/unordered_map>
#include <iostream>
#define maxn 100005
#define M 1000000007
using namespace std;
//using namespace tr1;
struct node
{
    int pos;
    int s;
    friend bool operator<(node n1,node n2)
    {
        return n1.s<n2.s;
    }
}a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {scanf("%d",&a[i].s);a[i].pos=i;}
    sort(a+1,a+n+1);
    printf("%d",a[1].pos);
    for(int i=2;i<=n;i++)
        printf(" %d",a[i].pos);
    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		int a=0;
		for(int i=1;i<=N;i++) {
			int b=0;
			for(int k=i;k>0;) {
				b=k%10+b;
				k=k/10;
			}
			if((b>=A)&&(b<=B)){
				a=a+i;
			}
		}
		System.out.println(a);
	}
}

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

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, a, b; cin >> n >> a >> b;
	cout << ((b - a) % 2 == 0 ? "Alice" : "Borys");
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int s = 0,m[10000],ans = 1;
  scanf("%d",&s);
  for(int i = 0;i < 10000;i++)
  {m[i] = 0;}
  for(;;)
  {
    if(m[s] == 1)
    {
      printf("%d",ans);
      break;
    }
    m[s] += 1;
    if(s%2 == 0){s /= 2;}else{s = 3 * s + 1;}
    ans++;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,L[maxn],R[maxn],l[maxn],r[maxn],sum[maxn];
char s[maxn];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(register int i=1;i<=n;i++)
	{
		if(s[i]=='L')
		{
			int k=i;
			L[i]=i;
			while(s[i]=='L')
			{
				l[i]=l[i-1]+1;
				L[i]=k;
				i++;
			}
			i--;
		}
	}
	for(register int i=n;i>=1;i--)
	{
		if(s[i]=='R')
		{
			int k=i;
			R[i]=i;
			while(s[i]=='R')
			{
				r[i]=r[i+1]+1;
				R[i]=k;
				i--;
			}
			i++;
		}
	}
	for(register int i=1;i<=n;i++)
	{
		if(l[i])
		{
			if(l[i]&1)
				sum[L[i]]++;
			else
				sum[L[i]-1]++;
		}
		if(r[i])
		{
			if(r[i]&1)
				sum[R[i]]++;
			else
				sum[R[i]+1]++;
		}
	}
	for(register int i=1;i<=n;i++)
		printf("%d ",sum[i]);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>

using namespace std;
int main() {
	int a,b;
	cin >> a >> b;

	if (a + b == 15) {
		cout << "+";
	} else if (a * b == 15) {
		cout << "*";
	} else {
		cout << "x";
	}
	cout << endl;


	return 0;
}

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

#define ll long long

int main() {
    string S;
    cin >> S;
    bool b = true;
    for(int i = 1;i < S.size();i++) {
        b = b && S[i] != S[i - 1];
    }
    if(b) {
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 200001
#define VMAX 10000

void CountingSort(unsigned short *A,unsigned short *B,int *C,int k,int n){
  int i,j;
  for(i=0;i<=k;i++)
    C[i]=0;
  for(j=1;j<=n;j++)
    C[A[j]]++;
  for(i=1;i<=k;i++)
    C[i]=C[i]+C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}

int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;
  int k=0;
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  
  for(i=1;i<=n;i++){
    scanf("%hd",&A[i]);
    if(k<=A[i]) k=A[i];
  }
    
  CountingSort(A,B,C,k,n);
  for(i=1;i<=n;i++){
    if(i==n){
       printf("%d\n",B[n]);
     }
     else
      printf("%d ",B[i]);
  }
  return 0;
}



Measured memory_bytes: 9708
MOD = 10 ** 9 + 7
import math


def compute_reverse(n: list):
    result = 0
    for i in range(len(n)):
        for j in range(i+1, len(n)):
            if n[i] > n[j]:
                result += 1
    return result


N, K = map(int, input().split())
A = list(map(int, input().split()))
case1 = compute_reverse(A) *  ((K * (K + 1)) // 2)
case3 = compute_reverse(A[::-1]) * ((K * (K - 1)) // 2)
ans = (case1 + case3) % MOD
print(ans)

Measured memory_bytes: 9312
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = max(len(K_bin), len(bin(max(A))[2:]))
K_bin = K_bin.zfill(digit)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の0の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '0':
            C[i] += 1
ideal = ''
for c in C:
    binary = '1' if c > N//2 else '0'
    ideal += binary
dp = [[0 for _ in range(2)] for _ in range(digit)]
cands = [0]
gain = [2**i for i in range(digit)][::-1]

def calc(s):
    ret = 0
    for i in range(digit):
        tmp = C[i] if s[i] == '1' else N-C[i]
        ret += tmp * gain[i]
    return ret

for i in range(digit):
    if K_bin[i] == '1':
        cands.append(calc(K_bin[:i] + '0' + ideal[i+1:]))
print(max(max(cands), calc(K_bin)))

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

using namespace std;

int S,hour,minute,seconds,a,b,c;

int main() {
    cin>>S;
    hour=S/3600;
    minute=S%3600/60;
    seconds=S%3600%60;
    a=hour;
    b=minute;
    c=seconds;
    cout<<a<<":"<<b<<":"<<c<<endl;
}


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

using namespace std;

int main()
{

   long long x;
   cin>>x;
   long long j=10e9+7;
   long long mult=1;
   for(long long i=1;i<=x;i++)
   {
       mult=mult*i%1000000007;
   }

   cout<<mult<<endl;

    return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int D;
    cin >> D;
    D = 25 - D;
    cout << "Christmas";
    for (int i = 0; i < D; i++) {
            cout << " Eve";
        }    
        cout << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
D,G=map(int,input().split())
table=[(0,0) for i in range(D)]
for i in range(D):
    p,c=map(int,input().split())
    table[i]=(p,c)
ans=10**9

for i in range(1<<D):
    t=G
    s=0
    for j in range(D):
        if i & (1<<j):
            s+=table[j][0]
            t=t-table[j][1]-table[j][0]*(j+1)*100
    if t<=0:
        ans=min(ans,s)
        #print(i,s)
    else:
        j=D-1
        flag=True
        while flag and (j>=0):
            #print(i,j)
            if not (i & (1<<j)):
                for u in range(table[j][0]-1):
                    if t<=0:
                        flag =False
                        break
                    else:
                        s+=1
                        t-=100*(j+1)
            j-=1
        if t<=0:
            ans=min(ans,s)
print(ans)

Measured memory_bytes: 3064
import heapq
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
A.sort(reverse=True)
ans = 0

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

queue = Heapq([], True)
for value in A:
    queue.push(value)

for i in range(M):
    work = queue.pop()
    queue.push(work // 2)

print(sum(queue.hq) * -1)

Measured memory_bytes: 14180
n,m = map(int, input().split())
highs = list(map(int, input().split()))
l = [1] * n

for i in range(m):
    a,b = map(int ,input().split())
    if highs[a-1] < highs[b-1]:
        l[a-1] = 0
    elif highs[a-1] > highs[b-1]:
        l[b-1] = 0
    else:
        l[a-1] = 0
        l[b-1] = 0

print(l.count(1))

Measured memory_bytes: 85012
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vi A(N);
	string ans = "APPROVED";
	rep(i, N) {
		cin >> A[i];
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				ans = "DENIED";
			}
		}
	}



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

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

using namespace std;

void solve() {
    long long N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N+1);
    for (long long i = 1; i <= N; i++)
    {
        cin >> A[i];
    }
    
    vector<long long> visited(N+1, -1), visit;
    long long now = 1;
    visited[now] = 0;
    visit.push_back(now);
    for (long long i = 1; i <= K; i++)
    {
        now = A[now];
        if (visited[now] != -1)
        {
            // すでに来たことがある場合。ここでループ
            long long loop_length;
            loop_length = i - visited[now];
            
            long long ans;
            ans = visit[visited[now] + (K-visited[now])%loop_length];
            cout << ans << endl;
            return;
        }
        visited[now] = i;
        visit.push_back(now);
    }
    cout << now << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 8492
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>

using namespace std;

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

    bool check = false;

    char one;
    char two;
    char three;
    char four;

    cin >> one >> two >> three >> four;

    if(one == two)
    {
        if(three == four && three != one)
        {
            check = true;
        }
    } else if(one == three)
    {
        if(two == four && two != one)
        {
            check = true;
        }
    } else if(one == four)
    {
        if(two == three && two != one)
        {
            check = true;
        }
    }

    if(check == true)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import std.stdio;
import std.string;

void main(){
	int n;
	string s, ans;
	readf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		s = chomp(readln());
		ans = "" ~ s[0];
		for (int j = 3; j < s.length; j+=3) {
			if (count(ans,s[j]) <= 0){
				if(s[j-1] == '>') ans ~= s[j];
				else ans = s[j] ~ ans;
			}
		}
		writeln(ans);
	}
}

Measured memory_bytes: 1024
import math
x = int(input())
if x == 1:
  print(0)
  exit()
  
d = math.ceil((x+1)**0.5)
def divisorize(fct):
    b, e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]
 
 
def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
 
 
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

ans = 0
fct = factorize(x)
for div in divisorize(fct):
    c = num(div)
    if d+1 <= c:
      ans += c-1
      
print(ans)

Measured memory_bytes: 41968
#include<stdio.h>

int main(){
int n;
char temp;
int c[4]={0},i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%c",&temp);
switch(temp){
case 'P':c[0]++;break;
case 'W':c[1]++;break;
case 'G':c[2]++;break;
case 'Y':c[3]++;break;
}
}
if(c[3]==0)puts("Three");
else puts("Four");
return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string s;
  cin >> s;
  set<char> st;
  for(const auto& c : s)
  {
    if (st.find(c) != st.end())
    {
      cout << "no";
      return;
    }
    st.insert(c);
  }
  cout << "yes";
}

int main()
{
  fastio;
  solve();

  return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    rep(i,min(k,(ll)s.size())){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, M;
    string S;
    cin >> N >> M >> S;
    vector<int> tmp,v;;
    rep(i,N+1){
        if(S[i] == '0')tmp.push_back(i);
    }
    //print(tmp);
    rep(i,tmp.size()-1){
        v.push_back(tmp[i+1] - tmp[i]);
    }
    //print(v);
    reverse(all(v));
    vec<int> ans;
    int sum = 0;
    int sz = v.size();
    rep(i,sz){
        if(sum+v[i] <= M){
            sum += v[i];
        }
        else{
            ans.push_back(sum);
            if(v[i] > M){
                cout << -1 <<  endl;
                return 0;
            }
            sum = v[i];
        }
    }
    ans.push_back(sum);
    reverse(all(ans));
    //print(ans);
    rep(i,ans.size()){
        cout << ans[i] <<  " ";
    }
    cout << endl;
}

Measured memory_bytes: 1864
# -*- coding: utf-8 -*-
from operator import itemgetter
n = int(input())
isp=[]
for i in range(n):
  s,p= input().split()
  isp.append([i+1, s, int(p)])
isp.sort(key=itemgetter(2))
isp.reverse()  
isp.sort(key=itemgetter(1))
for st in isp:
  print(st[0])

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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  
  if(s==u) a--;
  else b--;
  cout << a << " " << b;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int h = 100, w = 100;
  vector<vector<char>> s(101, vector<char>(101));
  rep(i, h / 2) {
    rep(j, w) s[i][j] = '.';
  }
  for(int i = h / 2; i < h; ++i) {
    rep(j, w) s[i][j] = '#';
  }

  --a; --b;
  int cur = 0;
  int height = 0;
  rep(i, b) {
    if(cur >= w) cur = 0, height += 2;
    s[height][cur] = '#';
    cur += 2;
  }
  height = h / 2 + 1;
  cur = 0;
  rep(i, a) {
    if(cur >= w) cur = 0, height += 2;
    s[height][cur] = '.';
    cur += 2;
  }
  cout << h << " " << w << endl;
  rep(i, h) {
    rep(j, w) {
      cout << s[i][j];
    }
    cout << endl;
  }

}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

s = input()

left = s[:2]
right = s[2:]

months = [str(x).zfill(2) for x in range(1, 13)]

ans = "AMBIGUOUS" if left in months and right in months else "YYMM" if right in months else "MMYY" if left in months else "NA"

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int b[210];
int main(){
	int a;scanf("%d",&a);
	int c;scanf("%d",&c);
	int at=0;
	int val=mod;
	int sum=0;
	for(int i=0;i<a;i++){
		b[i]=c+i;
		if(ABS(b[i])<val){
			at=i;
			val=ABS(b[i]);
		}
		sum+=b[i];
	}
	printf("%d\n",sum-b[at]);

}

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

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

  bool reversed = false;
  array<string, 2> pushed_chars;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      reversed = !reversed;
    } else {
      int f;
      char c;
      cin >> f >> c;
      pushed_chars[(f == 1) == reversed].push_back(c);
    }
  }

  reverse(pushed_chars.front().begin(), pushed_chars.front().end());
  s = pushed_chars.front() + s + pushed_chars.back();
  if (reversed) reverse(s.begin(), s.end());
  cout << s << endl;
}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
#define ll long long
#include <numeric>
using namespace std;
const int sz = 1e7+5;
ll int arr[sz], arr1[sz];
//ll int arr[100][100]= {0};
bool prime[sz]= {0};
vector <ll int> pr,vec1,vec2;
//vector <pair <int,int>> vec;


void NOD ( ll int n ) {

  for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j+=i)
        arr[j]++;


}

int main()
{

    ll int n;
    cin>>n;
    NOD(n);
    unsigned ll int k =0;
    for(int i=1;i<=n;i++)
    {
        k+=(arr[i]*i);
    }

    cout<<k<<endl;
}


Measured memory_bytes: 81712
#include <iostream>

int gcd(int smaller, int larger)
{
  if (larger < smaller) {
    return gcd(larger, smaller);
  }
  if (larger % smaller == 0) {
    return smaller;
  } else {
    return gcd(larger % smaller, smaller);
  }
}

int main()
{
  int n;
  std::cin >> n;
  int result;
  std::cin >> result;
  for (int i = 1; i < n; i++) {
    int num;
    std::cin >> num;
    result = gcd(result, num);
  }
  std::cout << result << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int t,n,i;
	for(i=0;i<4;i++){
		scanf("%d %d",&t,&n);
		if(t==1){
			printf("%d\n",n*6000);
		}
		if(t==2){
			printf("%d\n",n*4000);
		}
		if(t==3){
			printf("%d\n",n*3000);
		}
		if(t==4){
			printf("%d\n",n*2000);
		}
	}
	return 0;
}


Measured memory_bytes: 2148
using System;

class Program {
    static void Main()
    {
        string line = Console.ReadLine();
        string[] digit = line.Split();

        int c = int.Parse( digit[ 0 ] );
        int r = int.Parse( digit[ 1 ] );

        int[] colSum = new int[ r ];
        int wholeSum = 0;

        for ( int y = 0; y < c; ++y ) {
            line = Console.ReadLine();
            digit = line.Split();

            int rowSum = 0;

            for ( int x = 0; x < r; ++x ) {
                int n = int.Parse( digit[ x ] );

                rowSum += n;
                colSum[ x ] += n;
            }

            wholeSum += rowSum;
            Console.WriteLine( line + " " + rowSum );
        }

        for ( int x = 0; x < r; ++x ) {
            Console.Write( colSum[ x ] + " " );
        }

        Console.WriteLine( wholeSum );
    }
}

Measured memory_bytes: 9292
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	vector<int> p(n);

	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}

	int ans = 0;

	for (int i = 1; i < n - 1; ++i) {
		vector<int> temp;

		temp.push_back(p[i - 1]);
		temp.push_back(p[i]);
		temp.push_back(p[i + 1]);
		sort(temp.begin(), temp.end());

		if (temp[1] == p[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x;cin>>x;
  ll ans=(x/500)*1000;
  ans+=((x%500)/5)*5;

  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
import java.awt.Frame;
import java.awt.image.SinglePixelPackedSampleModel;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

import javax.print.attribute.standard.Chromaticity;
import javax.sql.rowset.FilteredRowSet;
import javax.swing.BorderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.events.EndDocument;
import javax.xml.transform.Templates;

import java.math.BigInteger;
import java.time.chrono.MinguoChronology;
import java.util.Scanner;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      StringBuilder str = new StringBuilder(in.next());
      int q = in.nextInt();
      
      for (int i = 0; i < q; i++) {
        String operation = in.next();
        int a = in.nextInt();
        int b = in.nextInt();
        
        switch (operation) {
          case "replace":
            String p = in.next();
            str.replace(a, b + 1, p);
            break;
          case "reverse":
            String tmp = new StringBuilder(str.substring(a, b+1)).reverse().toString();
            str.replace(a, b + 1, tmp);
            break;
          case "print":
            out.println(str.substring(a, b + 1));
            break;
          default:
            break;
        }
        
      }
      
//      End solve()
    }
    
//  End solution
  } 
  

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

Measured memory_bytes: 24944
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
//#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;


int main(){
    cin >> n;
    vec(a,n);
    input(a,n);
    Sort(a);
    cin >> n;
    int ans = 0;
    REP(i,n){
        int m;
        cin >> m;
        int tmp = lower_bound(All(a),m) - a.begin();
        if(a[tmp] == m) ans++;
    }
    print(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}




Measured memory_bytes: 3172
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

long A[200][200];
long B[200];
long N, M, C;

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

    long count = 0;
    long sum = C;
    for(long i = 0; i < N; ++i){
        for(long j = 0; j < M; ++j){
            sum += A[i][j] * B[j];
        }
        if(sum > 0) count++;
        sum = C;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


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

    vi dp(N+1, 1e8);
    dp[0]=0;
    rep(i, N+1) {
        int a = 1;
        if(i > 0) {
            dp[i] = min(dp[i], dp[i-1]+1);
        }
        while(i >= 6*a) {
            a *= 6;
            dp[i] = min(dp[i], dp[i-a]+1);
        }
        a = 1;
        while(i >= 9*a) {
            a *= 9;
            dp[i] = min(dp[i], dp[i-a]+1);
        }
    }
    cout << dp[N] << '\n';
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    int n,t,e;
    cin>>n>>t>>e;
    int x[200];
    rep(i,n){
        cin>>x[i];
    }
    int ans=-1;
    rep(i,n){
        int num=x[i];
        for(int j=1;;j++){
            if(num*j>=t-e && num*j<=t+e){
                ans=i+1;
                break;
            }
            if(num*j>t+e)break;
        }
    }
    cout<<ans<<endl;
}

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

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

    int n, x;
    cin >> n >> x;
    vector<long long> A(n);
    REP(i, n) cin >> A[i];

    long long cost = 0;
    REP(i, n){
        if(i){
            if(A[i - 1] + A[i] > x){
                cost += A[i] + A[i - 1] - x;
                A[i] -= A[i] + A[i - 1] - x;
                if(A[i] < 0) A[i] = 0;
            }
        }
    }
    cout << cost << endl;

    return 0;
}

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

int main(void) {
    int n, m;
    
    cin >> n >> m;
    
    int homeworks[m];
    
    for (int i = 0; i < m; i++) {
        cin >> homeworks[i];
    }
    
    for (int j = 0; j < m; j++) {
        n -= homeworks[j];
        if (n < 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    cout << n << endl;
    
    return 0;
}

Measured memory_bytes: 3620
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
	String a=sc.nextLine();
	long N=Long.parseLong(a);
	long count=0;
	long count2=1;
	while(true){
	if(N==1){
	count+=count2;
	break;
	}
		N/=2;
	count+=count2;
	count2*=2;
	}
	System.out.println(count);
 	}	
	
    

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

        public long nextInt() {
            return Integer.parseInt(next());
        }

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



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

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int dist[205][205], a[205];
int main() {
  int n, m, r;
  scanf("%d %d %d", &n, &m, &r);
  memset(dist, 1, sizeof dist);
  for (int i = 1; i <= n; i++) {
    dist[i][i] = 0;
  }
  for (int i = 0; i < r; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    dist[x][y] = min(dist[x][y], z);
    dist[y][x] = min(dist[y][x], z);
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  sort(a, a + r);
  int ans = 1234567890;
  do {
    int sum = 0;
    for (int i = 1; i < r; i++) {
      sum += dist[a[i]][a[i - 1]];
    }
    ans = min(ans, sum);
  } while (next_permutation(a, a + r));
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	int A[101];
	for (int i=0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	int flag = 1;
	int count = 0;
	while(flag) {
		flag = 0;
		for (int i=0; i < n-1; i++) {
			if (A[i] > A[i+1]) {
				int a = A[i];
				A[i] = A[i+1];
				A[i+1] = a;
				flag = 1;
				count++;
			}
		}
	}
    for (int i=0; i < n; i++) {
		if (i == n-1) {
			printf("%d", A[i]);
		} else {
			printf("%d ", A[i]);
		}
	}
    printf("\n%d\n", count);
}


Measured memory_bytes: 2756
// ABC120_B
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, K, cnt = 0;
    cin >> A >> B >> K;
    
    // calculation
    for (ll i = min(A, B); i >= 0; --i) {
        if (A%i == 0 && B%i == 0) cnt++;
        if (cnt == K) {
            cout << i << "\n";
            return 0;
        }
    }
    
    return 0;
}

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

int main(void) {
	int count=0,a;
	
	string S;
	cin >> S;
	
	
	for (char x : S) {
		if (x == 'o')count += 1;
		
	}
	if (S.length() == 15) {
		if (count>= 8)cout << "YES";
		else cout << "NO";
	}
	else if (S.length() == 14) {
		if (count >= 7)cout << "YES";
		else cout << "NO";
	}
	else if (S.length() == 13) {
		if (count >= 6)cout << "YES";
		else cout << "NO";
	}
	else if (S.length() == 12) {
		if (count >= 5)cout << "YES";
		else cout << "NO";
	}
	else if (S.length() == 11) {
		if (count >= 4)cout << "YES";
		else cout << "NO";
	}
	else if (S.length() == 10) {
		if (count >= 3)cout << "YES";
		else cout << "NO";
	}
	else if (S.length() == 9) {
		if (count >= 2)cout << "YES";
		else cout << "NO";
	}
	else if (S.length() == 8) {
		if (count >= 1)cout << "YES";
		else cout << "NO";
	}
	else cout << "YES";
}

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

using namespace std;

long long _();
int main() { _(); return 0; }
#define main _
#define int long long 

int main()
{
    ios_base::sync_with_stdio(false);
    int x;
    cin >> x;
    cout << (x/500)*1000 + (x%500)/5*5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ioso ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define endl '\n';
#define maxn 1000001;
int main() {
    ioso;
    int cy;
    string s,m="";
    cin >> cy >> s;
    for(int i=0;i<s.length();i++) {
        m += (((s[i]-'A')+cy)%26)+'A';
    }
    cout << m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    if((A*B) % 2 == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    } 
}

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

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  ll b[n+1];
  ll c[n+1];
  b[0]=0;
  c[n]=0;
  rep(i,0,n) b[i+1]=b[i]+a[i];
  rep(i,0,n) c[n-1-i]=c[n-i]+a[n-1-i];
  ll ans=2e14;
  rep(i,1,n) ans=min(ans,abs(b[i]-c[i]));
  cout<<ans<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()

#define modint_opdef(op,opeq) constexpr modint operator op (const modint &r) const noexcept { return modint(*this) opeq r;}
template <long long mod> struct modint {
    using ll = long long;
    ll val;
    constexpr modint(ll x=0) noexcept : val(x % mod){
        if (val < 0) val += mod;
    }
    constexpr int getmod() { return mod; }
    constexpr modint operator-() const noexcept {
        return val ? mod - val : 0;
    }
    modint_opdef(+,+=) modint_opdef(-,-=)
    modint_opdef(*,*=) modint_opdef(/,/=)
    constexpr modint& operator+=(const modint &r) noexcept {
        val += r.val;
        if (val>=mod) val -= mod;
        return *this;
    }
    constexpr modint& operator-=(const modint &r) noexcept {
        val -= r.val;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr modint& operator*=(const modint &r) noexcept {
        val = (val * r.val) % mod;
        return *this;
    }
    constexpr modint& operator/=(const modint &r) noexcept {
        ll a = r.val, b = mod, p = 1, q = 0;
        while(b>0){
            ll temp = a/b;
            a -= temp * b; swap(a, b);
            p -= temp * q; swap(p, q);
        }
        val = (val * p) % mod;
        if (val < 0) val += mod;
        return *this;
    }
    constexpr bool operator==(const modint &r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!=(const modint &r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator<<(ostream &os, const modint<mod> &x) noexcept{
        return os << x.val;
    }
    
    //O(logn)
    constexpr modint<mod> pow(const modint<mod> &a, ll n) noexcept{
        if (n == 0) return 1;
        auto t = pow(a, n/2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
    
    //O(n)
    constexpr modint<mod> factorial(ll n) noexcept{
        modint<mod> a = 1;
        rep(i,n) a *= (i+1);
        return a;
    }
    
    //O(k)
    constexpr modint<mod> permutation(const modint<mod> &n, ll k) noexcept{
        modint<mod> t = 1;
        for(ll i=n.val; i>n.val-k; i--) t *= i;
        return t;
    }
    
    //O(k)
    constexpr modint<mod> combination(const modint<mod> &n, ll k) noexcept{
        return permutation(n, k)/factorial(k);
    }
    
};

const int MOD = 1e9+7;
using mint = modint<MOD>;
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    mint result = 1;
    result = result.pow(2, n) - 1;
    result -= result.combination(n, a);
    result -= result.combination(n, b);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256