akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int nx = scan.nextInt();
		int ny = scan.nextInt();
		int capitalx = scan.nextInt();
		int capitaly = scan.nextInt();
		
		List<Integer> listx = new ArrayList<>();
		listx.add(capitalx);
		for (int i = 0; i < nx; i++) {
			listx.add(scan.nextInt());
		}
		Collections.sort(listx);
		
		List<Integer> listy = new ArrayList<>();
		listy.add(capitaly);
		for (int i = 0; i < ny; i++) {
			listy.add(scan.nextInt());
		}
		Collections.sort(listy);
		
		if (listx.get(listx.size() - 1) < listy.get(0)) {
			System.out.println("No War");
		} else {
			System.out.println("War");
		}
		
		
		
	}
}

Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

 long long int n;
  cin>>n;
 string str;
  cin>>str;
  long long int j=0;
  long long int k=n-1;
  long long int ans=0;
  while(j<k)
  {
   while(j<n&&str[j]!='W') 
         {
           j++;
         }
    while(k>=0&&str[k]!='R')
    {
      k--;
    }
    swap(str[j],str[k]);
    if(j<k)
      ans++;
    
  }
  cout<<ans<<endl;
  
  
  
  
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    string ans="No";
    rep(i,25){
        rep(j,30)if(4*i+7*j==n)ans="Yes";
    }
    cout<<ans;
    return 0;
    }


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

void solve1() {
    int N, K;
    string S;
    cin>> N >> K;
    cin>> S;
    S[K-1] = tolower(S[K-1]);
    cout<<S<<endl;
}

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

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            if(n==0) break;
            int ma=-1;
            int mi=1001;
            int sum=0;
            for(int i=0;i<n;i++){
                int s=sc.nextInt();
                if(s>ma) ma=s;
                if(s<mi) mi=s;
                sum+=s;
            }
            sum-=ma+mi;
            System.out.println(sum/(n-2));
        }
    }
}


Measured memory_bytes: 28904
a = int(input())
c = list(map(int, input().split()))
ans = int(1)
m = int(1000000000000000000)
ok = True
o = False
for i in c :
    if i == 0:
        print(0);
        o = True
        break
    elif ok == True :
        ans = int(ans*i)
        if ans > m:
            ok = False
if not ok and not o:
    print(-1)
elif not o :
    print(ans)

Measured memory_bytes: 84704
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M >> K;
	if (N == M) {
		cout << K << endl;
	}
	else if (N == K) {
		cout << M << endl;
	}
	else {
		cout << N << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[3][201]={0};
	int b[222]={0};
	int c[3][1001]={0};
	int n,i,j,x,y;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&a[j][i]);
			c[j][a[j][i]]++;
		}
	}
	for(i=0;i<3;i++){
		for(j=0;j<n;j++){
			if(c[i][a[i][j]]<2){
				b[j]+=a[i][j];
			}
		}
	}
	for(i=0;i<n;i++){
		printf("%d\n",b[i]);
	}
}


Measured memory_bytes: 2044
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e15;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

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


void solve()
{
    int k;
    cin>>k;
    int g,ans=0;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            g=gcd(i,j);
            for(int l=1;l<=k;l++)
            {
                ans=ans+gcd(g,l);
            }
        }
    }
    cout<<ans<<endl;
    
}


int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#else
    //    freopen("zalupa.in","r",stdin);
    //    freopen("zalupa.out","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(20);
    cout << fixed;
    ll n;
    ll left, right;
    cin >> n >> left >> right;
    if (left % 2 == right % 2) {
        cout << abs(left - right) / 2;
    } else {
        ll first = left;
        ll a = left - first;
        ll b = right - first;
        first--;
        first += (b+ 1) / 2;
        ll second = right;
        second = n - second;
        a  = left + second;
        b = right + second;
        second+= (n - a + 1)/2;
        cout << min(first, second);
    }
    return 0;
}

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

int main(){

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

    if(a==b){
        cout << "Draw" << endl;
    }else if(a==1){
        cout << "Alice" << endl;
    }else if(b==1){
        cout << "Bob" << endl;
    }else if(a>b){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int inf = 1e9;
int a[400000];
int segtree[650000];
int N;
void make(int n) {
	N = 1;
	while (N < n)	N *= 2;
	for (int i = N; i < 2*N; i++)	segtree[i] = 300000;
	for (int i = 0; i < n; i++)	segtree[i + N - 1] = i;
	for (int i = N - 2; i >= 0; i--) {
		if (a[segtree[2 * i + 1]] > a[segtree[2 * i + 2]])	segtree[i] = segtree[2 * i + 2];
		else	segtree[i] = segtree[2 * i + 1];
	}
}
int findsml(int l, int r, int p, int q, int k) {
	if (p <= l&&r <= q)	return segtree[k];
	if (r <= p||q <= l)	return 300000;
	int el = findsml(l, (l + r) / 2, p, q, 2 * k + 1);
	int er = findsml((l + r) / 2, r, p, q, 2 * k + 2);
	if (a[el] > a[er]) {
		return er;
	}
	else {
		return el;
	}
}
ll solve(int l,int r) {
	if (r == l)	return 0;
	if (r ==l+1)	return a[l];
	//cout << "start:" << l << " " << r << endl;
	int n = r - l;
	int sml = findsml(0, N, l, r, 0);
	ll ret = (ll)(sml - l + 1)*(r - sml)*a[sml];
	//cout << sml << " " << ret << endl;
	ret += solve(l, sml) + solve(sml+1, r);
	return ret;
}
int main() {
	for (int i = 0; i < 400000; i++) {
		a[i] = inf;
	}
	int n;	cin >> n;
	for (int i = 0; i < n; i++)	cin >> a[i];
	make(n);
	cout << solve(0, n) << endl;
}

Measured memory_bytes: 13184
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    combi = 0
    for a in range (1, n-1):
        for b in range (a+1, n): # c>b>a
            c = x - a - b # x = a+b+c
            if c <= b:
                break
            elif c > n:
                continue
            else:
                combi += 1
    print(combi)



Measured memory_bytes: 5596
import sys
import re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
    X,K,D = i_map()
    if X<=0:
        X = -X
    tmp1 = X//D
    tmp2 = X-(tmp1 * D)
    if(tmp1 < K):
        if((K-tmp1)%2 == 0):
            print(tmp2)
        else:
            print(D-tmp2)
    else:
        print(X - K * D)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 77244
N, A, B = map(int, input().split())
S = input()

num_japan_student = 0
num_foreign_student = 0
ans_list = ["No"] * N
for i in range(N):
    if S[i] == 'a':
        num_japan_student += 1
        if num_japan_student + num_foreign_student <= A + B:
            ans_list[i] = "Yes"
    elif S[i] == 'b':
        num_foreign_student += 1
        if num_foreign_student <= B and num_japan_student + num_foreign_student <= A + B:
            ans_list[i] = "Yes"
        else:       # 海外学生が進めなかったら足したnum_foreignは減らす
            num_foreign_student -= 1
    else:
        pass

for i in range(N):
    print(ans_list[i])

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N/100-(N/1000)*10 != N/10-(N/100)*10){
    cout << "No" << endl;
  }
  else if (N/1000 == N/100-(N/1000)*10 || N/10-(N/100)*10 == N-(N/10)*10){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

void solve(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a,a+n);
    int sum=accumulate(a,a+k,0);
    cout << sum <<endl;
}

int main(){
   // int t;  cin >> t;   while(t--)
    solve();

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vll A(N);
  REP(i, N){
    cin >> A[i];
  }

  vvll A_bits(N, vll(41, 0));
  REP(i, N){
    ll tmp = A[i];
    REP(j, 41){
      A_bits[i][j] = tmp%2;
      tmp/=2;
    }
  }

  vll K_bits(41);
  ll tmp = K;
  REP(i, 41){
    K_bits[i] = tmp%2;
    tmp/=2;
  }

  ll X_max=0;
  ll coef=1;
  coef <<= 40;
  bool flag=true;
  for(int i=40; i>=0; --i){
    ll tmp=0;
    ll count=0;
    if(flag){
      if(K_bits[i]==0){
        tmp=0;
      }else{
        for(int j=0; j<N; ++j){
          count+=A_bits[j][i];
        }
        if(count>N/2){
          tmp=0;
          flag=false;
        }else{
          tmp=1;
        }
      }
    }else{
      for(int j=0; j<N; ++j){
        count+=A_bits[j][i];
      }
      if(count>N/2){
        tmp=0;
      }else{
        tmp=1;
      }
    }
    X_max += tmp*coef;
    coef/=2;
  }

  ll ans=0;
  for(int i=0; i<N; ++i){
    ans += X_max^A[i];
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 36224
#include<stdio.h>
char s[10000][21],t[21];
int main(int argc, char const *argv[]){
	int n,a=0,b=0,i,j,bf,af;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	scanf("%s",t);
	for(i=0;i<n;i++){
		af=1;
		bf=1;
		for(j=0;j<20;j++){
			if(s[i][j]=='\0'){
				if(t[j]!='\0'){
					if(af) a++;
				}
				break;
			}else if(t[j]=='\0'){
				if(bf) b++;
				break;
			}else if(s[i][j]=='?'){
				if(t[j]=='a') bf=0;
				else if(t[j]=='z') af=0;
				else break;
			}else if(s[i][j]>t[j]){
				if(bf) b++;
				break;
			}else if(s[i][j]<t[j]){
				if(af) a++;
				break;
			}
		}
	}
	printf("%d",a+1);
	for(i=a+2;i<=n+1-b;i++){
		printf(" %d",i);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 384
def stream():
    n,m=map(int,input().split())
    x=[int(i) for i in input().split()]

    x.sort()

    if n>=m:
        print(0)
        exit()

    L=[0]*(m-1)

    for i in range(m-1):
        L[i]=x[i+1]-x[i]

    L.sort(reverse=True)

    ans=sum(L[n-1:])


    return ans
print(stream())

Measured memory_bytes: 13840
n = gets.to_i
ary = []
while a = gets do
    ary.push(a.to_s)
end

result = "Yes"

if ary.uniq.length != n
    result = "No"
end

(n-1).times do |i|
    if ary[i].to_s[-2].chomp != ary[i+1].to_s[0]
        result = "No"
    end
    i = i + 1
end

puts result

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  vector<string> s;
  for(int i=0; i<n; i++){
    string a;
    cin >> a;
    s.push_back(a);
    if(i==0) continue;
    if(s[i-1][s[i-1].length()-1]!=a[0]){
      cout << "No" << endl;
      return 0;
    }
    for(int j=0; j<i; j++){
      if(a==s[j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
    const char* day[] = {
        "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday",
    };
    const int daysPerMonth[] = {
        31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
    };
    int m, d;
    while (true) {
        cin >> m >> d;
        if (m == 0)
            break;

        int daysFromNewYear = d;
        for (int i = 0; i < m - 1; i++) {
            daysFromNewYear += daysPerMonth[i];
        }
        cout << day[daysFromNewYear % 7] << endl;
    }
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        int[] a = ReadLineParseIntArray();
        int x = 0;
        for (int i = 0; i < N; i++)
            x ^= a[i];
        WriteLine(x == 0 ? "Yes" : "No");
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 21088
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            string S = Console.ReadLine();
            string result = "Yes"; 
            for(int j = 0; j < AB[0]+AB[1]; j++)
            {
                if (j != AB[0])
                {
                    if (int.TryParse(S.Substring(j, 1), out int x))
                    {
                        if (10 < x)
                        {
                            result = "No";
                        }
                    }
                    else
                    {
                        result = "No";
                    }
                }
                if (S.Substring(AB[0], 1) != "-")
                {
                    result = "No";
                }
                
            }
            Console.WriteLine(result);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 28268
# -*- coding: utf-8 -*-
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

T,X = list(map(int, input().rstrip().split()))
ans = T/X
print( Decimal(str(ans)).quantize(Decimal('0.0000000001'), rounding=ROUND_HALF_UP) )


Measured memory_bytes: 5332
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	class P implements Comparable<P>{
		long x;
		long y;
		P(long x, long y){
			this.x=x;
			this.y=y;
		}
		@Override
		public int compareTo(P arg0) {
			return Long.compare(this.x, arg0.x);
		}
	}
	public void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();

		long x[] = new long[N];
		long y[] = new long[N];
		for(int i=0; i<N; i++) {
			x[i]=sc.nextLong();
			y[i]=sc.nextLong();

		}

		long ans = Long.MAX_VALUE;
		//左
		for(int i=0; i<N; i++) {
			long x1 = x[i];
			//右
			for(int j=0; j<N; j++) {
				long x2 = x[j];
				if(x1>=x2) continue;
				//下
				for(int k=0; k<N; k++) {
					long y1 = y[k];
					//上
					for(int l=0; l<N; l++) {
						long y2 = y[l];
						if(y1>=y2) continue;
						int cnt=0;
						for(int m=0; m<N; m++) {
							if(x1<=x[m] && x[m]<=x2 && y1<=y[m] && y[m] <=y2) {
								cnt++;
							}
						}
						if(cnt==K) {
							ans = Math.min(ans, (x2-x1) * (y2-y1));
						}
					}
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}



}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll n;
    cin >> n;
    bool ch = 1;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        if(x % 2 == 0)
        {

            if(x % 3 != 0 && x % 5 != 0) ch=0;
        }
    }
    if(ch) cout << "APPROVED";
    else cout << "DENIED";
}


Measured memory_bytes: 256
#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 eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef pair<ll,ll> P;
#define se second
#define fi first
struct PP{ll fi;ll se;ll th;};
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<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n;cin>>n;
  ll ans=0;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll k=1;
    while(true){
        ll c=0;bool b=true;
        rep(i,n){
            if(v[i]%2)c++;
            if(v[i]!=0)b=false;
            v[i]/=2;
        }
        if(b)break;
        ans=(ans+(c*(n-c))%mod*k)%mod;
        k*=2;
        k%=mod;
    }
    cout<<ans%mod<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <random>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
  int n ; cin >> n ;
  cout << (n^1) << endl ;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		sc.close();
		int[] r = new int[(K * 2) - 1];
		int x = X - K + 1;
		for(int i = 0; i < r.length; i++) {
			r[i] = x;
			x++;
		}
		for(int i = 0; i < r.length; i++) {
			System.out.print(r[i] + " ");
		}
	}
}


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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	string S;
	cin >> S;

	ll ansOne = 0;
	ll ans = 0;
	REP(i, 3) {
		if (S[i] == ('R')) {
			ansOne++;
		} else {
			ans = max(ans, ansOne);
			ansOne = 0;
		}
	}
	ans = max(ans, ansOne);

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

int main (void){

    int n, i;
    cin >> n;

    vector <int> a(n);
    for(i = 0;i < n;i++){

      cin >> a[i];
    }

    cout << a[n-1];

    for(i = n-2;i >= 0;i--)
    cout << " " << a[i];
    cout << endl;

    return 0; 
}


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int d = n % 10;
    if (d == 3) cout << "bon";
    else if (d == 0 || d == 1 || d == 6 || d == 8) cout << "pon";
    else cout << "hon";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int dp[1000005],odd_dp[1000005];
vector<int> pol;

void init(){
  REP(i,1,1000){
    int num=i*(i+1)*(i+2)/6;
    if(num>1000000)break;
    pol.pb(num);
    //cout<<num<<endl;
  }
  rep(i,1000005)dp[i]=odd_dp[i]=i;
}

void DP(){
  bool ok;
  REP(i,1,pol.size()){
    ok=true;
    for(int j=pol[i];j<1000005;j++){
      if(j-dp[i]>=0)dp[j]=min(dp[j],dp[j-pol[i]]+1);
      if(pol[i]%2)if(j-odd_dp[i]>=0)odd_dp[j]=min(odd_dp[j],odd_dp[j-pol[i]]+1);
    }
  }
}

int main(){
  init();
  DP();
  int n;
  while(cin>>n,n){
    cout<<dp[n]<<" "<<odd_dp[n]<<endl;
  }
  return 0;
}



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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
ll n,m,k;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	k=(n*2+m)/4;
	if(n<=k){
		cout<<k;
	}
	else{
		cout<<m/2;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
public class Hello
{    
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int a = 10000;
        int b;
        if (N > 1000)
        {
            a = N;
            while(a > 1000)
            {
                a -= 1000;
            }
            b = 1000 - a;
        }
        else
        {
            b = 1000 - N;
        }
        Console.WriteLine(b);
    }
}

Measured memory_bytes: 27500
import java.util.*;

public class Main {


    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();



        if ((c-a-b)*(c-a-b)-4*a*b>0) {
            if (c-a-b>0) {
                System.out.print("Yes");
            } else {
                System.out.print("No");
            }
        }else {
            System.out.println("No");
        }

//        System.out.println((c-a-b)*(c-a-b));
//        System.out.println(4*a*b);

    }
}



Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

int main() {
	map<long long,long long> a;
    long long n,sum=0;
    cin>>n;
    long long arr[n];
    for(long long i=0;i<n;i++){
        cin>>arr[i];
        a[arr[i]]=0;
    }
    for(long long i=0;i<n;i++){
        a[arr[i]]++;
    }
    for(auto x=a.begin();x!=a.end();++x){
        long long num=x->second;
        sum+=num*(num-1)/2;
    }
    for(long long i=0;i<n;i++){
        long num=arr[i];
        long choices=a[num]*(a[num]-1)/2;
        long ans=sum-choices;
        ans+=(a[num]-1)*(a[num]-2)/2;
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 11008
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt();
    let A = cin.getIntArray(N);
    let B = new Array(N);
    let fu = 0, min = 1e10;
    for (let n = 0; n < N; n++) { 
        if (A[n] < 0) B[n] = -A[n], fu++;
        else B[n] = A[n];
        if (min > B[n]) min = B[n];
    }
    let ans = B.reduce((ac, v) => ac + v, 0);
    if (fu % 2 != 0) ans -= min*2;
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);

    ll n,max=0;cin>>n;string str;
    set<string> s;map<string,int> mp;
    set<string>::iterator it;
    for(int i=1;i<=n;i++){
        cin>>str;
        if(!s.count(str)){
             s.insert(str);
        }
        mp[str]++;
        if(mp[str]>max) max=mp[str];
    }
    for(it=s.begin();it!=s.end();it++){
        if(mp[*it]==max){
            cout<<*it<<endl;
        }
    }
}


Measured memory_bytes: 33280
import sys
from collections import defaultdict,deque
input = sys.stdin.readline
n,m = map(int,input().split())
#+路線*chg : その路線ホーム
chg = 10**6

edge=defaultdict(set)
used =defaultdict(bool)
for i in range(m):
    p,q,c = map(int,input().split())
    edge[p].add(p+c*chg)
    edge[p+c*chg].add(p)
    edge[p+c*chg].add(q+c*chg)
    edge[q+c*chg].add(p+c*chg)
    edge[q].add(q+c*chg)
    edge[q+c*chg].add(q)
    used[p] = False
    used[q] = False
    used[p+c*chg] = False
    used[q+c*chg] = False

edgelist = deque()
edgelist.append((1,0))
res = float("inf")
while len(edgelist):
    x,cost = edgelist.pop()
    used[x] = True

    if x == n:
        res = cost
        break
    for e in edge[x]:
        if used[e]:
            continue
        #行先が改札
        if x <= 10**5 and chg <= e:
            edgelist.appendleft((e,cost+1))
        else:
            edgelist.append((e,cost))
        
if res == float("inf"):
    print(-1)
else:
    print(res)

Measured memory_bytes: 216172
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long q=sc.nextLong(),h=sc.nextLong(),s=sc.nextLong(),d=sc.nextLong();
    long n=sc.nextLong();
    long odd=Math.min(q*4, Math.min(h*2, s)),even=Math.min(odd*2, d);
    System.out.println((n/2)*even+(n%2)*odd);
  }
	public static boolean check(long a,long b,long c) {
		return true;
	}
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int>a(n);
    ll allsum=0;
    int tmp=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        allsum+=abs(a[i]-tmp);
        tmp=a[i];
    }
    allsum+=abs(a[n-1]);
    tmp=0;
    for(int i=0;i<n;i++){
        ll ans=allsum;
        if(i==n-1) ans=ans-abs(a[i]-tmp)-abs(a[i])+abs(a[i-1]);
        else ans=ans-abs(a[i]-tmp)-abs(a[i+1]-a[i])+abs(a[i+1]-tmp);
        tmp=a[i];
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3720
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**7
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([2**(int(i)-1) for i in input().split()])
        for s in range(p):
                t = s|c
                if dp[t] > dp[s] + a:
                    dp[t] = dp[s] + a
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

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

int main()
{
  long long int a, v;
  
  cin>>a>>v;
  
  long long int b, w;
  
  cin>>b>>w;
  
  long long int t;
  
  cin>>t;
  
  long long int d=abs(a-b);
  long long int d2=(v-w)*t;
  
  if(d<=d2)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  
  return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl



void func() {
  LL N, M;
  cin >> N >> M;

  vector<vector<LL>> A(N+1);
  vector<LL> P;
  vector<LL> Y;
  for (LL i = 0; i < M; ++i) {
    LL p, y;
    cin >> p >> y;
    A[p].push_back(y);
    P.push_back(p);
    Y.push_back(y);
  }

  for (auto& a : A) {
    sort(ALL(a),less<LL>());
  }
  /*
  for (LL i = 1; i <= N; ++i) {
    cerr << i << " : ";
    for (auto y : A[i]) {
      cerr << y << " ";
    }
    cerr << endl;
  }
  */
  for (LL i = 0; i < M; ++i) {
    LL y = Y[i];
    LL idx = 1+lower_bound(ALL(A[P[i]]), y)-A[P[i]].begin();
    //fprintf(stderr, "%d %d  %.6lld%.6lld\n", P[i],Y[i], P[i],idx);
    fprintf(stdout, "%.6lld%.6lld\n", P[i],idx);
  }


}








#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





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

int main(){

    while(1){

    int n; cin>>n;

    if(n==0) break;

    vector<string> s(n);

    for(int i=0; i<n; i++) cin>>s[i];

    int l=0,r=0,count=0;

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

        if( s[i-1] == "lu" ) l++;

        else if(s[i-1] == "ru") r++;

        else if(s[i-1] == "ld") l--;

        else if(s[i-1] =="rd") r--; 

        if( l == 1 && r == 1){
             count++;
             l = 0; 
             r = 0;
        }

        if( l == -1 && r == -1){
             count++;
             l = 0; 
             r = 0;
        }

    }

    cout<<count<<endl;
    }

    return 0;

}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll left;
    ll right;
    if(a[n-1]%2==0){
        left=a[n-1]/2;
        right=left;
    }
    else{
        left=a[n-1]/2;
        right=left+1;
    }
    ll sub;
    ll ans=a[0];
    rep(i,n-1){
        if(i==0){
            if(a[i]<=left){
                sub=left-a[i];
            }
            else if(a[i]>=right){
                sub=a[i]-right;
            }
        }
        else{
            if(a[i]<=left){
                ll x=left-a[i];
                if(x<=sub){
                    sub=x;
                    ans=a[i];
                }
            }
            else if(a[i]>=right){
                ll x=a[i]-right;
                if(x<=sub){
                    sub=x;
                    ans=a[i];
                }
            }
        }
    }
    cout << a[n-1] << " " << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
using namespace std;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
    return 0;
}


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

struct C{ 
	int A, B, t;
};

int main(){
	struct C c[2010], temp;
	int N, M, count = 0, minj, ans = 0;

	cin>>N>>M;

	for(int i = 0; i < M; i++){
		cin>>c[i].A>>c[i].B;
		if(c[i].A >= N){
			count++;
			c[i].t = 2 * N;
		} else {
			c[i].t = fabs(N - c[i].A);
		}
		
	}
	
	for(int i = 0; i < M; i++){
		minj = i;
		for(int j = i; j < M; j++){
			if(c[minj].t > c[j].t) minj = j;
		}
		temp = c[i];
		c[i] = c[minj];
		c[minj] = temp;
		
	}


	if(count >= M - 1){
		cout<<"0"<<endl;
	} else {
		for(int i = 0;count < M - 1; i++){
			ans += c[i].t;
			count++;
		}
		cout<<ans<<endl;
	}	


	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
	int size[3];

	while (cin >> size[0] >> size[1] >> size[2]) {
		if (size[0] == 0 && size[1] == 0 && size[2] == 0) {
			break;
		}
		std::sort(size, size + 3);

		// 直方体の最小面の対角線
		double diagonal = sqrt(pow(size[0], 2) + pow(size[1], 2));
		int num_entries, r;

		cin >> num_entries;

		for (int i = 0; i < num_entries; i++) {
			cin >> r;
			cout << (r * 2 > diagonal ? "OK" : "NA") << endl;
		}
	}
}

Measured memory_bytes: 1168
import sys, heapq, itertools
input = sys.stdin.readline
inf = float('inf')
N, M, R = map(int, input().split())
r = list(map(lambda x: int(x)-1, input().split()))

sec = [[inf] * N for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            sec[i][j] == 0
for abc in [list(map(int, input().split())) for _ in range(M)]: 
    sec[abc[0]-1][abc[1]-1] = abc[2]
    sec[abc[1]-1][abc[0]-1] = abc[2]
def marsh():
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if sec[i][j] > sec[i][k] + sec[k][j]:
                    sec[i][j] = sec[i][k] + sec[k][j]
marsh()
cost = inf
for perm in itertools.permutations(r):
    temp = 0
    for i in range(R-1):
        temp += sec[perm[i]][perm[i+1]]
    if temp < cost:
        cost = temp

print(cost)



Measured memory_bytes: 7652
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
 
function main(){
  for(var i = 0, len = input.length; i < len; i++){
    var c = input[i].split('');
    
    var count = [0,0,0,0,0,0,0,0,0,0,0];
    for(var j = 0, jlen = c.length; j < jlen; j++){
      count[c[j]]++; // 入力の個数をカウント
    }

    var result = [];
  JLOOP:for(var j = 1; j <= 9; j++){
      // 引く牌のループ

      if(count[j] == 4 || (!count[j-1] && !count[j] && !count[j+1])){
        continue;
      }

      var count2 = count.slice(0);
      count2[j]++;
    
      for(var k = 1; k <= 9; k++){
        if(count2[k] < 2)
          continue;

        var count3 = count2.slice(0);
        count3[k] -= 2;
        
        for(var l = 1; l <= 9; l++){
          if(count3[l-1] >= 1 && count3[l] >= 1 && count3[l+1] >= 1){
            count3[l-1]--;
            count3[l]--;
            count3[l+1]--;
          }
          if(count3[l-1] >= 1 && count3[l] >= 1 && count3[l+1] >= 1){
            count3[l-1]--;
            count3[l]--;
            count3[l+1]--;
          }
          if(count3[l] >= 3){
            count3[l] -= 3;
          }
        }
        var sum = 0;
        for(var l = 1; l <=9; l++){
          sum += count3[l];
        }

        if(!sum){
          result.push(j);
          continue JLOOP;
        }
      }
    }

    console.log(result.length?result.join(' '):'0');
    

  }
  
}

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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<ll> a(n);
	for(auto &i:a)cin >> i;
	int l = 0;
	int r = k;
	for(int i = 0;i<n-k;i++)
	{
		if(a[l+i]<a[r+i])cout << "Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 4792
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll h, w, a, b; cin >> h >> w >> a >> b;

    if (a == 0) {
        REP(i, h) {
            REP(j, w) {
                cout << (i < b ? '1' : '0');
            }
            cout << '\n';
        }
        return 0;
    } else if (b == 0) {
        REP(i, h) {
            REP(j, w) {
                cout << (j < a ? '1' : '0');
            }
            cout << '\n';
        }
        return 0;
    }

    string s(w, '0'), t(w, '1');
    REP(j, w) if (j < a) {
        s[j] = '1';
        t[j] = '0';
    }
    REP(i, h) {
        cout << (i < b ? s : t) << endl;
    }
    
}

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

int main()
{
  string s;
  cin >> s;
  for(int i = 0; i < 3; i++)
  {
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3620
{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad

main = do
    n <- readLn :: IO Int
    (dp :: VUM.IOVector Int) <- VUM.replicate (10^5+100) (10^9)
    VUM.write dp 0 0
    let six a = filter (<=a) $! map (6^) [0..6]
    let nine a = filter (<=a) $! map (9^) [0..5]
    forM_ [1..n] $ \i -> do
        forM_ (six i) $ \j -> do
            curr <- VUM.read dp i
            a <- VUM.read dp (i-j)
            VUM.write dp i $! min curr (a+1)
        forM_ (nine i) $ \k -> do
            curr' <- VUM.read dp i
            b <- VUM.read dp (i-k)
            VUM.write dp i $! min curr' (b+1)
    VUM.read dp n >>= print

Measured memory_bytes: 1788
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	static Scanner stdIn = new Scanner(System.in);
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);
	static String[] s = new String[] {"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};
	public static void main(String[] args) {
		while(true) {
			int[] list = new int[18];
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0) break;
			list[0] = a;
			for(int i = 2; i <= b; i++) {
				for(int j = 0; j < 18; j++) {
					list[j] *= a;
				}
				for(int j = 0; j < 17; j++) {
					list[j+1] += list[j] / 10000;
					list[j] %= 10000;
				}
			}
			
			for(int i = 17; i >= 0; i--) {
				if(list[i] != 0) {
					out.print(list[i] + s[i]);
				}
			}
			out.println();
		}
		out.flush();
		
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		return (int)nextLong();
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
 
}

Measured memory_bytes: 18540