akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int KOUSYA = 4;
const int FLOOR = 3;
const int ROOM = 10;

struct floor {
    int room[ROOM];
};

struct Kousya {
    struct floor fr[FLOOR]; 
};

int main()
{
    Kousya k[KOUSYA] = { 0 };

    int n;              // 入力数
    int b;              // 棟
    int f;              // 階
    int r;              // 部屋
    int v;              // 人数

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;

        if (b > 0 && b <= KOUSYA) {
            if (f > 0 && f <= FLOOR) {
                if (r > 0 && r <= ROOM) {
                    int nin = k[b-1].fr[f-1].room[r-1] + v;
                    if (nin >= 0 && nin <= 9) {
                        k[b-1].fr[f-1].room[r-1] = nin;    
                    }
                }
            }
        }
    }

    for (int j = 0; j < KOUSYA; j++) {
        if (j > 0) {
            cout << "####################" << endl;
        }
        for (int l = 0; l < FLOOR; l++) {
            for (int m = 0; m < ROOM; m++) {
                cout << " " << k[j].fr[l].room[m];
            }
            cout << endl;
        }

    }

    return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

const int MAX_N = 100001;
bool exist[MAX_N];
int dp[MAX_N][2];

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

    int n, k;
    while(cin >> n >> k, n) {
        fill(exist, exist + n + 1, false);
        rep(i, k) {
            int x;
            cin >> x;
            exist[x] = true;
        }

        rep(i, n + 1) {
            rep(j, 2) {
                dp[i][j] = 0;
            }
        }

        rep2(i, 1, n + 1) {
            rep(j, 2) {
                if (exist[i]) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j] + 1);
                }
            }
            if (exist[0]) {
                dp[i][1] = max(dp[i][1], dp[i - 1][0] + 1);
            }
        }

        int ma = 0;
        rep(i, n + 1) rep(j, 2) ma = max(ma, dp[i][j]);

        cout << ma << endl;
    }
}

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

int main() {
    int n;
    cin >> n;
    int A = n / 4;
    int B = n / 7;
    bool res = false;
    for(int a = 0; a <= 30; a++){
        for (int b = 0; b <= 30; b++){
            if (4*a + 7*b == n) res = true;
        }
    }

    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iterator>

int main() {
  std::pair<int, bool> a[9];
  for (int i = 0; i < 9; ++i)
    std::cin >> a[i].first;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    int b;
    std::cin >> b;
    std::find(a, a + 9, std::make_pair(b, false))->second = true;
  }

  int l[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6},
                 {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

  for (int i = 0; i < 8; ++i) {
    if (a[l[i][0]].second == true && a[l[i][1]].second == true &&
        a[l[i][2]].second == true) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7

n, k = list(map(int, input().split()))
c = {i: pow(k//i, n, mod) for i in range(1, k+1)}
for i in range(k, 0, -1):
    for j in range(2*i, k+1, i):
        c[i] -= c[j]
_sum = 0
for x in range(1, k+1):
    _sum += c[x] * x % mod
print(_sum % mod)


Measured memory_bytes: 21064
#include <stdio.h>
#include <iostream>
#include <map>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    long A[N];
    REP(0, i, N) {
        cin >> A[i];
    }

    long B[N + 1];
    B[0] = 0;
    REP(1, i, N + 1) {
        B[i] = (B[i - 1] + A[i - 1]) % M;
    }

    map<long, long> m;
    REP(0, i, N + 1) {
        map<long, long>::iterator it = m.find(B[i]);
        if (it != m.end()) {
            m[B[i]]++;
        } else {
            m.insert(make_pair(B[i], 1));
        }
    }

    long ans = 0;
    for (map<long, long>::iterator it = m.begin(); it != m.end(); ++it) {
        ans += (it->second) * (it->second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5760
! 2019.11.4
!
      program answer
      implicit none
      character(len=499999) :: S
      integer(8) :: N_1
      integer(8),dimension(499999) :: counting
      integer(8) :: co
      integer(8) :: i
      integer(8) :: ans
      integer(8),external :: sumsq
      intrinsic len_trim,mod
!
      read(*,*) S
      N_1 = len_trim(S)
! initialization
      do i=1,N_1+1
        counting(i) = 1
      end do
      co = 1
      ans = 0
!
      do i=1,N_1
        if(S(i:i) == S((i+1):(i+1))) then
          counting(co) = counting(co) + 1
        else
          co = co+1
        end if
      end do
      co = co-1
!      write(*,*) (counting(i),i=1,co)
!
      if( S(1:1) == '<') then
        do i=1,co
          if(mod(i,2) == 0) then
          else
            if(counting(i) < counting(i+1)) then
              counting(i) = counting(i) - 1
            else
              counting(i+1) = counting(i+1) - 1
            end if
          end if
        end do
      else
        do i=1,co
          if(mod(i,2) == 1) then
          else
            if(counting(i) < counting(i+1)) then
              counting(i) = counting(i) - 1
            else
              counting(i+1) = counting(i+1) - 1
            end if
          end if
        end do
      end if
!
!      write(*,*) (counting(i),i=1,co)
      do i=1,co
        ans = ans + sumsq(counting(i))
      end do
!
      write(*,*) ans
      end program answer
!
      function sumsq(A) result(res)
      implicit none
      integer(8) :: A,res
      res = A*(A+1)/2
      end function sumsq 

Measured memory_bytes: 5216
/*************************************
 *プログラム名：D.c
 *
 *************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
#include <pthread.h>

//<<<<<>>>>>//

int main(void)
{
	long i, N, T;
	long *A;
	long num1 = 0, num2 = 0, min = pow(10, 9);
	
	scanf("%ld %ld", &N, &T);
	
	A = malloc(sizeof(long) * N);
	
	for (i = 0; i < N; i++) {
		scanf("%ld", A + i);
	}
	
	for (i = 0; i < N; i++) {
		if (*(A + i) < min) {
			min = *(A + i);
		}
		if (num1 < *(A + i) - min) {
			num1 = *(A + i) - min;
			num2 = 0;
		}
		if (num1 == *(A + i) - min) {
			num2++;
		}
	}
	
	printf("%d\n", num2);
	
	free(A);
	
	return (0);

}

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

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
        //primeFactors.Dump();
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i <= n)
        {
            if(n % i == 0){
                n /= i;
                yield return i;
            }else{
                i++;
            }
             
            if(i > Math.Sqrt(tmp)){
                i = int.MaxValue; //???????????????
                yield return n;
            }
        }
    }
}

Measured memory_bytes: 20316
#include<bits/stdc++.h>
using namespace std;
int a[101][101];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			a[i][j]+=max(a[i-1][j],a[i][j-1]);
		}
	}
	printf("%d\n",a[2][n]);
	return 0;
}

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

int main()
{
  string S,T;cin>>S>>T;
  int count=0;
  for (int i=0;i<3;i++)
  {
    if (S[i]==T[i])
      count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define int long long
int a[20001],x;
signed main(){
    for(int i=-1000;i<=1000;i++)a[i+1000]=1ll*i*i*i*i*i;
    scanf("%lld",&x);
    for(int i=0;i<=2000;i++){
        int k=std::lower_bound(a+i+1,a+2000,a[i]+x)-a;
        if(a[k]==a[i]+x)return printf("%lld %lld\n",k-1000,i-1000),0;
    }
}

Measured memory_bytes: 1696
sn = 50000.0**0.5 + 1
is_prime = [false, false] + [true]*49999
(2..sn).each do |i|
  next unless is_prime[i]
  (i*i).step(50000, i).each do |j|
    is_prime[j] = false
  end
end
plist = (2..50000).to_a.select{ |i| is_prime[i] }

while gets
  s = $_.to_i
  break if s == 0
  tmp = plist.dup
  l = tmp.shift
  h = tmp.pop
  c = 0

  until tmp.empty?
    if l + h == s
      c += 1
      l = tmp.shift
    elsif l + h < s
      l = tmp.shift
    else
      h = tmp.pop
    end
  end

  c += 1 if l*2 == s or h*2 == s or l+h == s
  puts c
end

Measured memory_bytes: 7400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;
int n;

const int INF = 1 << 29;

int main(void)
{
	string str;
	cin >> str;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		string ring;
		cin >> ring;
		for (int i = 0, length = ring.size(); i < length - 1; i++)
		{
			ring += ring[i];
		}
		if(ring.find(str) != string::npos) ans++;
	}
	cout << ans << endl;;
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define lint long long
//#define P pair<int, int>

int main(){
    lint N;
    cin >> N;
    vector<bool> ans;
    
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    
    while(N != 0){
        int s = N % 4;
        N/= 4;
        if(s == 0){
            ans.push_back(0);
            ans.push_back(0);
        }
        if(s == 1 | s == -3){
            if(s == -3){
                N--;
            }
            ans.push_back(1);
            ans.push_back(0);
        }
        if(s == 2 | s == -2){
            if(s == 2){
                N++;
            }
            ans.push_back(0);
            ans.push_back(1);
        }
        if(s == 3 | s == -1){
            if(s == 3){
                N++;
            }
            ans.push_back(1);
            ans.push_back(1);
        }
    }

    int b = ans.size();
    if(ans[b - 1] == 0){
        b--;
    }
    
    for(int i = b - 1; i >= 0; --i){
        cout << ans[i];
    }
    cout << endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	vector<bool> check(1000000);
	int s, tmp, i = 0;
	cin >> s;
	tmp = s;
	while (check.at(s - 1) == false) {
		check.at(s - 1) = true;
		if (s % 2) {
			s = 3 * s + 1;
		}
		else {
			s /= 2;
		}
		++i;
	}
	cout << i + 1;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        sum += s[i];
    }
    sort(s.begin(),s.end());
    if(sum%10 != 0){
        cout << sum << endl;
    }
    else{
        for(int i=0;i<n;i++){
            if(s[i]%10 !=0){
                cout << sum-s[i] << endl;
                return 0;
            }
            else if(i == n-1){
                cout << '0' << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
using ll = long long;
using namespace std;

int n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i < 10; ++i) {
        if (n%i == 0 && n/i < 10) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}





Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 2e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	FIO
	ll n; cin >> n;
	ll h[n];
	FOR(i, n) cin >> h[i];
	ll dp[n + 1] = {}; // dp[i] min cost to reach at the ith point
	// dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i-2]-h[i]));
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (ll i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 5160
N = int(input())
if N >= 500:
    t = N//500
    a = N%500
    if a >= 5:
        f = a//5
        print(1000*t+f*5)
    else:
        print(1000*t)
elif N >= 5:
    f = N//5
    print(f*5)
else:
    print("0")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main() {
	int n = 0, x = 0, m = 0;
	int count[2] = {};
	int a[1000] = {};
	std::cin >> n >> m >> x;
	for (int i = 0; i < m; i++) { std::cin >> a[i]; }
	for (int i = 0; i < m; i++) {
		if (a[i] < x) {
			count[0]++;
		}
		else {
			count[1]++;
		}
	}
	std::cout << std::min(count[0], count[1]) << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
N = input()
turn = 1
sum_AC = 0
while int(N)>=turn:
  if turn % 15 == 0:
    turn += 1
  elif turn % 3 == 0:
    turn += 1 
  elif turn % 5 ==0:
    turn += 1
  else:
    sum_AC += turn
    turn += 1

print(sum_AC)

Measured memory_bytes: 9140
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	b1, b2, b4 := 0, 0, 0

	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if a%4 == 0 {
			b4++
		} else if a%2 == 0 {
			b2++
		} else {
			b1++
		}
	}

	b1 += b2 % 2
	if b1 <= b4+1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += Integer.parseInt(br.readLine());
        }
        System.out.println(sum / n);
    }
}


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

int SumOfDIgits(int n) {
  int sum=0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {

  int N, a, b;
  cin >> N >> a >> b;
  int ans=0;

  for (int i=1; i<=N; ++i) {
    int sum=SumOfDIgits(i);
    if (sum >= a && sum <= b) {
    ans += i;
    } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
using namespace std;
typedef int ll;
struct node{
	short x=0,y=0;
	int p=0;
}a[20]; 
long long ans[20];
short mi[20],m1[20];
short px[20][20],py[20][20];
int main(void)
{
 
	short n;
	scanf("%hd",&n);
	for(short i=0;i<n;i++) scanf("%hd%hd%d",&a[i].x,&a[i].y,&a[i].p);
	int ma=1;
	for(short i=0;i<=n;i++) ans[i]=1000000000000000;
	for(short i=0;i<n;i++) ma*=3;
	for(short i=0;i<n;i++) m1[i]=min(abs(a[i].x),abs(a[i].y));
	for(short i=0;i<n;i++)
	{
		for(short j=0;j<n;j++)
		{
			px[i][j]=(short)abs(a[i].x-a[j].x);
			py[i][j]=(short)abs(a[i].y-a[j].y);
		}
	}
	for(int zhu=0;zhu<ma;zhu++)
	{
		int ppk=zhu;
		short cnt=0;
		int st=ma/3;
		for(short i=0;i<n;i++) mi[i]=m1[i];
		for(short i=0;i<n;i++,st/=3)
		{
			int now=ppk/st;
			if(now==2)
			{
				cnt++;
				for(ll j=0;j<n;j++) if(mi[j]>px[i][j]) mi[j]=px[i][j];
			}
			else if(now==1)
			{
				cnt++;
				for(ll j=0;j<n;j++) if(mi[j]>py[i][j]) mi[j]=py[i][j];
			}
			ppk-=st*now;
		}
		long long sum=0;
		for(short i=0;i<n;i++) sum+=(long long)mi[i]*a[i].p;
		ans[cnt]=min(ans[cnt],sum);
	}
	for(ll i=0;i<=n;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 3196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        HashSet<Integer> r = new HashSet<>(), g = new HashSet<>(), b = new HashSet<>();
        for (int i = 0; i < n; i++)
            switch (s[i]) {
                case 'R':
                    r.add(i);
                    break;
                case 'G':
                    g.add(i);
                    break;
                case 'B':
                    b.add(i);
                    break;
            }
        long ans = 0;
        for (int x : r) {
            for (int y : g) {
                ans += b.size();
                int i = Math.min(x, y), j = Math.max(x, y);
                int diff = j - i;
                if (b.contains(i - diff)) ans--;
                if (b.contains(j + diff)) ans--;
                if (diff % 2 == 0 && b.contains(i + diff / 2))
                    ans--;
            }
        }
        out.println(ans);
        out.flush();
        out.close();
    }


    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        boolean ready() throws IOException {
            return br.ready();
        }

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

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        int nextChar() throws IOException {
            return next().charAt(0);
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

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

    }
}


Measured memory_bytes: 53392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	ll n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	ll mi=min({a,b,c,d,e});
	cout << 4+(n+mi-1)/mi;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

MOD = 10 ** 9 + 7

# nを素因数分解する(O(n ^ (1 / 2)))
# primeFactorDecomposition(12): {2: 2, 3: 1}
def prime_factor_decomposition(n):
    import math
    m = defaultdict(int)
    while n > 1:
        find_factor = False
        for i in range(2, int(math.sqrt(n)) + 1):

            if n % i == 0:
                m[i] += 1
                n //= i
                find_factor = True
                break

        if not find_factor:
            m[n] += 1
            break

    return m


def main():
    N = int(input())
    m = defaultdict(int)
    for i in range(1, N + 1):
        d = prime_factor_decomposition(i)
        for k, v in d.items():
            m[k] += v
    ans = 1
    for k, v in m.items():
        ans = (ans * (v + 1)) % MOD

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int count(int x){
    int ct = 0;
    while(x%2 == 0){
        ct++;
        x /= 2;
    }
    return ct;
}

int main(){
    int N;
    cin >> N;
    
    int res = 0;
    int ct = 0 ;
    for(int i=1 ; i<=N ; i++){
        ct = count(i);
        res = max(res,ct);
    }
    int res2 = 1;
    for(int i=0 ; i<res ; i++){
        res2 *= 2;
    }
    cout << res2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfsvisit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfsvisit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfsvisit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
    v--;
    M[u][v]=1;
    }
  }
  dfs();
  
  return 0;
}



Measured memory_bytes: 2104
/*
    Ankit Singhal
 */
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/


const unsigned ll mod= (ll)1e9 + 7 ;
const ll inf = (ll)1e15 + 42;
const ll N = (ll)1e6 + 2;
 
ll power ( ll x , unsigned ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
 
/*struct node{
    ll x , y , z;
};
vector<set<ll>> tree;
vector<ll> ar , ans;
set<ll> s;
ll get(ll x)
{
    if(x == ar[x])
        return x;
    return ar[x] = get(ar[x]);
}
void merge(ll a ,ll b)
{
    a = get(a);
    b = get(b);
    if(a == b)
        return;
    ar[b] = ar[a];
    //ans[a] += ans[b];
 }

ll sev[1000001];


void seive()
{
    for(ll i = 2 ; i <= 1000000 ; i ++)
    {
        if(!sev[i])
        {
            for(ll j = i ; j <= 1000000 ; j += i)
            {
                if(!sev[j])
                    sev[j] = i;
            }
        }
    }
}
*/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    while(t --)
    {
        ll n;
        cin >> n;
        string str;
        cin >> str;
        for(ll i = 0 ;i < str.size() ;i ++)
        {
            ll temp = str[i] - 'A';
            str[i] = 'A' + ((temp + n) % 26);
        }
        print(str);
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
    
}
 


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h = read::<usize>();
    let w = read::<usize>();
    let mut field = vec![vec![]; h];
    for y in 0..h {
        field[y] = read::<String>().chars().collect::<Vec<char>>();
    }
    let mut ans = std::cmp::max(h, w);
    let mut heights = vec![vec![1; w]; h];
    for y in 0..h - 1 {
        for x in (0..w - 1).rev() {
            if (field[y][x] == field[y][x + 1]) == (field[y + 1][x] == field[y + 1][x + 1]) {
                heights[y][x] += heights[y][x + 1];
            }
        }
    }
    for x in 0..w - 1 {
        let mut stack = vec![(0, 0)];
        for y in 0..h {
            let mut miny = y;
            let lh = heights[y][x];
            while stack.last().unwrap().1 > lh {
                let (py, ph) = stack.pop().unwrap();
                ans = std::cmp::max(ans, (y - py + 1) * ph);
                miny = py;
            }
            stack.push((miny, lh));
        }
    }
    println!("{}", ans);
}


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

#define ll long long 
#define pll pair<ll,ll> 

int main(){

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

	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll x=0, y=n-1,ans=0;
	while(x<y){
		if(s[x]=='W'){
			while(x<y && s[y]!='R')
				y--;
			if(s[y]=='R'){
				ans++;
				s[x]='R';
				s[y]='W';
			}
		}
		x++;
	}
	cout<<ans<<endl;
}




Measured memory_bytes: 3724
#include<iostream>
#include<algorithm>
using namespace std;
int n, m, s[10000000], k[10000000], MAX;
int main() {
	while (true) {
		MAX = -2000000000;
		cin >> n >> m;
		if (!n) { break; }
		for (int i = 1; i <= n; i++) {
			cin >> s[i];
			k[i] = k[i - 1] + s[i];
		}
		for (int i = 1; i <= n - m; i++) {
			MAX = max(MAX, k[i + m] - k[i]);
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3600
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if(n % 10 == 7 || (n / 10) % 10 == 7 || n / 100 == 7){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
}

Measured memory_bytes: 3652
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long n;
    std::cin >> n;

    long long ans = 0;
    std::priority_queue<long long, std::vector<long long>, std::greater<long long>> q;
    for (int i = 0; i < n; i++) {
        long long temp;
        std::cin >> temp;

        q.push(temp);
        ans += temp;
    }

    while (ans % 10 == 0 && q.size()) {
        if (q.top() % 10) {
            ans -= q.top();
        }
        q.pop();
    }

    std::cout << (ans % 10 ? ans : 0) << std::endl;
}


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

int main(){
    int flag=1;
    int ans=0,i=0;
    int a,b;
    string s;
    cin >>a>>b>>s;

    while (i<a){
        if((s[i]-'0')>=10 ||(s[i]-'0')<0){
            flag=0;
        }
        i++;
    }
    if(s[i++]!='-')flag=0;
    while (i<a+b+1){
        if((s[i]-'0')>=10 ||(s[i]-'0')<0){
            flag=0;
        }
        i++;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
# Aizu Problem CGL_3_B: Is-Convex
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input3.txt", "rt")


def is_convex(P):
    # check whether polygon P is convex or not
    # see: https://stackoverflow.com/questions/471962/how-do-determine-if-a-polygon-is-complex-convex-nonconvex
    N = len(P)
    prods = []
    for k in range(N):
        x0, y0 = P[k]
        x1, y1 = P[(k + 1) % N]
        x2, y2 = P[(k + 2) % N]
        dx1 = x1 - x0
        dy1 = y1 - y0
        dx2 = x2 - x1
        dy2 = y2 - y1
        cross = dx1 * dy2 - dy1 * dx2
        prods.append(cross)
    prods = sorted(prods)
    return prods[0] * prods[-1] >= 0


N = int(input())
P = [[int(_) for _ in input().split()] for __ in range(N)]
print(1 if is_convex(P) else 0)

Measured memory_bytes: 7804
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define MAX 200005
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
const int N = 3e5 + 5;
#define MOD 1000000007
#define mod1 998244353
 
int n;
int a[N];
int cache[N];
int vis[N]={0};
vector<int> graph[N];

int handle(int x)
{
    return (x%MOD + MOD)%MOD;
}
void dfs(int u)
{
    vis[u]=1;
    for(auto x:graph[u])
    {
        if(!vis[x])
        {
            dfs(x);
        }
    }
}
void GO()
{
    int m;
    cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        /* code */
        if(!vis[i])
        {
            ans++;
            dfs(i);
        }
    }
    cout<<ans-1;
}

int32_t main()
{
    FAST
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    int tc;
    tc = 1;
    // cin>>tc;
    while(tc--) GO(); // let's solve this case :)
    return 0;
}

Measured memory_bytes: 15764
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 5005;
const int MM = 1000000007;

int main()
{
	int N, L;
	map<int, int> D;
	scanf("%d%d", &N, &L);
	for(int i = 1; i <= N; i++){
		int a;
		scanf("%d", &a);
		D[a] += 1;
	}
	vector<int> X;
	for(auto p : D) X.push_back(p.second);
	sort(X.begin(), X.end());
	reverse(X.begin(), X.end());
	int ans = 0;
	for(int i = L; i < X.size(); i++) ans += X[i];
	printf("%d\n", ans);
}



Measured memory_bytes: 10748
while True:
  t = int(input())
  if t == 0:
    break
    
  n = int(input())
  
  ans = 0
  for _ in range(n):
    s, f = map(int, input().split())
    ans += f - s
    
  if ans >= t:
    print('OK')
  else:
    print(t - ans)


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

int n,l[1000],a[1000],b[1000],c[1000];
char s[1000][1000];
vector<int> v[1000];
int main(){
	scanf("%d",&n);
while(n){
	for(int i=0;i<n;i++){
		scanf(" %s",s[i]);
		l[i]=strlen(s[i])-1;
		if(s[i][l[i]]=='+')
			b[i]=1;
		else if(s[i][l[i]]=='*')
			b[i]=2;
		else{
			b[i]=0;
			a[i]=s[i][l[i]]-'0';
		}
	}
	l[n]=0;
	for(int i=0;i<=100;i++)
	v[i].clear();
	for(int i=0;i<n;i++){
		if(b[i]==0){
			if(l[i]==l[i+1])
				v[l[i]].push_back(a[i]);
			else{
				v[l[i]].push_back(a[i]);

				for(int j=l[i];j>l[i+1];j--){
					//for(auto k: v[j])	printf("%d ",k);printf("!!i%d\n",c[j]);
					int t=c[j]-1;
					for(auto k:v[j])
						if(c[j]==1)
							t+=k;
						else
							t*=k;
					//printf("%d %d\n",t,j);
					v[j-1].push_back(t);
					v[j].clear();
				}
			}
		}else{
			c[l[i]+1]=b[i];
		}
	}
	printf("%d\n",v[0][0]);
	scanf("%d",&n);
}
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
    ll n, k;
    cin >> n >> k;

    ll sq = k, ans = 1;
    while(sq <= n){
        sq *= k;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

    long long int H,W;
    cin >> H >> W;

    char S[H+1][W+1];
    long long int T[H+1][W+1] = {0};
    for(int i = 1; i < H+1; i++) {
        for(int j = 1; j < W+1; j++) {
            cin >> S[i][j];
            if(S[i][j] == '#') {
                for(int k = i-1; k < i+2; k++) {
                    for(int l = j-1; l < j+2; l++) {
                        if(k >= 1 && k < H+1 && l >= 1 && l < W+1) {
                            T[k][l]++;
                        }
                    }
                }
            }
        }
    }

    for(int i = 1; i < H+1; i++) {
        for(int j = 1; j < W+1; j++) {
            if(S[i][j] == '#') {
                cout << '#';
            }else {
                cout << T[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
        string s=(b-a+1)+"";
        for(int i=0;i<(a-1)*2;i++){
          s=s+" "+(b-a+2+i);
        }
		
		//出力
		Console.WriteLine(s);
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const long long INF = 1e13;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define endl "\n"
#define test cout<<"debuged\n";
#define si 1000000
#define pi pair<ll,ll>

ll a[25][25];
ll dp[22][2098152];
ll N;

ll solve(ll x,ll mask)
{
  if(x>=N)
    return 1;
  if(dp[x][mask]!=-1)
    return dp[x][mask];
  ll ans=0;
  for(ll i=0;i<N;i++)
  {
    if(a[x][i]==1 and !(mask & (1<<i)))
    {
        ans=(ans+solve(x+1,mask|(1<<i)))%MOD;
    }
  }
  dp[x][mask]=ans;
  return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    N=n;
    for(ll i=0;i<22;i++)
      for(ll j=0;j<2098152;j++)
        dp[i][j]=-1;
    for(ll i=0;i<n;i++)
      for(ll j=0;j<n;j++)
        cin>>a[i][j];
    cout<<solve(0,0);
}


Measured memory_bytes: 360832
#include<iostream>
#include<map>

int main(void){
    std::map<char, int> mp;
    std::string s;
    std::cin >> s;
    for(int i = 0; i < s.size(); i++){
        mp[s[i]]++;
    }
    for(auto i = mp.begin(); i != mp.end(); i++){
        if(i->second != 2){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

Measured memory_bytes: 3628
k,n = map(int,input().split())
a = list(map(int,input().split()))

# d[i] = i番目とi+1番目の間の距離（d[n]はnと0番目の家の距離）
d = [0 for i in range(n)]
for i in range(n-1) :
  d[i] = a[i+1] - a[i]
d[n-1] = k - a[n-1] + a[0]

print(sum(d)-max(d))

Measured memory_bytes: 25452
#include <stdio.h>

char s[16][16];

void solve(int x, int y);

int main(void)
{
	char *surface;
	
	while (surface = &s[0][1], scanf("%s", surface) != EOF){
		int i;
		
		for (i = 1; i < 8; i++){
			surface += 16;
			scanf("%s", surface);
		}
		for (i = 0; i < 64; i++) s[i / 8][i % 8 + 1] -= '0';
		for (i = 0; i < 64; i++){
			if (s[i / 8][i % 8 + 1] == 1){
				solve(i % 8 + 1, i / 8);
				break;
			}
		}
	}
	
	return 0;
}

void solve(int x, int y)
{
	if (s[y + 1][x] + s[y][x + 1] + s[y + 1][x + 1] == 3) puts("A");
	else if (s[y + 1][x] + s[y + 2][x] + s[y + 3][x] == 3) puts("B");
	else if (s[y][x + 1] + s[y][x + 2] + s[y][x + 3] == 3) puts("C");
	else if (s[y + 1][x - 1] + s[y + 1][x] + s[y + 2][x - 1] == 3) puts("D");
	else if (s[y][x + 1] + s[y + 1][x + 1] + s[y + 1][x + 2] == 3) puts("E");
	else if (s[y + 1][x] + s[y + 1][x + 1] + s[y + 2][x + 1] == 3) puts("F");
	else puts("G");
}

Measured memory_bytes: 524
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            int a = int.Parse(input);
            
            if(a > 81)
            {
                Console.WriteLine("No");
            }
            else
            {
                for(int i = 1; i < 10; i++)
                {
                    for(int j = 1; j < 10; j++)
                    {
                        if(i * j == a)
                        {
                            Console.WriteLine("Yes");
                            return;
                        }
                    }
                }
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
from string import ascii_lowercase


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def solve(s):
    indices = {c: [] for c in ascii_lowercase}
    for i, c in enumerate(s):
        indices[c].append(i)

    n = len(s)
    center = n // 2
    bubbles = [-1] * n
    odd_flag = False
    pairs = []
    for c, ids in indices.items():
        cnt = len(ids)
        if cnt & 1:
            if odd_flag:
                return -1
            odd_flag = True
            bubbles[ids[cnt // 2]] = center + 1
        for i in range(cnt // 2):
            li, ri = ids[i], ids[-i - 1]
            pairs.append((li, ri))
    pairs.sort()
    for i, (li, ri) in enumerate(pairs):
        bubbles[li] = i + 1
        bubbles[ri] = n - i

    ans = 0
    bit = Bit(n)
    for i, m in enumerate(bubbles):
        ans += i - bit.sum(m)
        bit.add(m, 1)
    return ans


print(solve(input()))


Measured memory_bytes: 30560
import sys
from collections import Counter, deque
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]

    res = []
    for h in range(H):
        for w in range(W) if h % 2 == 0 else reversed(range(W)):
            if h % 2 == 0:
                if A[h][w] % 2:
                    if w == W - 1:
                        if h == H - 1:
                            continue
                        else:
                            A[h][w] -= 1
                            A[h + 1][w] += 1
                            res.append([h + 1, w + 1, h + 2, w + 1])
                    else:
                        A[h][w] -= 1
                        A[h][w + 1] += 1
                        res.append([h + 1, w + 1, h + 1, w + 2])
            else:
                if A[h][w] % 2:
                    if w == 0:
                        if h == H - 1:
                            continue
                        else:
                            A[h][w] -= 1
                            A[h + 1][w] += 1
                            res.append([h + 1, w + 1, h + 2, w + 1])
                    else:
                        A[h][w] -= 1
                        A[h][w - 1] += 1
                        res.append([h + 1, w + 1, h + 1, w])
    print(len(res))
    for i in res:
        print(*i)



if __name__ == '__main__':
    resolve()


Measured memory_bytes: 30644
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

ans = True
for i in range(n-1):
    if h[i] > h[i+1]:
        ans = False

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n in O(log(n)) time

const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;

/*********** variables ************/
string S;
string day[] = {"resare", "esare", "remaerd", "maerd"};
int nums[] = {6,5,7,5};
/**********************************/


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

    reverse(ALL(S));
    int len = (int)S.size();
    S += "kkkkkkkkkkk";
    int ind = 0;
    while(ind < len) {
        bool found = false;
        REP(i, 4) {
            if(S.substr(ind, nums[i]) == day[i]) {
                ind += nums[i];
                found = true;
                break;
            }
        }
        if(!found) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 512