akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;



int main() {
  int N;
  cin>>N;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  bool can=true;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(vec.at(i)==vec.at(j)){
        can=false;
        break;
      }
    }
    if(can) continue;
    else break;
  }
  
  for(int i=0;i<N-1;i++){
    int S=vec.at(i).size();
    if(vec.at(i).at(S-1)!=vec.at(i+1).at(0)){
      can=false;
      break;
    }
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
       
 
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
using namespace std;
const int MAXN = 100005;
int main()
{
    string star;
    cin >> star;
    int ans = 0;
    for(int j, i = 0; i < star.size(); i = j)
    {
        ans++;
        j = i;
        while(j < star.size() && star[j] == star[i]) j++;
    }
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 512
s = input()
s = s[::-1]

words = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(4):
    words[i] = words[i][::-1]

cnt = 0
while cnt < len(s):
    for w in words:
        if s[cnt: cnt + len(w)] == w:
            cnt += len(w)
            break
    else:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fore(i,n,s) for(lli i=n;i>=s;i--)

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;

lli recpow(lli x, lli n)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % M, n / 2);
    else //n is odd
        return (x * recpow((x * x) % M, (n - 1) / 2)) % M;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.second < b.second);
}

bool comp(pair<lli, lli> a, pair<lli, lli> b)
{
    if(a.first==b.first)
        return a.second<b.second;
    else
        return a.first<b.first;
}

//code begins here
int main()
{
    fast_io;
    string s,t;
    cin>>s>>t;
    lli m=s.length(), n=t.length();
    pair<lli, pair<lli, lli>> l[m+1][n+1];
    forz(i,0,n+1)
    l[0][i]={0,{0,0}};
    forz(i,0,m+1)
    l[i][0]={0,{0,0}};
    forz(i,1,m+1)
    {
        forz(j,1,n+1)
        {
            if(s[i-1]==t[j-1])
            {
                l[i][j]={1+l[i-1][j-1].first, {i-1,j-1}};
            }
            else
            {
                // l[i][j]=max(l[i-1][j], l[i][j-1]);
                if(l[i-1][j]>=l[i][j-1])
                {
                    l[i][j]={l[i-1][j].first, {i-1,j}};
                }
                else
                {
                    l[i][j]={l[i][j-1].first, {i,j-1}};
                }
            }
            
        }
    }
    // forz(i,0,m+1)
    // {
    //     forz(j,0,n+1)
    //     cout<<l[i][j]<<" ";
    //     cout<<endl;
    // }
    
    lli i=m, j=n;
    string ans="";
    while(i!=0 and j!=0)
    {
        if(s[i-1]==t[j-1])
        ans.pb(s[i-1]);
        pair<lli, lli> temp=l[i][j].second;
        i=temp.first;
        j=temp.second;
       // cout<<i<<" "<<j<<endl;
    }
    if(ans.length()>0)
        fore(i, ans.length() - 1, 0)
        cout<< ans[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 211328
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int x,y,z; cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >>N;
  vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int count=0, first=1;
  while (count<=N){
    count++;
    first = vec.at(first-1);
    if (first==2){
      cout<<count<<endl;
      break;
    }
    if (first==1){
      cout << -1<<endl;
      break;
    }
    if (count==N){
      cout << -1<<endl;
    }
 
  }
}

Measured memory_bytes: 640
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ');
  buildMaxHeap(arr);
  console.log(' ' + arr.join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = (2 * i + 1)|0;
    right = (2 * i + 2)|0;
    if (left < n && Number(arr[left]) > Number(arr[largest])) largest = left;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };
  for (let i = Math.floor(n / 2 - 1); i >= 0; i=(i-1)|0) maxHeapify(i);
}



Measured memory_bytes: 88300
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Main main = new Main();

		int n = scan.nextInt();
		int a[] = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = scan.nextInt();
		}

		int v;
		int j;
		main.print(a);

		for(int i = 1 ; i < n ; i++) {
			v = a[i];
			j = i-1;
			while(j >= 0 && a[j] > v) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = v;
			main.print(a);
		}

	}

	private void print(int[] a) {

		System.out.print(a[0]);
		for(int i = 1 ; i < a.length ; i++) {

			System.out.print(" " + a[i]);

		}
		System.out.println();
	}
}



Measured memory_bytes: 31412
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  
  if(A%3==0 || B%3==0 || (A+B)%3==0){
    cout << "Possible" << endl;
  }else {cout << "Impossible" << endl;}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n, a[N];
LL sum[N];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum[i] = sum[i-1] + a[i];
    }
    LL ans = 1e18;
    for(int i = 1; i < n; i++) {
        ans = min(ans, abs(sum[n] - sum[i] - sum[i]));
    }
    printf("%lld\n", ans);
    return 0;
}


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

const int MAXN = 105;

char s[MAXN];
int N, K;

int main(){
	scanf("%s %d", s, &K);
	N = strlen(s);
	
	int x = 1, y = 1;
	while(x < N && s[x] == s[0])x++;
	while(y < N && s[N - y - 1] == s[N - 1])y++;
	
	if(x == N){
		printf("%lld\n", 1LL * N * K / 2);
	}else if(s[0] != s[N - 1]){
		int z = 1, r = 0;
		for(int i = 1; i < N; i++){
			if(s[i] == s[i - 1]){
				z++;
			}else{
				r += z / 2;
				z = 1;
			}
		}
		r += z / 2;
		printf("%lld\n", 1LL * r * K);
	}else{
		int z = 1, r = 0;
		for(int i = x + 1; i < N - y; i++){
			if(s[i] == s[i - 1]){
				z++;
			}else{
				r += z / 2;
				z = 1;
			}
		}
		r += z / 2;
		
		long long res = 1LL * r * K;
		res += x / 2;
		res += y / 2;
		res += 1LL * (x + y) / 2 * (K - 1);
		printf("%lld\n", res);
	}
	
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int a,b;
    scan(a,b);
    writeln(a*b % 2 ? "Odd" : "Even");
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: i,n,x,ans
    integer(int64),parameter:: md=1000000007
    integer(int64), allocatable:: a(:), ma(:)

    read*, n
    allocate(a(n), ma(n))
    read*, a(:)
    x=0
    do i=n,2,-1
        x=mod(x+a(i), md)
        ma(i) = x
    end do
    ans=0
    do i=2,n
        ans=ans+mod(a(i-1)*ma(i),md)
    end do
    print'(i0)', mod(ans,md)

end program main

Measured memory_bytes: 6228
#!/usr/bin/python3

import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys


def main():
    N, M = read_ints()
    A = read_ints()
    B = [(l, r) for l, r in [read_ints() for _ in range(M)]]
    print(solve(N, M, A, B))


def solve(N, M, A, B):
    B.sort()
    bi = 0
    dp = [0] * (N + 1)
    range_counts = []
    range_starts = []
    ri = 0
    range_map = {}
    end_map = {}
    for i in range(1, N + 1):
        while bi < len(B) and B[bi][0] == i:
            l, r = B[bi]
            if l not in range_map:
                range_map[l] = len(range_counts)
                range_counts.append(0)
                range_starts.append(l)
            range_counts[range_map[l]] += 1
            if r not in end_map:
                end_map[r] = []
            end_map[r].append(range_map[l])
            bi += 1

        li = i - 1
        if ri < len(range_counts):
            li = range_starts[ri] - 1
        dp[i] = max(dp[i - 1], dp[li] + A[i - 1])

        if i in end_map:
            for rangei in end_map[i]:
                range_counts[rangei] -= 1
        while ri < len(range_counts) and range_counts[ri] == 0:
            ri += 1

    return dp[-1]


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 78408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
using namespace std;

int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << setprecision(15) << (long double) W*H/2;
    cout << ' ' << (x*2==W && y*2==H ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
class Heap
  attr_accessor :id, :key, :pk, :lk, :rk

  def initialize(id, key, max)
    @id = id.to_i + 1
    @key = key
    set_parent unless @id == 1
    set_left if @id * 2 <= max
    set_right if @id * 2 + 1 <= max
  end

  def set_parent
    @pk = id / 2
  end 

  def set_left 
    @lk = id * 2
  end

  def set_right
    @rk = id * 2 + 1
  end 

end

n = gets.to_i
keys = Array.new(n)
keys = gets.split
heap = Array.new(n)
n.times do |i|
  heap[i] = Heap.new(i,keys[i], n) 
end
n.times do |i|
  print "node ", heap[i].id, ": key = ", heap[i].key, ", "
  print "parent key = ", heap[heap[i].pk-1].key, ", " unless heap[i].pk.nil?
  print "left key = ", heap[heap[i].lk-1].key, ", " unless heap[i].lk.nil?
  print "right key = ", heap[heap[i].rk-1].key, ", " unless heap[i].rk.nil?
  puts
end

Measured memory_bytes: 8812
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        if (k <= a) {
            System.out.println(k);
            return;
        }
        if (k <= a + b) {
            System.out.println(a);
            return;
        }
        System.out.println(a - (k - a - b));
    }

}

Measured memory_bytes: 35548
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<typeinfo>
#include<sstream>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int in()
{
	int x;cin>>x;
	return x;
}
int stringInt(string a)
{
	return atoi(a.c_str());
}
string intString(int a)
{
	stringstream ss;
	ss<<a;
	return ss.str();
}
vector<int> SieveOfEratosthenes(int x)
{
	vector<int> a;
	vector<int> b(x+1,0);
	for(int i=2;i<=x;i++)
	{
		if(b[i]==0)
		{
			a.push_back(i);
			for(int l=i;l<=x;l+=i)
			{
				b[l]=1;
			}
		}
	}
	return a;
}

int main ()
{
	int d;
	while(cin>>d&&d)
	{
		int n,m;
		int ans=0;
		vector<int> a;
		a.push_back(0);
		cin>>n>>m;
		rep(i,n-1)a.push_back((int)in());
		sort(a.begin(),a.end());
		rep(i,n)a.push_back(a[i]+d);
		rep(i,m)
		{
			int x;
			cin>>x;
			int al=999999999;
			vector<int>::iterator t1,t2,t3,t4;
			t1=lower_bound(a.begin(),a.end(),x);
			t2=upper_bound(a.begin(),a.end(),x);
			t3=lower_bound(a.begin(),a.end(),x+d);
			t4=upper_bound(a.begin(),a.end(),x+d);
			if(t1!=a.begin()&&t1!=a.end())al=min(al,(int)abs((int)(*(t1-1)-x)));
			if(t2!=a.begin()&&t2!=a.end())al=min(al,(int)abs((int)(*t2-x)));
			if(t3!=a.begin()&&t3!=a.end())al=min(al,(int)abs((int)(*(t3-1)-(x+d))));
			if(t4!=a.begin()&&t4!=a.end())al=min(al,(int)abs((int)(*t3-(x+d))));
			ans+=al;
		}
		cout<<ans<<endl;
	}

}

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

int main(){
  int a,b, c;
  cin >> a >> b >> c;
  if(a == b && b==c){cout << "No" << endl;
                    return 0;}
  if(a != b && b!=c && c!=a){cout << "No" << endl;
                            return 0;}
  cout << "Yes" << endl;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	while(a != 0 || b != 0){
		if(a < b)
			cout << a << " " << b << endl;
		else
			cout << b << " " << a << endl;
		cin >> a >> b;
	}
}


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

int main() {
	int N, K;
	static long Imos[2010][2010] = {}, ans = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if (c == 'B') {
			x = x % (K * 2);
			y = y % (K * 2);
		}
		else {
			x = (x + K) % (K * 2);
			y = y % (K * 2);
		}
		if (x < K == y < K) {
			x = x % K;
			y = y % K;
			Imos[0][0]++;
			Imos[0][y + 1]--;
			Imos[x + 1][0]--;
			Imos[x + 1][y + 1]++;
			Imos[x + 1][y + 1]++;
			Imos[x + 1][y + K + 1]--;
			Imos[x + K + 1][y + 1]--;
			Imos[x + K + 1][y + K + 1]++;
			Imos[x + K + 1][0]++;
			Imos[x + K + 1][y + 1]--;
			Imos[K * 2][0]--;
			Imos[K * 2][y + 1]++;
			Imos[0][y + K + 1]++;
			Imos[0][K * 2]--;
			Imos[x + 1][y + K + 1]--;
			Imos[x + 1][K * 2]++;
			Imos[x + K + 1][y + K + 1]++;
			Imos[x + K + 1][K * 2]--;
			Imos[K * 2][y + K + 1]--;
			Imos[K * 2][y + K + 1]++;
		}
		else {
			x = x % K;
			y = y % K;
			Imos[x + 1][0]++;
			Imos[x + 1][y + 1]--;
			Imos[x + K + 1][0]--;
			Imos[x + K + 1][y + 1]++;
			Imos[0][y + 1]++;
			Imos[0][y + K + 1]--;
			Imos[x + 1][y + 1]--;
			Imos[x + 1][y + K + 1]++;
			Imos[x + K + 1][y + 1]++;
			Imos[x + K + 1][y + K + 1]--;
			Imos[K * 2][y + 1]--;
			Imos[K * 2][y + K + 1]++;
			Imos[x + 1][y + K + 1]++;
			Imos[x + 1][K * 2]--;
			Imos[x + K + 1][y + K + 1]--;
			Imos[x + K + 1][K * 2]++;
		}
	}
	for (int i = 0; i < K * 2; i++) {
		for (int j = 1; j < K * 2; j++) {
			Imos[i][j] += Imos[i][j - 1];
		}
	}
	for (int i = 0; i < K * 2; i++) {
		for (int j = 1; j < K * 2; j++) {
			Imos[j][i] += Imos[j - 1][i];
		}
	}
	for (int i = 0; i < K * 2; i++) {
		for (int j = 0; j < K * 2; j++) {
			ans = max(ans, Imos[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 31616
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int x[4];
	int sum = 0;
	int min, sec;
	
	for (int i = 0; i < 4; i++){
		scanf("%d", &x[i]);
		sum += x[i];
	}
	
	min = sum / 60;
	sec = sum % 60;
	
	printf("%d\n%d\n", min, sec);
	
}

Measured memory_bytes: 1184
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

map<pii,int> mp;

int fl(int n)
{
    return n%10;
}

int ff(int n)
{
    int d;
    for(;n;d=n%10,n/=10);

    return d;
}

void solve()
{
    int n;
    cin>>n;

    int ans=0;
    int first,last;
    for(int i=1;i<=n;++i)
    {
        first=ff(i);
        last=fl(i);

        if(first==last)
            ++ans;

        ans+=2ll*mp[{last,first}];

        ++mp[{first,last}];
    }

    cout<<ans;
}

int32_t main()
{
    fast();

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

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
char s[4005];
ll ans;
int main(){
	int n,a[3]={};
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='R') a[0]++;
		else if(s[i]=='G') a[1]++;
		else a[2]++;
	} 
	ans=(ll)a[0]*a[1]*a[2];
	for(int i=1;i<n;i++)
		for(int d=1;i+d+d<=n;d++)
			if((s[i]^s[i+d]^s[i+d+d])==('R'^'G'^'B')) --ans;
	printf("%lld\n",ans);
	return 0;
}
	


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y);
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=a[0];
    for(int i=1;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}
int gcd(int x, int y){
    if(y==0)return x;
    else return gcd(y,x%y);
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n[1];
  cin >> n[0] >> n[1] >> n[2];
  sort(n, n + 3);
  cout << n[0] << ' ' << n[1] << ' ' << n[2] << endl;
  return 0;
}

Measured memory_bytes: 3120
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int N, K;
    cin >> N >> K;
    int count[2 * K][K];
    fill(count[0], count[2 * K], 0);
    for (int i = 0; i < N; i++) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if ((x / K + y / K) % 2 == 0) {
            if (c == 'B') {
                count[x % K][y % K]++;
            } else {
                count[x % K + K][y % K]++;
            }
        } else {
            if (c == 'B') {
                count[x % K + K][y % K]++;
            } else {
                count[x % K][y % K]++;
            }
        }
    }

    for (int i = 2*K-1; i >= 0; i--) {
        for (int j = K-1; j >= 0; j--) {
            if (i == 2*K-1 && j == K-1) {
                continue;
            } else if (i == 2*K-1) {
                count[i][j] += count[i][j+1];
            } else if (j == K-1) {
                count[i][j] += count[i+1][j];
            } else {
                count[i][j] += count[i+1][j] + count[i][j+1] - count[i+1][j+1];
            }
        }
    }

    int mx = 0;
    // blackの左下が (i, j)
    for (int i = 0; i < 2*K; i++) {
        for (int j = 0; j < K; j++) {
            int ans = 0;
            if (i < K) {
                ans += count[i][j] - count[i+K][j];
                ans += count[0][0] - count[i][0] - count[0][j] + count[i][j];
                ans += count[i+K][0] - count[i+K][j];
            } else {
                ans += count[i][j];
                ans += count[i-K][0] - count[i][0] - count[i-K][j] + count[i][j];
                ans += count[0][j] - count[i-K][j];
            }
            mx = max(mx, ans);
        }
    }

    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 8064
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;
 
const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 0, 1,-1};
const int dy4[6] = {1, -1, 0,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};

void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}
 
ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 1e5 + 15;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
/*************************************************************************/


void solve() {
    double x;
    cin>>x;
    double ans = (x/3)*(x/3)*(x/3);
    printf("%.10lf\n",ans );
}

int main()
{   

    solve();
    return 0;
 
}
 

Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
a,f=[gets,gets].map{|x|x.split.map(&:to_i).sort}
p (0..(a.max*f.max)).bsearch{|x|
  t=0
  f.each_with_index{|f,i| t += a[n-1-i] < x / f ? 0 : (a[n-1-i]-x/f)}
  t <= k
}


Measured memory_bytes: 34644
#include <iostream>
using namespace std;
int main(){
  long long n;
  long long a,b;cin>>n>>a>>b;
  n = n%12;
  for(int i = 0; n > i; i++){
    if(i%2){
      b = a+b;
    }else{
      a = a-b;
    }
    //cout << a << " " << b << endl;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 3120
#include <iostream> 
using namespace std; 
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long int
#define REPI(a, b, i, inc) for(ll i = a; i < b; i = i + inc)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define F first
#define S second
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define testi ll t; cin>>t; REP(tc,1,t+1)
#define vec vector
#define veci vector<ll>
#define pi pair<ll,ll>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define uset unordered_set
#define umap unordered_map

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int n,k,m;
	cin>>n>>k>>m;
	cout<< (k/m - (n-1)/m);

        return 0;
    }

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

int main() {
  int n,count=0;
  string s="none";
  cin>> n;
  vector<int> v(n,0);
  r(i,n)cin >> v[i];
  r(i,n-1){
    if(v[i]<v[i+1]&&s!="positive"){
      if(s!="none"){
        count++;
        s="none";
      }
      else s="positive";
    }
    if(v[i]>v[i+1]&&s!="negative"){
      if(s!="none"){
        count++;
        s="none";
      }
      else s="negative";
    }
  }
  cout << count+1<<endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

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

int n;
int x[24];
int y[24];
int r[24];
int c[24];
int memo[1 << 24];

bool intersect(int i, int j){
  int dx = x[i] - x[j];
  int dy = y[i] - y[j];
  if(dx * dx + dy * dy < (r[i] + r[j]) * (r[i] + r[j])) return true;
  else return false;
}

int dfs(int state){
	if(memo[state] >= 0){
		return memo[state];
	}else{
		memo[state] = 0;
		bool top[24];
		fill(top, top + 24, true);
		rep(i,n){
			rep(j,i){
				if((state&(1<<i)) && (state&(1<<j)) &&intersect(i,j)) top[i]=false;
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < i; j++){
				if( (state&(1<<i)) && (state&(1<<j)) && top[i] && top[j] && c[i]==c[j]){
					memo[state] = max(memo[state], 2 + dfs(state ^ (1 << i) ^ (1 << j)));
				}
			}
		}
		return memo[state];
	}
}
  

int main(){
  while(cin >> n && n){
    memset(memo, -1, sizeof(memo));
    rep(i,n)cin>>x[i]>>y[i]>>r[i]>>c[i];
    cout<<dfs((1<<n)-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
X,Y = map(int,input().split())
if((-X+2*Y)%3 != 0 or (-Y+2*X)%3 != 0 or -X+2*Y<0 or -Y+2*X<0):
    print(0)
    exit()
A = (-X+2*Y)//3
B = (-Y+2*X)//3
mod = 10**9+7
def combinations_count(A,B):
    bunsi,bunbo = 1,1
    for i in range(1,A+1):
        bunsi = (bunsi*(B+i))%mod
        bunbo = (bunbo*i) % mod
    return (bunsi*pow(bunbo,mod-2,mod))%mod
ans = combinations_count(A,B)
print(ans)

Measured memory_bytes: 3064
function main(k, l, r) {
  	let quo1=Math.floor(l/k);
 	let quo2=Math.floor(r/k);
 	let rem=l%k;
 	
  	if(rem==0)
 	{
   		count=quo2-quo1+1;
 	}
 	else
 	{
    	count=quo2-quo1;
  	}

  	if(count === 0) {
    	console.log("NG");
    } else {
    	console.log("OK");
    }
}
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const [l , r] = input[1].split(" ").map(x=> parseInt(x));

main(parseInt(input[0]), l , r);


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010

const ll mod = 1e9+7;

int main() {
    int n, m;
    int tmp;

    cin >> n >> m;
    vector<int> ok(n+1, true);
    
    for(int i=0; i<m; i++) {
        cin >> tmp;
        ok[tmp] = false;
    }

    vector<ll>dp(n+1);
    dp[0] = 1;
    
    for(int  now=0; now<n;++now) {
        for(int next=now+1; next<=min(now+2, n); ++next ) {
            if (ok[next]) {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"

typedef long long int lli;

using namespace std;

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

	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D >> S;
	S = "#" + S + "#";

	for (int i = A; i < C; i++)
	{
		if (S[i] == '#'&&S[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = B; i < D; i++)
	{
		if (S[i] == '#'&&S[i + 1] == '#') {
			cout << "No" << endl;
			return 0;
		}
	}

	if (C < D) {
		cout << "Yes" << endl;
		return 0;
	}

	if (C > D) {
		for (int i = B; i <= D; i++)
		{
			if (S[i - 1] == '.'&&S[i] == '.'&&S[i + 1] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}

}

Measured memory_bytes: 720
def main():
    A, B = map(int, input().split())
    if A == B:
        print('Draw')
    elif A == 1:
        print('Alice')
    elif B == 1:
        print('Bob')
    elif A < B:
        print('Bob')
    else:
        print('Alice')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
O = input()
E = input()

if len(O) - len(E) == 0:
    for i in range(len(O)):
        print(O[i]+E[i],end="")
else:
    print(O[0],end="")
    for i in range(1,len(O)):
        print(E[i-1]+O[i],end="")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <set>
using std::vector;
using namespace std;

int main(){
  string S;
  cin >> S;
  int N = (int)S.size();
  int ans = 0;
  int cnt = 0;
  for(int i = 0 ; i < N; ++i){
    if(S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G'){
      ++cnt;
    }
    else cnt = 0;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin >> k;
  cin >> s;
  if(k>=s.size()){
    cout << s << endl;
  }else{
    string t;
    for (int i = 0;i<k;i++){
      t +=s.at(i);
    }
    t+="...";
    cout << t << endl;
  }
  
}

Measured memory_bytes: 3632
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N = int(stdin.readline().rstrip().split()[0])
S=[]
for i in range(N):
  s, p = [x for x in stdin.readline().rstrip().split()]
  S.append(s+str(999-int(p)))
# print(S)
Sidx=sorted(S)
# print(S)
# print(Sidx)
for i in range(N):
  print(S.index(Sidx[i])+1)


Measured memory_bytes: 21524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll n, d, x, y, ans = 0;
  // set<pair<ll, ll> > s;
  
  cin >> n >> d;
  
  while(n--)
  {
    cin >> x >> y;
    if(/*s.count({x, y}) == 0 &&*/ x*x+y*y <= d*d)
    {
      ans++;
      // s.insert({x, y});
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const unsigned int mod = 1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    
    int n,num,val;
    cin >> n;
    ll a[n];
    ll pref[n];
    cin >> num;
    a[0] = num;
    pref[0]= num;
    for(int i = 1; i < n; i++)
    {
        cin >> val;
        val = val % mod;
        a[i] = val;
    }
    for(int i = 0; i < n; i++)
    {
        if(i == 0)
        {
            pref[i] = a[i] % mod;
        }
        else
        {
            pref[i] = (pref[i-1] + a[i]) % mod;
        }
    }
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        ll m;
        m = (a[i]*(pref[n-1] - pref[i])) % mod;
        sum += m;
        sum = sum % mod;
    }
    if(sum < 0){
        cout << (sum + mod) << "\n" ;
    }
    else{
        cout << sum << "\n" ;
    }
}


Measured memory_bytes: 6728
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(20)

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;



int main(){
  string s;
  cin>>s;
  int dif = 753;
  int len = s.size();
  rep(i,len-3+1){
    string tmp = s.substr(i,3);//i番目から3要素抜き出した。
    int num = abs(753 - stoi(tmp));
    dif = min(num,dif);
  }
  cout<<dif<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	string s="ACGT",t="TGCA";
	char a;
	cin>>a;
	for(int i=0;i<4;i++)
	{
		if(a==s[i])cout<<t[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int r;
    cin >> r;
    cout << setprecision(15) << 2 * M_PI * r << endl;
    return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

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


Measured memory_bytes: 3624
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <unordered_set>
#include<unordered_map>
#include <random>
#include <valarray>
//#include <fstream>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll n,m;
    cin>>n>>m;
    if((n+m)>16 || n>8 || m>8 )
    {
        cout<<":("<<endl;
    }
    else
    {
        cout<<"Yay!"<<"\n";   
    }
    
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

Measured memory_bytes: 256
n, T = map(int, input().split())
t = list(map(int, input().split()))
ans = 0
tmp = t[0]
for i in range(1, n):
    if t[i] > t[i-1] + T:
        ans += t[i-1] - tmp + T
        tmp = t[i]
ans += t[n-1] - tmp + T
print(ans)

Measured memory_bytes: 26708
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
void ckmx(int &a, int b){ if(a < b) a = b; }
cs int Mod = 998244353;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
void Add(int &a, int b){ a = add(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
cs int N = 305;
int n; char S[N];
int dp[N][N][N], ok[N][N][N];
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s",S+1); n=strlen(S+1);
	dp[n][0][0] = 1;
	for(int i=n; i>=1; i--)
	for(int j=0; j<=i; j++)
	for(int k=0,coe; j+k<=i; k++)
	if(coe=dp[i][j][k]){	
		Add(dp[i-1][j][k],coe);
		if(S[i]=='0')Add(dp[i][j][k+1],coe);
		if(S[i]=='1')Add(dp[i][j+1][k],coe);
	}
	memset(ok,-1,sizeof(ok));
	ok[0][0][0] = 0;
	for(int i=0; i<n; i++)
	for(int j=0; j<=i; j++)
	for(int k=0,coe; j+k<=i; k++)
	if(~(coe=ok[i][j][k])){
		ckmx(ok[i+1][j][k],coe);
		if(S[i+1]=='0'&&coe)ckmx(ok[i+1][j+1][k],coe-1);
		if(S[i+1]=='1'&&coe)ckmx(ok[i+1][j][k+1],coe-1);
		if(i+1<n){
			ckmx(ok[i+2][j][k],coe+1);
			if(S[i+1]=='0'||S[i+2]=='0')ckmx(ok[i+2][j+1][k],coe);
			if(S[i+1]=='1'||S[i+2]=='1')ckmx(ok[i+2][j][k+1],coe);
		}
	} int ans = 0;
	for(int i=0; i<=n; i++)
	for(int j=0; j<=i; j++)
	for(int k=0,t; j+k<=i; k++)
	if(ok[i][j][k]>=0 && n-i+j+k>0)
	Add(ans,dp[i][j][k]);
	cout << ans; return 0;
}

Measured memory_bytes: 169716
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int _compare(const void *a, const void *b) {
	if(*(int *)a < *(int *)b)
		return -1;
	else if(*(int *)a == *(int *)b)
		return 0;
	else
		return 1;
}

void getInput(int *data, long long int data_cnt, long long int str_size) {
	long long int i, N;
	char str[str_size], *tok;

	i = 0;
	N = data_cnt;
	gets(str);
	tok = strtok(str, " ");
	data[i++] = atoi(tok);
	for(; i < N; i++) {
		tok = strtok(NULL, " ");
		if(tok == NULL)
			break;
		data[i] = atoi(tok);
	}
}

int main(void) {
	int d[100000];
	long long int num, i, l1 = 0, l2 = 0;

	scanf("%lld", &num);
	getchar();
	getInput(d, num, 10 * 200000);

	qsort(d, num, sizeof *d, _compare);
	for(i = num - 1; i >= 1; i--) {
		if(d[i] == d[i - 1]) {
			if(l1 == 0 && l2 == 0)
				l1 = d[i--];
			else if(l2 == 0) {
				l2 = d[i--];
				break;
			}
		}
	}

	if(l2 == 0)
		printf("0");
	else
		printf("%lld", l1 * l2);

	return 0;
}

Measured memory_bytes: 1916
import java.util.Scanner;
class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		int pret = 0,prex = 0,prey = 0;
		boolean f = true;
		for (int i = 0; i < n; i ++) {
			int t = scan.nextInt();
			int x = scan.nextInt();
			int y = scan.nextInt();

			int d = Math.abs(x - prex) + Math.abs(y - prey);

			int dt  = t - pret;

			if(dt < d || (dt - d) % 2 == 1){
				f =false;
				break;
			}
			pret = t;prex = x;prey = y;
		}

		if(f){
			System.out.println("Yes");
		}else
			System.out.println("No");
	}
}


Measured memory_bytes: 87324
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    vector<double> A(N);
    double cnt = 0;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
        cnt += A.at(i);
    }
    sort(A.begin(),A.end());
    double usi = cnt/(4*M);
    if(A.at(N-M) >= usi) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const int N=200100,powN=pow(2,ceil(log2(N)));
ll dp[N];
int h[N],a[N],n;
ll tree[2*powN];

ll update(int l,int r,int idx,int tl,int tr,ll d){
	if(l==tl&&r==tr)return tree[idx]=d; // got'em
	if(l>=tr||r<=tl)return tree[idx]; // out
	int md=(tl+tr)/2;
	return tree[idx]=max(update(l,r,2*idx,tl,md,d),update(l,r,2*idx+1,md,tr,d));
}

ll query(int l,int r,int idx,int tl,int tr){
	if(l<=tl&&r>=tr)return tree[idx]; // in
	if(l>=tr||r<=tl)return 0; // out
	int md=(tl+tr)/2;
	return max(query(l,r,2*idx,tl,md),query(l,r,2*idx+1,md,tr));
}

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n;
	for(int i=0;i<n;++i)cin>>h[i];
	for(int i=0;i<n;++i)cin>>a[i];
	for(int i=0;i<n;++i){
		ll mx=query(0,h[i],1,0,powN);
		update(h[i]-1,h[i],1,0,powN,mx+a[i]);
	}
	ll res=0;
	for(int i=powN;i-powN<n;++i)res=max(res,tree[i]);
	cout<<res<<endl;
}


Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    ll D, T, S;
    cin >> D >> T >> S;
    bool bl = (D <= S * T);
    puts(bl ? "Yes" : "No");
    return 0;
}

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

using namespace std;

int main(){
	string a;
	cin >> a;
	int cnt=0;
	int mx=0;
	for(int i =0;i<3;++i){
        if(a[i]=='R'){
            cnt++;
            if(cnt>mx) mx = cnt;
        }
        if(a[i]=='S') cnt=0;

	}
	cout << mx;
	return 0;
}


Measured memory_bytes: 3620
dur=int(input())
c=list(map(int,input().split()))
d=[0]*26
r=1.5
for i in range(dur):
  t=0
  s=list(map(int,input().split()))
  m=-1<<64
  for j in range(26):
    alt=s[j]+r*c[j]*(i+1-d[j])+sum([-r*c[k]*(i+1-d[k]) for k in range(26)])
    if alt>m:
      m=alt
      t=j
  print(t+1)
  d[t]=i+1


Measured memory_bytes: 69728
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


struct item {
  int v, w;
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a = {{0, 0}};
  vector<item> c;
  c.reserve(1<<sz(is));
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
    c.clear();
  }
  return a;
}


int solve(const vector<item> &a, const vector<item> &b, int W) {
  int ans = 0;
  int vbmax = -INF;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), {0, 0});

  const int m = 10;
  int M = 1<<m;
  chmin(M, n+1);
  vector<vector<item>> pre(M);
  pre[0] = {{0, 0}};
  rep2(i, 1, M) {
    auto a = pre[i/2];
    for (auto &e : a) e += is[i];
    merge(all(pre[i/2]), all(a), back_inserter(pre[i]));
  }
  rep(i, M) reverse(all(pre[i]));

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v >= M) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(pre[v], enum_powerset(qi), l) << '\n';
  }
}


Measured memory_bytes: 10660
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = list(map(int, input().split()))
n = int(input())
from collections import defaultdict
mind = [10**15] * h
dw = defaultdict(list)
for i in range(n):
    r,c,a = map(int, input().split())
    r -= 1
    c -= 1
    mind[r] = min(mind[r], a)
    dw[c].append((a,r))
# 0未満になる要素があるか判定
es = [[] for _ in range(h)]
def main():
    ans = True
    for c in range(w):
        if len(dw[c])<=1:
            continue
        dw[c].sort()
        tmp = 0
        for i in range(len(dw[c])-1):
            u = dw[c][i][1]
            v = dw[c][i+1][1]
            val = dw[c][i+1][0] - dw[c][i][0]
            es[u].append((val, v))
            es[v].append((-val, u))
            tmp += val
            if mind[v]<tmp:
                return False
#     print(es)
#     print(dw)
    vals = [None]*h
    for start in range(h):
        if vals[start] is not None:
            continue
        q = [start]
        vals[start] = 0
        l = [(0, mind[start])]
        while q:
            u = q.pop()
            for d,v in es[u]:
                if vals[v] is None:
                    vals[v] = vals[u] + d
                    l.append((vals[v], mind[v]))
                    q.append(v)
                elif vals[v]!=vals[u]+d:
                    return False
        l.sort()
        for i in range(len(l)):
            if l[i][1]<l[i][0]-l[0][0]:
                return False
#     for u in range(h):
#         for d,v in es[u]:
#             if vals[u]+d!=vals[v]:
#                 return False
    return True
ans = main()
if ans:
    print("Yes")
else:
    print("No")

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

int main(){
  const double PI=3.14159265358979323846;
  int n;
  cin >> n;
  cout << 2*n*PI << endl;
  return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int H, W;
	
	while (1)
	{
		cin >> H >> W;
		if (H==0 && W==0) return 0;
		
		for (int i=0; i<H; i++)
		{
			for (int j=0; j<W; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut d: Vec<i32> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    d.push(0);
    d.sort();

    let mut unko = Vec::new();
    for i in 0..n + 1 {
        if i % 2 == 0 {
            unko.push(d[i]);
        } else {
            unko.push((24 - d[i]) % 24);
        }
    }
    unko.sort();
    unko.push(24);

    let mut ans = 1 << 30;
    for i in 0..n + 1 {
        ans = min(ans, unko[i + 1] - unko[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352