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

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

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

int main() {
  string s, t; cin >> s >> t;
  vector<string> ans;
  REP(i,s.size()-t.size()+1) {
    bool f = true;
    REP(j, t.size()) {
      if (s[i+j] != t[j] && s[i+j] != '?') {
        f = false; break;
      }
    }
    if (f) {
      string a = s;
      REP(j,a.size()) if (a[j] == '?') a[j] = 'a';
      REP(j,t.size()) a[i+j] = t[j];
      ans.push_back(a);
    }
  }
  if (ans.empty()) cout << "UNRESTORABLE" << endl;
  else cout << *(ans.end()-1) << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = n.times.map {gets.to_i}

$cnt = 0
$g = []

def insertion_sort(a, n, g)
  for i in g..n-1
    v = a[i]
    j = i - g

    while j >= 0 && a[j] > v
      a[j+g] = a[j]
      j = j - g

      $cnt += 1
    end
    a[j+g] = v
  end
end

def shell_sort(a, n)
  h = 1

  while h <= n
    $g.unshift(h)
    h = (3 * h) + 1
  end

  $m = $g.count

  for i in 0..$m-1
    insertion_sort(a, n, $g[i])
  end
  a
end

ss = shell_sort(a, n)
puts $m
puts $g.join(' ')
puts $cnt
puts ss


Measured memory_bytes: 16676
#include <algorithm>
#include <iostream>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  long long a[100001];
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];
  const long long *end = std::unique(a, a + n);

  for (auto i = a; i != end; ++i) {
    if (i > a)
      std::cout << " ";
    std::cout << *i;
  }
  std::cout << std::endl;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 998244353;

long long inv(long long x){
  long long res = 1;
  long long k = mod - 2;
  long long y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  int n,m,k;
  cin >> n >> m >> k;

  vll fact(n), powm(n);
  fact[0] = 1;
  rep(i,n-1) fact[i+1] = (fact[i]*(i+1)) % mod;
  powm[0] = 1;
  rep(i,n-1) powm[i+1] = (powm[i]*(m-1)) % mod;

  ll ret = 0;
  rep(i,k+1){
    ll cur = (fact[n-1]*inv(fact[i]) % mod) * inv(fact[n-1-i]) % mod;
    cur = (cur * m % mod) * powm[n-1-i] % mod;
    ret = (ret + cur)%mod;
  }

  cout << ret << endl;
}

Measured memory_bytes: 6268
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

from collections import deque

def main():
	n,m=MI()
	G=[[] for _ in range(n+1)]

	for _ in range(m):
		a,b=MI()
		G[a].append(b)

	A=[10**5]*(n+1)

	for i in range(1,n+1):
		Q=deque([[i,0]])
		D=[-1]*(n+1)
		while Q:
			#print(Q)
			now,d=Q.popleft()
			if now==i and d>0:
				A[i]=d
				break
			for nx in G[now]:
				if D[nx]==-1:
					D[nx]=d+1
					Q.append([nx,d+1])
	#print(A)

	k=min(A)
	#print(k)

	if k==10**5:
		print(-1)
		exit()

	s=A.index(k)
	#print(s)

	A=[]
	Q=deque([[s,0]])
	D=[10**5]*(n+1)

	while Q:
		now,d=Q.pop()
		if now==s and d>0:
			break
		if d==k:
			continue
		A.append(now)
		for nx in G[now]:
			if D[nx]>d+1:
				D[nx]=d+1
				Q.append([nx,d+1])
	D[s]=0

	#print(A)
	#print(D)

	ans=[]
	d=k-1
	for i in reversed(A):
		if D[i]==d:
			ans.append(i)
			d-=1

	print(k)
	print(*ans[::-1],sep="\n")










if __name__ == "__main__":
	main()


Measured memory_bytes: 9780
n = gets(&:to_i)
len = gets.chomp.split.map(&:to_i)
i=0
max=len[0]
min=len[0]
while i<len.length
        if max<len[i] then
            max=len[i]
        end
        if len[i]<min then
            min=len[i]
        end
        i=i+1
end
puts max-min

Measured memory_bytes: 1788
# -*- coding utf-8 -*-

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(reverse=True, key=lambda x: x[1])

C = []
for bc in BC:
    C += [bc[1]] * bc[0]
    if len(C) > N:
        break

score = sum(A)
ans = score
for i in range(N):
    if i >= len(C):
        break
    score = score - A[i] + C[i]
    ans = max(ans, score)

print(ans)


Measured memory_bytes: 34424
import sys

n,x,m=map(int,input().split())

if m==1:
    print(0)
    sys.exit()

check=[-1 for i in range(m)]#which tells position

A=[x%m]
check[x%m]=0

roopstart=10**15
for i in range(1,m):
    Ai=(A[i-1]*A[i-1])%m
    if check[Ai]!=-1:
        roopstart=check[Ai]
        break
    else:
        check[Ai]=i
        A.append(Ai)

if roopstart>=n:
    print(sum(A[:n]))
    sys.exit()

s=sum(A[:roopstart])

nn=n-roopstart
rooplen=len(A)-roopstart
roopnum=nn//rooplen
d=nn%rooplen

roopsum=sum(A[roopstart:])

s+=roopsum*roopnum
s+=sum(A[roopstart:roopstart+d])

print(s)
        


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vl;
#define kill(N) cout<<N<<'\n'
#define forn(N) for(int i=0; i<N; i++)
#define pb push_back

int N;

int main(){
	cin>>N;
	long long total=0;
	for(int i=1; i<=N; i++){
		long long tmp=N/i;
		total+=tmp*(tmp+1)*i/2;
	}
	cout<<total<<'\n';
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String a1 = n();
		String a2 = n();
		String a3 = n();

		out("" + a1.charAt(0) + a2.charAt(1) + a3.charAt(2));

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

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

	static int gcd(int a, int b) {

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

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 39216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double D1, D2, D3, Dx;
		double sum1 = 0, sum2 = 0, sum3 = 0, max = 0;
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			y[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			sum1 += Math.abs(x[i] - y[i]);
			sum2 += Math.pow(Math.abs(x[i] - y[i]), 2);
			sum3 += Math.pow(Math.abs(x[i] - y[i]), 3);
			max = Math.max(max, Math.abs(x[i] - y[i]));
		}
		D1 = sum1;
		D2 = Math.sqrt(sum2);
		D3 = Math.cbrt(sum3);
		Dx = max;
		System.out.printf("%f%n", D1);
		System.out.printf("%f%n", D2);
		System.out.printf("%f%n", D3);
		System.out.printf("%f%n", Dx);
		sc.close();
	}
}


Measured memory_bytes: 26360
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <queue>
#include <cmath>
#include <array>

typedef struct {
    int t;
    int f;
    char c;
} query;

int main(int argc, char *argv[])
{
    std::string s;
    std::string front, back;
    int q;
    bool reverse = false;

    std::cin >> s;
    std::cin >> q;

    for (int i = 0; i < q; i++) {
        query qi;

        // input
        std::cin >> qi.t;
        if (qi.t == 2) {
            std::cin >> qi.f >> qi.c;
        }

        // process
        if (qi.t == 1) {
            reverse = !reverse;
        } else {
            if (qi.f == 1) {
                (reverse?back:front) += qi.c;
            } else {
                (reverse?front:back) += qi.c;
            }
        }
    }

    std::reverse(front.begin(), front.end());

    s = front + s + back;
    if (reverse) {
        std::reverse(s.begin(), s.end());
    }

    std::cout << s << std::endl;

    return 0;
}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
#define mem(a,b)  memset(a,b,sizeof(a))
const ll MAX=1e5+3;
const ll mod=1e9+7;
int main()
{
   FASTIO
   int t=1;
   //cin>>t;
   while(t--)
  {
      ll n;
      cin>>n;
      vi v(n);
      rep(i,0,n)
      cin>>v[i];
      ll x=1,cnt=0,c=0;
      rep(i,0,n)
      {
         if(v[i]==x)
         {
             c=1;
             x++;
         }
         else
            cnt++;
      }
      if(c==0)
        cout<<"-1";
      else
      cout<<cnt;
   }
 return 0;
}



Measured memory_bytes: 1792
import sys
s= list(input())
t= list(input())
s.sort()
t.sort()

count = 0
for i in range(min(len(t),len(s))):
    if t[i] == s[i]:
        count += 1
if count == min(len(t),len(s)):
    if len(s)<len(t):
        print("Yes")
    else:
        print("No")
        

elif s[0]<t[len(t)-1]:

    print("Yes")


else:
    print("No")

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

  $x=[];
  $y=[];
  for($i=0;$i<$n;$i++){
    list($x[], $y[]) = explode(" ", trim(fgets(STDIN)));
  }
  
  $distance = 0;
  $o=0;
  for($i=0;$i<$n-1;$i++)
  {
    for($j=$i+1;$j<$n;$j++)
    {
      $o++;
      $distance += sqrt(($x[$i]-$x[$j])*($x[$i]-$x[$j])+($y[$i]-$y[$j])*($y[$i]-$y[$j]));
    }
  }
  
  //echo $distance;
  echo $distance * ($n-1) / $o;


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

int main()
{
  int n;
  string s;
  cin>>n>>s;
  if(n&1)
  {
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<=n/2-1;i++)
  { 
    if(s[i]!=s[i+n/2])
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)


func main() {
	var h, w int
	fmt.Scan(&h, &w)

	for j := 0; j < w + 2; j++ {
		fmt.Print("#")
	}
	fmt.Println("")
	
	for i := 0; i < h; i++ {
		fmt.Print("#")
		var s string
		fmt.Scan(&s)
		fmt.Print(s)
		fmt.Println("#")
	}
	
	for j := 0; j < w + 2; j++ {
		fmt.Print("#")
	}
	fmt.Println("")
}


Measured memory_bytes: 512
'use strict';
const i = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
let s = i[0], p = parseInt(i[1]), code;
for(let j = 0;j < s.length;j++){
  code = s[j].charCodeAt(0);
  if (s.length - 1 === j) {
    code += p%26;
    code += (code > 122)? -26:0;
    s = s.slice(0, j) + String.fromCharCode(code) + s.slice(j+1);
  } else {
    if((123 - code) <= p && !(s[j] === "a")){
      p -= (123 - code);
      s = s.slice(0, j) + "a" + s.slice(j+1);
    }
  }
}
console.log(s);

Measured memory_bytes: 37732
#coding:utf-8
import itertools,sys

N,A,B,C=map(int, raw_input().split())
l=[]
for _ in range(N):
    l.append(input())

def eval(a,b,c,aa,bb,cc):
    #print(a,b,c,aa,bb,cc)
    ra=a+sum(aa)
    rb=b+sum(bb)
    rc=c+sum(cc)
    #print("rarbrc:",ra,rb,rc, abs(A-ra), abs(B-rb), abs(C-rc),C,rc)
    diff = abs(A-ra) + abs(B-rb) + abs(C-rc)
    diff+=10*len(aa)
    diff+=10*len(bb)
    diff+=10*len(cc)
    return diff


cn=0
ans=1<<20
ops=[-1,0,1,2]
for a,b,c in itertools.permutations(range(N), 3):
    others=set(range(N))
    others.remove(a)
    others.remove(b)
    others.remove(c)
    others=list(others)
    for O in itertools.product(ops, repeat=len(others)):
        aa,bb,cc=[],[],[]
        for i,op in enumerate(O):
            if op==-1:continue
            if op==0:aa.append(l[others[i]])
            if op==1:bb.append(l[others[i]])
            if op==2:cc.append(l[others[i]])
        #print(aa,bb,cc)
        val=eval(l[a],l[b],l[c],aa,bb,cc)
        #print(val)
        # cn+=1
        # if cn==2:
        #     pass
            #sys.exit(0)
        ans=min(ans,val)
print(ans)


Measured memory_bytes: 2912
import java.util.*;
public class Main {
    public static void main(String args[]) {
       Scanner sc=new Scanner(System.in);
       int n=sc.nextInt();
       long d=sc.nextLong();
       int count=0;
       for(int i=0;i<n;i++)
       {
           long x=sc.nextLong();
           long y=sc.nextLong();
           double dis=Math.sqrt((x*x)+(y*y));
           if(dis<=d)
           {
               count++;


           }
       }
       System.out.print(count);
    }
}

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



int main() {
	while (1) {
		int n; cin >> n;
		if (!n)break;
		vector<pair<int, int>>mers;
		for (int i = 0; i < n; ++i) {
			int t, c; cin >> t >> c;
			c *= 2;
			mers.push_back(make_pair(t, c));
		}
		sort(mers.begin(), mers.end(), [](const pair<int, int>&l, const pair<int, int>&r) {return l.first < r.first; });

		vector<pair<int, int>>sits;//f:終了時間　s:残りレーン数
		vector<int>lanetime(2);
		for (int i = 0; i < n; ++i) {
			sits.push_back(make_pair(mers[i].first, mers[i].second));
			lanetime[0] = mers[i].first;
		}
		lanetime[1] = 0;
		int swimming = n;
		int time = 1;
		for (time = 1; swimming;++time){
			for (int i = 0; i < n; ++i) {
				if (sits[i].second == 0) {
					continue;
				}else if (sits[i].first == time) {
					sits[i].second--;
					if (sits[i].second == 0) {
						swimming--;
						continue;
					}
					else {
						sits[i].first = max(time + mers[i].first, lanetime[sits[i].second % 2]);
						lanetime[sits[i].second % 2] = sits[i].first;
					}
				}
			}
		}
		cout << time - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3060
N=int(raw_input())
a=map(int,raw_input().split(' '))

flg=0
if abs(max(a))>=abs(min(a)):
  m=max(a)
  flg=1
else:
  m=min(a)

for i in range(len(a)):
  if a[i]==m:
    p=i
    break

print 2*N-1
for i in range(N):
  print p+1, i+1
  a[i]+=a[p]

if flg:
  for i in range(N-1):
    print i+1, i+2
    a[i+1]+=a[i]
else:
  for i in range(N-1)[::-1]:
    print i+2, i+1
    a[i]+=a[i+1]
#print a

Measured memory_bytes: 2692
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d,e=0,f=0,i=0,j=0;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	while(e<n)
	{
		e+=a;
		i++;
	}
	while(f<n)
	{
		f+=c;
		j++;
	}
	b=b*i;
	d=d*j;
	if(b<d)
		printf("%d\n",b);
	else
	printf("%d\n",d);
	return 0;
}


Measured memory_bytes: 2056
///
// File:  0558.go
// Author: ymiyamoto
//
// Created on Sun Mar  4 20:58:45 2018
//
package main

import (
	"fmt"
	"strconv"
	"strings"
)

type pos struct {
	x, y int
}

var H, W, N int
var graph [][]string

func wfs(p pos, index int) (int, pos) {
	var q []pos
	dists := make([][]int, H)
	for i := range dists {
		dists[i] = make([]int, W)
	}

	q = append(q, p)
	for len(q) > 0 {
		p := q[0]
		dist := dists[p.x][p.y]
		q = q[1:]

		for _, d := range []pos{{-1, 0}, {1, 0}, {0, -1}, {0, 1}} {
			x := p.x + d.x
			y := p.y + d.y
			if 0 <= x && x < H && 0 <= y && y < W && graph[x][y] != "X" && dists[x][y] == 0 {
				dists[x][y] = dist + 1
				q = append(q, pos{x, y})
			}
		}
	}

	for i := range graph {
		for j := range graph[i] {
			if graph[i][j] == strconv.Itoa(index) {
				return dists[i][j], pos{i, j}
			}
		}
	}

	panic("not found")
}

func main() {
	fmt.Scan(&H, &W, &N)

	var start pos

	graph = make([][]string, H)
	for i := range graph {
		var s string
		fmt.Scan(&s)
		graph[i] = strings.Split(s, "")
		for j := range graph[i] {
			if graph[i][j] == "S" {
				start.x = i
				start.y = j
			}
		}
	}

	count := 0
	for i := 1; i <= N; i++ {
		c, s := wfs(start, i)
		start = s
		count += c
	}

	fmt.Println(count)
}



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

double angleClock(int hour, int minutes) {
    double hourAngle = ((hour % 12) + minutes * 1.0/60) * 30;
    double minutesAngle = minutes * 6;
    double a = abs(hourAngle - minutesAngle);
    double b = 360 - a;
    return a < b ? a : b;
}

int a, b, m, h;

int main() {
	cin>>a>>b>>h>>m;
	double angle=angleClock(h, m);
	if(angle==0.0) cout<<abs(a-b)<<endl;
	else {
		double ans=sqrt((a*a)+(b*b) - 2*a*b*cos(3.1415926535897932384*angle/180.00));
		cout<<fixed<<setprecision(15)<<ans<<endl; 
	}
	return 0;
}

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

typedef long long LL;

#define int LL

signed main() {
    int T; scanf("%d", &T);
    while (T--) {
        int A, B, C, D; scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
        int len = (max(A, B) + min(A, B)) / (min(A, B) + 1);
        int l = 0, r = 1e9, mid, pos = -1;
        while (l <= r) {
            mid = (l + r) >> 1;
            int t1 = A - mid / (len + 1) * len - mid % (len + 1);
            int t2 = B - mid / (len + 1);
            int h1 = t1 * len + (mid % (len + 1) || !mid ? len : 0);
            if (t1 >= 0 && t2 >= 0 && h1 >= t2) pos = mid, l = mid + 1;
            else r = mid - 1;
        } 
        assert(pos >= 0);
        for (int i = C; i <= min(D, pos); i++) 
            putchar(i % (len + 1) ? 'A' : 'B');
        for (int i = min(D, max(pos, C - 1)) + 1; i <= D; i++) 
            putchar((A + B - i + 1) % (len + 1) ? 'B' : 'A');
        puts("");
    }
    return 0;
}//

Measured memory_bytes: 384
#include<iostream>
#include<vector>

using namespace std;

int main() {
  int a;
  vector<int> A(3);
  while(cin >> a) {
    if(A[0] < a) {
      if(A[1] < a) {
        if(A[2] < a) {
          swap(A[2],a);
        }
        swap(A[1], a);
      }
      swap(A[0], a);
    }
  }
  for(int i = 2; i >= 0; i--) {
    cout << A[i] << endl;
  }
 
  return 0;
}



Measured memory_bytes: 3076
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    vector<int> count(3, 0);
    rep(i, n)
    {
        int temp;
        cin >> temp;
        if (a >= temp)
            count[0]++;
        else if (b >= temp)
            count[1]++;
        else
            count[2]++;
    }
    int ans=INF;
    rep(i,3){
        chmin(ans,count[i]);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
use std::vec::Vec;
use std::cmp::max;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T, T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 4);
  (v[0], v[1], v[2], v[3])
}

fn main() {
  let (a, b, c, d) = read_touple::<usize>();
  println!("{}", max(a * b, c * d));

}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int a,b,res=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		string x=to_string(i);
		string y=to_string(i);
		reverse(x.begin(),x.end());
		if(x==y)res++;
	}
	cout<<res<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;
struct Point {
	int cost, x, y;
};

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

int main(){
	while(true){
		int t, n;
		cin >> t >> n;
		if(t == 0 && n == 0){ break; }
		memset(passed, 0, sizeof(passed));
		for(int i = 0; i < n; ++i){
			int x, y;
			cin >> x >> y;
			passed[y + 100][x + 100] = true;
		}
		queue<Point> q;
		Point first = { 0, 0, 0 };
		cin >> first.x >> first.y;
		first.x += 100; first.y += 100;
		q.push(first);
		passed[first.y][first.x] = true;
		int answer = 0;
		while(!q.empty()){
			Point p = q.front();
			q.pop();
			if(p.cost > t){ break; }
			++answer;
			for(int i = 0; i < 6; ++i){
				int x = p.x + dx[i], y = p.y + dy[i];
				if(!passed[y][x]){
					passed[y][x] = true;
					q.push((Point){ p.cost + 1, x, y });
				}
			}
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 960
def cin():
	return map(int,input().split())

def cino(test=False):
    if not test:
        return int(input())
    else:
        return input()
def cina():
  return list(map(int,input().split()))

a = cino()
b = cino()
c = cino()
d = cino()

ans = min(a,b)*c + (a-min(a,b))*d
print(ans)
# a = list(a)
# has = {}
# x,y = -1,-1
# for i in range(len(a)):
#     has[a[i]]=[0,0]

# for i in range(len(a)):
#     has[a[i]][0] += 1
#     if has[a[i]][0]==1:
#         has[a[i]][1] = i
#     temp1 = has[a[i]][0]
#     # print(temp1)
#     if i>2 and temp1>2:
#         temp = has[a[i]][1]
#         if temp1>(i-temp)//2:
#             x,y = temp+1,i+1
#             break
# print(x,y)




Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

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

long long lcm(long long a,long long b){
	long long g=gcd(a,b);
	return a/g*b;
}

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	LL a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/lcm(c,d)+(a-1)/lcm(c,d))<<endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

ans = 0
for i in range(N):
    added = min(As[i], Bs[i])
    Bs[i] -= added
    added2 = min(As[i + 1], Bs[i])
    As[i + 1] -= added2
    ans += added + added2
print(ans)


Measured memory_bytes: 21652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int ans=2e9;
    for(int i=0;i<n;i++){
        int mn=b[i];
        int ok=n,ng=i-1;
        while(ok-ng>1){
            int mid=(ok+ng)/2;
            int mx=b[mid];
            int lensum=0;
            for(int j=0;j<n;j++){
                int len=0,cnt=0;
                while(j<n&&mn<=a[j]){
                    if(a[j]<=mx)cnt++;
                    j++;
                    len++;
                }
                lensum+=min(max(0,len+1-k),cnt);
            }
            if(lensum>=q)ok=mid;
            else ng=mid;
        }
        if(ok!=n){
            ans=min(ans,b[ok]-mn);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
void shichigosan(long long now, bool shichi, bool go, bool san, int &cnt) {
    if(now > N) return;
    if(shichi && go && san) cnt++;
    
    shichigosan(now*10+7, true, go, san, cnt);
    shichigosan(now*10+5, shichi, true, san, cnt);
    shichigosan(now*10+3, shichi, go, true, cnt);
}
int main() {
    cin >> N;
    int cnt = 0;
    shichigosan(0, false, false, false, cnt);
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int main(){
    int64_t A, B, C, K;
    cin >> A >> B >> C >> K;

    if(abs(A - B) >= 1e18){
        cout << "Unfair" << endl;
    }
    if(K % 2 == 0){ 
        cout << A - B << endl;
    } else {
        cout << B - A << endl;
    }
}

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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    for(int i = A;i <= B;i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n,k int
	var s string
	fmt.Scan(&n,&k,&s)
  
	//ToLowerはbyteで返すのでstringに変換
	fmt.Println(s[:k-1] + strings.ToLower(string(s[k-1])) + s[k:])
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    char post[11];
    int a,b;
    scanf ("%d %d",&a,&b);
    scanf ("%s",post);
    int i;
    for(i = 0;i<a;i++){
        if(!(post[i] >= '0' && post[i] <= '9')){
            printf("No\n");
            return 0;
        }
        if(post[a]!= '-'){
            printf("No\n");
            return 0;
        }

    }

    for(i = a+1;i<a+b;i++){
        if(!(post[i] >= '0' && post[i] <= '9')){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int maney=100000;
	int week;
	cin >> week;
	while(week--){
		maney *= 1.05;
		if(maney%1000){
			maney -= maney%1000;
			maney += 1000;
		}
	}
	cout << maney << endl;
	return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 2e9, mod = 1e9 + 7;
struct SEG{
    int comb = 1, l,r;
    vi st, lazy;
    SEG(int n){
        for(int i = n-1;i;i>>=1) comb <<= 1;
        st.resize(2*comb); lazy.resize(2*comb, 0);
        for(int i=0;i<comb;i++) st[comb + i] = -i;
        for(int i = comb-1;i;--i) st[i] = max(st[i<<1], st[i<<1|1]);
    }
    void push(int cur){
        st[cur] += lazy[cur];
        if(cur < comb) lazy[cur<<1] += lazy[cur], lazy[cur<<1|1] += lazy[cur];
        lazy[cur] = 0;
    }

    void update(int _l, int _r){
        l = _l; r = _r;
        update(1,0,comb - 1);
    }
    inline void update(int cur, int rl, int rr){
        push(cur);
        if(rr < l || rl > r) return;
        if(l <= rl && r >= rr){
            lazy[cur]++;
            push(cur);
            return;
        }
        int mid = (rl+rr)>>1;
        update(cur << 1, rl, mid);
        update(cur << 1 | 1, mid + 1, rr);
        st[cur] = max(st[cur << 1], st[cur << 1|1]);
    }

    int query(){
        return st[1];
    }

};
int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n, m;
    cin >> n >> m;
    SEG st(m+2);
    ii bnd(-inf, inf);
    vector<ii> p(n);
    for(int i=0;i < n;i++){
        cin >> p[i].x >> p[i].y;
        bnd.x = max(bnd.x, p[i].x);
        bnd.y = min(bnd.y, p[i].y);
    }
    int res = max(n - min(m ,m - (bnd.y - bnd.x - 1)), 0);
    sort(all(p));
    for(auto &e:p){
        e.y = m-e.y + 1;
        st.update(e.y, st.comb - 1);
        res = max(res, -e.x + st.query());
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5888
#include <stdio.h>
long long llmax(long long a, long long b){return a>b?a:b;}
long long llmin(long long a, long long b){return a<b?a:b;}
long long llgcd(long long a, long long b){return llmin(a,b)==0?llmax(a,b):llgcd(llmin(a,b),llmax(a,b)%llmin(a,b));}
int main(void){
    long long n,m;
    scanf("%lld%lld",&n,&m);
    char s[n+1],t[m+1];
    scanf("%s%s",s,t);
    for (long long i=0; i<llgcd(n,m); i++){
        if (s[i*n*m/llgcd(n,m)/m]!=t[i*n*m/llgcd(n,m)/n]){
            printf("-1\n");
            return 0;
        }
    }
    printf("%lld\n",n*m/llgcd(n,m));
	return 0 ;
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL h,i,j,k,m,n,t,u,v,w,z,b[516]={1},c[12],d[12],x[12][1005],y[12][1005];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>h>>w>>k;
	t=h+w;
	for(;i++<511;)
	{
		b[i]=b[i&i-1]+1;
	}
	for(i=0;i++<h;)
	{
		cin>>s;
		for(j=0;j<w;j++)
		{
			x[i][j+1]=s[j]&1;
		}
	}
	for(i=0;i++<h;)
	{
		for(j=0;j++<w;)
		{
			y[i][j]=y[i-1][j]+x[i][j];
		}
	}
	for(v=1<<h-1;u<v;u++)
	{
		for(i=j=0;++i<h;)
		{
			if(u&1<<i-1)
			{
				c[++j]=i;
			}
		}
		c[++j]=h;
		for(j=m=0;j++<w;)
		{
			for(i=0;i++<b[u];)
			{
				z=y[c[i]][j]-y[c[i-1]][j];
				//cout<<i<<' '<<z<<endl;
				if(z>k)
				{
					for(i=b[u];i;i--)d[i]=0;
					goto G;
				}
				else if(d[i]+z>k)
				{
					m++;
					for(i=b[u];i;i--)d[i]=0;
				}
				else
				{
					d[i]+=z;
				}
			}
			//cout<<j<<' '<<m<<endl;
		}
		t=min(t,b[u]+m-1);
		//cout<<endl<<u<<' '<<b[u]+m-1<<endl<<endl;
		for(i=b[u];i;i--)d[i]=0;
		G:;
	}
	cout<<t;
}

Measured memory_bytes: 384
# D
from collections import Counter
from collections import deque
h, w = map(int, input().split())

cost = [[] for _ in range(10)]
for i in range(10):
    row = map(int, input().split())
    for ind, v in enumerate(row):
        if ind == i:
            cost[i].append(float('inf'))
        else:
            cost[i].append(v)

nums = []
for _ in range(h):
    arow = list(map(int, input().split()))
    nums += arow
counter = Counter(nums)

### dijkstra
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

total = 0
for num, cnt in counter.items():
    if (num == -1) or (num == 1):
        continue
    else:
        dist = dijkstra(s=num, n=10, w=10*10, cost=cost)
        total += dist[1]*cnt
print(total)

Measured memory_bytes: 3828
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
ans = 0
hand = []

for i in range(len(t)):
    if t[i] == 'r':
        if i - k >= 0 and hand[i - k] == 'p':
            hand.append(' ')
            continue
        else:
            ans += p
            hand.append('p')
    elif t[i] == 's':
        if i - k >= 0 and hand[i - k] == 'r':
            hand.append(' ')
            continue
        else:
            ans += r
            hand.append('r')
    else:
        if i - k >= 0 and hand[i - k] == 's':
            hand.append(' ')
            continue
        else:
            hand.append('s')
            ans += s

print(ans)


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

int     main() {
        long N;
        long K;
        cin >>N >>K;
        vector<long> A(2002, 0);
        long AA;
        long S1=0;
        long S2=0;
        for (int i=0; i<N; i++) {
                cin >>AA;
                A.at(AA)++;
                for (int j=0; j<AA; j++) {
                        S2 += A.at(j);
                        S2 %= 1000000007;
                }
                for (int j=AA+1; j<2002; j++) {
                        S1 += A.at(j);
                        S1 %= 1000000007;
                }
        }
        long S;
        long KK;
        if (0==K%2) {
                KK=K/2;
                KK *= K-1;
        } else {
                KK=(K-1)/2;
                KK *=K;
        }
        KK %= 1000000007;
        S=S1*KK;
        S %= 1000000007;
        S+=S1*K;
        S %= 1000000007;
        long SS=S2*KK;
        SS %= 1000000007;
        S += SS;
        S %= 1000000007;
        cout <<S <<endl;
        return 0;
};

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Building Houses
public class Main{

	int n, res, INF = 1<<29;
	int[][] a;
	int[] p;
	boolean[] u;
	int[] mem;
	
	int get(int S){
		if(mem[S]!=-1)return mem[S];
		if(Integer.bitCount(S)<2)return mem[S] = 0;
		int min = 0;
		for(int i=0;i<n;i++)if(!u[i]){
			int m = INF;
			for(int j=0;j<n;j++)if(!u[j] && i!=j){
				m = Math.min(m, a[i][j]);
			}
			min+=m;
		}
		return mem[S] = min/2;
	}
	
	void f(int k, int last, int S){
		if(res<=last+get(S))return;
		if(k==n){
			res = Math.min(res, last); return;
		}
		for(int i=0;i<n;i++)if(!u[i]){
			p[i] = 0;
			if(k!=0){
				p[i] = INF;
				for(int j=0;j<n;j++)if(u[j]){
					int pos = p[j] + a[j][i];
					if(pos<=last)continue;
					boolean ok = true;
					for(int x=0;x<n;x++)if(u[x] && Math.abs(pos-p[x])<a[x][i])ok=false;
					if(ok)p[i] = Math.min(p[i], pos);
				}
			}
			u[i] = true;
			f(k+1, p[i], S-(1<<i));
			u[i] = false;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			a = new int[n][n];
			for(int i=0;i<n;i++)for(int j=0;j<n;j++)a[i][j] = a[j][i] = Math.max(sc.nextInt(), Math.max(a[i][j], a[j][i]));
			res = INF;
			p = new int[n];
			u = new boolean[n];
			mem = new int[1<<n];
			Arrays.fill(mem, -1);
			f(0, 0, (1<<n)-1);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll a[3][3];
ll b[10];
void solve() {
    REP(i, 3) {
        REP(j, 3) {
            cin >> a[i][j];
        }
    }

    ll n;
    cin >> n;
    map<ll, ll> mp;
    REP(i, n) {
        cin >> b[i];
        mp[b[i]]++;
    }

    REP(i, 3) {
        bool flag = true;
        REP(j, 3) {
            if(!mp.count(a[i][j])) {
                flag = false;
            }
        }
        if(flag) {
            cout << "Yes" << en;
            return;
        }
    }
    REP(i, 3) {
        bool flag = true;
        REP(j, 3) {
            if(!mp.count(a[j][i])) {
                flag = false;
            }
        }
        if(flag) {
            cout << "Yes" << en;
            return;
        }
    }

    bool flag = true;
    REP(i, 3) {
        if(!mp.count(a[i][i])) {
            flag = false;
        }
    }
    if(flag) {
        cout << "Yes" << en;
        return;
    }

    flag = true;
    REP(i, 3) {
        if(!mp.count(a[i][2 - i])) {
            flag = false;
        }
    }
    if(flag) {
        cout << "Yes" << en;
        return;
    }
    cout << "No" << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<cmath>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

using namespace std;

int main(){
    cs
    ll a,b;
    cin>>a>>b;
    cout<<a*b/__gcd(a,b);
}

Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    a = [["#" for j in range(W)] for i in range(H)]
    b = ["".join(a[i]) for i in range(H)]
    print(b[0])
    coma = ["."for i in range(W-2)]
    coma = "".join(coma)
    for i in range(H-2):
        print("#"+coma+"#")
    print(b[H-1])
    print()

Measured memory_bytes: 7824
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N;

    cin >> N;

    int maxn = N / 4 + 10;

    bool ok = false;
    REP(i , maxn) REP(j, maxn) {
        int t = 4 * i + 7 * j;

        if (t == N) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
ll n,k;
cin>>n>>k;
cout<<min(n%k,k-n%k);
	}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
int main() {
	int a[3];
	for (int i = 0; i < 3; ++i) {
		std::cin >> a[i];
	}
	std::sort(a, a + 3);
		std::cout << a[0] << " "<< a[1] << " "<< a[2] <<std::endl;
	return 0;
}

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

int solve();
void visit(int n);

int N,M;
vector<int> vec[5010];
bool O = true;
bool visited[5050] = {0};
vector<int> ANS;
int cou = 0;

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        vec[a].push_back(b);
    }
    solve();
    return 0;
}

int solve()
{
    for(int i = 1; i <= N; i++)
    {
        visit(i);
    }
    for(int i = ANS.size() - 1; i >= 0 ; i--)
    {
        printf("%d\n",ANS[i]);
    }
    for(int i = ANS.size() - 1; i > 0; i--)
    {
        bool o = 0;
        for(int j = 0; j < vec[ANS[i]].size(); j++)
        {
            if(ANS[i - 1] == vec[ANS[i]][j])o = true;
        }
        if(o == true)cou++;
    }
    if(cou == ANS.size() - 1)printf("0\n");
    else printf("1\n");
    return 0;
}

void visit(int n)
{
    if(visited[n])return;
    visited[n] = true;
    for(int i = 0; i < vec[n].size(); i++)
    {
        visit(vec[n][i]);
    }
    ANS.push_back(n);
    return;
}

Measured memory_bytes: 3932
#include <stdio.h>

int main(void) {
  int a,b,c,d,e,g,x[100][100],y[100][100];
  long int r;
  scanf("%d %d %d",&a,&b,&c);
  for(d=0;d<a;d++)
    for(e=0;e<b;e++)
     scanf("%d",&x[d][e]);
  
  for(d=0;d<b;d++)
   for(e=0;e<c;e++)
    scanf("%d",&y[d][e]);

  for(d=0;d<a;d++)
   for(e=0;e<c;e++){
     r=0;
    for(g=0;g<b;g++)
    r+=x[d][g]*y[g][e];
    printf("%ld",r);
    if(e+1==c)
    printf("\n");
    else
    printf(" ");
   }
  return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <string>


class Stack {
private:
  int container[100];
  int num;

public:
  Stack(){ num=0; };
  void show() {
    for (int i = 0; i < num; i++) {
      std::cout << container[i] << ' ';
    }
    std::cout  << '\n';
};
  void push(int val){ container[num++]=val; };
  int pop(){ num--; return container[num]; };

};



int main(void){
  std::string s;
  int a,b;
  Stack stack = Stack();

  while(std::cin >> s){
    if(s=="+"){
      b = stack.pop();
      a = stack.pop();
      stack.push(a + b);
    } else if (s=="-") {
      b = stack.pop();
      a = stack.pop();
      stack.push(a - b);
    } else if (s=="*") {
      b = stack.pop();
      a = stack.pop();
      stack.push(a * b);
    } else {
      int val = std::stoi(s);
      stack.push( val );
    }
//    stack.show();
  }


  std::cout << stack.pop() << '\n';

  return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string n;
	cin >> n;


	cout << n[0] << n.size() - 2 << n[n.size() - 1] << endl;
	


}

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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  int c = 0;
  
  if (op == '+') {
    c = A + B;
  }
  else {
    c = A - B;
  }
  
  cout << c << endl;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    // string s;
    // cin >> s;
    // int fsize = s.size();
    // set<char> st;
    // rep(i, s.size())
    // {
    //     st.insert(s[i]);
    // }
    // int esize = st.size();
    // cout << (fsize == esize ? "yes" : "no") << endl;
    // return 0;
    string s;
    cin >> s;
    int fsize = s.size();
    sort(all(s));
    eunique(s);
    int esize = s.size();
    cout << (fsize == esize ? "yes" : "no") << endl;
    return 0;
}

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

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

  vector<int> a(n);

  for(int i = 0; i < n; i++)
    cin >> a[i];

  list<int> li;

  for(int i = 0; i < n; i++) {
    if((n - i) % 2 == 0) {
      li.push_back(a[i]);
    }else{
      li.push_front(a[i]);
    }
  }

  for(auto it = li.begin(); it != li.end(); ++it) {
    if(it != li.begin()) {
      cout << ' ';
    }

    cout << *it;

  }

  cout << endl;

}


Measured memory_bytes: 9216