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

#define         ull             unsigned long long
#define         ll              long long
#define         inf             INT_MAX
#define         pi              acos(-1.0)
#define         vi              vector<int>
#define         vl              vector<long long>
#define         pii             pair<int,int>
#define         pll             pair<long long,long long>
#define         mp              make_pair
#define         mii             map<int,int>
#define         mll             map<int,int>
#define         mli             multimap<int,int>
#define         mlll            multimap<long long,long long>
#define         msi             multiset<int>
#define         msl             multiset<long long>
#define         si              set<int>
#define         sl              set<long long>
#define         FOR(I,A,B)      for(int I = (A); I < (B); I++)
#define         rev(I,A,B)      for(int I = A ; I >= B ; I--)
#define         mem(a, v)       memset(a, v, sizeof (a))
#define         mod             1000000007
#define         all(a)          a.begin(),a.end()
#define         rall(a)         a.rbegin(),a.rend()
#define         ff              first
#define         ss              second
#define         arsort(ar,n)    sort(ar,ar+n);
#define         vsort(v)        sort(v.begin(),v.end())
#define         vrev(v)         reverse(v.begin(),v.end())
#define         arrev(ar,n)     reverse(ar,ar+n)
#define         pb              push_back
#define         popb            pop_back
#define         booster()       ios_base::sync_with_stdio(0); cin.tie(0);
#define         read(f)         freopen(f, "r", stdin)


#define         min3(a,b,c)     min(a,min(b,c))
#define         max3(a,b,c)     max(a,max(b,c))
#define         min4(a,b,c,d)   min(min(a,b),min(c,d))
#define         max4(a,b,c,d)   max(max(a,b),max(c,d))
#define         max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define         min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))


#define         bitCheck(a,k)     ((bool)(a&(1<<(k))))
#define         bitOff(a,k)       (a&(~(1<<(k))))
#define         bitOn(a,k)        (a|(1<<(k)))
#define         bitFlip(a,k)      (a^(1<<(k)))


int fx[] = {-1,+0,+1,+0,+1,+1,-1,-1,+0};
int fy[] = {+0,-1,+0,+1,+1,-1,+1,-1,+0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

using namespace std;

bool comp(int x, int y) { return x > y; }

/*********************** let the play begin() ***********************************/

int main()
{
    booster()
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)
        cout<<"Possible\n";
    else
        cout<<"Impossible\n";
    return 0;
}


Measured memory_bytes: 256
#!python3

import sys
sys.setrecursionlimit(10 ** 6)

MOD = 10 ** 9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


LI = lambda: list(map(int, input().split()))

# input
N = int(input())
AB = [LI() for _ in range(N - 1)]

# params
links = [[] for i in range(N)]
dp = [ModInt(1) for _ in range(N)]
c = [1] * N

MAX = 2 * (10 ** 5) + 5
fac, finv, inv = [None] * MAX, [None] * MAX, [None] * MAX


def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = -inv[MOD%i] * int(MOD / i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def create_links():
    for a, b in AB:
        links[a - 1].append(b - 1)
        links[b - 1].append(a - 1)
    return links


def dfs1(v, p=-1):
    for u in links[v]:
        if u == p:
            continue
        dfs1(u, v)
        c[v] += c[u]
        dp[v] *= dp[u]
        dp[v] *= finv[c[u]]
    dp[v] *= fac[c[v] - 1]


def dfs2(v, p=-1):
    for u in links[v]:
        if u == p:
            continue
        dp[u] = dp[v] * c[u] * inv[(N - c[u])]
        dfs2(u, v)


def main():
    comb_init()
    create_links()
    dfs1(0)
    dfs2(0)
    [print(ans) for ans in dp]


if __name__ == "__main__":
    main()


Measured memory_bytes: 174116
/*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     mt           make_tuple
#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=1e5+10;

vector<int> v[N],vis(N,0),dp(N,0);

void dfs(int x)
{
    vis[x]=1;

    for(auto c:v[x])
    {
        if(!vis[c])
            dfs(c);

        dp[x]=max(dp[x],dp[c]+1);
    }
}

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

    int a,b;
    for(int i=0;i<m;++i)
    {
        cin>>a>>b;
        v[a].pb(b);
    }

    for(int i=1;i<=n;++i)
    {
        if(!vis[i])
            dfs(i);
    }

    int ans=0;
    for(int i=1;i<=n;++i)
        ans=max(ans,dp[i]);

    cout<<ans;
}

int32_t main()
{
    fast();

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

    return 0;
}




Measured memory_bytes: 9344
#include<cstdio>
int a[100005];
int abs(int x) {return x>0?x:-x;}
int main()
{
	int n,ans=0;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),ans+=abs(a[i]-a[i-1]);
	ans+=abs(a[n]);
	for(int i=1;i<=n;i++) printf("%d\n",ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1])); 
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N=0,K=0;
  long long sum=0;
  cin >> N >> K;
  vector<int> vec(N);
  
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
    sum+=vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  if(K!=0 && N>K){
    for(int i=0;i<K;i++){
      sum-=vec.at(i);
  }
  }
  else if(N<=K){
   sum=0;
  }

  cout << sum << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
   int a,b;
   scanf("%d %d",&a,&b);
   char A[a];
   char B[b];

   if(a>b){
      for(int i=0;i<a;i++){
         printf("%d",b);
      }
   }else{
      for(int i=0;i<b;i++){
         printf("%d",a);
      }
   }
      
   return 0;
}
      


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

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

const int mod = (int)1e9 + 7;
const int MAXN = 1e5+12;
//indexed_set s;

int x;

int main() {

    cin >> x;
    if (x >= 30) cout << "Yes";
    else cout << "No";

return 0;
}


Measured memory_bytes: 3592
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0
n = inp()
p = inpl()

for i in range(1,n-1):
    temp = sorted([p[i-1],p[i],p[i+1]])
    if temp[1] == p[i]:
        ans += 1
print(ans)

Measured memory_bytes: 21996
uses math;
var
	N,i,j:Longint;
	ans:int64;
begin
	read(N);
	j:=floor(sqrt(N));
	if j*j>N then dec(j);
	for i:=1 to j do inc(ans,(N div i)*(N div i+1)*i-i*i*i);
	writeln(ans);
end.

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

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

void fastscan(ll &number)
{
	bool negative = false;
	register int c;
	number = 0;
	c = getchar();
	if (c=='-') 
	{
		negative = true;
		c = getchar();
	}
	for (; (c>47 && c<58); c=getchar())
		number = number *10 + c - 48;
	if (negative)
		number *= -1;
}

bool isprime(ll n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

bool checkisTree(ll degree[],ll n) 
{
    ll deg_sum = 0; 
    for (ll i = 0; i < n; i++) 
        deg_sum += degree[i]; 
    return (2*(n-1) == deg_sum);
}

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

}
int main()
{
	cin.sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n, d;
      	cin>>n>>d;
      	cout<<ceil(n/(float)(2*d + 1));
	}
	
}

Measured memory_bytes: 256
def slove():
    import sys
    import heapq
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    bc = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    heapq.heapify(a)
    for b, c in bc:
        for i in range(b, 0, -1):
            p = heapq.heappop(a)
            if p < c:
                heapq.heappush(a, c)
            else:
                heapq.heappush(a, p)
                print(sum(a))
                exit()
    print(sum(a))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 91264
import java.util.*;
import java.io.*;

public class Main {
	final static int MOD = 1000000007;
	final static int intMax = 1000000000;
	final static int intMin = -1000000000;
	final static int[] dx = { 0, 0, -1, 1 };
	final static int[] dy = { -1, 1, 0, 0 };

	static int T;

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[360]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
	
	public static void main(String[] args) throws Exception {
		Reader in = new Reader();
		int N = in.nextInt();
		int K = in.nextInt();
		int h[] = new int[N];
		for(int i = 0; i < N; ++i) {
			h[i] = in.nextInt();
		}
		int[] dp = new int[N];
		Arrays.fill(dp, intMax);
		dp[0] = 0;
		for(int i = 1; i < N; ++i) {
			for(int j = i - 1; j >= Math.max(0, i - K); --j) {
				dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[i] - h[j]));
			}
		}
		System.out.println(dp[N - 1]);
		in.close();
	}
}

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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var ans = 100000;
        for (int i = 0; i <= N; ++i)
        {
            var cost = 0;
            //6進数
            cost += GetCost(i,6);
            //9
            cost += GetCost(N-i,9);
            ans=Math.Min(ans,cost);
        }
        Console.WriteLine(ans);
    }
    static int GetCost(int originalNum,int dividedNum)
    {
        var cost = 0;
        while (0<originalNum)
        {
            cost += originalNum % dividedNum;
            originalNum /= dividedNum;
        }
        return cost;
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e5+5, M=5e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

ll n, arr[N], mem[N], k;
int solve(ll ind){
    if(ind == n-1) return 0;
    if(mem[ind] != -1) return mem[ind];
    ll ret = oo;
    for(int i=1; i<=k; i++){
        if(ind+i < n)
            ret = min(ret, solve(ind+i)+abs(arr[ind]-arr[ind+i]));
        else
            break;
    }
    return mem[ind] = ret;

}
int main()
{
    _69e27
    memset(mem, -1, sizeof mem);
    cin >> n >> k;
    for(int i=0; i<n; i++)
        cin >> arr[i];
    cout << solve(0);

    return 0;
}



Measured memory_bytes: 6528
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

int n ,x ;
long long ans ;
map<int,int> cnt ;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",&x);
        ++cnt[x] ;
    }
    for(auto go:cnt){
        if(go.first>go.second) ans += go.second ;
        else ans += go.second - go.first ;
    }
    cout << ans ;
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    if (a > 8 || b > 8)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
    return 0;
}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int a;
    cin >> a;
    if(a==1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
	//cout << "test" << endl;
	return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();

    let mut ans = 0;
    for i in s.trim().chars() {
        if i == '+' {
            ans += 1;
        } else {
            ans -= 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define MAX_N 100001


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;
int K;
int Q;

int score[MAX_N];

int main () {

	// 初期化
	memset(score, 0, sizeof(score));
	// 個数の読込み
	scanf("%d %d %d", &N, &K, &Q);
	// 数列 B
	for(int i = 0; i < Q; i++) {
		int x;
		scanf("%d", &x);
		score[x-1] ++;
	}
	
	//
	for(int i = 0; i < N; i++) {
		if(K - (Q - score[i]) <= 0)
			printf("No\n");
		else
			printf("Yes\n");
	}

	return 0;
}


Measured memory_bytes: 896
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=mp()
h=lmp()
ans=0
for i in range(n):
    if h[i]>=k:
        ans+=1
print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}

int main() {
  int n;
  cin >> n;
  vector <int64_t> v(3*n);
  rep(i,3*n) cin >> v.at(i);
  sort(v.begin(), v.end());
  int64_t ans = 0;
  rep(i, n) {
    ans += v.at(3*n-2-2*i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(ll H, ll W, ll d) {
  vector<string> res(H, string(W, '.'));
  if (d % 2 == 1) {
    REP(i,H) REP(j,W) {
      res[i][j] = ((i + j) % 2 ? 'R' : 'Y');
    }
  }
  else {
    REP(i,H) REP(j,W) {
      int jj = j + (i + j) % 2;
      int x = (i - jj + 2000) / 2;
      int y = (i + jj) / 2;
      x /= (d / 2);
      y /= (d / 2);
      x = x % 2;
      y = y % 2;
      // cout << x * 2 + y << endl;
      res[i][j] = "RYBG"[x * 2 + y];
    }
  }
  REP(i,H) cout << res[i] << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll H;
	ll d;
	ll W;
	scanf("%lld", &H);
	scanf("%lld", &W);
	scanf("%lld", &d);
	solve(H, W, d);
	return 0;
}


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

int main(void){
   int K,X; 
   cin >>K>>X;
   
   if(500*K>=X){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
   
  
}


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

int main() {
  int n;
  cin>>n;
  vector<tuple<string,int,int>> k(n);
  for (size_t i = 0; i < n; i++) {
    cin>>get<0>(k[i])>>get<1>(k[i]);
    get<1>(k[i])*=(-1);
    get<2>(k[i])=i+1;
  }
  sort(k.begin(),k.end());
  for (size_t i = 0; i < n; i++) {
    cout<<get<2>(k[i])<<endl;
  }
}

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

using namespace std;

int main()
{
	int n, l = 0;
	cin >> n;
	string s;
	cin >> s;
	vector <char> v;
	for (int i = 0; i < n; i ++)
	{
		if (s[i] != s[i - 1])
			v.push_back(s[i]);
	}
	cout << v.size();
}



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

const int INF = 1001001001;
vector<int> to[100005];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;//0からスタートだから頂点番号をデクリメント
    to[a].push_back(b);//toというリストを各頂点ごとに持っておいてaに繋がってる頂点のリスト
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);//直前の頂点を持つ
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v]+1;
      pre[u] = v;//直前の頂点を記録
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i,n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}
//BFSは同じ状態は一度しか通らないから計算量がDFSより少ない

Measured memory_bytes: 10572
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = sum(B)

for i in range(N):
    if B[N-1-i] >= A[N-i]:
        B[N-1-i] -= A[N-i]
        A[N-i] = 0
    else:
        A[N-i] -= B[N-i-1]
        B[N-i-1] = 0

    if B[N-1-i] > 0:
        if A[N-1-i] > B[N-1-i]:
            A[N-1-i] -= B[N-1-i]
            B[N-1-i] = 0
        else:
            B[N-1-i] -= A[N-1-i]
            A[N-1-i] = 0
    # print(A)
    # print(B)
    # print("=============")

print(ans-sum(B))


Measured memory_bytes: 24248
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main()
{
	int N;
	int cl_branks = 0;
	string S;
	string ans = "";
	stack<int> branks;
	cin >> N >> S;

	for (int i = 0; i < N; i++)
	{
		switch (S[i])
		{
		case '(':
			branks.push(i);
			break;

		case ')':
			if (branks.empty())
				cl_branks++;
			else
				branks.pop();
			break;
		}
	}

	for (int i = 0; i < cl_branks; i++)
		ans.push_back('(');

	for (int i = 0; i < N; i++)
		ans.push_back(S[i]);

	for (int i = 0; i < branks.size(); i++)
		ans.push_back(')');

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
void ABC167B()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (A + B >= K)
	{
		cout << min(A,K) << endl;
		return;
	}
	cout << A - (K - (A + B)) << endl;
}
int main()
{
	ABC167B();
	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric> 
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
///////////////////////////////////////////////////////////////////////

const int N = 1005;
const int MOD = 1e9 + 7;
char matrix[N][N];
vector<vector<int>> res(N, vector<int>(N, 0));

int main() {
    int row, col;
    scanf("%d%d", &row, &col);
    for (int i = 0; i < row; ++i) {
        scanf("%s", matrix[i]);
    }

    res[1][1] = 1;
    for (int i = 1; i <= row; ++i) {
        for (int j = 1; j <= col; ++j) {
            if (matrix[i - 1][j - 1] == '#') res[i][j] = 0;
            else res[i][j] += res[i - 1][j] + res[i][j - 1];
            res[i][j] %= MOD;
        }
    }

    printf("%d\n", res[row][col]);
}

Measured memory_bytes: 5248
#include <iostream>
using namespace std;
int main() {
    long n,m;
    cin>>n>>m;
    long a,b;
    long min=n, max =0;
    for(long i=0;i<m;i++)
    {
       cin>>a>>b;
       if(min>=b)
       min=b;
       if(max<=a)
       max=a;
    }
    if(max<=min)
    cout<<(min-max +1);
    else
    cout<<0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <map>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int n, m, t, x, y, p[200005], s[200005];
pair<int, pair<int, int>> a[200005], b[200005];

int f(int x)
{
    if (p[x] == x)
        return x;
    return p[x] = f(p[x]);
}

void g(int a, int b)
{
    if (f(a) == f(b))
        return;
    s[f(b)] += s[f(a)];
    p[f(a)] = f(b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;

    for (int i = 0; i <= n; ++i)
        p[i] = i, s[i] = 1;

    for (int i = 0; i < n; ++i)
    {
        cin >> x >> y;
        a[i] = {x, {y, i}};
        b[i] = {y, {x, i}};
    }

    sort(a, a + n);
    sort(b, b + n);

    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> q;
    for (int i = 1; i < n; ++i)
    {
        q.push({a[i].first - a[i - 1].first, {a[i].second.second, a[i - 1].second.second}});
        q.push({b[i].first - b[i - 1].first, {b[i].second.second, b[i - 1].second.second}});
    }



    ll c = 0;
    while (!q.empty())
    {
        auto t = q.top();
        q.pop();
        if (f(t.second.first) == f(t.second.second))
            continue;
        g(t.second.first, t.second.second);

        c += t.first;
        if (s[f(t.second.first)] == n)
            return cout << c << endl, 0;
    }
}

Measured memory_bytes: 10228
#include <stdio.h>

int main(void){
int i;
long int K;
long int x;
double n=1.01;
x=100;
 
scanf("%ld",&K);


for(i=1;i<5000;i++){
	x=x*n;
  if(K<=x){
	      printf("%d",i);
    break;
  }}

return 0;
  
}

Measured memory_bytes: 1732
#include <iostream>

int h,w;
bool s[55][55];
constexpr int X[4]={1,-1,0,0};
constexpr int Y[4]={0,0,1,-1};
int main(){
  std::cin>>h>>w;
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j){
      char input;
      std::cin>>input;
      s[i][j]=(input=='#')?true:false;
    }
  
  bool check;
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j){
      if(!s[i][j])
        continue;
      check=true;
      for(int k=0;k<4;++k)
        if(s[i+X[k]][j+Y[k]])
          check=false;
      if(check){
        std::cout<<"No"<<std::endl;
        return 0;
      }
    }
  std::cout<<"Yes"<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  int n,r;
  cin >> n >> r;
  if(n >= 10) cout << r << endl;
  else cout << r + 100*(10-n) << endl; //ir -100*(10-n)= r
return 0;
}

Measured memory_bytes: 3648
N = int(input())
AB = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[1])
CD = sorted([list(map(int,input().split())) for _ in range(N)])

cnt = 0
for c, d in CD:
  for a, b in AB:
    if(a < c and b < d):
      cnt += 1
      AB.remove([a,b])
      break
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

const int MAX = 100000;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(NULL);
  string S;
  cin >> S;
  int A[26]={0};
  int p=0;
  for(int i=0;i<S.size();i++){
    A[S[i]-'a']++;
    if(S[i]=='z') p=S[i]-'a';
  }
  int k=0;
  for(int i=0;i<26;i++){
    if(A[i]==0){
      k=i;
      cout << S << char(i+'a') << endl;
      return 0;
    }
  }
  if(S=="zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
    return 0;
  }
  string T=S,ans;
  next_permutation(T.begin(),T.end());
  for(int i=0; i<S.size();i++){
    ans+=T[i];
    if(S[i]!=T[i]) break;
  }
  cout << ans << endl;
}

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

int main()
{
    int X, Y;
    cin >> X >> Y;

    int base = 100'000;
    int res = 0;
    if (X <= 3)res += base * (4 - X);
    if (Y <= 3)res += base * (4 - Y);
    if (X == 1 && Y == 1)res += 4 * base;
    cout << res << endl;
    return 0;
}


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

const int MAX = 20000;
const int BASE = 10000;
const int INF = 1e9;
vector<int>vec[MAX];
vector<int>order;
int N;

void input(){
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    int x,y;
    cin >> x >> y;
    x += BASE;
    vec[x].push_back(y);
  }
  for(int i = 0 ; i < MAX ; i++){
    if(vec[i].size() == 0)continue;
    order.push_back(i);
    sort(vec[i].begin(),vec[i].end());
  }
}

int pow(int a){
  return a*a;
}

int main(){
  input();
  int res = INF;

  for(int i = 0 ; i < order.size() ; i++){
    int x = order[i];
    for(int j = 1 ; j < vec[i].size() ; j++){
      res = min(res,pow(vec[i][j] - vec[i][j-1]));
    }
  }

  for(int i = 0 ; i < order.size() ; i++){
    int x = order[i];
    for(int j = 0 ; j < vec[x].size() ; j++){
      int y = vec[x][j];
      for(int k = i+1 ; k < order.size() ; k++){
        int x2 = order[k];
        if(pow(x2 - x) >= res)break;
        int id = lower_bound(vec[x2].begin(),vec[x2].end(),y) - vec[x2].begin();
        int y2;
        if(id != vec[x2].size()){
          y2 = vec[x2][id];
          res = min(res,pow(x2 - x) + pow(y2 - y));
        }
        if(id != 0){
          y2 = vec[x2][id-1];
          res = min(res,pow(x2 - x) + pow(y2 - y));
        }
      }
    }
  }

  cout << res << endl;
  return 0;
}

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

int main(){
	//解説参考
	
	int n, a[100000];
	cin >> n;

	a[0] = 0;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[n + 1] = 0;
	
	int sum=0;
	for(int i=0;i<=n;i++) sum+=abs(a[i+1]-a[i]);
	
	for(int i=1;i<=n;i++){
		int ans=sum+abs(a[i+1]-a[i-1])-abs(a[i]-a[i-1])-abs(a[i+1]-a[i]);
		cout<<ans<<endl;
	}
	
	return 0;
}

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

using namespace std;

int n, cnt;
string s, t;

int main () {
	cin >> s;
	t = s;
	reverse(t.begin(), t.end());
	for(int i = 0; i < s.size() / 2; i++) {
		if(s[i] != t[i]) {
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

dp = [[0] * 3010 for _ in range(3010)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

i = len(s)
j = len(t)
res = ""
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res += s[i-1]
        i -= 1
        j -= 1

ans = ""
for i in reversed(range(len(res))):
    ans += res[i]

print(ans)


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

using namespace std;

const int INF = 1 << 30;

int N, M;
vector< int > A, B;
bool v[51][51][51][51][2][3];
int dp[51][51][51][51][2][3];

int rec(vector< int >& me, vector< int >& you, int head_a, int head_b, int block_a, int block_b, bool turn, int pass)
{
  if(v[head_a][head_b][block_a][block_b][turn][pass]++) return (dp[head_a][head_b][block_a][block_b][turn][pass]);

  int ret = -INF;

  if(head_a < me.size()) {
    if(~me[head_a]) ret = max(ret, -rec(you, me, head_b, head_a + 1, block_b, block_a, turn ^ 1, 0));
    else ret = max(ret, -rec(you, me, head_b, head_a + 1, head_b, block_a, turn ^ 1, 0));
  }

  int cost = 0;
  for(int i = block_a; i < head_a; i++) if(~me[i]) cost += me[i];
  for(int i = block_b; i < head_b; i++) if(~you[i]) cost -= you[i];
  if(pass == 2) ret = max(ret, cost);
  else ret = max(ret, cost - rec(you, me, head_b, head_a, head_b, head_a, turn ^ 1, pass + 1));

  return (dp[head_a][head_b][block_a][block_b][turn][pass] = ret);
}

int main()
{
  cin >> N >> M;
  A.resize(N);
  B.resize(M);
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for(int i = 0; i < M; ++i) {
    cin >> B[i];
  }
  cout << rec(A, B, 0, 0, 0, 0, 0, 0) << endl;
}

Measured memory_bytes: 89036
import java.util.*;
public class Main{
    
    static final int MOD = (int)1e9+7;
    static final int MAX = (int)1e6+1;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        HashMap<Integer, Integer> h = new HashMap<>();
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
            h.put(a[i], h.getOrDefault(a[i], 0)+1);
        }
        
        boolean[] prime = new boolean[MAX];
        Arrays.fill(prime, true);
        boolean pc = true;
        for(int i=2; i<MAX; i++){
            if(!prime[i]){
                continue;
            }
            int cnt = 0;
            for(int j=i; j<MAX; j+=i){
                prime[j] = false;
                cnt += h.getOrDefault(j, 0);
            }
            if(cnt > 1){
                pc = false;
            }
        }
        
        int gcd = gcd(a);
        if(pc && gcd==1){
            System.out.println("pairwise coprime");
        }else if(gcd==1){
            System.out.println("setwise coprime");
        }else{
            System.out.println("not coprime");
        }
        
    }
    
    static int gcd(int a, int b){
        if(a < b){
            return gcd(b, a);
        }
        if(b > 0){
            return gcd(b, a%b);
        }
        return a;
    }
    
    static int gcd(int[] a){
        int res = a[0];
        for(int i=1; i<a.length; i++){
            res = gcd(res, a[i]);
        }
        return res;
    }
    
    static public int[] osa_k(int max){
        int[] res = new int[max];
        for(int i=0; i<max; i++){
            res[i] = i;
        }
        for(int i=2; i*i<max; i++){
            if(res[i] < i) continue;
            for(int j=i*i; j<max; j+=i){
                if(res[j] == j){
                    res[j] = i;
                }
            }
        }
        
        for(int i=0; i<max; i++){
            System.out.println(res[i]);
        }
        
        return res;
    }
}


Measured memory_bytes: 140016
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
#include <math.h>
using namespace std;

const int N = 2e5 + 10, mod = 1e9 + 7;


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1;
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int n; scanf("%d", &n);
        __int128 m = 1;
        int z = 0;
        for(int i = 0; i < n; i++) {
            long long x; scanf("%lld", &x);
            z += (!x);
            if(m < 0) continue;
            m = m * (__int128)x;
            if(m > (__int128)1e18) m = -1;
        }
        if(z) puts("0");
        else if(m < 0) printf("%d\n", -1);
        else printf("%lld\n", (long long)m);
    }
    return 0;
}

Measured memory_bytes: 3816
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=1e5+100;
int n,w[200],m;
ll f[maxn],v[200];
int main(){
//	freopen(".in","r",stdin);
	n=read(),m=read();
	for(int i=1;i<=n;i++)
		scanf("%d%lld",&w[i],&v[i]);
	for(int i=1;i<=n;i++)
		for(int j=m;j>=w[i];j--)
			f[j]=max(f[j],f[j-w[i]]+v[i]);
	printf("%lld\n",f[m]);
	return 0;
}








Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

int isPalindrome(string str) 
{
    int l = 0; 
    int h = str.length()- 1; 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return 0; 
        } 
    } 
    return 1;
} 

int main()
{
	chutiyaap;
    string s;cin>>s;
    int n=s.length();
    string c1=s.substr(0,(n-1)/2);
    string c2=s.substr(((n+3)/2)-1,n-1);
    if(isPalindrome(s)&&isPalindrome(c1)&&isPalindrome(c2))cout<<"Yes";
    else cout<<"No";

}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL d,g;
	cin >> d >> g;
	VL p(d),c(d);
	for (int i = 0; i < d; i++) {
		cin >> p[i] >> c[i];
	}
	LL ans = INT64_MAX;
	for (int i = 0; i < (1 << d); i++) {
		LL score = 0;
		LL tmp = 0;
		for (int j = 0; j < d; j++) {
			LL fulls = p[j] * (j+1) * 100 + c[j];
			if ((i>>j)&1) {
				score += fulls;
				tmp += p[j];
			}
		}
		for (int j = d-1; j >= 0; j--) {
			if ((i>>j)&1) {
				continue;
			}
			for (int k = 0; k < p[j]; k++) {
				if (score >= g) {
					break;
				}
				score += (j+1)*100;
				tmp++;
			}
		}
		ans = min(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=801;
int n,m,x,y,ind[maxn],k,b[maxn][maxn];
char s[maxn][maxn];
queue<int> qx,qy,qk;
void put(int x,int y,int k)
{
	if(b[x][y]||x<0||x>n||y<0||y>m||k<0||s[x][y]=='#')return;
	b[x][y]=1;qx.push(x);qy.push(y);qk.push(k);
}
void bfs(int xx,int yy,int kk)
{
	qx.push(xx),qy.push(yy);qk.push(kk),b[xx][yy]=1;
	while(!qx.empty())
	{
		int x=qx.front(),y=qy.front(),k=qk.front();
		qx.pop();qy.pop();qk.pop();
		put(x+1,y,k-1);put(x-1,y,k-1);put(x,y+1,k-1);put(x,y-1,k-1);
	}
}
signed main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)cin>>(s[i]+1);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)if(s[i][j]=='S')x=i,y=j;
	bfs(x,y,k);
	int ans=n+m;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		int x=min(min(i,n-i+1),min(j,m-j+1));
		x--;
		if(b[i][j])
			ans=min(ans,(int)ceil((double)x/k+1));
	}
	cout<<ans;
}
/*
7 7 2
#######
#######
##.....
###S###
##.#.##
###.###
#######
一个网格图，从一个起点出发。
有些格子上锁。
每一轮你都可以不断往一个已解锁的四个方向的相邻格子走，
最多走k次走完后你可以选择至多k个未解锁的格子，将它们解锁。
求最少多少轮能走到一个边界格子。
选定路线之后肯定就不会干无聊的事情，那么选定路线就好了。
首先每一轮肯定是开满下一轮要走的k个格子，在有剩余的情况下也不需要继续向前开。
即使早早地开完了格子，该走几轮还是几轮。
也就是说，如果确定了第一轮的终点，那么后面的事情都就非常简单了。
因此只需要找到第一轮的最优起点。
那么从S开始搜一轮，对于所有可行点直接搞一下就好了。
*/

Measured memory_bytes: 6784
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    s = readline().strip()

    print(s.rfind('Z') - s.find('A') + 1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9252
<?php
$num = trim(fgets(STDIN));
$array = explode(' ', trim(fgets(STDIN)));
rsort($array);

$alice = 0;
$bob = 0;

for($i=0;$i<$num;$i++){
  if($i%2===0){$alice+=$array[$i];}
  else{$bob+=$array[$i];}
}

echo $alice-$bob;

Measured memory_bytes: 4604
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<vector>
using namespace std;

const int inf = 1<<29;
#define rep(i,n) for(i=0; i<n; ++i)

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

void bfs(const vector<vector<bool> > &grid,vector< vector<int> > &dist,
	 pair<int,int> start) {
  int i;
  dist[start.first][start.second] = 0;
  queue<pair<int,int> > Q;
  Q.push(start);
  while(!Q.empty()) {
    pair<int,int> now = Q.front(); Q.pop();
    int nx = now.second,ny = now.first;
    rep(i,4) {
      if(nx+dx[i] >= 0 && nx+dx[i] < grid[0].size() &&
	 ny+dy[i] >= 0 && ny+dy[i] < grid.size() &&
	 grid[ny+dy[i]][nx+dx[i]] == true && dist[ny+dy[i]][nx+dx[i]] == inf) {
	dist[ny+dy[i]][nx+dx[i]] = dist[ny][nx]+1;
	Q.push(make_pair(ny+dy[i],nx+dx[i]));
      }
    }
  }
  return;
}

int main() {
  int h,w,i,j,k;
  string s,pattern;
  while(cin>>h>>w, h|w) {
    vector< vector<bool> > grid(h, vector<bool>(w, true));
    vector< vector<int> > dist(h, vector<int>(w, inf));
    pair<int,int> start,ghost;
    rep(i,h) {
      cin>>s;
      rep(j,w) {
	if(s[j] == 'A') start = make_pair(i,j);
	if(s[j] == 'B') ghost = make_pair(i,j);
	if(s[j] == '#') grid[i][j] = false;
      }
    }
    cin>>pattern;
    bfs(grid,dist,start);
    int pat = pattern.length();
    bool possible = false;

    rep(i, h*w+h*w*pat+2) {
      if(dist[ghost.first][ghost.second] <= i) {
	cout<<i<<" "<<ghost.first<<" "<<ghost.second<<endl;
	goto NEXT;
      }
      int d = i%pat;
      if(pattern[d] == '8') {
	ghost.first--;
	if(ghost.first < 0) ghost.first = 0;
      }else if(pattern[d] == '2') {
	ghost.first++;
	if(ghost.first >= h) ghost.first = h-1;
      }else if(pattern[d] == '6') {
	ghost.second++;
	if(ghost.second >= w) ghost.second = w-1;
      }else if(pattern[d] == '4') {
	ghost.second--;
	if(ghost.second < 0) ghost.second = 0;
      }
    }
    cout<<"impossible"<<endl;
  NEXT:;

  }
}

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

int main() {
	// your code goes here
	int k,s;
	cin >> k >> s;
	int sum=0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(i+j<=s){
				if(i+j+k>=s){
					sum=sum+1;
				}	
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){

	int n,i,j,k,y,z;
	char cards[4][13] = {0};
	char x,a;

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		cin >> x >> y;

		

		switch (x){
		case 'S':
			z = 0;
			break;
		case 'H':
			z = 1;
			break;
		case 'C':
			z = 2;
			break;
		case 'D':
			z = 3;
			break;

		}
		cards[z][y-1] = 1;

	}
	
	

		for (i = 0; i < 4; i++){
			for (j = 0;j<13; j++){
				if (cards[i][j] == '\0'){
					switch (i){
					case 0:
						a = 'S';
						break;
					case 1:
						a = 'H';
						break;
					case 2:
						a = 'C';
						break;
					case 3:
						a = 'D';
						break;
					}
					printf("%c %d\n", a, j+1);
				}
			}

			
		}
	
	
	return 0;

}

Measured memory_bytes: 1228
#include<iostream>
#include<cmath>

using namespace std;
typedef long long LL;
const int N=110;
int n;
int l[N];

bool judge(int a,int b,int c){
    if(a==b) return false;
    if(b==c) return false;
    if(a==c) return false;
    if((LL)a+b<=c) return false;
    if((LL)b+c<=a) return false;
    if((LL)a+c<=b) return false;
    return true;
}

int main(){
    cin>>n;
    for(int i=0;i<n;++i) cin>>l[i];
    int cnt=0;
    for(int i=0;i<n;++i)
        for(int j=i+1;j<n;++j)
            for(int k=j+1;k<n;++k){
                if(judge(l[i],l[j],l[k])){
                    //cout<<i<<" "<<j<<" "<<k<<" "<<cnt<<endl;
                    cnt++;
                }
            }
    
    cout<<cnt<<endl;
    return 0;
}

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


void solve(long long A, long long B){
    for(long long i=1;i<=3;i++){
        if(i != A && i!= B){
            cout << i << endl;
        }

    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, n-2){
    if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256