akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
      int a[10],i,j,test;
	  for(i=0;i<10;i++){
		  scanf("%d",&a[i]);
	  }
	  for(i=0;i<10;i++){
		  for(j=i+1;j<10;j++){
			  if(a[i]>a[j]){
			test=a[i];
			a[i]=a[j];
			a[j]=test;
			  }
		  }
	  }
	  
	  printf("%d\n",a[9]);
	  printf("%d\n",a[8]);
	  printf("%d\n",a[7]);
	  return 0;
}

Measured memory_bytes: 600
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;

int n ;
int arr[20000];
void findNumberOfTriangles()
{
    sort(arr,arr+n);
    int count = 0;

    for (int i = 0; i < n - 2; ++i)
    {
        int k = i + 2;

        for (int j = i + 1; j < n; ++j)
        {
            while (k < n && arr[i] + arr[j] > arr[k])
                ++k;
            if(k > j)
                count += k - j - 1;
        }
    }
    cout << count <<"\n";
}

int main()
{
    cin >> n ;
    for (int i =0 ; i < n ;i++)cin >> arr[i];
    findNumberOfTriangles();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;

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

//uに隣接するvを番号順に取得
int next(int u) {
    for(int v = nt[u]; v < n; v++) {
        nt[u] = v + 1;
        if(M[u][v]) return v;
    }
    return -1;
}

void dfs_visit(int r) {
    for(int i = 0; i < n; i++) nt[i] = 0;
    
    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;
    
    while(!S.empty()) {
        int u = S.top();
        int v = next(u);
        if(v != -1) {
            if(color[v] == WHITE) {
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }else {
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs() {
    //初期化
    for(int i = 0; i < n; i++) {
        color[i] = WHITE;
        nt[i] = 0;
    }
    tt = 0;
    
    for(int u = 0; u < n; u++) {
        if(color[u] == WHITE) dfs_visit(u);
    }
    for(int i = 0; i < n; i++) {
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
    }
}

int main() {
    int u, k, v;
    
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }
    
    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for(int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    dfs();
    
    return 0;
}


Measured memory_bytes: 3108
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const MAX = 40

var IN [MAX]int
var PRE [MAX]int
var index int

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}
func findIndex(n int) int {
	for i, e := range IN {
		if e == n {
			return i
		}
	}
	return -1
}

func setTree(left, right int, ans *[]int) {
	if left >= right {
		return
	}
	c := PRE[index]
	m := findIndex(c)
	index++
	setTree(left, m, ans)
	setTree(m+1, right, ans)
	*ans = append(*ans, c)
}

func main() {
	n := scanInt()
	for i := 0; i < n; i++ {
		PRE[i] = scanInt()
	}
	for i := 0; i < n; i++ {
		IN[i] = scanInt()
	}
	ans := make([]int, 0)
	setTree(0, n, &ans)
	fmt.Println(strings.Trim(fmt.Sprint(ans), "[]"))
}



Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = null;
            while((line = br.readLine()) != null){
            	String lines[] = line.split(" ");
            	int height = Integer.parseInt(lines[0]);
            	int width = Integer.parseInt(lines[1]);

            	if(height==0||width==0)break;
            	for(int i=0;i<height;i++){
            		for(int j=0; j<width; j++){
            			if(i==0 || i==height-1){
            				System.out.print("#");
            			}else{
            				System.out.print((j==0 || j==width-1) ? "#" : ".");
            			}
            		}
            		System.out.println("");
            	}
            	System.out.println("");
            }
    }
}

Measured memory_bytes: 30292
n = int(input())
s = [int(x) for x in input()]

dp_1 = [False] * 10
dp_2 = [False] * 100
dp_3 = [False] * 1000

for x in s:
    for i in range(100):
        if dp_2[i]:
            dp_3[i * 10 + x] = True
    for j in range(10):
        if dp_1[j]:
            dp_2[j * 10 + x] = True
    dp_1[x] = True

print(sum(dp_3))

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

vector<pair<int,int>> p(8);

double dist(int from, int to) {
    int dx = p[to].first - p[from].first;
    int dy = p[to].second - p[from].second;
    return pow(dx * dx + dy * dy, 0.5);
}

int fact(int n){
    int res = 1;
    for(int i = 2;i <= n;i++) res *= i;
    return res;
}

int main() {
    int n;
    cin >> n;
    rep(i,n) cin >> p[i].first >> p[i].second;
    vector<int> root(n);
    iota(root.begin(),root.end(),0);
    double ans = 0;
    do {
        rep(i,n-1) ans += dist(root[i],root[i+1]);
    } while (next_permutation(root.begin(),root.end()));
    ans /= fact(n);
    printf("%.10lf\n",ans);
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long a,b;
  cin >>a>>b;
  long x = a*b;
  long tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  long r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  cout << x/b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int res = 0;
    rep(i,n){
        vector<int> a(30);
        vector<int> flag(30);
        int tmp = 0;
        for(int j = 0;j<i;j++){
            a[s[j]-'a']++;
        }
        for(int j = i;j<n;j++){
            if (a[s[j] - 'a'])
            {
                tmp++;
                a[s[j] - 'a'] = 0;
            }
        }
        res = max(res,tmp);
    }
    cout << res<<endl;
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;


void solution();

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    ull n, a, b;
    cin >> n >> a >> b;
    ull ans = (n/(a+b))*a;
    ull d = n%(a+b);

    if(d >= a){
        ans += a;
        d -= a;
    }else if(d < a){
        ans += d;
    }
    
    cout << ans << endl;

}   

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

using namespace std;


void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a[i] = {y, x};
    }
    sort(a.begin(), a.end());
    int t = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        tie(y, x) = a[i];
        t += x;
        if (t > y) {
            cout << "No"; return;
        }
    }
    cout << "Yes";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1792
w, h, n = map(int, input().split())
l = []
for i in range(n):
    x = input().split()
    x[0], x[1], x[2]= map(int, x)
    l.append(x)
originalh = []
originalw = []
for i in range(h):
    originalh.append(1)
for i in range(w):
    originalw.append(1)
for i in l:
    if i[2] == 1:
        for i in range(i[0]):
            originalw[i] = 0
    elif i[2] == 2:
        for i in range(1, w-i[0]+1):
            originalw[-i] = 0
    elif i[2] == 3:
        for i in range(i[1]):
            originalh[i] = 0
    else:
        for i in range(1, h-i[1]+1):
            originalh[-i] = 0
    
r = sum(originalw) * sum(originalh)
print(r)

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

int main()
{
	int r, g, b;
	std::cin >> r >> g >> b;
	if ((g * 10 + b) % 4 == 0)
	{
		std::cout << "YES";
	}
	else
	{
		std::cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> ban(h);
    vector<vector<int>> count(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        cin >> ban[i];
        for (int j = 0; j < w; j++) {
            if (ban[i][j] != '.') {
                for (int k = -1; k <= 1; k++) {
                    for (int l = -1; l <= 1; l++) {
                        if (k == 0 && l == 0)continue;
                        count[i + k][j + l]++;
                    }
                }
            }
        }
    }
    queue<pair<int, int>> q;
    vector<vector<bool>> broken(h, vector<bool>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ban[i][j] != '.') {
                if (ban[i][j] - '0' <= 8 - count[i][j]) {
                    q.push(make_pair(i, j));
                    broken[i][j] = true;
                }
            }
        }
    }
    q.push(make_pair(-1, -1));
    int ret = 0;
    while (true) {
        pair<int, int> x = q.front();
        if (x.first < 0) {
            q.pop();
            ret++;
            if (q.empty())break;
            q.push(make_pair(-1, -1));
        } else {
            q.pop();
            for (int k = -1; k <= 1; k++) {
                for (int l = -1; l <= 1; l++) {
                    if (k == 0 && l == 0)continue;
                    int a = x.first + k;
                    int b = x.second + l;
                    count[a][b]--;
                    bool flag=broken[a][b];
                    if (ban[a][b] != '.' && !flag) {
                        if (ban[a][b] - '0' <= 8 - count[a][b]) {
                            q.push(make_pair(a, b));
                            broken[a][b] = true;
                        }
                    }
                }
            }
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 8224
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
typedef long long ll;
using namespace std;

int main(){
  int a, b, h;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &h);

  printf("%d\n", (a+b)*h/2);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int ans = (H-h)*(W-w);
		System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 22612
import java.util.*;
 
public class Main{

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

        int N = sc.nextInt();
        long K = sc.nextLong();
        Map<Long, Long> map = new TreeMap<>();
        long[][] a = new long[2][N];
        for(int i = 0; i < N; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
            if(map.containsKey(a[0][i]))
                map.put(a[0][i], map.get(a[0][i]) + a[1][i]);
            else
                map.put(a[0][i], a[1][i]);
        }
        sc.close();
        
        long sum = 0;
        for(Long key: map.keySet()){
            sum += map.get(key);
            if(sum >= K){
                System.out.println(key);
                return;
            }
        }
    }
}

Measured memory_bytes: 93044
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>

using namespace std;

int main()
{
	int a, b;
	char op;
	while(true) {
		cin >> a >> op >> b;
		if(op == '?')
			break;
		else if(op == '+')
			cout << a + b << endl;
		else if(op == '-')
			cout << a - b << endl;
		else if(op == '*')
			cout << a * b << endl;
		else if(op == '/')
			cout << a / b << endl;
	}
		return 0;
}

Measured memory_bytes: 1160
Q = int(input())


def solve(a, b):
    if a == b:
        return 2 * a - 2
    if b < a:
        return solve(b, a)
    lb, ub, ab = a, 2 * b, a * b
    while 1 < ub - lb:
        mid = (lb + ub) // 2
        maxp = (mid + 1) // 2 * (mid // 2 + 1)
        if maxp < ab:
            lb = mid
        else:
            ub = mid
    return lb - 1

for _ in range(Q):
    a, b = map(int, input().split())
    print(solve(a, b))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll d, t, s;
  cin >> d >> t >> s;
  if (d <= t * s) cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3612
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    H, W, N = LI()
    start = LI()
    S = SI(); T = SI()
    for t,a in [["U","D"],["R","L"]]:
        if t=="U":
            n = H
        else:
            n = W
        # 落ちないエリア
        l = 1; r = n
        if S[-1]==t:
            r -=1
        elif S[-1]==a:
            l +=1
        for i in range(N-2,-1,-1):
            if T[i]==t and l>1:
                l -= 1
            elif T[i]==a and r<n:
                r += 1
            if S[i] == t:
                r -= 1
            elif S[i] == a:
                l += 1
#            print(l,r)
            if l>r:
                print("NO")
                return
            if t=="U" and (r==0 or l==n):
                print("NO")
                return
            if t=="R" and (r==0 or l==n):
                print("NO")
                return

        if t=="U" and (not l<=H + 1 -start[0]<=r):
            print("NO")
            return
        elif t=="R" and (not l<=start[1]<=r):
            print("NO")
            return
    print("YES")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""


Measured memory_bytes: 4280
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  string n ; cin>>n  ;
  rep(i,3){
  if(n[i]=='1')cout<<'9';
    else cout<<'1';
  }
  cout<<endl;
}


Measured memory_bytes: 256
def d_crossing(N):
    """
    S_k は、どの2つの部分集合の共通部分の要素数が1であり、1からNのどの要素も
    ちょうど2回しか使われないため、各集合の要素数はいずれもk-1である。
    また、要素数の和を考えると、 2N=k(k-1) ⇔ N=k(k-1)/2 である。

    逆に、1からk(k-1)/2までの数を三角形に並べたあと、対称行列になるように
    行列を構成すると、各行(列でも可)または対角成分を要素とした集合を部分集合とすれば
    条件を満たせる。
    (例: N=6)
    1         1 2 4
    2 3   <=> 2 3 5
    4 5 6     4 5 6
    として、{1, 2, 4}, {2, 3, 5}, {4, 5, 6}, {1, 3, 6} を部分集合とすればよい。
    """

    # N = k(k-1)/2 となる正整数kが存在するなら、求めるものが作れる
    k = 2
    while True:
        tmp = k * (k - 1)
        if tmp > 2 * N:
            return 'No'
        elif tmp == 2 * N:
            ans = ['Yes']
            break
        k += 1

    ans.append(str(k))
    # 1からk(k-1)/2までの数を三角形に並べ、対称行列を構成する
    matrix = [[0] * (k - 1) for _ in range(k - 1)]
    cnt = 1
    for r in range(k - 1):
        for c in range(r + 1):
            matrix[c][r] = matrix[r][c] = cnt
            cnt += 1
    # 各行を取り出したものを部分集合とする
    for r in matrix:
        ans.append('{0} {1}'.format(k - 1, ' '.join(map(str, r))))
    # 対角成分を取り出したものを部分集合とする
    tmp = [matrix[j][j] for j in range(k - 1)]
    ans.append('{0} {1}'.format(k - 1, ' '.join(map(str, tmp))))
    # 出力形式に沿って出力
    ans = '\n'.join(ans)
    return ans

N = int(input())
print(d_crossing(N))

Measured memory_bytes: 10100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin >> S.at(i);
        if (S.at(i)=="AC"){
            ac++;
        }
        else if (S.at(i)=="WA"){
            wa++;
        }
        else if (S.at(i)=="TLE"){
            tle++;
        }
        else if (S.at(i)=="RE"){
            re++;
        } 
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  ll a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;

}


Measured memory_bytes: 3624
#include<iostream>
#include<climits>
#include<vector>
using namespace std;
int frog(vector<int> h,int n,int k){
    vector<int> dp(n+1);
    dp[1]=0;
    for(int i=2;i<=n;i++){
        int m=INT_MAX;
        for(int j=1;j<k+1;j++){
            if(i-j>=1){
                int op=abs(h[i]-h[i-j])+dp[i-j];
                m=min(op,m);
            }
        }
        dp[i]=m;
    }
    return dp[n];
}
int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int> h(n+1);
    for(int i=1;i<=n;++i){
        cin>>h[i];
    }
    int f=frog(h,n,k);
    cout<<f<<endl;
}


Measured memory_bytes: 4528
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    if(n * 500 >= k) cout << "Yes";
    else cout << "No";

    return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  REP(i, N) {
    if (S[i] != S[K - 1]) S[i] = '*';
  }
  cout << S << endl;
}


Measured memory_bytes: 384
from itertools import permutations
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

i = 0
# 辞書順の順列をつくる そして比較。
for x in permutations(range(1, n+1)):
	i += 1
	if list(x) == p:
		a = i
	if list(x) == q:
		b = i
print(abs(a-b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	int N, A, C = 0;
	cin >> N;
	for (int i = 1;i <= N;i++) {
		cin >> A;
		if (A % 2 == 1 && i % 2 == 1)C++;
	}
	cout << C << endl;
}

Measured memory_bytes: 3620
// Aaradhya Beri
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(i == 10 or i == 1000 or i == 100000){
            i*=10;
            i--;
            continue;
        } 
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a, b, n, ans;
int main()
{
	cin >> a >> b >> n;
	if (n < b)  ans = a * n / b;
	else if (n >= b)  ans = a * (b - 1) / b;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//素因数分解
map<ll, ll> prime_factor(ll n)
{
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n] = 1;
	return ret;
}

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


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

#define   M             100000005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           (int)1e9

typedef   pair<int,int> P;

int h,w,d;
struct node{
	int x,y;
}a[M];
int dis[M];

int add(int x) {
	int t1=fabs(a[x+d].x - a[x].x);
	int t2=fabs(a[x+d].y - a[x].y);
	return  t1+t2;
}



int main() {
	
	scanf("%d %d %d",&h,&w,&d);
	for(int i=0;i<h;i++) 
		for(int j=0;j<w;j++) {
			int ch;
			scanf("%d",&ch);
			a[ch].x = i+1;
			a[ch].y = j+1;
		}
/*	for(int i=0;i<h;i++) 
		for(int j=0;j<w;j++)
			printf(j==w-1?"%2d\n":"%2d ",a[i][j]);*/
	
	for(int i=d+1;i<=h*w;i++){ 
        dis[i]=dis[i-d]+abs(a[i].x-a[i-d].x)+ abs(a[i].y - a[i-d].y );
    } 	
	
			
			
	int T;
	scanf("%d",&T);
	while(T--) {
		int a,b;
		scanf("%d %d",&a,&b);
		printf("%d\n",dis[b]-dis[a]);
	}
	
	
	
	
}




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

int main() {

  long long int n;

  while(true) {

    cin >> n;
    if ( n == 0 ) break;

    long long int cnt = 0;

    for ( long long int i = 5; i <= n; i*=5 ) {
      cnt += n/i;
    }

    cout << cnt << endl;

  }

  return 0;

}

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

typedef long long ll;

int main(){
	cout.precision(13);
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,q;
	cin >> n >> q;
	bool one[n] = {};
	int cur = 0;
	one[1] = 1;
	while(q--){
		int a,b;
		cin >> a >> b;
		--a;--b;
		if(a == cur)cur = b;
		else if(b == cur)cur = a;

		swap(one[a], one[b]);
		if(cur - 1 >= 0)one[cur-1] = 1;
		if(cur + 1 < n)one[cur+1] = 1;
	}
	one[cur] = 1;
	int ans = accumulate(one,one+n,0);
	cout << ans << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

const ll mod = 1e9+7;

int main(void){
	int W, H;
	ll p[114514], q[114514];
	cin >> W >> H;
	ll res = 0;
	REP(i, W){
		cin >> p[i];
		res += p[i];
	}
	REP(i, H){
		cin >> q[i];
		res += q[i];
	}
	sort(p, p+W);
	sort(q, q+H);
	REP(i, W){
		int in = lower_bound(q, q+H, p[i])-q;
		res += (H-in)*p[i];
	}
	REP(i, H){
		int in = upper_bound(p, p+W, q[i])-p;
		res += (W-in)*q[i];
	}
	cout << res << endl;
}


Measured memory_bytes: 1792
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int, int> iP;

int main(){
  
  int d, c;
  cin >> d >> c;
  cout << d * c << endl;
 
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(){

    int N;
    float ans;

    cin >> N;

    if(N % 2 == 0)
        cout << float(1) / float(2) << endl;
    else
        cout << float(N / 2 + 1) / float(N) << endl;

    return 0;
}
    


Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

ans = 0
dp = [[0 for _ in range(3)] for _ in range(N)]
for k in range(K):
  for i in range(k,N,K):
    if i < K:
      if T[i] == 'r':
        dp[i][2] = P
      elif T[i] == 's':
        dp[i][0] = R
      else:
        dp[i][1] = S
    else:
      if T[i] == 'r':
        dp[i][0] = max(dp[i-K][1],dp[i-K][2])
        dp[i][1] = max(dp[i-K][0],dp[i-K][2])
        dp[i][2] = max(dp[i-K][0],dp[i-K][1])+P
      elif T[i] == 's':
        dp[i][0] = max(dp[i-K][1],dp[i-K][2])+R
        dp[i][1] = max(dp[i-K][0],dp[i-K][2])
        dp[i][2] = max(dp[i-K][0],dp[i-K][1])
      elif T[i] == 'p':
        dp[i][0] = max(dp[i-K][1],dp[i-K][2])
        dp[i][1] = max(dp[i-K][0],dp[i-K][2])+S
        dp[i][2] = max(dp[i-K][0],dp[i-K][1])
  ans += max(dp[i][0],dp[i][1],dp[i][2])
print(ans)
#print(dp)

Measured memory_bytes: 72284
#include <stdio.h>

int main(void)
{
	char s[2] = {'\0', '\0'};
	
	scanf("%s", s);
	if ((s[0] == 'a') || (s[0] == 'e') || (s[0] == 'i') || (s[0] == 'o') || (s[0] == 'u') ) 
		printf("vowel");
	else
		printf("consonant");
	
	return 0;
}


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

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:f64 = read();
    let k:f64 = read();
    let a: Vec<u32> = (0..n as usize).map(|_| read()).collect();

    println!("{}", ((n-1.0) / (k-1.0)).ceil());

}


Measured memory_bytes: 4352
#ifdef HIRO
#include "../stdc++.h"
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#include <bits/stdc++.h>
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int m;
  cin >> n;
  cin >> m;
  char arr[n][m+1];
  for(int i=0;i<n;++i)
    cin >> arr[i];
  
  int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
  for(int i=0;i<n;i++)
    for(int j=0;j<m;++j){
      if(arr[i][j]=='.') continue;
      int has=0;
      for(int *d: dir){
        int y=i+d[0];
        int x=j+d[1];
        if(y<0||x<0||y>=n||x>=m) continue;
        if(arr[y][x]=='#'){
          has=1;
          break;
        }
      }
      if(!has){
        cout<<"No";
        return 0;
      }
    }

  cout<<"Yes";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll n,c=0; cin>>n;
ll a[n];
ll mn=INT_MAX;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    mn=min(mn,a[i]);
   // cout<<mn<<endl;
    if(mn==a[i])
    {
       c++;
    }
}
cout<<c<<endl;
}



Measured memory_bytes: 5160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
    string b;
    cin>>b;
    bool a[28];
    memset(a,0,sizeof(a));
    int k=b.length();
    for(int i=0; i<k; i++)
    {
        a[b[i]-'a']=1;
    }
    int s=0;
    while(a[s]==1)
        s++;
    if(s<26&&s<=k)
    {
        char t=s+'a';
        cout<<b<<t<<endl;
    }
    else
    {
        int p=k-1;
        for(; p>=0; p--)
        {
            a[b[p]-'a']=0;
            b[p]++;
            while(a[b[p]-'a']==1)
            {
                b[p]++;
                if(b[p]>'z')
                    break;
            }
            if(b[p]<='z')
                break;
        }
        if(p==-1)
            printf("-1\n");
        else
        {
            for(int i=0; i<k; i++)
            {
                if(b[i]<='z') 
                    printf("%c",b[i]);
                else break;
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int count = 0;
		//ドーナツの種類
		int N = scanner.nextInt();
		//お菓子の素の総量
		int X = scanner.nextInt();

		//お菓子の素m_iグラム
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			int m = scanner.nextInt();
			list.add(m);

			//Xの残りを求める
			X -= m;
		}

		Collections.sort(list);
		//お菓子の素が一番必要なものを求める
		int max = list.get(N-1);

		//お菓子の素が一番必要ないものを求める
		int min = list.get(0);

		//System.out.println("max：" + max);
		//System.out.println("min：" + min);
		//System.out.println("Xの残り：" + X);

		for (int x = 0; x <= X/min; x++) {
			//System.out.println(min + "*" + x + "：" + min * x);
			//System.out.println("x：" + x);
			count = x;
			if (min * x > X) {
				break;
			}
		}
		count += N;
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
using ll = long long;

ll solve(ll c, const vector<ll>& x, const vector<ll>& v){
	const int n = x.size();
	vector<ll> v_acc(n + 1);
	for(int i = 0; i < n; ++i){ v_acc[i + 1] = v_acc[i] + v[i]; }
	multiset<ll> s;
	ll answer = 0;
	for(int i = 0; i < n; ++i){
		const ll score = v_acc[i + 1] - x[i];
		answer = max(answer, score);
		s.insert(score);
	}
	for(int i = n - 1; i > 0; --i){
		s.erase(s.find(v_acc[i + 1] - x[i]));
		answer = max(answer, (v_acc[n] - v_acc[i]) - 2 * (c - x[i]) + *s.rbegin());
	}
	return answer;
}

int main(){
	ios_base::sync_with_stdio(false);
	ll n, c;
	cin >> n >> c;
	vector<ll> x(n), v(n);
	for(int i = 0; i < n; ++i){ cin >> x[i] >> v[i]; }
	ll answer = solve(c, x, v);
	reverse(x.begin(), x.end());
	reverse(v.begin(), v.end());
	for(int i = 0; i < n; ++i){ x[i] = c - x[i]; }
	answer = max(answer, solve(c, x, v));
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 7296
x,k,d=map(int,input().split())
if k*d>abs(x):
  x-=(x//(2*d))*2*d
  if k%2==0:
    print(min(abs(x-2*d),x,abs(x+2*d)))
  else:
    print(min(abs(x-d),abs(x+d)))
elif k*d==abs(x):
  print(0)
else:
  print(abs(x)-k*d)

Measured memory_bytes: 9196
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

func main() {
	s := readString()

	ans := make([]int, len(s))
	prec := byte(' ')
	prej := 0
	for i := range s {
		c := s[i]
		j := 1

		if c == 'R' {
			if c == prec {
				j = prej - 1
			}
			for s[i+j] == 'R' {
				j++
			}
			if j%2 == 0 {
				ans[i+j]++
			} else {
				ans[i+j-1]++
			}
		} else {
			if c == prec {
				j = prej + 1
			}
			for s[i-j] == 'L' {
				j++
			}
			if j%2 == 0 {
				ans[i-j]++
			} else {
				ans[i-j+1]++
			}
		}

		prec = c
		prej = j
	}

	for i := range ans {
		fmt.Printf("%v ", ans[i])
	}
}


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

int main(void){
  long long int A, B;
  cin >> A >> B;
  if ((A + B) % 2 == 0){
    cout << (A + B) / 2 << endl;
  }else cout << "IMPOSSIBLE" << endl;  
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#pragma GCC optimize ("O3")

inline static long gl(void){
    long x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[10];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    str[pos] = '\n';
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    write(1, str+pos, 10-pos);
}

inline static int sp(unsigned char* str, unsigned short i){
    if(i>99){
        str[2] = i%10+48; i/=10;
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 3;
    }else if(i>9){
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

unsigned char a[2*500*500];
unsigned char buffer[8*1024*1024];

int main(void){
    const unsigned long h=gl(), w=gl();
    fread(a, 1, 2*w*h, stdin);
    unsigned long p=0, pos=0;
    unsigned char *aa = a-2; 
    {
        bool haveCoin = false;
        unsigned short old_y, old_x;
        for(unsigned long i=1; i<=h; i++){
            if(i%2==1){
                for(unsigned long j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = aa[2*j]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(long j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = aa[2*j]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }
            aa+=2*w;
        }
    }
    pl(pos);
    //fwrite(buffer, 1, p, stdout);
    write(1, buffer, p);
    return 0;
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            if (A < 10 && B < 10)
            {
                Console.WriteLine(A * B);
            }
            else
            {
                Console.WriteLine(-1);
            }
        }
    }
}



Measured memory_bytes: 13140
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int N, A;
	cin >> N >> A;
	if (N % 500 - A <= 0)puts("Yes");
	else puts("No");


	return(0);
}

Measured memory_bytes: 256
n, k = map(int, input().split())
nb = k
nr = n-k
mod = 10**9+7
fac = [1] * 2001
fac_inv = [1] * 2001
for i in range(1,2001):
    fac[i] = (fac[i-1] * i) %mod
    fac_inv[i] = pow(fac[i], mod-2, mod)

# 足してa個をb分割する場合の数(順序考慮)が分かればいい
def f(a,b):
    if (a == 0) & (b==0):
        return 1
    if b <= 0:
        return 0
    if b > a:
        return 0
    res = fac[a-1] * fac_inv[b-1] * fac_inv[a-b] %mod
    return res

cnt = 0    
for i in range(1,k+1): # blue 1～k
    fnbi = f(nb, i)
    cnt = f(nr, i-1) * fnbi \
           + 2 * f(nr, i) * fnbi\
           + f(nr, i+1) * fnbi
    cnt = cnt%mod
    print(cnt)


Measured memory_bytes: 3444
h,w=map(int,input().split())
ans=[[-3]*w for _ in range(h)]
s=[input() for _ in range(h)]
for i in range(h):
    tmp=0
    for j in range(w):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp
    tmp=0
    for j in range(w-1,-1,-1):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp

for j in range(w):
    tmp=0
    for i in range(h):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp
    tmp=0
    for i in range(h-1,-1,-1):
        if s[i][j]=="#": tmp=0
        else: tmp+=1
        ans[i][j]+=tmp

print(max( max(ans[i]) for i in range(h) ))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

// geometry
typedef long double Real;
#define EPS 1e-12
typedef complex<Real> P;
bool P_less(const P &a,const P &b){
  if(a.real()!=b.real())return a.real()<b.real();
  return a.imag()<b.imag();
}
Real dot(const P &a,const P &b){return real(conj(a)*b);}
Real cross(const P &a,const P &b){return imag(conj(a)*b);}
int ccw(const P &a,const P &b,const P &c){
  Real x = cross(b-a,c-a);
  if(abs(x)<EPS)return 0;
  else if(x<0)return -1;
  else return 1;
}

struct ccw_less{
  P x;
  bool operator()(const P &a,const P &b) const{
    int c = ccw(x,a,b);
    if(c==0) return norm(a-x)<norm(b-x);
    return c==1;
  }
};
vector<P> createConvexHull(vector<P> p){
  // Graham's scan
  sort(ALL(p),P_less);
  vector<P> ret(p.size());
  ccw_less cw;
  cw.x = p[0];
  sort(p.begin()+1,p.end(),cw);
  ret[0] = p[0];
  int iter = 1;
  REPR(i,p.size()){
    while(iter>=2 && ccw(ret[iter-2],ret[iter-1],p[i])<=0)--iter;
    ret[iter++] = p[i];
  }
  ret.resize(iter);
  return ret;
}

int main(){
  // verify : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0068
  while(true){
    int n;
    scanf("%d",&n);
    if(!n)break;
    vector<P> p(n);
    REP(i,n){
      Real x,y;
      scanf("%Lf,%Lf",&x,&y);
      p[i] = P(x,y);
    }
    vector<P> conv = createConvexHull(p);
    cout<< (n-conv.size()) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1276
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        GCDonBlackboard solver = new GCDonBlackboard();
        solver.solve(1, in, out);
        out.close();
    }

    static class GCDonBlackboard {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];

            long[] left = new long[n + 1];
            long[] right = new long[n + 1];

            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }

            left[0] = a[0];
            right[n - 1] = a[n - 1];

            for (int i = 1; i < n; i++) {
                left[i] = gcd(left[i - 1], a[i]);
                right[n - i - 1] = gcd(right[n - i], a[n - i - 1]);
            }

            long result = Math.max(right[1], left[n - 2]);
            for (int i = 1; i < n - 1; i++) {
                result = Math.max(result, gcd(left[i - 1], right[i + 1]));
            }

            out.println(result);
        }

        static long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

    }
}



Measured memory_bytes: 63588