akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3


INF = 10**9

def main():
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    h, w = map(int, input().split())
    s = []
    for i in range(h):
        t = input()
        s.append(t)

    from collections import deque
    d = deque()
    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                d.append([i, j])

    ans = 0
    while len(d) != 0:
        x, y = d.popleft()
        
        sc = [[-1] * (w) for i in range(h)]
        sc[x][y] = 0
        
        dd = deque()
        dd.append([x,y])

        while len(dd) != 0:
            # for i in sc:
            #     print(i)
            ix, iy = dd.popleft()
            for k in range(4):
                i = dx[k]
                j = dy[k]
                # print(ix+i, iy+j)
                if 0 <= ix+i < h and 0 <= iy+j < w:
                    if s[ix+i][iy+j] == '.':
                        if sc[ix+i][iy+j] == -1:
                            sc[ix+i][iy+j] = sc[ix][iy]+1   
                            dd.append([ix+i, iy+j])
                    
                            
        # for i in sc:
        #     print(i)
        # print('')
        ans = max(ans, max([max(i) for i in sc]))
    
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main(void){
    int x, y, a, i, r;
    cin >> x >> y;
    while(x != 0 || y != 0){
        i = 0;
        
        if(y > x){
            a = x;
            x = y;
            y = a;
        }

        while(y != 0){
            r = x % y;
            x = r;
            r = y;
            y = x;
            x = r;
            i++;
        }
        
        cout << x << " " << i << endl;
        cin >> x >> y;
    }
    
}



Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <queue>
#include <map>
#include <list>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

bool iskaibun(string s, int start, int end) {
  int n = s.size();
  for (int i = start; i <= end / 2; ++i) {
    if (s[i] != s[end - i - 1]) return false;
  }
  return true;
}

bool isStrongKaibun(string s) {
  int n = s.size();
  return iskaibun(s, 0, n) && iskaibun(s, 0, (n - 1) / 2) && iskaibun(s, (n + 3) / 2, n);
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  string s;
  cin >> s;

  cout << (isStrongKaibun(s) ? "Yes" : "No") << endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int son[MAXN][2],N,rt = 1,Ncnt = 1;
int64 L,dep[MAXN];
char s[MAXN];
int64 lowbit(int64 x) {
    return x & -x;
}
void Insert(char *str) {
    int len = strlen(str + 1);
    int p = rt;
    for(int i = 1 ; i <= len ; ++i) {
	if(!son[p][str[i] - '0']) {
	    son[p][str[i] - '0'] = ++Ncnt;
	    dep[Ncnt] = dep[p] + 1;
	}
	p = son[p][str[i] - '0'];
    }
}
void Solve() {
    read(N);read(L);
    for(int i = 1 ; i <= N ; ++i) {
	scanf("%s",s + 1);
	Insert(s);
    }
    int64 ans = 0;
    for(int i = 1 ; i <= Ncnt ; ++i) {
	if((son[i][0] == 0 && son[i][1] != 0) || (son[i][0] != 0 && son[i][1] == 0)) {
	    ans ^= lowbit(L - dep[i]);
	}
    }
    if(ans) puts("Alice");
    else puts("Bob");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 1920
#include <iostream>

char chage_number(char s);

int main() {

  std::string n;

  std::cin >> n;

  for (int i = 0; i < 3; i++) {
    if (n[i] == '1' || n[i] == '9') {
      n[i] = chage_number(n[i]);
    }
  }
  std::cout << n << std::endl;
}

char chage_number(char s) {
  if (s == '9') {
    return '1';
  }
  return '9';
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	int n = N;
	int ans = LLINF;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			//if (i*i != n)
			
				ans = min(ans, (i - 1) + (n / i - 1));
			

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



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
   int E,Y,BASE;
   BASE=1867;
   scanf("%d %d",&E,&Y);
   switch(E){
   case 0:
	   if(Y<=1911){printf("M%d\n",Y-BASE);}
	   else if(Y<=1925){printf("T%d\n",Y-1911);}
	   else if(Y<=1988){printf("S%d\n",Y-1925);}
	   else {printf("H%d\n",Y-1988);}
        break;
   case 4:
	   BASE+=63;
   case 3:
	   BASE+=14;
   case 2:
	   BASE+=44;
   case 1:
	   printf("%d\n",BASE+Y);
   }
   return 0;
}



Measured memory_bytes: 2104
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    # floor(Ax/B)-A*floor(x/B)
    # floor(A(kB+p)/B)-A*floor((kB+p)/B)= Ak+floor(Ap/B)-A*(k+floor(p/B))=
    # = floor(Ap/B)
    # x = kB+p, p<B, X<=N
    # p = min(B-1, N)
    # A(B-1)/B
    A, B, N = read_ints()
    p = min(B-1, N)
    return A*p//B


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 9112
#include <iostream>
using namespace std;
int main() {
	int count ;
	cin >> count;
	int ans = 0;
	int max = 0;
	for(int i=0;i<count;i++){
		int tmp;
		cin >>  tmp;
		if(tmp >= max){
			ans ++;
			max = tmp;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int l, r, d, count = 0;
    scanf("%d %d %d", &l, &r, &d);

    for(int i = l; i <= r; i++) {
        if(i % d == 0) {
            count++;
        }
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;



int MOD=1000000007;
int main(void){
	long long A,B,K,T=0;
	cin >> A >> B>>K;
	T=A;
    if(K>A){K=K-A; A=0;}
	else{ A=A-K; K=0; } 
	if(K>B){B=0;}
	else B=B-K;
	cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int count = 0;
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) {
            ++count;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}

ll modpow(ll a,ll n,ll mod){
  ll ret=1;
  while(n>0){
    if(n&1) ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}

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

  cout<<(n+1)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  double n;
  int banti;
  int seisu,syousu;
  while(1){
    char seisuu[9];
    char syousuu[5];
    strcpy(seisuu,"00000000");
    strcpy(syousuu,"0000");
    cin>>n;
    if(n<0){
      break;
    }
    seisu=0;
    syousu=0;
    banti=0;
    for(int i=128;i!=0;i/=2){
      if(n-(double)i>=0){
	seisuu[banti]='1';
	seisu++;
	n-=(double)i;
      }
      if(i!=1){
	seisu=seisu<<1;
	banti++;
      }
    }
    banti=0;
    for(int i=2;i!=32;i*=2){
      if(n-(double)(1/(double)i)>=0){
	syousuu[banti]='1';
	syousu++;
	n-=(double)(1/(double)i);
      }
      if(i!=16){
	syousu=syousu<<1;
	banti++;
      }
    }
    if(n==0){
      cout<<seisuu<<'.'<<syousuu<<endl;
    }
    else{
      cout<<"NA"<<endl;
    }
  }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(ll, n);
  ll ans = 0;
  vector<ll> v(n + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      ++v[j];
    }
    ans += i * v[i];
  }
  out(ans);
}


Measured memory_bytes: 81376
n = int(input())
k = int((2*n)**.5)
for i in range(k, k*(k+1)+1):
    if 2*n >= i*(i+1):
        continue
    k = i
    break


def sigma(a, b):
    if a == b:
        return a
    elif b < a:
        return 0
    else:
        return (a+b)*(b-a+1)//2

excess = sigma(1, k)-n
for i in range(1, k+1):
    if i == excess:
        continue
    print(i)


Measured memory_bytes: 3316
n=int(input())
a=list(map(int,input().split()))
s=[0]
if n==2:
	print(abs(a[0]-a[1]))
	exit()
for i in range(n):
	s.append(s[i]+a[i])
ans=1e18
for i in range(1,n-1):
	ans=min(abs(s[i]*2-s[0]-s[n]),ans)
print(ans)


Measured memory_bytes: 30724
<?php
$n = trim(fgets(STDIN));
$arr = explode(" ",trim(fgets(STDIN)));

for($i=$n-1; $i>0; $i--){
    if($arr[$i] < $arr[$i-1]){
        if(abs($arr[$i]-$arr[$i-1]) >= 2){
            echo "No";
            exit;
        }else{
            $arr[$i-1] = $arr[$i-1] -1;
        }
    }
}

echo "Yes";

?>

Measured memory_bytes: 22076
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int N,K;
vector<int> V;
long long ans = 0;

int main(){
  cin >> N >> K;
  for(int i=0; i<N; i++){
    int v;
    cin >> v;
    V.push_back(v);
  }
  int k;
  k = min(N, K);
  for(int i=0; i<k; i++){
    int T = k - i;
    int Remain = i;
    if(N < K){
      Remain = Remain + K - N;
    }
    // cout << "T is " << T << endl;
    for(int j=0; j<=T; j++){
      int L = T - j;
      int R = T - L;
      long long sum = 0;
      // cout << "----------------------" << endl;
      priority_queue<int, vector<int>, greater<int>> que;
      for(int l=0; l<L; l++){
        if(V[l] < 0){
          que.push(V[l]);
        };
        // cout << "l1 is " << l << endl;
        // cout << "l1 value is " << V[l] << endl;
        sum = sum + V[l];
      }
      for(int l=N-1; l>=N-R; l--){
        if(V[l] < 0){
          que.push(V[l]);
        };
        sum = sum + V[l];
        // cout << "l2 is " << l << endl;
        // cout << "l2 value is " << V[l] << endl;
      }
      // cout << L << ',' << R << endl;
      // cout << "remain is " << Remain << endl;
      // cout << "sum is " << sum << endl;
      // for(int o=0; o<i; o++){
      for(int o=Remain; o>0; o--){
        if(!que.empty()){
          // cout << "que.top is " << que.top() << endl;
          sum = sum - que.top();
          que.pop();
        }
        // que.pop();
        // cout << "o is " << o << endl;
      }
      ans = max(ans, sum);
      // cout << "final sum is " << sum << endl;
    }
  }

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


Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,m = map(int,ipt().split())
    s = input()[::-1]
    ni = 0
    me = []
    while ni < n:
        for i in range(m):
            if ni+m-i <= n and s[ni+m-i] == "0":
                ni = ni+m-i
                me.append(str(m-i))
                break
            if i == m-1:
                print(-1)
                exit()
    print(" ".join(me[::-1]))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 48876
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int x=sc.nextInt();
    int[] a=new int[n];
    int b=0;
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      b+=a[i];
    }
    Arrays.sort(a);
    x-=b;
    int c=x/a[0];
    System.out.println(n+c);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a;
cin>>a;
if(a==111){
cout<<3<<endl;}

if
(a==110){
cout<<2<<endl;}
if
(a==101){
cout<<2<<endl;}
if
(a==11){
cout<<2<<endl;}

if(a==100){
cout<<1<<endl;}
if(a==1){
cout<<1<<endl;}
if(a==10){
cout<<1<<endl;}

if(a==000){
cout<<0<<endl;}

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var k = sc.nextInt();
		sc.close();

		var count = 1;
		var value = 7;
		while (count < k + 1) {
			var m = value % k;
			if (m == 0) {
				break;
			}
			value = m * 10 + 7;
			count++;
		}
		System.out.println(count > k ? -1 : count);
	}
}


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

const int MAXNUM = 1e5 + 7;
bool Prime[MAXNUM+1];
bool resemble[MAXNUM+1];
int table[MAXNUM+1];
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int Q;
	cin >> Q;
	for(int i=2;i<=MAXNUM;i++){
		if(IsPrime(i))Prime[i] = 1;
	}
	for(int i=2;i<=MAXNUM;i++){
		if(i%2==0)continue;
		if(Prime[i]&& Prime[(i+1)/2]){
			resemble[i] = 1;
		}
	}
	for(int i=2;i<=MAXNUM;i++){
		table[i] = resemble[i] + table[i-1];
	}
	vector<int> ans;
	for(int i=0;i<Q;i++){
		int left,right;
		cin >> left >> right;
		ans.push_back(table[right]-table[left-1]);
	}
	for(auto x:ans)cout << x << endl;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
// #include <math.h>
// #include <cmath>
// #include <vector>
// #include <utility> 
// #include <unordered_map>
#include <map>
// #include <string>

using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;

#define M_PI_H  3.14159265358979323846/2  /* pi by two*/
#define rep(i, start, end) for(int i = start; i < end; i++) 
#define repr(i, start, end) for(int i = start; i >= end; i--)   //INCLUSIVE



int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n; cin>>n;
    map<string, int> mp;
    rep(i, 0, n){
        string s; cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
    return 0;
}

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

namespace Atc_0031
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long result = 0;

            if (N % 2 == 1)
            {
                result = N / 2 * (N / 2 + 1);
            }
            else
            {
                result = N / 2 * (N / 2);
            }

            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 27440
import numpy as np
N, M, C = map(int, input().split())
b = np.array(list(map(int, input().split())))
cnt = 0

for i in range(N):
  a = np.array(list(map(int, input().split())))
  result = np.dot(a, b) + C
  if result > 0:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 27132
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    print(n//3)
    return

#B
def B():
    n = II()
    s = S()
    print(["Three", "Four"][len(set(s)) - 4])
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


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

using namespace std;

int main(){
  int a,b,k;
  vector<int> s;
  cin>>a>>b>>k;
  for(int i=a;i<=min(b,a+k-1);i++) cout<<i<<endl;
  for(int i=max(a+k,b-k+1);i<=b;i++) cout<<i<<endl;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int K, S, z;
  int ans = 0;
  cin >> K >> S;

  for (int x = 0; x <= K; ++x) {
    if (x > S)
      continue;

    for (int y = 0; (y <= K); ++y) {
      if (x + y > S)
        continue;

      z = S - x - y;
      if (z >= 0 && z <= K) {
        // cout << x << ":" << y << ":" << z << endl;
        ++ans;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	bool FLG = true;
	int tmp;

	for(int loop = 0; loop < N; loop++){

		scanf("%d",&tmp);
		if(tmp%2 == 0 && tmp%3 != 0 && tmp%5 != 0){

			FLG = false;
		}
	}

	if(FLG){

		printf("APPROVED\n");

	}else{

		printf("DENIED\n");
	}

	return 0;
}


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

template <typename T>
void print(const T &v);

int main()
{
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    ll ap, bp;
    if (a < b)
    {
        bp = b + w * t;
        ap = a + v * t;
        if (ap >= bp)
        {
            cout << "YES" << endl;
            return 0;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    else
    {
        bp = b - w * t;
        ap = a - v * t;
        if (ap <= bp)
        {
            cout << "YES" << endl;
            return 0;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 1; i < v.size(); i++)
    {
        if (i - 1)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	cin >> N >> S;
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == ('0' + (unsigned char)c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int sh[10000],m,n,l=100000,k;
int main()
{
	//freopen("tt.txt", "w", stdin);
	int sh[5];
	cin>>sh[0]>>sh[1]>>sh[2];
	sort(sh,sh+3);
	cout<<sh[0]+sh[1];
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long int n, a, b, sum;
int main() {
	cin >> n >> a >> b;
	sum+=(a*(n/(a+b)));
	if (n%(a+b)<=a) sum+=n%(a+b);
	else sum+=a;
	cout << sum << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n; cin>>n;
        int ans=0;
        rep(i,n)
        {
                int l,r; cin>>l>>r;
                ans+=r-l+1;
        }
        cout<<ans<<endl;
}


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

using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int dev4 = 0;
    int odd = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        if (a.at(i) % 2 != 0)
            odd++;
        if (a.at(i) % 4 == 0)
            dev4++;
    }
    if (odd + dev4 == n && odd > dev4 + 1)
        cout << "No" << endl;
    else if (odd + dev4 != n && odd > dev4)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int [] m = new int [n];
        int min = 1000;
        for(int i = 0; i < n; i++) {
            m[i] = sc.nextInt();
            x -= m[i];
            min = Math.min(min,m[i]);
        }
        int ans = n + x / min;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
// ABC059
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

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

typedef long long ll;

int main()
{
    string ans;
    rep(i, 3)
    {
        string s;
        cin >> s;
        ans.push_back(s[0]-'a'+'A');
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto V = aryread();
    long v0 = V[0];
    if (V.all!(v => v == v0))
    {
        writeln(N / 2);
        return;
    }
    long[long][2] dict;
    foreach (i; 0 .. N)
    {
        dict[i & 1][V[i]] = dict[i & 1].get(V[i], 0) + 1;
    }
    alias T = Tuple!(long, long);
    auto d0 = dict[0].byKeyValue().map!(t => T(-t.value, t.key)).array;
    d0.sort();
    auto d1 = dict[1].byKeyValue().map!(t => T(-t.value, t.key)).array;
    d1.sort();
    // writeln(d0);
    // writeln(d1);
    if (d0.length == 1 && d1.length == 1)
    {
        writeln(0);
        return;
    }
    long ans = long.max;
    foreach (i; 0 .. 2)
        foreach (j; 0 .. 2)
            if (i < d0.length && j < d1.length)
            {
                if (d0[i][1] != d1[j][1])
                {
                    ans = ans.min(N + d0[i][0] + d1[j][0]);
                }
            }
    writeln(ans);
}


Measured memory_bytes: 12604
/**
*    created: 23.06.2020 23:28:27
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    if (100 <= n && n <= 111) cout << 111 << endl;
    if (111 < n && n <= 222) cout << 222 << endl;
    if (222 < n && n <= 333) cout << 333 << endl;
    if (333 < n && n <= 444) cout << 444 << endl;
    if (444 < n && n <= 555) cout << 555 << endl;
    if (555 < n && n <= 666) cout << 666 << endl;
    if (666 < n && n <= 777) cout << 777 << endl;
    if (777 < n && n <= 888) cout << 888 << endl;
    if (888 < n && n <= 999) cout << 999 << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  string s;
  int ans=BIG;
  int rb=0,rw=0,lb=0,lw=0;
  cin>>n>>s;
  rep(i,s.size() ){
    if(s[i]=='#') rb++;
    else rw++;
  }
   ans=min(ans,rw+lb);
  rep(i,s.size()){
    if(s[i]=='#'){rb--;lb++;}
    else {rw--;lw++;}
    ans=min(ans,rw+lb);
  }
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;
typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)


#define REP(n) for(int i = 0;i < (int)(n);i++)
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;


ll binary(ll bina)
{
    long long ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    string a;
    return ans;

}

int main()
{
    ll N;
    cin >> N;
    vector<int> W(N);
    ll min = 100000000000000;
    rep(i,N)
    {
        cin >> W.at(i);
    }
    ll sum;
    sum = accumulate(ALL(W),0);
    rep(i,N)
    {
        ll sum1 = 0;
        Rep(j,0,i + 1)
        {
            sum1 += W[j];
        }
        if(min > abs(sum - sum1 - sum1))
        {
            min = abs(sum - sum1 - sum1);
        }
    }
    cout << min << endl;

}

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

int main(){
  string s,code_festival = "CODEFESTIVAL2016";
  int check = 0;
  cin >> s;
  for(int i = 0;i < 16;i++){
    if(s[i] != code_festival[i]){
      check++;
    }
  }
  cout << check << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;

#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)

#define     deb(x)      cout<<#x<<"="<<x<<endl
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
#define PI 3.1415926535897932384626
 
const int mod = 1e9+7;
const int N = 1e5+5;

//==========================================//

void solve()
{
	string s;
	cin>>s;
	if(s[0]==s[1] && s[1]==s[2] && s[1]=='R')
		cout<<3;
	else if((s[0]==s[1] && s[1]=='R') || (s[1]==s[2] && s[1]=='R'))
		cout<<2;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
		cout<<1;
	else
		cout<<0;
}
int main()
{
	sync;

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> units = new ArrayList<>();
		for (int i = 1; i <= Math.sqrt(n); i++) {
		    if (n % i == 0) {
		        units.add(i);
		        if (i * i != n) {
		            units.add(n / i);
		        }
		    }
		}
		Collections.sort(units);
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		    for (int j = 0; j < units.size(); ) {
		        int x = units.get(j);
		        if (i - x < 0) {
		            break;
		        }
		        if (arr[i] != arr[i - x]) {
		            units.remove(Integer.valueOf(x));
		        } else {
		            j++;
		        }
		    }
		}
		if (units.size() == 0) {
		    System.out.println(1);
		} else {
		    System.out.println(n / units.get(0));
		}
	}
}



Measured memory_bytes: 102064
#include <stdio.h>

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);

  if(a < b) printf("a < b\n");
  if(a>b) printf("a > b\n");
  if(a==b) printf("a == b\n");
  return 0;
}

  

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

typedef long long ll;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

// 深さ優先探索 r:頂点, c:色の番号
void dfs(int r, int c) {
	color[r] = c;

	for (int i = 0; i < G[r].size(); i++) {
		int v = G[r][i];
		if (color[v] == NIL) {
			color[v] = c;
			dfs(v, c);
		}
	}
}

void assignColor() {
	int id=1;
	// 色の初期化
	for(int i=0; i<n; i++) color[i]=NIL;
	// 事前にそれぞれの頂点の色分けをする
	for (int u = 0; u < n; u++) {
		// 色分けが行われていない頂点に新しい色を割り当てる
		if (color[u] == NIL) {
			dfs(u, id++);
		}
	}
}

int main() {
	int s,t,m,q;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	assignColor();

	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> s >> t;
		if (color[s] == color[t]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
}



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

int main() {
  int X;
  cin >> X;
  int i = X;
  bool loop = true;
  while (loop) {
    bool isp = true;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) {
        isp = false;
        break;
      }
    }
    if (isp)
      loop = false;
    else
      i += 1;
  }
  cout << i << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string s;
int main(){
    cin>>s;
    for(ll i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(i==s.length()-2)continue;
        if(s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<"-1 -1"<<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int count = 0;
  for(int i = 1; i < N+1; i+=2){
    int c = 0;
    for (int j = 1; j < i+1; j++){ 
    	if(i % j == 0){
      		c+=1;
    	}
    }
    if(c == 8){
      count +=1;
    }
  }
  cout << count << endl;
}

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    bool res = true;
    for(int i = 0; i < n; i++){
        if(a[i] & 1)continue;
        if(a[i] % 3 != 0 && a[i] % 5 !=0)res = false;
    }
    std::cout << (res ? "APPROVED" : "DENIED") << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define ll long long
#define ull unsigned long long
#define out(a) printf("%d",a)
#define outl(a) printf("%lld",a)
#define outu(a) printf("%lu",a)
#define kg cout<<' '
#define writeln printf("\n")
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define down(i,a,b) for (int i=a;i>=b;i--)
#define inf 0x7fffffff
#define yes puts("Yes")
#define no puts("No")
#define ms(a,b) memset(a,b,sizeof(a))
#define deb printf("%d\n",233)
using namespace std;
typedef int Array[100050];
Array a,b;
ll sum[100050];
int n;
ll sum1,sum2;
int cnt=0;
ll num1,num2;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
ll readl()
{
	ll s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int power(int a,int b)
{
	int ans=1;
	while(b)
	{
	  if(b&1) ans*=a,b--;
	  b>>=1; a*=a;
	}
	return ans;
}
int main()
{
	n=read();
	rep(i,1,n)
	  a[i]=read(),sum1+=a[i];
	rep(i,1,n)
	  b[i]=read(),sum2+=b[i];
	if (sum1>sum2) {
	  no; return 0;
    }
    rep(i,1,n) {
      if (a[i]==b[i]) cnt++;
      sum[i]=a[i]-b[i];
    }
    if (cnt==n) {
      yes; return 0;
    }
    rep(i,1,n) {
      if (sum[i]<0) num1+=sum[i]/2;
      else if (sum[i]>0) num2+=sum[i];
    }
    if (abs(num1)>=num2) yes;
    else no;
	return 0;
}


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


int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) cout << c << endl;
    else if (b == c) cout << a << endl;
    else if (c == a) cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
solve :: Int -> Int -> Int -> Int -> Bool
solve a b c n =
    if n == b then
        False
    else
        a * n `mod` b == c || solve a b c (n + 1)

main :: IO ()
main = do
    [a,b,c] <- map read . words <$> getLine
    if solve a b c 1 then
        putStrLn "YES"
    else
        putStrLn "NO"

Measured memory_bytes: 508
n, a, b = map(int, input().split())
s = input()
c = a+b

for x in s:
    if x == 'a' and c > 0:
        c -= 1
        print('Yes')
    elif x == 'b' and b > 0 and c > 0:
        b -= 1
        c -= 1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 76148
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
 
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
	    cout << "+";
	} else if (a * b == 15) {
	    cout << "*";
	} else cout << 'x';
	return 0;
}  

Measured memory_bytes: 384
//Union find.
//One of my favorite quizes.
#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long   llong;
typedef vector<int> vi;

struct UnionFind{
	std::vector<int> par;//xの親はpar[x]. もしx自身が親ならpar[x]<0で,-par[x]がその集合のサイズ.
	int cnt;			 //グループの数.
	
	UnionFind(int n):par(n,-1),cnt(n){}//コンストラクタ.
	
	void reset(int n){par.assign(n,-1),cnt=n;}
	int root(int x){return (par[x]<0)?x:par[x]=root(par[x]);}//再帰.
	int size(int x){return -par[root(x)];}
	bool same(int x,int y){return root(x)==root(y);}
	bool unite(int x,int y){
		x=root(x), y=root(y);
		if(x==y) return false;//do nothing.
		if(size(x)<size(y)) swap(x,y);//merge technique.
		par[x]+=par[y];
		par[y]=x;
		cnt--;
		return true;
	}
};

int main(){
	int n,m;
	cin>>n>>m;
	
	vi a(m),b(m);
	REP(i,m){
		cin>>a[i]>>b[i];
		a[i]--, b[i]--;
	}
	
	UnionFind is(n);
	vector<llong> ans(m);
	ans[m-1]=(llong)n*(n-1)/2;//nC2.
	for(int i=m-1;i>=1;--i){
		if(is.same(a[i],b[i])) ans[i-1]=ans[i];
		else ans[i-1]=ans[i]-(llong)is.size(a[i])*is.size(b[i]);
		is.unite(a[i],b[i]);
	}
	
	REP(i,m) cout<<ans[i]<<endl;
}


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


class Program
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());

        int s = X % 500;

        int happ = (X - s) * 2 + s - s % 5;

        Console.WriteLine(happ);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> h(N),cost(N,INT_MAX);
  for(int i = 0; i < N; ++i) cin >> h[i];
  cost[0] = 0;
  for(int i = 1; i < N; ++i){
    for(int j = max(0,i-2); j < i; ++j){
      cost[i] = min(cost[i],cost[j]+abs(h[j]-h[i]));
    }
  }
  cout << cost[N-1];
  return 0;
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	if (N % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < N / 2; i++) {
		if (S[i] != S[N / 2 + i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

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

int q1, b, c1, c2, q2;

bool check(int m){
	if(m > q2) return false;
	if(m * c1 > b) return false;
	int n = b - m * c1;
	if(m + n / c2 < q1) return false;
	return true;
}

int main(){
	int l, r, m;
	int a1, a2;
	while(cin>>q1 && q1){
		cin>>b>>c1>>c2>>q2;
		l = 0; r = q2;
		rep(i, 30){
			m = (l + r) / 2;
			if(check(m+1)){
				l = m+1;
			}
			else if(check(m)){
				l = m;
			}
			else {
				r = m;
			}
		}
		if(l == 0){
			cout<<"NA"<<endl;
			continue;
		}
		cout<<l<<" "<<(b-m*c1)/c2<<endl;
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 文字列を取得
		String S = sc.next();
		
		for (int i=0; i < S.length(); i++) {
			char c = S.charAt(i);
			// UならOK
			if (c == 'U')
				continue;
			// DならOK
			if (c == 'D')
				continue;
			
			//偶数番目
			if (i%2 == 0) {
				// LならOK
				if (c == 'R')
					continue;
			}
			//奇数番目
			else {
				// RならOK
				if (c == 'L')
					continue;
			}
			
			//ここまでに引っかからなかったらNoを出力して終了
			System.out.println("No");
			return;
		}
		
		//全部通ったらYesを出力
		System.out.println("Yes");
	}
}


Measured memory_bytes: 22740
import java.util.Scanner;

class AskCubeOfX {
    
    public int Input() {
        
        int x = 0;
        Scanner in = new Scanner(System.in);
        
        x = in.nextInt();
        
        return x;
    }
    
    public int askCube(int x) {
        return  x * x * x;
    }
    
    public void Print(int cube) {
        System.out.println(cube);
    }
}

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        int x = 0, cube = 0;
        
        AskCubeOfX test = new AskCubeOfX();
        
        x = test.Input();
        
        cube = test.askCube(x);
        
        test.Print(cube);
    }
}

Measured memory_bytes: 26232
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b, c; cin >> a >> b >> c;
	int d = a - b;
	int ans = max(c - d, 0);
	cout << ans << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,L,t; cin >> n >> L >> t;
	vector<vpl> v(2);
	rep(i,n){
		ll x,w; cin >> x >> w; w--;
		v[w].emplace_back(x,i);
		v[w].emplace_back(x+L,i);
	}
	rep(i,2) sort(all(v[i]));
	ll inc = t / L;
	t %= L;
	vl ans(n);
	for(auto i : v[0]){
		if(i.first >= L) break;
		auto itr = lower_bound(all(v[1]), P(i.first+2*t, -inf));
		auto itr2 = lower_bound(all(v[1]), P(i.first, -inf));
		ll id = i.second + (itr-itr2) + inc * v[1].size();
		if(i.first+2*t >= 2*L){
			id += lower_bound(all(v[1]),P(i.first+2*t-2*L, -inf)) - v[1].begin();
		}
		ans[id%n] = (t + i.first) % L;
	}
	for(auto i : v[1]){
		if(i.first < L) continue;
		ll tmp = i.first - 2*t;
		ll d;
		if(tmp >= 0){
			auto itr = lower_bound(all(v[0]), P(i.first, -inf));
			d = itr - upper_bound(all(v[0]), P(tmp, inf));
		}else{
			d = lower_bound(all(v[0]), P(i.first, -inf)) - v[0].begin();
			d += v[0].end() - upper_bound(all(v[0]), P(2*L+tmp, inf));
		}
		d += inc * v[0].size();
		d %= n;
		ans[(i.second-d+3*n)%n] = (i.first - t) % L;
		//cout << (i.second-d+n)%n << "\n";
	}
	rep(i,n) cout << ans[i] << "\n";
}

Measured memory_bytes: 7288
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>
#include <cmath>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

ll f(ll n)
{
    ll ret = 0;
    ll x = (n + 1) / 2;
    if (x & 1) ret = 1;
    if ((n & 1) == 0)
    {
        ret = ret ^ n;
    }
    return ret;
}

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

    bool grid[52][52];
    for (int i = 0; i < 52; i++)
    {
        for (int j = 0; j < 52; j++)
        {
            grid[i][j] = false;
        }
    }
    for (int i = 1; i <= H; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++)
        {
            grid[i][j] = (s[j] == '#');
        }
    }

    bool result = true;
    for (int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            if (grid[j][i])
            {
                if (grid[j - 1][i] == false && grid[j + 1][i] == false && grid[j][i - 1] == false && grid[j][i + 1] == false)
                {
                    result = false;
                    goto exit;
                }
            }
        }
    }
    exit:
    cout << (result ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {

	int n; cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];

	vector<int> x(n,0);
	rep(i,n){
		int sgn = (i+1)%2 ? 1 : -1;
		x[0] += sgn*a[i];
	}
	rep2(i,1,n){
		x[i] = 2*(a[i-1]-x[i-1]/2);
	}
	rep(i,n) cout << x[i] << " ";
	cout << endl;
}




Measured memory_bytes: 2048